1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Rbo state query tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3fShaderStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "es3fApiCase.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
32*35238bceSAndroid Build Coastguard Worker #include "deString.h"
33*35238bceSAndroid Build Coastguard Worker
34*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
35*35238bceSAndroid Build Coastguard Worker using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker namespace deqp
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker namespace gles3
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace Functional
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker static const char *commonTestVertSource = "#version 300 es\n"
47*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
48*35238bceSAndroid Build Coastguard Worker "{\n"
49*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
50*35238bceSAndroid Build Coastguard Worker "}\n\0";
51*35238bceSAndroid Build Coastguard Worker static const char *commonTestFragSource = "#version 300 es\n"
52*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;\n"
53*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
54*35238bceSAndroid Build Coastguard Worker "{\n"
55*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
56*35238bceSAndroid Build Coastguard Worker "}\n\0";
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker static const char *brokenShader = "#version 300 es\n"
59*35238bceSAndroid Build Coastguard Worker "broken, this should not compile!\n"
60*35238bceSAndroid Build Coastguard Worker "\n\0";
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker // rounds x.1 to x+1
63*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerUp(GLfloat val)64*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerUp(GLfloat val)
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker return (T)(ceil(val));
67*35238bceSAndroid Build Coastguard Worker }
68*35238bceSAndroid Build Coastguard Worker
69*35238bceSAndroid Build Coastguard Worker // rounds x.9 to x
70*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerDown(GLfloat val)71*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerDown(GLfloat val)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker return (T)(floor(val));
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker
checkIntEquals(tcu::TestContext & testCtx,GLint got,GLint expected)76*35238bceSAndroid Build Coastguard Worker bool checkIntEquals(tcu::TestContext &testCtx, GLint got, GLint expected)
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
79*35238bceSAndroid Build Coastguard Worker
80*35238bceSAndroid Build Coastguard Worker if (got != expected)
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got
83*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
84*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
85*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
86*35238bceSAndroid Build Coastguard Worker return false;
87*35238bceSAndroid Build Coastguard Worker }
88*35238bceSAndroid Build Coastguard Worker return true;
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker
checkPointerEquals(tcu::TestContext & testCtx,const void * got,const void * expected)91*35238bceSAndroid Build Coastguard Worker void checkPointerEquals(tcu::TestContext &testCtx, const void *got, const void *expected)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
94*35238bceSAndroid Build Coastguard Worker
95*35238bceSAndroid Build Coastguard Worker if (got != expected)
96*35238bceSAndroid Build Coastguard Worker {
97*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got
98*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
99*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
100*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker }
103*35238bceSAndroid Build Coastguard Worker
verifyShaderParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint shader,GLenum pname,GLenum reference)104*35238bceSAndroid Build Coastguard Worker void verifyShaderParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint shader, GLenum pname,
105*35238bceSAndroid Build Coastguard Worker GLenum reference)
106*35238bceSAndroid Build Coastguard Worker {
107*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
108*35238bceSAndroid Build Coastguard Worker gl.glGetShaderiv(shader, pname, &state);
109*35238bceSAndroid Build Coastguard Worker
110*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
111*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
112*35238bceSAndroid Build Coastguard Worker }
113*35238bceSAndroid Build Coastguard Worker
verifyProgramParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLenum pname,GLenum reference)114*35238bceSAndroid Build Coastguard Worker bool verifyProgramParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLenum pname,
115*35238bceSAndroid Build Coastguard Worker GLenum reference)
116*35238bceSAndroid Build Coastguard Worker {
117*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
118*35238bceSAndroid Build Coastguard Worker gl.glGetProgramiv(program, pname, &state);
119*35238bceSAndroid Build Coastguard Worker
120*35238bceSAndroid Build Coastguard Worker return state.verifyValidity(testCtx) && checkIntEquals(testCtx, state, reference);
121*35238bceSAndroid Build Coastguard Worker }
122*35238bceSAndroid Build Coastguard Worker
verifyActiveUniformParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLuint index,GLenum pname,GLenum reference)123*35238bceSAndroid Build Coastguard Worker void verifyActiveUniformParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLuint index,
124*35238bceSAndroid Build Coastguard Worker GLenum pname, GLenum reference)
125*35238bceSAndroid Build Coastguard Worker {
126*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
127*35238bceSAndroid Build Coastguard Worker gl.glGetActiveUniformsiv(program, 1, &index, pname, &state);
128*35238bceSAndroid Build Coastguard Worker
129*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
130*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
131*35238bceSAndroid Build Coastguard Worker }
132*35238bceSAndroid Build Coastguard Worker
verifyActiveUniformBlockParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLuint blockIndex,GLenum pname,GLenum reference)133*35238bceSAndroid Build Coastguard Worker void verifyActiveUniformBlockParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program,
134*35238bceSAndroid Build Coastguard Worker GLuint blockIndex, GLenum pname, GLenum reference)
135*35238bceSAndroid Build Coastguard Worker {
136*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
137*35238bceSAndroid Build Coastguard Worker gl.glGetActiveUniformBlockiv(program, blockIndex, pname, &state);
138*35238bceSAndroid Build Coastguard Worker
139*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
140*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
141*35238bceSAndroid Build Coastguard Worker }
142*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribf(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)143*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribf(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLfloat x, GLfloat y,
144*35238bceSAndroid Build Coastguard Worker GLfloat z, GLfloat w)
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
147*35238bceSAndroid Build Coastguard Worker
148*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
149*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
152*35238bceSAndroid Build Coastguard Worker
153*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
156*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
157*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
158*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
159*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
160*35238bceSAndroid Build Coastguard Worker }
161*35238bceSAndroid Build Coastguard Worker }
162*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribIi(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLint x,GLint y,GLint z,GLint w)163*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribIi(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLint x, GLint y,
164*35238bceSAndroid Build Coastguard Worker GLint z, GLint w)
165*35238bceSAndroid Build Coastguard Worker {
166*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[4]> attribValue;
169*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribIiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
176*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
177*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
178*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
179*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
180*35238bceSAndroid Build Coastguard Worker }
181*35238bceSAndroid Build Coastguard Worker }
182*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribIui(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLuint x,GLuint y,GLuint z,GLuint w)183*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribIui(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLuint x, GLuint y,
184*35238bceSAndroid Build Coastguard Worker GLuint z, GLuint w)
185*35238bceSAndroid Build Coastguard Worker {
186*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
187*35238bceSAndroid Build Coastguard Worker
188*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[4]> attribValue;
189*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribIuiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
192*35238bceSAndroid Build Coastguard Worker
193*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
194*35238bceSAndroid Build Coastguard Worker {
195*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
196*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
197*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
198*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
199*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
200*35238bceSAndroid Build Coastguard Worker }
201*35238bceSAndroid Build Coastguard Worker }
202*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribConversion(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)203*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribConversion(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLfloat x,
204*35238bceSAndroid Build Coastguard Worker GLfloat y, GLfloat z, GLfloat w)
205*35238bceSAndroid Build Coastguard Worker {
206*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
207*35238bceSAndroid Build Coastguard Worker
208*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[4]> attribValue;
209*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker const GLint referenceAsGLintMin[] = {
214*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerDown<GLint>(x), roundGLfloatToNearestIntegerDown<GLint>(y),
215*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerDown<GLint>(z), roundGLfloatToNearestIntegerDown<GLint>(w)};
216*35238bceSAndroid Build Coastguard Worker const GLint referenceAsGLintMax[] = {
217*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerUp<GLint>(x), roundGLfloatToNearestIntegerUp<GLint>(y),
218*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerUp<GLint>(z), roundGLfloatToNearestIntegerUp<GLint>(w)};
219*35238bceSAndroid Build Coastguard Worker
220*35238bceSAndroid Build Coastguard Worker if (attribValue[0] < referenceAsGLintMin[0] || attribValue[0] > referenceAsGLintMax[0] ||
221*35238bceSAndroid Build Coastguard Worker attribValue[1] < referenceAsGLintMin[1] || attribValue[1] > referenceAsGLintMax[1] ||
222*35238bceSAndroid Build Coastguard Worker attribValue[2] < referenceAsGLintMin[2] || attribValue[2] > referenceAsGLintMax[2] ||
223*35238bceSAndroid Build Coastguard Worker attribValue[3] < referenceAsGLintMin[3] || attribValue[3] > referenceAsGLintMax[3])
224*35238bceSAndroid Build Coastguard Worker {
225*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected in range "
226*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[0] << " " << referenceAsGLintMax[0] << "], "
227*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[1] << " " << referenceAsGLintMax[1] << "], "
228*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[2] << " " << referenceAsGLintMax[2] << "], "
229*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[3] << " " << referenceAsGLintMax[3] << "]"
230*35238bceSAndroid Build Coastguard Worker << "; got " << attribValue[0] << ", " << attribValue[1] << ", " << attribValue[2] << ", "
231*35238bceSAndroid Build Coastguard Worker << attribValue[3] << " "
232*35238bceSAndroid Build Coastguard Worker << "; Input=" << x << "; " << y << "; " << z << "; " << w << " " << TestLog::EndMessage;
233*35238bceSAndroid Build Coastguard Worker
234*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
235*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid attribute value");
236*35238bceSAndroid Build Coastguard Worker }
237*35238bceSAndroid Build Coastguard Worker }
238*35238bceSAndroid Build Coastguard Worker
verifyVertexAttrib(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLenum pname,GLenum reference)239*35238bceSAndroid Build Coastguard Worker void verifyVertexAttrib(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLenum pname, GLenum reference)
240*35238bceSAndroid Build Coastguard Worker {
241*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
242*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribIiv(index, pname, &state);
243*35238bceSAndroid Build Coastguard Worker
244*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
245*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
246*35238bceSAndroid Build Coastguard Worker }
247*35238bceSAndroid Build Coastguard Worker
verifyUniformValue1f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x)248*35238bceSAndroid Build Coastguard Worker void verifyUniformValue1f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x)
249*35238bceSAndroid Build Coastguard Worker {
250*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
251*35238bceSAndroid Build Coastguard Worker
252*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[1]> state;
253*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
254*35238bceSAndroid Build Coastguard Worker
255*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
256*35238bceSAndroid Build Coastguard Worker return;
257*35238bceSAndroid Build Coastguard Worker
258*35238bceSAndroid Build Coastguard Worker if (state[0] != x)
259*35238bceSAndroid Build Coastguard Worker {
260*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << "]; got [" << state[0] << "]"
261*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
262*35238bceSAndroid Build Coastguard Worker
263*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
264*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
265*35238bceSAndroid Build Coastguard Worker }
266*35238bceSAndroid Build Coastguard Worker }
267*35238bceSAndroid Build Coastguard Worker
verifyUniformValue2f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y)268*35238bceSAndroid Build Coastguard Worker void verifyUniformValue2f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
269*35238bceSAndroid Build Coastguard Worker float y)
270*35238bceSAndroid Build Coastguard Worker {
271*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
272*35238bceSAndroid Build Coastguard Worker
273*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[2]> state;
274*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
275*35238bceSAndroid Build Coastguard Worker
276*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
277*35238bceSAndroid Build Coastguard Worker return;
278*35238bceSAndroid Build Coastguard Worker
279*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y)
280*35238bceSAndroid Build Coastguard Worker {
281*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << "]; got [" << state[0]
282*35238bceSAndroid Build Coastguard Worker << ", " << state[1] << "]" << TestLog::EndMessage;
283*35238bceSAndroid Build Coastguard Worker
284*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
285*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
286*35238bceSAndroid Build Coastguard Worker }
287*35238bceSAndroid Build Coastguard Worker }
288*35238bceSAndroid Build Coastguard Worker
verifyUniformValue3f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y,float z)289*35238bceSAndroid Build Coastguard Worker void verifyUniformValue3f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
290*35238bceSAndroid Build Coastguard Worker float y, float z)
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
293*35238bceSAndroid Build Coastguard Worker
294*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[3]> state;
295*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
298*35238bceSAndroid Build Coastguard Worker return;
299*35238bceSAndroid Build Coastguard Worker
300*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z)
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << "]; got ["
303*35238bceSAndroid Build Coastguard Worker << state[0] << ", " << state[1] << ", " << state[2] << "]" << TestLog::EndMessage;
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
306*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
307*35238bceSAndroid Build Coastguard Worker }
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker
verifyUniformValue4f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y,float z,float w)310*35238bceSAndroid Build Coastguard Worker void verifyUniformValue4f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
311*35238bceSAndroid Build Coastguard Worker float y, float z, float w)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
314*35238bceSAndroid Build Coastguard Worker
315*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> state;
316*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
317*35238bceSAndroid Build Coastguard Worker
318*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
319*35238bceSAndroid Build Coastguard Worker return;
320*35238bceSAndroid Build Coastguard Worker
321*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z || state[3] != w)
322*35238bceSAndroid Build Coastguard Worker {
323*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << ", " << w
324*35238bceSAndroid Build Coastguard Worker << "]; got [" << state[0] << ", " << state[1] << ", " << state[2] << ", " << state[3] << "]"
325*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
326*35238bceSAndroid Build Coastguard Worker
327*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
328*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
329*35238bceSAndroid Build Coastguard Worker }
330*35238bceSAndroid Build Coastguard Worker }
331*35238bceSAndroid Build Coastguard Worker
verifyUniformValue1i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x)332*35238bceSAndroid Build Coastguard Worker void verifyUniformValue1i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x)
333*35238bceSAndroid Build Coastguard Worker {
334*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
335*35238bceSAndroid Build Coastguard Worker
336*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[1]> state;
337*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
340*35238bceSAndroid Build Coastguard Worker return;
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker if (state[0] != x)
343*35238bceSAndroid Build Coastguard Worker {
344*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << "]; got [" << state[0] << "]"
345*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
346*35238bceSAndroid Build Coastguard Worker
347*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
348*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
349*35238bceSAndroid Build Coastguard Worker }
350*35238bceSAndroid Build Coastguard Worker }
351*35238bceSAndroid Build Coastguard Worker
verifyUniformValue2i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y)352*35238bceSAndroid Build Coastguard Worker void verifyUniformValue2i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
353*35238bceSAndroid Build Coastguard Worker GLint y)
354*35238bceSAndroid Build Coastguard Worker {
355*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
356*35238bceSAndroid Build Coastguard Worker
357*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[2]> state;
358*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
359*35238bceSAndroid Build Coastguard Worker
360*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
361*35238bceSAndroid Build Coastguard Worker return;
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y)
364*35238bceSAndroid Build Coastguard Worker {
365*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << "]; got [" << state[0]
366*35238bceSAndroid Build Coastguard Worker << ", " << state[1] << "]" << TestLog::EndMessage;
367*35238bceSAndroid Build Coastguard Worker
368*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
369*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
370*35238bceSAndroid Build Coastguard Worker }
371*35238bceSAndroid Build Coastguard Worker }
372*35238bceSAndroid Build Coastguard Worker
verifyUniformValue3i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y,GLint z)373*35238bceSAndroid Build Coastguard Worker void verifyUniformValue3i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
374*35238bceSAndroid Build Coastguard Worker GLint y, GLint z)
375*35238bceSAndroid Build Coastguard Worker {
376*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
377*35238bceSAndroid Build Coastguard Worker
378*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[3]> state;
379*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
380*35238bceSAndroid Build Coastguard Worker
381*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
382*35238bceSAndroid Build Coastguard Worker return;
383*35238bceSAndroid Build Coastguard Worker
384*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z)
385*35238bceSAndroid Build Coastguard Worker {
386*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << "]; got ["
387*35238bceSAndroid Build Coastguard Worker << state[0] << ", " << state[1] << ", " << state[2] << "]" << TestLog::EndMessage;
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
390*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
391*35238bceSAndroid Build Coastguard Worker }
392*35238bceSAndroid Build Coastguard Worker }
393*35238bceSAndroid Build Coastguard Worker
verifyUniformValue4i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y,GLint z,GLint w)394*35238bceSAndroid Build Coastguard Worker void verifyUniformValue4i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
395*35238bceSAndroid Build Coastguard Worker GLint y, GLint z, GLint w)
396*35238bceSAndroid Build Coastguard Worker {
397*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[4]> state;
400*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
401*35238bceSAndroid Build Coastguard Worker
402*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
403*35238bceSAndroid Build Coastguard Worker return;
404*35238bceSAndroid Build Coastguard Worker
405*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z || state[3] != w)
406*35238bceSAndroid Build Coastguard Worker {
407*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << ", " << w
408*35238bceSAndroid Build Coastguard Worker << "]; got [" << state[0] << ", " << state[1] << ", " << state[2] << ", " << state[3] << "]"
409*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
410*35238bceSAndroid Build Coastguard Worker
411*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
412*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
413*35238bceSAndroid Build Coastguard Worker }
414*35238bceSAndroid Build Coastguard Worker }
415*35238bceSAndroid Build Coastguard Worker
verifyUniformValue1ui(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLuint x)416*35238bceSAndroid Build Coastguard Worker void verifyUniformValue1ui(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLuint x)
417*35238bceSAndroid Build Coastguard Worker {
418*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
419*35238bceSAndroid Build Coastguard Worker
420*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[1]> state;
421*35238bceSAndroid Build Coastguard Worker gl.glGetUniformuiv(program, location, state);
422*35238bceSAndroid Build Coastguard Worker
423*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
424*35238bceSAndroid Build Coastguard Worker return;
425*35238bceSAndroid Build Coastguard Worker
426*35238bceSAndroid Build Coastguard Worker if (state[0] != x)
427*35238bceSAndroid Build Coastguard Worker {
428*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << "]; got [" << state[0] << "]"
429*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
430*35238bceSAndroid Build Coastguard Worker
431*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
432*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
433*35238bceSAndroid Build Coastguard Worker }
434*35238bceSAndroid Build Coastguard Worker }
435*35238bceSAndroid Build Coastguard Worker
verifyUniformValue2ui(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLuint x,GLuint y)436*35238bceSAndroid Build Coastguard Worker void verifyUniformValue2ui(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLuint x,
437*35238bceSAndroid Build Coastguard Worker GLuint y)
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[2]> state;
442*35238bceSAndroid Build Coastguard Worker gl.glGetUniformuiv(program, location, state);
443*35238bceSAndroid Build Coastguard Worker
444*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
445*35238bceSAndroid Build Coastguard Worker return;
446*35238bceSAndroid Build Coastguard Worker
447*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y)
448*35238bceSAndroid Build Coastguard Worker {
449*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << "]; got [" << state[0]
450*35238bceSAndroid Build Coastguard Worker << ", " << state[1] << "]" << TestLog::EndMessage;
451*35238bceSAndroid Build Coastguard Worker
452*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
453*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
454*35238bceSAndroid Build Coastguard Worker }
455*35238bceSAndroid Build Coastguard Worker }
456*35238bceSAndroid Build Coastguard Worker
verifyUniformValue3ui(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLuint x,GLuint y,GLuint z)457*35238bceSAndroid Build Coastguard Worker void verifyUniformValue3ui(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLuint x,
458*35238bceSAndroid Build Coastguard Worker GLuint y, GLuint z)
459*35238bceSAndroid Build Coastguard Worker {
460*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
461*35238bceSAndroid Build Coastguard Worker
462*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[3]> state;
463*35238bceSAndroid Build Coastguard Worker gl.glGetUniformuiv(program, location, state);
464*35238bceSAndroid Build Coastguard Worker
465*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
466*35238bceSAndroid Build Coastguard Worker return;
467*35238bceSAndroid Build Coastguard Worker
468*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z)
469*35238bceSAndroid Build Coastguard Worker {
470*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << "]; got ["
471*35238bceSAndroid Build Coastguard Worker << state[0] << ", " << state[1] << ", " << state[2] << "]" << TestLog::EndMessage;
472*35238bceSAndroid Build Coastguard Worker
473*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
474*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
475*35238bceSAndroid Build Coastguard Worker }
476*35238bceSAndroid Build Coastguard Worker }
477*35238bceSAndroid Build Coastguard Worker
verifyUniformValue4ui(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLuint x,GLuint y,GLuint z,GLuint w)478*35238bceSAndroid Build Coastguard Worker void verifyUniformValue4ui(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLuint x,
479*35238bceSAndroid Build Coastguard Worker GLuint y, GLuint z, GLuint w)
480*35238bceSAndroid Build Coastguard Worker {
481*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
482*35238bceSAndroid Build Coastguard Worker
483*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[4]> state;
484*35238bceSAndroid Build Coastguard Worker gl.glGetUniformuiv(program, location, state);
485*35238bceSAndroid Build Coastguard Worker
486*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
487*35238bceSAndroid Build Coastguard Worker return;
488*35238bceSAndroid Build Coastguard Worker
489*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z || state[3] != w)
490*35238bceSAndroid Build Coastguard Worker {
491*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << ", " << w
492*35238bceSAndroid Build Coastguard Worker << "]; got [" << state[0] << ", " << state[1] << ", " << state[2] << ", " << state[3] << "]"
493*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
494*35238bceSAndroid Build Coastguard Worker
495*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
496*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
497*35238bceSAndroid Build Coastguard Worker }
498*35238bceSAndroid Build Coastguard Worker }
499*35238bceSAndroid Build Coastguard Worker
500*35238bceSAndroid Build Coastguard Worker template <int Count>
verifyUniformValues(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,const GLfloat * values)501*35238bceSAndroid Build Coastguard Worker void verifyUniformValues(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location,
502*35238bceSAndroid Build Coastguard Worker const GLfloat *values)
503*35238bceSAndroid Build Coastguard Worker {
504*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
505*35238bceSAndroid Build Coastguard Worker
506*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[Count]> state;
507*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
510*35238bceSAndroid Build Coastguard Worker return;
511*35238bceSAndroid Build Coastguard Worker
512*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < Count; ++ndx)
513*35238bceSAndroid Build Coastguard Worker {
514*35238bceSAndroid Build Coastguard Worker if (values[ndx] != state[ndx])
515*35238bceSAndroid Build Coastguard Worker {
516*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: at index " << ndx << " expected " << values[ndx]
517*35238bceSAndroid Build Coastguard Worker << "; got " << state[ndx] << TestLog::EndMessage;
518*35238bceSAndroid Build Coastguard Worker
519*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
520*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
521*35238bceSAndroid Build Coastguard Worker }
522*35238bceSAndroid Build Coastguard Worker }
523*35238bceSAndroid Build Coastguard Worker }
524*35238bceSAndroid Build Coastguard Worker
525*35238bceSAndroid Build Coastguard Worker template <int N>
verifyUniformMatrixValues(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,const GLfloat * values,bool transpose)526*35238bceSAndroid Build Coastguard Worker void verifyUniformMatrixValues(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location,
527*35238bceSAndroid Build Coastguard Worker const GLfloat *values, bool transpose)
528*35238bceSAndroid Build Coastguard Worker {
529*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
530*35238bceSAndroid Build Coastguard Worker
531*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[N * N]> state;
532*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
533*35238bceSAndroid Build Coastguard Worker
534*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
535*35238bceSAndroid Build Coastguard Worker return;
536*35238bceSAndroid Build Coastguard Worker
537*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < N; ++y)
538*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < N; ++x)
539*35238bceSAndroid Build Coastguard Worker {
540*35238bceSAndroid Build Coastguard Worker const int refIndex = y * N + x;
541*35238bceSAndroid Build Coastguard Worker const int stateIndex = transpose ? (x * N + y) : (y * N + x);
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker if (values[refIndex] != state[stateIndex])
544*35238bceSAndroid Build Coastguard Worker {
545*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: at index [" << y << "][" << x << "] expected "
546*35238bceSAndroid Build Coastguard Worker << values[refIndex] << "; got " << state[stateIndex] << TestLog::EndMessage;
547*35238bceSAndroid Build Coastguard Worker
548*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
549*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
550*35238bceSAndroid Build Coastguard Worker }
551*35238bceSAndroid Build Coastguard Worker }
552*35238bceSAndroid Build Coastguard Worker }
553*35238bceSAndroid Build Coastguard Worker
554*35238bceSAndroid Build Coastguard Worker class ShaderTypeCase : public ApiCase
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker public:
ShaderTypeCase(Context & context,const char * name,const char * description)557*35238bceSAndroid Build Coastguard Worker ShaderTypeCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
558*35238bceSAndroid Build Coastguard Worker {
559*35238bceSAndroid Build Coastguard Worker }
560*35238bceSAndroid Build Coastguard Worker
test(void)561*35238bceSAndroid Build Coastguard Worker void test(void)
562*35238bceSAndroid Build Coastguard Worker {
563*35238bceSAndroid Build Coastguard Worker const GLenum shaderTypes[] = {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER};
564*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
565*35238bceSAndroid Build Coastguard Worker {
566*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(shaderTypes[ndx]);
567*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_TYPE, shaderTypes[ndx]);
568*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
569*35238bceSAndroid Build Coastguard Worker }
570*35238bceSAndroid Build Coastguard Worker }
571*35238bceSAndroid Build Coastguard Worker };
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker class ShaderCompileStatusCase : public ApiCase
574*35238bceSAndroid Build Coastguard Worker {
575*35238bceSAndroid Build Coastguard Worker public:
ShaderCompileStatusCase(Context & context,const char * name,const char * description)576*35238bceSAndroid Build Coastguard Worker ShaderCompileStatusCase(Context &context, const char *name, const char *description)
577*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
578*35238bceSAndroid Build Coastguard Worker {
579*35238bceSAndroid Build Coastguard Worker }
580*35238bceSAndroid Build Coastguard Worker
test(void)581*35238bceSAndroid Build Coastguard Worker void test(void)
582*35238bceSAndroid Build Coastguard Worker {
583*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
584*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
585*35238bceSAndroid Build Coastguard Worker
586*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_FALSE);
587*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
588*35238bceSAndroid Build Coastguard Worker
589*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
590*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
591*35238bceSAndroid Build Coastguard Worker
592*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
593*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
594*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
595*35238bceSAndroid Build Coastguard Worker
596*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
597*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
598*35238bceSAndroid Build Coastguard Worker
599*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
600*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
601*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
602*35238bceSAndroid Build Coastguard Worker }
603*35238bceSAndroid Build Coastguard Worker };
604*35238bceSAndroid Build Coastguard Worker
605*35238bceSAndroid Build Coastguard Worker class ShaderInfoLogCase : public ApiCase
606*35238bceSAndroid Build Coastguard Worker {
607*35238bceSAndroid Build Coastguard Worker public:
ShaderInfoLogCase(Context & context,const char * name,const char * description)608*35238bceSAndroid Build Coastguard Worker ShaderInfoLogCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
609*35238bceSAndroid Build Coastguard Worker {
610*35238bceSAndroid Build Coastguard Worker }
611*35238bceSAndroid Build Coastguard Worker
test(void)612*35238bceSAndroid Build Coastguard Worker void test(void)
613*35238bceSAndroid Build Coastguard Worker {
614*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
615*35238bceSAndroid Build Coastguard Worker
616*35238bceSAndroid Build Coastguard Worker // INFO_LOG_LENGTH is 0 by default and it includes null-terminator
617*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
618*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_INFO_LOG_LENGTH, 0);
619*35238bceSAndroid Build Coastguard Worker
620*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 1, &brokenShader, DE_NULL);
621*35238bceSAndroid Build Coastguard Worker glCompileShader(shader);
622*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
623*35238bceSAndroid Build Coastguard Worker
624*35238bceSAndroid Build Coastguard Worker // check the log length
625*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> logLength;
626*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
627*35238bceSAndroid Build Coastguard Worker if (!logLength.verifyValidity(m_testCtx))
628*35238bceSAndroid Build Coastguard Worker {
629*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
630*35238bceSAndroid Build Coastguard Worker return;
631*35238bceSAndroid Build Coastguard Worker }
632*35238bceSAndroid Build Coastguard Worker if (logLength == 0)
633*35238bceSAndroid Build Coastguard Worker {
634*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
635*35238bceSAndroid Build Coastguard Worker return;
636*35238bceSAndroid Build Coastguard Worker }
637*35238bceSAndroid Build Coastguard Worker
638*35238bceSAndroid Build Coastguard Worker // check normal case
639*35238bceSAndroid Build Coastguard Worker {
640*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'}; // non-zero initialization
641*35238bceSAndroid Build Coastguard Worker
642*35238bceSAndroid Build Coastguard Worker GLint written = 0; // written does not include null terminator
643*35238bceSAndroid Build Coastguard Worker glGetShaderInfoLog(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
644*35238bceSAndroid Build Coastguard Worker
645*35238bceSAndroid Build Coastguard Worker // check lengths are consistent
646*35238bceSAndroid Build Coastguard Worker if (logLength <= DE_LENGTH_OF_ARRAY(buffer))
647*35238bceSAndroid Build Coastguard Worker {
648*35238bceSAndroid Build Coastguard Worker if (written != logLength - 1)
649*35238bceSAndroid Build Coastguard Worker {
650*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << logLength - 1 << "; got "
651*35238bceSAndroid Build Coastguard Worker << written << TestLog::EndMessage;
652*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
653*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
654*35238bceSAndroid Build Coastguard Worker }
655*35238bceSAndroid Build Coastguard Worker }
656*35238bceSAndroid Build Coastguard Worker
657*35238bceSAndroid Build Coastguard Worker // check null-terminator, either at end of buffer or at buffer[written]
658*35238bceSAndroid Build Coastguard Worker const char *terminator = &buffer[DE_LENGTH_OF_ARRAY(buffer) - 1];
659*35238bceSAndroid Build Coastguard Worker if (logLength < DE_LENGTH_OF_ARRAY(buffer))
660*35238bceSAndroid Build Coastguard Worker terminator = &buffer[written];
661*35238bceSAndroid Build Coastguard Worker
662*35238bceSAndroid Build Coastguard Worker if (*terminator != '\0')
663*35238bceSAndroid Build Coastguard Worker {
664*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)*terminator
665*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
666*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
667*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
668*35238bceSAndroid Build Coastguard Worker }
669*35238bceSAndroid Build Coastguard Worker }
670*35238bceSAndroid Build Coastguard Worker
671*35238bceSAndroid Build Coastguard Worker // check with too small buffer
672*35238bceSAndroid Build Coastguard Worker {
673*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'}; // non-zero initialization
674*35238bceSAndroid Build Coastguard Worker
675*35238bceSAndroid Build Coastguard Worker // check string always ends with \0, even with small buffers
676*35238bceSAndroid Build Coastguard Worker GLint written = 0;
677*35238bceSAndroid Build Coastguard Worker glGetShaderInfoLog(shader, 1, &written, buffer);
678*35238bceSAndroid Build Coastguard Worker if (written != 0)
679*35238bceSAndroid Build Coastguard Worker {
680*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length 0; got " << written
681*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
682*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
683*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
684*35238bceSAndroid Build Coastguard Worker }
685*35238bceSAndroid Build Coastguard Worker if (buffer[0] != '\0')
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)buffer[0]
688*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
689*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
690*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
691*35238bceSAndroid Build Coastguard Worker }
692*35238bceSAndroid Build Coastguard Worker }
693*35238bceSAndroid Build Coastguard Worker
694*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
695*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
696*35238bceSAndroid Build Coastguard Worker }
697*35238bceSAndroid Build Coastguard Worker };
698*35238bceSAndroid Build Coastguard Worker
699*35238bceSAndroid Build Coastguard Worker class ShaderSourceCase : public ApiCase
700*35238bceSAndroid Build Coastguard Worker {
701*35238bceSAndroid Build Coastguard Worker public:
ShaderSourceCase(Context & context,const char * name,const char * description)702*35238bceSAndroid Build Coastguard Worker ShaderSourceCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
703*35238bceSAndroid Build Coastguard Worker {
704*35238bceSAndroid Build Coastguard Worker }
705*35238bceSAndroid Build Coastguard Worker
test(void)706*35238bceSAndroid Build Coastguard Worker void test(void)
707*35238bceSAndroid Build Coastguard Worker {
708*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
709*35238bceSAndroid Build Coastguard Worker
710*35238bceSAndroid Build Coastguard Worker // SHADER_SOURCE_LENGTH does include 0-terminator
711*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
712*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_SOURCE_LENGTH, 0);
713*35238bceSAndroid Build Coastguard Worker
714*35238bceSAndroid Build Coastguard Worker // check the SHADER_SOURCE_LENGTH
715*35238bceSAndroid Build Coastguard Worker {
716*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 1, &brokenShader, DE_NULL);
717*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
718*35238bceSAndroid Build Coastguard Worker
719*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sourceLength;
720*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
721*35238bceSAndroid Build Coastguard Worker
722*35238bceSAndroid Build Coastguard Worker sourceLength.verifyValidity(m_testCtx);
723*35238bceSAndroid Build Coastguard Worker
724*35238bceSAndroid Build Coastguard Worker const GLint referenceLength =
725*35238bceSAndroid Build Coastguard Worker (GLint)std::string(brokenShader).length() + 1; // including the null terminator
726*35238bceSAndroid Build Coastguard Worker if (sourceLength != referenceLength)
727*35238bceSAndroid Build Coastguard Worker {
728*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got "
729*35238bceSAndroid Build Coastguard Worker << sourceLength << TestLog::EndMessage;
730*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
731*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker }
734*35238bceSAndroid Build Coastguard Worker
735*35238bceSAndroid Build Coastguard Worker // check the concat source SHADER_SOURCE_LENGTH
736*35238bceSAndroid Build Coastguard Worker {
737*35238bceSAndroid Build Coastguard Worker const char *shaders[] = {brokenShader, brokenShader};
738*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 2, shaders, DE_NULL);
739*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
740*35238bceSAndroid Build Coastguard Worker
741*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sourceLength;
742*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
743*35238bceSAndroid Build Coastguard Worker
744*35238bceSAndroid Build Coastguard Worker sourceLength.verifyValidity(m_testCtx);
745*35238bceSAndroid Build Coastguard Worker
746*35238bceSAndroid Build Coastguard Worker const GLint referenceLength =
747*35238bceSAndroid Build Coastguard Worker 2 * (GLint)std::string(brokenShader).length() + 1; // including the null terminator
748*35238bceSAndroid Build Coastguard Worker if (sourceLength != referenceLength)
749*35238bceSAndroid Build Coastguard Worker {
750*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got "
751*35238bceSAndroid Build Coastguard Worker << sourceLength << TestLog::EndMessage;
752*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
753*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
754*35238bceSAndroid Build Coastguard Worker }
755*35238bceSAndroid Build Coastguard Worker }
756*35238bceSAndroid Build Coastguard Worker
757*35238bceSAndroid Build Coastguard Worker // check the string length
758*35238bceSAndroid Build Coastguard Worker {
759*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
760*35238bceSAndroid Build Coastguard Worker DE_ASSERT(DE_LENGTH_OF_ARRAY(buffer) > 2 * (int)std::string(brokenShader).length());
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker GLint written = 0; // not inluding null-terminator
763*35238bceSAndroid Build Coastguard Worker glGetShaderSource(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
764*35238bceSAndroid Build Coastguard Worker
765*35238bceSAndroid Build Coastguard Worker const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length();
766*35238bceSAndroid Build Coastguard Worker if (written != referenceLength)
767*35238bceSAndroid Build Coastguard Worker {
768*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length " << referenceLength
769*35238bceSAndroid Build Coastguard Worker << "; got " << written << TestLog::EndMessage;
770*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
771*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
772*35238bceSAndroid Build Coastguard Worker }
773*35238bceSAndroid Build Coastguard Worker // check null pointer at
774*35238bceSAndroid Build Coastguard Worker else
775*35238bceSAndroid Build Coastguard Worker {
776*35238bceSAndroid Build Coastguard Worker if (buffer[referenceLength] != '\0')
777*35238bceSAndroid Build Coastguard Worker {
778*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at "
779*35238bceSAndroid Build Coastguard Worker << referenceLength << TestLog::EndMessage;
780*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
781*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "did not get a null terminator");
782*35238bceSAndroid Build Coastguard Worker }
783*35238bceSAndroid Build Coastguard Worker }
784*35238bceSAndroid Build Coastguard Worker }
785*35238bceSAndroid Build Coastguard Worker
786*35238bceSAndroid Build Coastguard Worker // check with small buffer
787*35238bceSAndroid Build Coastguard Worker {
788*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker GLint written = 0;
791*35238bceSAndroid Build Coastguard Worker glGetShaderSource(shader, 1, &written, buffer);
792*35238bceSAndroid Build Coastguard Worker
793*35238bceSAndroid Build Coastguard Worker if (written != 0)
794*35238bceSAndroid Build Coastguard Worker {
795*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written
796*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
797*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
798*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
799*35238bceSAndroid Build Coastguard Worker }
800*35238bceSAndroid Build Coastguard Worker if (buffer[0] != '\0')
801*35238bceSAndroid Build Coastguard Worker {
802*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator; got=" << int(buffer[0])
803*35238bceSAndroid Build Coastguard Worker << ", char=" << buffer[0] << TestLog::EndMessage;
804*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
805*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid terminator");
806*35238bceSAndroid Build Coastguard Worker }
807*35238bceSAndroid Build Coastguard Worker }
808*35238bceSAndroid Build Coastguard Worker
809*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
810*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
811*35238bceSAndroid Build Coastguard Worker }
812*35238bceSAndroid Build Coastguard Worker };
813*35238bceSAndroid Build Coastguard Worker
814*35238bceSAndroid Build Coastguard Worker class DeleteStatusCase : public ApiCase
815*35238bceSAndroid Build Coastguard Worker {
816*35238bceSAndroid Build Coastguard Worker public:
DeleteStatusCase(Context & context,const char * name,const char * description)817*35238bceSAndroid Build Coastguard Worker DeleteStatusCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
818*35238bceSAndroid Build Coastguard Worker {
819*35238bceSAndroid Build Coastguard Worker }
820*35238bceSAndroid Build Coastguard Worker
test(void)821*35238bceSAndroid Build Coastguard Worker void test(void)
822*35238bceSAndroid Build Coastguard Worker {
823*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
824*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
825*35238bceSAndroid Build Coastguard Worker
826*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
827*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
830*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
831*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
832*35238bceSAndroid Build Coastguard Worker
833*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
834*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
835*35238bceSAndroid Build Coastguard Worker
836*35238bceSAndroid Build Coastguard Worker GLuint shaderProg = glCreateProgram();
837*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderVert);
838*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderFrag);
839*35238bceSAndroid Build Coastguard Worker glLinkProgram(shaderProg);
840*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
841*35238bceSAndroid Build Coastguard Worker
842*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
843*35238bceSAndroid Build Coastguard Worker
844*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_FALSE);
845*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_FALSE);
846*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_FALSE);
847*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
848*35238bceSAndroid Build Coastguard Worker
849*35238bceSAndroid Build Coastguard Worker glUseProgram(shaderProg);
850*35238bceSAndroid Build Coastguard Worker
851*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
852*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
853*35238bceSAndroid Build Coastguard Worker glDeleteProgram(shaderProg);
854*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
855*35238bceSAndroid Build Coastguard Worker
856*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_TRUE);
857*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_TRUE);
858*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_TRUE);
859*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
860*35238bceSAndroid Build Coastguard Worker
861*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
862*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
863*35238bceSAndroid Build Coastguard Worker }
864*35238bceSAndroid Build Coastguard Worker };
865*35238bceSAndroid Build Coastguard Worker
866*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribInitialCase : public ApiCase
867*35238bceSAndroid Build Coastguard Worker {
868*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribInitialCase(Context & context,const char * name,const char * description)869*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribInitialCase(Context &context, const char *name, const char *description)
870*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
871*35238bceSAndroid Build Coastguard Worker {
872*35238bceSAndroid Build Coastguard Worker }
873*35238bceSAndroid Build Coastguard Worker
test(void)874*35238bceSAndroid Build Coastguard Worker void test(void)
875*35238bceSAndroid Build Coastguard Worker {
876*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
877*35238bceSAndroid Build Coastguard Worker
878*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
879*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
880*35238bceSAndroid Build Coastguard Worker
881*35238bceSAndroid Build Coastguard Worker // initial
882*35238bceSAndroid Build Coastguard Worker
883*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
884*35238bceSAndroid Build Coastguard Worker {
885*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
886*35238bceSAndroid Build Coastguard Worker glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
887*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(m_testCtx);
888*35238bceSAndroid Build Coastguard Worker
889*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != 0.0f || attribValue[1] != 0.0f || attribValue[2] != 0.0f || attribValue[3] != 1.0f)
890*35238bceSAndroid Build Coastguard Worker {
891*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected [0, 0, 0, 1];"
892*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
893*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
894*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
895*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
896*35238bceSAndroid Build Coastguard Worker }
897*35238bceSAndroid Build Coastguard Worker }
898*35238bceSAndroid Build Coastguard Worker }
899*35238bceSAndroid Build Coastguard Worker };
900*35238bceSAndroid Build Coastguard Worker
901*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribFloatCase : public ApiCase
902*35238bceSAndroid Build Coastguard Worker {
903*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribFloatCase(Context & context,const char * name,const char * description)904*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribFloatCase(Context &context, const char *name, const char *description)
905*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
906*35238bceSAndroid Build Coastguard Worker {
907*35238bceSAndroid Build Coastguard Worker }
908*35238bceSAndroid Build Coastguard Worker
test(void)909*35238bceSAndroid Build Coastguard Worker void test(void)
910*35238bceSAndroid Build Coastguard Worker {
911*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
912*35238bceSAndroid Build Coastguard Worker
913*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
914*35238bceSAndroid Build Coastguard Worker
915*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
916*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
917*35238bceSAndroid Build Coastguard Worker
918*35238bceSAndroid Build Coastguard Worker // test write float/read float
919*35238bceSAndroid Build Coastguard Worker
920*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
921*35238bceSAndroid Build Coastguard Worker {
922*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
923*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
924*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
925*35238bceSAndroid Build Coastguard Worker const GLfloat w = rnd.getFloat(-64000, 64000);
926*35238bceSAndroid Build Coastguard Worker
927*35238bceSAndroid Build Coastguard Worker glVertexAttrib4f(index, x, y, z, w);
928*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
929*35238bceSAndroid Build Coastguard Worker }
930*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
931*35238bceSAndroid Build Coastguard Worker {
932*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
933*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
934*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
935*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
936*35238bceSAndroid Build Coastguard Worker
937*35238bceSAndroid Build Coastguard Worker glVertexAttrib3f(index, x, y, z);
938*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
939*35238bceSAndroid Build Coastguard Worker }
940*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
941*35238bceSAndroid Build Coastguard Worker {
942*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
943*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
944*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
945*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
946*35238bceSAndroid Build Coastguard Worker
947*35238bceSAndroid Build Coastguard Worker glVertexAttrib2f(index, x, y);
948*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
949*35238bceSAndroid Build Coastguard Worker }
950*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
951*35238bceSAndroid Build Coastguard Worker {
952*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
953*35238bceSAndroid Build Coastguard Worker const GLfloat y = 0.0f;
954*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
955*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
956*35238bceSAndroid Build Coastguard Worker
957*35238bceSAndroid Build Coastguard Worker glVertexAttrib1f(index, x);
958*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
959*35238bceSAndroid Build Coastguard Worker }
960*35238bceSAndroid Build Coastguard Worker }
961*35238bceSAndroid Build Coastguard Worker };
962*35238bceSAndroid Build Coastguard Worker
963*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribIntCase : public ApiCase
964*35238bceSAndroid Build Coastguard Worker {
965*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribIntCase(Context & context,const char * name,const char * description)966*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribIntCase(Context &context, const char *name, const char *description)
967*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
968*35238bceSAndroid Build Coastguard Worker {
969*35238bceSAndroid Build Coastguard Worker }
970*35238bceSAndroid Build Coastguard Worker
test(void)971*35238bceSAndroid Build Coastguard Worker void test(void)
972*35238bceSAndroid Build Coastguard Worker {
973*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
974*35238bceSAndroid Build Coastguard Worker
975*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
976*35238bceSAndroid Build Coastguard Worker
977*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
978*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
979*35238bceSAndroid Build Coastguard Worker
980*35238bceSAndroid Build Coastguard Worker // test write float/read float
981*35238bceSAndroid Build Coastguard Worker
982*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
983*35238bceSAndroid Build Coastguard Worker {
984*35238bceSAndroid Build Coastguard Worker const GLint x = rnd.getInt(-64000, 64000);
985*35238bceSAndroid Build Coastguard Worker const GLint y = rnd.getInt(-64000, 64000);
986*35238bceSAndroid Build Coastguard Worker const GLint z = rnd.getInt(-64000, 64000);
987*35238bceSAndroid Build Coastguard Worker const GLint w = rnd.getInt(-64000, 64000);
988*35238bceSAndroid Build Coastguard Worker
989*35238bceSAndroid Build Coastguard Worker glVertexAttribI4i(index, x, y, z, w);
990*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribIi(m_testCtx, *this, index, x, y, z, w);
991*35238bceSAndroid Build Coastguard Worker }
992*35238bceSAndroid Build Coastguard Worker }
993*35238bceSAndroid Build Coastguard Worker };
994*35238bceSAndroid Build Coastguard Worker
995*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribUintCase : public ApiCase
996*35238bceSAndroid Build Coastguard Worker {
997*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribUintCase(Context & context,const char * name,const char * description)998*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribUintCase(Context &context, const char *name, const char *description)
999*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1000*35238bceSAndroid Build Coastguard Worker {
1001*35238bceSAndroid Build Coastguard Worker }
1002*35238bceSAndroid Build Coastguard Worker
test(void)1003*35238bceSAndroid Build Coastguard Worker void test(void)
1004*35238bceSAndroid Build Coastguard Worker {
1005*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1006*35238bceSAndroid Build Coastguard Worker
1007*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
1008*35238bceSAndroid Build Coastguard Worker
1009*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
1010*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
1011*35238bceSAndroid Build Coastguard Worker
1012*35238bceSAndroid Build Coastguard Worker // test write float/read float
1013*35238bceSAndroid Build Coastguard Worker
1014*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
1015*35238bceSAndroid Build Coastguard Worker {
1016*35238bceSAndroid Build Coastguard Worker const GLuint x = rnd.getInt(0, 64000);
1017*35238bceSAndroid Build Coastguard Worker const GLuint y = rnd.getInt(0, 64000);
1018*35238bceSAndroid Build Coastguard Worker const GLuint z = rnd.getInt(0, 64000);
1019*35238bceSAndroid Build Coastguard Worker const GLuint w = rnd.getInt(0, 64000);
1020*35238bceSAndroid Build Coastguard Worker
1021*35238bceSAndroid Build Coastguard Worker glVertexAttribI4ui(index, x, y, z, w);
1022*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribIui(m_testCtx, *this, index, x, y, z, w);
1023*35238bceSAndroid Build Coastguard Worker }
1024*35238bceSAndroid Build Coastguard Worker }
1025*35238bceSAndroid Build Coastguard Worker };
1026*35238bceSAndroid Build Coastguard Worker
1027*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribConversionCase : public ApiCase
1028*35238bceSAndroid Build Coastguard Worker {
1029*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribConversionCase(Context & context,const char * name,const char * description)1030*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribConversionCase(Context &context, const char *name, const char *description)
1031*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1032*35238bceSAndroid Build Coastguard Worker {
1033*35238bceSAndroid Build Coastguard Worker }
1034*35238bceSAndroid Build Coastguard Worker
test(void)1035*35238bceSAndroid Build Coastguard Worker void test(void)
1036*35238bceSAndroid Build Coastguard Worker {
1037*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1038*35238bceSAndroid Build Coastguard Worker
1039*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
1040*35238bceSAndroid Build Coastguard Worker
1041*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
1042*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
1043*35238bceSAndroid Build Coastguard Worker
1044*35238bceSAndroid Build Coastguard Worker // test write float/read float
1045*35238bceSAndroid Build Coastguard Worker
1046*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
1047*35238bceSAndroid Build Coastguard Worker {
1048*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
1049*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
1050*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
1051*35238bceSAndroid Build Coastguard Worker const GLfloat w = rnd.getFloat(-64000, 64000);
1052*35238bceSAndroid Build Coastguard Worker
1053*35238bceSAndroid Build Coastguard Worker glVertexAttrib4f(index, x, y, z, w);
1054*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
1055*35238bceSAndroid Build Coastguard Worker }
1056*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
1057*35238bceSAndroid Build Coastguard Worker {
1058*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
1059*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
1060*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
1061*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
1062*35238bceSAndroid Build Coastguard Worker
1063*35238bceSAndroid Build Coastguard Worker glVertexAttrib3f(index, x, y, z);
1064*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
1065*35238bceSAndroid Build Coastguard Worker }
1066*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
1067*35238bceSAndroid Build Coastguard Worker {
1068*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
1069*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
1070*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
1071*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
1072*35238bceSAndroid Build Coastguard Worker
1073*35238bceSAndroid Build Coastguard Worker glVertexAttrib2f(index, x, y);
1074*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
1075*35238bceSAndroid Build Coastguard Worker }
1076*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
1077*35238bceSAndroid Build Coastguard Worker {
1078*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
1079*35238bceSAndroid Build Coastguard Worker const GLfloat y = 0.0f;
1080*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
1081*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
1082*35238bceSAndroid Build Coastguard Worker
1083*35238bceSAndroid Build Coastguard Worker glVertexAttrib1f(index, x);
1084*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
1085*35238bceSAndroid Build Coastguard Worker }
1086*35238bceSAndroid Build Coastguard Worker }
1087*35238bceSAndroid Build Coastguard Worker };
1088*35238bceSAndroid Build Coastguard Worker
1089*35238bceSAndroid Build Coastguard Worker class ProgramInfoLogCase : public ApiCase
1090*35238bceSAndroid Build Coastguard Worker {
1091*35238bceSAndroid Build Coastguard Worker public:
1092*35238bceSAndroid Build Coastguard Worker enum BuildErrorType
1093*35238bceSAndroid Build Coastguard Worker {
1094*35238bceSAndroid Build Coastguard Worker BUILDERROR_COMPILE = 0,
1095*35238bceSAndroid Build Coastguard Worker BUILDERROR_LINK
1096*35238bceSAndroid Build Coastguard Worker };
1097*35238bceSAndroid Build Coastguard Worker
ProgramInfoLogCase(Context & context,const char * name,const char * description,BuildErrorType buildErrorType)1098*35238bceSAndroid Build Coastguard Worker ProgramInfoLogCase(Context &context, const char *name, const char *description, BuildErrorType buildErrorType)
1099*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1100*35238bceSAndroid Build Coastguard Worker , m_buildErrorType(buildErrorType)
1101*35238bceSAndroid Build Coastguard Worker {
1102*35238bceSAndroid Build Coastguard Worker }
1103*35238bceSAndroid Build Coastguard Worker
test(void)1104*35238bceSAndroid Build Coastguard Worker void test(void)
1105*35238bceSAndroid Build Coastguard Worker {
1106*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1107*35238bceSAndroid Build Coastguard Worker
1108*35238bceSAndroid Build Coastguard Worker enum
1109*35238bceSAndroid Build Coastguard Worker {
1110*35238bceSAndroid Build Coastguard Worker BUF_SIZE = 2048
1111*35238bceSAndroid Build Coastguard Worker };
1112*35238bceSAndroid Build Coastguard Worker
1113*35238bceSAndroid Build Coastguard Worker static const char *const linkErrorVtxSource = "#version 300 es\n"
1114*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_pos;\n"
1115*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 u_uniform;\n"
1116*35238bceSAndroid Build Coastguard Worker "void main ()\n"
1117*35238bceSAndroid Build Coastguard Worker "{\n"
1118*35238bceSAndroid Build Coastguard Worker " gl_Position = a_pos + u_uniform;\n"
1119*35238bceSAndroid Build Coastguard Worker "}\n";
1120*35238bceSAndroid Build Coastguard Worker static const char *const linkErrorFrgSource = "#version 300 es\n"
1121*35238bceSAndroid Build Coastguard Worker "in highp vec4 v_missingVar;\n"
1122*35238bceSAndroid Build Coastguard Worker "uniform highp int u_uniform;\n"
1123*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;\n"
1124*35238bceSAndroid Build Coastguard Worker "void main ()\n"
1125*35238bceSAndroid Build Coastguard Worker "{\n"
1126*35238bceSAndroid Build Coastguard Worker " fragColor = v_missingVar + vec4(float(u_uniform));\n"
1127*35238bceSAndroid Build Coastguard Worker "}\n";
1128*35238bceSAndroid Build Coastguard Worker
1129*35238bceSAndroid Build Coastguard Worker const char *vtxSource = (m_buildErrorType == BUILDERROR_COMPILE) ? (brokenShader) : (linkErrorVtxSource);
1130*35238bceSAndroid Build Coastguard Worker const char *frgSource = (m_buildErrorType == BUILDERROR_COMPILE) ? (brokenShader) : (linkErrorFrgSource);
1131*35238bceSAndroid Build Coastguard Worker
1132*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1133*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1134*35238bceSAndroid Build Coastguard Worker
1135*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &vtxSource, DE_NULL);
1136*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &frgSource, DE_NULL);
1137*35238bceSAndroid Build Coastguard Worker
1138*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1139*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1140*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1141*35238bceSAndroid Build Coastguard Worker
1142*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1143*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1144*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1145*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1146*35238bceSAndroid Build Coastguard Worker
1147*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> logLength;
1148*35238bceSAndroid Build Coastguard Worker glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
1149*35238bceSAndroid Build Coastguard Worker logLength.verifyValidity(m_testCtx);
1150*35238bceSAndroid Build Coastguard Worker
1151*35238bceSAndroid Build Coastguard Worker // check INFO_LOG_LENGTH == GetProgramInfoLog len
1152*35238bceSAndroid Build Coastguard Worker {
1153*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryLarge", "Query to large buffer");
1154*35238bceSAndroid Build Coastguard Worker char buffer[BUF_SIZE] = {'x'};
1155*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1156*35238bceSAndroid Build Coastguard Worker
1157*35238bceSAndroid Build Coastguard Worker glGetProgramInfoLog(program, BUF_SIZE, &written, buffer);
1158*35238bceSAndroid Build Coastguard Worker
1159*35238bceSAndroid Build Coastguard Worker if (logLength != 0 && written + 1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
1160*35238bceSAndroid Build Coastguard Worker {
1161*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written + 1
1162*35238bceSAndroid Build Coastguard Worker << "; got " << logLength << TestLog::EndMessage;
1163*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1164*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
1165*35238bceSAndroid Build Coastguard Worker }
1166*35238bceSAndroid Build Coastguard Worker else if (logLength != 0 && buffer[written] != '\0')
1167*35238bceSAndroid Build Coastguard Worker {
1168*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at index " << written
1169*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1170*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1171*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "missing null terminator");
1172*35238bceSAndroid Build Coastguard Worker }
1173*35238bceSAndroid Build Coastguard Worker }
1174*35238bceSAndroid Build Coastguard Worker
1175*35238bceSAndroid Build Coastguard Worker // check query to just correct sized buffer
1176*35238bceSAndroid Build Coastguard Worker if (BUF_SIZE > logLength)
1177*35238bceSAndroid Build Coastguard Worker {
1178*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryAll",
1179*35238bceSAndroid Build Coastguard Worker "Query all to exactly right sized buffer");
1180*35238bceSAndroid Build Coastguard Worker char buffer[BUF_SIZE] = {'x'};
1181*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1182*35238bceSAndroid Build Coastguard Worker
1183*35238bceSAndroid Build Coastguard Worker glGetProgramInfoLog(program, logLength, &written, buffer);
1184*35238bceSAndroid Build Coastguard Worker
1185*35238bceSAndroid Build Coastguard Worker if (logLength != 0 && written + 1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
1186*35238bceSAndroid Build Coastguard Worker {
1187*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written + 1
1188*35238bceSAndroid Build Coastguard Worker << "; got " << logLength << TestLog::EndMessage;
1189*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1190*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
1191*35238bceSAndroid Build Coastguard Worker }
1192*35238bceSAndroid Build Coastguard Worker else if (logLength != 0 && buffer[written] != '\0')
1193*35238bceSAndroid Build Coastguard Worker {
1194*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at index " << written
1195*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1196*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1197*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "missing null terminator");
1198*35238bceSAndroid Build Coastguard Worker }
1199*35238bceSAndroid Build Coastguard Worker }
1200*35238bceSAndroid Build Coastguard Worker
1201*35238bceSAndroid Build Coastguard Worker // check GetProgramInfoLog works with too small buffer
1202*35238bceSAndroid Build Coastguard Worker {
1203*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), "QueryNone", "Query none");
1204*35238bceSAndroid Build Coastguard Worker char buffer[BUF_SIZE] = {'x'};
1205*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1206*35238bceSAndroid Build Coastguard Worker
1207*35238bceSAndroid Build Coastguard Worker glGetProgramInfoLog(program, 1, &written, buffer);
1208*35238bceSAndroid Build Coastguard Worker
1209*35238bceSAndroid Build Coastguard Worker if (written != 0)
1210*35238bceSAndroid Build Coastguard Worker {
1211*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written
1212*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1213*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1214*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
1215*35238bceSAndroid Build Coastguard Worker }
1216*35238bceSAndroid Build Coastguard Worker }
1217*35238bceSAndroid Build Coastguard Worker
1218*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1219*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1220*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1221*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1222*35238bceSAndroid Build Coastguard Worker }
1223*35238bceSAndroid Build Coastguard Worker
1224*35238bceSAndroid Build Coastguard Worker const BuildErrorType m_buildErrorType;
1225*35238bceSAndroid Build Coastguard Worker };
1226*35238bceSAndroid Build Coastguard Worker
1227*35238bceSAndroid Build Coastguard Worker class ProgramValidateStatusCase : public ApiCase
1228*35238bceSAndroid Build Coastguard Worker {
1229*35238bceSAndroid Build Coastguard Worker public:
ProgramValidateStatusCase(Context & context,const char * name,const char * description)1230*35238bceSAndroid Build Coastguard Worker ProgramValidateStatusCase(Context &context, const char *name, const char *description)
1231*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1232*35238bceSAndroid Build Coastguard Worker {
1233*35238bceSAndroid Build Coastguard Worker }
1234*35238bceSAndroid Build Coastguard Worker
test(void)1235*35238bceSAndroid Build Coastguard Worker void test(void)
1236*35238bceSAndroid Build Coastguard Worker {
1237*35238bceSAndroid Build Coastguard Worker // test validate ok
1238*35238bceSAndroid Build Coastguard Worker {
1239*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1240*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1241*35238bceSAndroid Build Coastguard Worker
1242*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1243*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
1244*35238bceSAndroid Build Coastguard Worker
1245*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1246*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1247*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1248*35238bceSAndroid Build Coastguard Worker
1249*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1250*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1251*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1252*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1253*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1254*35238bceSAndroid Build Coastguard Worker
1255*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
1256*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
1257*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE);
1258*35238bceSAndroid Build Coastguard Worker
1259*35238bceSAndroid Build Coastguard Worker glValidateProgram(program);
1260*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_TRUE);
1261*35238bceSAndroid Build Coastguard Worker
1262*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1263*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1264*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1265*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1266*35238bceSAndroid Build Coastguard Worker }
1267*35238bceSAndroid Build Coastguard Worker
1268*35238bceSAndroid Build Coastguard Worker // test with broken shader
1269*35238bceSAndroid Build Coastguard Worker {
1270*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1271*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1272*35238bceSAndroid Build Coastguard Worker
1273*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1274*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &brokenShader, DE_NULL);
1275*35238bceSAndroid Build Coastguard Worker
1276*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1277*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1278*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1279*35238bceSAndroid Build Coastguard Worker
1280*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1281*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1282*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1283*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1284*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1285*35238bceSAndroid Build Coastguard Worker
1286*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
1287*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
1288*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_FALSE);
1289*35238bceSAndroid Build Coastguard Worker
1290*35238bceSAndroid Build Coastguard Worker glValidateProgram(program);
1291*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_FALSE);
1292*35238bceSAndroid Build Coastguard Worker
1293*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1294*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1295*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1296*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1297*35238bceSAndroid Build Coastguard Worker }
1298*35238bceSAndroid Build Coastguard Worker }
1299*35238bceSAndroid Build Coastguard Worker };
1300*35238bceSAndroid Build Coastguard Worker
1301*35238bceSAndroid Build Coastguard Worker class ProgramAttachedShadersCase : public ApiCase
1302*35238bceSAndroid Build Coastguard Worker {
1303*35238bceSAndroid Build Coastguard Worker public:
ProgramAttachedShadersCase(Context & context,const char * name,const char * description)1304*35238bceSAndroid Build Coastguard Worker ProgramAttachedShadersCase(Context &context, const char *name, const char *description)
1305*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1306*35238bceSAndroid Build Coastguard Worker {
1307*35238bceSAndroid Build Coastguard Worker }
1308*35238bceSAndroid Build Coastguard Worker
test(void)1309*35238bceSAndroid Build Coastguard Worker void test(void)
1310*35238bceSAndroid Build Coastguard Worker {
1311*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1312*35238bceSAndroid Build Coastguard Worker
1313*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1314*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1315*35238bceSAndroid Build Coastguard Worker
1316*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1317*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
1318*35238bceSAndroid Build Coastguard Worker
1319*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1320*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1321*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1322*35238bceSAndroid Build Coastguard Worker
1323*35238bceSAndroid Build Coastguard Worker // check ATTACHED_SHADERS
1324*35238bceSAndroid Build Coastguard Worker
1325*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1326*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 0);
1327*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1328*35238bceSAndroid Build Coastguard Worker
1329*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1330*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 1);
1331*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1332*35238bceSAndroid Build Coastguard Worker
1333*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1334*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 2);
1335*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1336*35238bceSAndroid Build Coastguard Worker
1337*35238bceSAndroid Build Coastguard Worker // check GetAttachedShaders
1338*35238bceSAndroid Build Coastguard Worker {
1339*35238bceSAndroid Build Coastguard Worker GLuint shaders[2] = {0, 0};
1340*35238bceSAndroid Build Coastguard Worker GLint count = 0;
1341*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, DE_LENGTH_OF_ARRAY(shaders), &count, shaders);
1342*35238bceSAndroid Build Coastguard Worker
1343*35238bceSAndroid Build Coastguard Worker if (count != 2)
1344*35238bceSAndroid Build Coastguard Worker {
1345*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 2; got " << count << TestLog::EndMessage;
1346*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1347*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1348*35238bceSAndroid Build Coastguard Worker }
1349*35238bceSAndroid Build Coastguard Worker // shaders are the attached shaders?
1350*35238bceSAndroid Build Coastguard Worker if (!((shaders[0] == shaderVert && shaders[1] == shaderFrag) ||
1351*35238bceSAndroid Build Coastguard Worker (shaders[0] == shaderFrag && shaders[1] == shaderVert)))
1352*35238bceSAndroid Build Coastguard Worker {
1353*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected {" << shaderVert << ", " << shaderFrag
1354*35238bceSAndroid Build Coastguard Worker << "}; got {" << shaders[0] << ", " << shaders[1] << "}" << TestLog::EndMessage;
1355*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1356*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1357*35238bceSAndroid Build Coastguard Worker }
1358*35238bceSAndroid Build Coastguard Worker }
1359*35238bceSAndroid Build Coastguard Worker
1360*35238bceSAndroid Build Coastguard Worker // check GetAttachedShaders with too small buffer
1361*35238bceSAndroid Build Coastguard Worker {
1362*35238bceSAndroid Build Coastguard Worker GLuint shaders[2] = {0, 0};
1363*35238bceSAndroid Build Coastguard Worker GLint count = 0;
1364*35238bceSAndroid Build Coastguard Worker
1365*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, 0, &count, shaders);
1366*35238bceSAndroid Build Coastguard Worker if (count != 0)
1367*35238bceSAndroid Build Coastguard Worker {
1368*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0; got " << count << TestLog::EndMessage;
1369*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1370*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1371*35238bceSAndroid Build Coastguard Worker }
1372*35238bceSAndroid Build Coastguard Worker
1373*35238bceSAndroid Build Coastguard Worker count = 0;
1374*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, 1, &count, shaders);
1375*35238bceSAndroid Build Coastguard Worker if (count != 1)
1376*35238bceSAndroid Build Coastguard Worker {
1377*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 1; got " << count << TestLog::EndMessage;
1378*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1379*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1380*35238bceSAndroid Build Coastguard Worker }
1381*35238bceSAndroid Build Coastguard Worker }
1382*35238bceSAndroid Build Coastguard Worker
1383*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1384*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1385*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1386*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1387*35238bceSAndroid Build Coastguard Worker }
1388*35238bceSAndroid Build Coastguard Worker };
1389*35238bceSAndroid Build Coastguard Worker
1390*35238bceSAndroid Build Coastguard Worker class ProgramActiveUniformNameCase : public ApiCase
1391*35238bceSAndroid Build Coastguard Worker {
1392*35238bceSAndroid Build Coastguard Worker public:
ProgramActiveUniformNameCase(Context & context,const char * name,const char * description)1393*35238bceSAndroid Build Coastguard Worker ProgramActiveUniformNameCase(Context &context, const char *name, const char *description)
1394*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1395*35238bceSAndroid Build Coastguard Worker {
1396*35238bceSAndroid Build Coastguard Worker }
1397*35238bceSAndroid Build Coastguard Worker
test(void)1398*35238bceSAndroid Build Coastguard Worker void test(void)
1399*35238bceSAndroid Build Coastguard Worker {
1400*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1401*35238bceSAndroid Build Coastguard Worker
1402*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "#version 300 es\n"
1403*35238bceSAndroid Build Coastguard Worker "uniform highp float uniformNameWithLength23;\n"
1404*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 uniformVec2;\n"
1405*35238bceSAndroid Build Coastguard Worker "uniform highp mat4 uniformMat4;\n"
1406*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1407*35238bceSAndroid Build Coastguard Worker "{\n"
1408*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0) + vec4(uniformNameWithLength23) + "
1409*35238bceSAndroid Build Coastguard Worker "vec4(uniformVec2.x) + vec4(uniformMat4[2][3]);\n"
1410*35238bceSAndroid Build Coastguard Worker "}\n\0";
1411*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
1412*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
1413*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1414*35238bceSAndroid Build Coastguard Worker "{\n"
1415*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
1416*35238bceSAndroid Build Coastguard Worker "}\n\0";
1417*35238bceSAndroid Build Coastguard Worker
1418*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1419*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1420*35238bceSAndroid Build Coastguard Worker
1421*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
1422*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
1423*35238bceSAndroid Build Coastguard Worker
1424*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1425*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1426*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1427*35238bceSAndroid Build Coastguard Worker
1428*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1429*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1430*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1431*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1432*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1433*35238bceSAndroid Build Coastguard Worker
1434*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORMS, 3);
1435*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_MAX_LENGTH,
1436*35238bceSAndroid Build Coastguard Worker (GLint)std::string("uniformNameWithLength23").length() + 1); // including a null terminator
1437*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1438*35238bceSAndroid Build Coastguard Worker
1439*35238bceSAndroid Build Coastguard Worker const char *uniformNames[] = {"uniformNameWithLength23", "uniformVec2", "uniformMat4"};
1440*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformIndices;
1441*35238bceSAndroid Build Coastguard Worker glGetUniformIndices(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformNames, uniformIndices);
1442*35238bceSAndroid Build Coastguard Worker uniformIndices.verifyValidity(m_testCtx);
1443*35238bceSAndroid Build Coastguard Worker
1444*35238bceSAndroid Build Coastguard Worker // check name lengths
1445*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
1446*35238bceSAndroid Build Coastguard Worker {
1447*35238bceSAndroid Build Coastguard Worker const GLuint uniformIndex = uniformIndices[ndx];
1448*35238bceSAndroid Build Coastguard Worker
1449*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> uniformNameLen;
1450*35238bceSAndroid Build Coastguard Worker glGetActiveUniformsiv(program, 1, &uniformIndex, GL_UNIFORM_NAME_LENGTH, &uniformNameLen);
1451*35238bceSAndroid Build Coastguard Worker
1452*35238bceSAndroid Build Coastguard Worker uniformNameLen.verifyValidity(m_testCtx);
1453*35238bceSAndroid Build Coastguard Worker
1454*35238bceSAndroid Build Coastguard Worker const GLint referenceLength = (GLint)std::string(uniformNames[ndx]).length() + 1;
1455*35238bceSAndroid Build Coastguard Worker if (referenceLength != uniformNameLen) // uniformNameLen is with null terminator
1456*35238bceSAndroid Build Coastguard Worker {
1457*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << referenceLength << "got "
1458*35238bceSAndroid Build Coastguard Worker << uniformNameLen << TestLog::EndMessage;
1459*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1460*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
1461*35238bceSAndroid Build Coastguard Worker }
1462*35238bceSAndroid Build Coastguard Worker }
1463*35238bceSAndroid Build Coastguard Worker
1464*35238bceSAndroid Build Coastguard Worker // check names
1465*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
1466*35238bceSAndroid Build Coastguard Worker {
1467*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1468*35238bceSAndroid Build Coastguard Worker
1469*35238bceSAndroid Build Coastguard Worker const GLuint uniformIndex = uniformIndices[ndx];
1470*35238bceSAndroid Build Coastguard Worker
1471*35238bceSAndroid Build Coastguard Worker GLint written = 0; // null terminator not included
1472*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1473*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1474*35238bceSAndroid Build Coastguard Worker glGetActiveUniform(program, uniformIndex, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
1475*35238bceSAndroid Build Coastguard Worker
1476*35238bceSAndroid Build Coastguard Worker const GLint referenceLength = (GLint)std::string(uniformNames[ndx]).length();
1477*35238bceSAndroid Build Coastguard Worker if (referenceLength != written)
1478*35238bceSAndroid Build Coastguard Worker {
1479*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << referenceLength << "got " << written
1480*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1481*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1482*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
1483*35238bceSAndroid Build Coastguard Worker }
1484*35238bceSAndroid Build Coastguard Worker
1485*35238bceSAndroid Build Coastguard Worker // and with too small buffer
1486*35238bceSAndroid Build Coastguard Worker written = 0;
1487*35238bceSAndroid Build Coastguard Worker glGetActiveUniform(program, uniformIndex, 1, &written, &size, &type, buffer);
1488*35238bceSAndroid Build Coastguard Worker
1489*35238bceSAndroid Build Coastguard Worker if (written != 0)
1490*35238bceSAndroid Build Coastguard Worker {
1491*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0 got " << written << TestLog::EndMessage;
1492*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1493*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
1494*35238bceSAndroid Build Coastguard Worker }
1495*35238bceSAndroid Build Coastguard Worker }
1496*35238bceSAndroid Build Coastguard Worker
1497*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1498*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1499*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1500*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1501*35238bceSAndroid Build Coastguard Worker }
1502*35238bceSAndroid Build Coastguard Worker };
1503*35238bceSAndroid Build Coastguard Worker
1504*35238bceSAndroid Build Coastguard Worker class ProgramUniformCase : public ApiCase
1505*35238bceSAndroid Build Coastguard Worker {
1506*35238bceSAndroid Build Coastguard Worker public:
ProgramUniformCase(Context & context,const char * name,const char * description)1507*35238bceSAndroid Build Coastguard Worker ProgramUniformCase(Context &context, const char *name, const char *description)
1508*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1509*35238bceSAndroid Build Coastguard Worker {
1510*35238bceSAndroid Build Coastguard Worker }
1511*35238bceSAndroid Build Coastguard Worker
test(void)1512*35238bceSAndroid Build Coastguard Worker void test(void)
1513*35238bceSAndroid Build Coastguard Worker {
1514*35238bceSAndroid Build Coastguard Worker const struct UniformType
1515*35238bceSAndroid Build Coastguard Worker {
1516*35238bceSAndroid Build Coastguard Worker const char *declaration;
1517*35238bceSAndroid Build Coastguard Worker const char *postDeclaration;
1518*35238bceSAndroid Build Coastguard Worker const char *precision;
1519*35238bceSAndroid Build Coastguard Worker const char *layout;
1520*35238bceSAndroid Build Coastguard Worker const char *getter;
1521*35238bceSAndroid Build Coastguard Worker GLenum type;
1522*35238bceSAndroid Build Coastguard Worker GLint size;
1523*35238bceSAndroid Build Coastguard Worker GLint isRowMajor;
1524*35238bceSAndroid Build Coastguard Worker } uniformTypes[] = {
1525*35238bceSAndroid Build Coastguard Worker {"float", "", "highp", "", "uniformValue", GL_FLOAT, 1, GL_FALSE},
1526*35238bceSAndroid Build Coastguard Worker {"float[2]", "", "highp", "", "uniformValue[1]", GL_FLOAT, 2, GL_FALSE},
1527*35238bceSAndroid Build Coastguard Worker {"vec2", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC2, 1, GL_FALSE},
1528*35238bceSAndroid Build Coastguard Worker {"vec3", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC3, 1, GL_FALSE},
1529*35238bceSAndroid Build Coastguard Worker {"vec4", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC4, 1, GL_FALSE},
1530*35238bceSAndroid Build Coastguard Worker {"int", "", "highp", "", "float(uniformValue)", GL_INT, 1, GL_FALSE},
1531*35238bceSAndroid Build Coastguard Worker {"ivec2", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC2, 1, GL_FALSE},
1532*35238bceSAndroid Build Coastguard Worker {"ivec3", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC3, 1, GL_FALSE},
1533*35238bceSAndroid Build Coastguard Worker {"ivec4", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC4, 1, GL_FALSE},
1534*35238bceSAndroid Build Coastguard Worker {"uint", "", "highp", "", "float(uniformValue)", GL_UNSIGNED_INT, 1, GL_FALSE},
1535*35238bceSAndroid Build Coastguard Worker {"uvec2", "", "highp", "", "float(uniformValue.x)", GL_UNSIGNED_INT_VEC2, 1, GL_FALSE},
1536*35238bceSAndroid Build Coastguard Worker {"uvec3", "", "highp", "", "float(uniformValue.x)", GL_UNSIGNED_INT_VEC3, 1, GL_FALSE},
1537*35238bceSAndroid Build Coastguard Worker {"uvec4", "", "highp", "", "float(uniformValue.x)", GL_UNSIGNED_INT_VEC4, 1, GL_FALSE},
1538*35238bceSAndroid Build Coastguard Worker {"bool", "", "", "", "float(uniformValue)", GL_BOOL, 1, GL_FALSE},
1539*35238bceSAndroid Build Coastguard Worker {"bvec2", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC2, 1, GL_FALSE},
1540*35238bceSAndroid Build Coastguard Worker {"bvec3", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC3, 1, GL_FALSE},
1541*35238bceSAndroid Build Coastguard Worker {"bvec4", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC4, 1, GL_FALSE},
1542*35238bceSAndroid Build Coastguard Worker {"mat2", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT2, 1, GL_FALSE},
1543*35238bceSAndroid Build Coastguard Worker {"mat3", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT3, 1, GL_FALSE},
1544*35238bceSAndroid Build Coastguard Worker {"mat4", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT4, 1, GL_FALSE},
1545*35238bceSAndroid Build Coastguard Worker {"mat2x3", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT2x3, 1, GL_FALSE},
1546*35238bceSAndroid Build Coastguard Worker {"mat2x4", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT2x4, 1, GL_FALSE},
1547*35238bceSAndroid Build Coastguard Worker {"mat3x2", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT3x2, 1, GL_FALSE},
1548*35238bceSAndroid Build Coastguard Worker {"mat3x4", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT3x4, 1, GL_FALSE},
1549*35238bceSAndroid Build Coastguard Worker {"mat4x2", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT4x2, 1, GL_FALSE},
1550*35238bceSAndroid Build Coastguard Worker {"mat4x3", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT4x3, 1, GL_FALSE},
1551*35238bceSAndroid Build Coastguard Worker {"sampler2D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_2D, 1, GL_FALSE},
1552*35238bceSAndroid Build Coastguard Worker {"sampler3D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_3D, 1, GL_FALSE},
1553*35238bceSAndroid Build Coastguard Worker {"samplerCube", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_CUBE, 1, GL_FALSE},
1554*35238bceSAndroid Build Coastguard Worker {"sampler2DShadow", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_2D_SHADOW, 1,
1555*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1556*35238bceSAndroid Build Coastguard Worker {"sampler2DArray", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_2D_ARRAY, 1,
1557*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1558*35238bceSAndroid Build Coastguard Worker {"sampler2DArrayShadow", "", "highp", "", "float(textureSize(uniformValue,0).r)",
1559*35238bceSAndroid Build Coastguard Worker GL_SAMPLER_2D_ARRAY_SHADOW, 1, GL_FALSE},
1560*35238bceSAndroid Build Coastguard Worker {"samplerCubeShadow", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_SAMPLER_CUBE_SHADOW, 1,
1561*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1562*35238bceSAndroid Build Coastguard Worker {"isampler2D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_INT_SAMPLER_2D, 1, GL_FALSE},
1563*35238bceSAndroid Build Coastguard Worker {"isampler3D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_INT_SAMPLER_3D, 1, GL_FALSE},
1564*35238bceSAndroid Build Coastguard Worker {"isamplerCube", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_INT_SAMPLER_CUBE, 1, GL_FALSE},
1565*35238bceSAndroid Build Coastguard Worker {"isampler2DArray", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_INT_SAMPLER_2D_ARRAY, 1,
1566*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1567*35238bceSAndroid Build Coastguard Worker {"usampler2D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_UNSIGNED_INT_SAMPLER_2D, 1,
1568*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1569*35238bceSAndroid Build Coastguard Worker {"usampler3D", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_UNSIGNED_INT_SAMPLER_3D, 1,
1570*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1571*35238bceSAndroid Build Coastguard Worker {"usamplerCube", "", "highp", "", "float(textureSize(uniformValue,0).r)", GL_UNSIGNED_INT_SAMPLER_CUBE, 1,
1572*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1573*35238bceSAndroid Build Coastguard Worker {"usampler2DArray", "", "highp", "", "float(textureSize(uniformValue,0).r)",
1574*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, 1, GL_FALSE},
1575*35238bceSAndroid Build Coastguard Worker };
1576*35238bceSAndroid Build Coastguard Worker
1577*35238bceSAndroid Build Coastguard Worker static const char *vertSource = "#version 300 es\n"
1578*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1579*35238bceSAndroid Build Coastguard Worker "{\n"
1580*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
1581*35238bceSAndroid Build Coastguard Worker "}\n\0";
1582*35238bceSAndroid Build Coastguard Worker
1583*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1584*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1585*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1586*35238bceSAndroid Build Coastguard Worker
1587*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1588*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1589*35238bceSAndroid Build Coastguard Worker
1590*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &vertSource, DE_NULL);
1591*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1592*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1593*35238bceSAndroid Build Coastguard Worker
1594*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformTypes); ++ndx)
1595*35238bceSAndroid Build Coastguard Worker {
1596*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection(m_log, uniformTypes[ndx].declaration,
1597*35238bceSAndroid Build Coastguard Worker std::string("Verify type of ") + uniformTypes[ndx].declaration + " variable" +
1598*35238bceSAndroid Build Coastguard Worker uniformTypes[ndx].postDeclaration);
1599*35238bceSAndroid Build Coastguard Worker
1600*35238bceSAndroid Build Coastguard Worker // gen fragment shader
1601*35238bceSAndroid Build Coastguard Worker
1602*35238bceSAndroid Build Coastguard Worker std::ostringstream frag;
1603*35238bceSAndroid Build Coastguard Worker frag << "#version 300 es\n";
1604*35238bceSAndroid Build Coastguard Worker frag << uniformTypes[ndx].layout << "uniform " << uniformTypes[ndx].precision << " "
1605*35238bceSAndroid Build Coastguard Worker << uniformTypes[ndx].declaration << " uniformValue" << uniformTypes[ndx].postDeclaration << ";\n";
1606*35238bceSAndroid Build Coastguard Worker frag << "layout(location = 0) out mediump vec4 fragColor;\n";
1607*35238bceSAndroid Build Coastguard Worker frag << "void main (void)\n";
1608*35238bceSAndroid Build Coastguard Worker frag << "{\n";
1609*35238bceSAndroid Build Coastguard Worker frag << " fragColor = vec4(" << uniformTypes[ndx].getter << ");\n";
1610*35238bceSAndroid Build Coastguard Worker frag << "}\n";
1611*35238bceSAndroid Build Coastguard Worker
1612*35238bceSAndroid Build Coastguard Worker {
1613*35238bceSAndroid Build Coastguard Worker std::string fragmentSource = frag.str();
1614*35238bceSAndroid Build Coastguard Worker const char *fragmentSourceCStr = fragmentSource.c_str();
1615*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &fragmentSourceCStr, DE_NULL);
1616*35238bceSAndroid Build Coastguard Worker }
1617*35238bceSAndroid Build Coastguard Worker
1618*35238bceSAndroid Build Coastguard Worker // compile & link
1619*35238bceSAndroid Build Coastguard Worker
1620*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1621*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1622*35238bceSAndroid Build Coastguard Worker
1623*35238bceSAndroid Build Coastguard Worker // test
1624*35238bceSAndroid Build Coastguard Worker if (verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE))
1625*35238bceSAndroid Build Coastguard Worker {
1626*35238bceSAndroid Build Coastguard Worker const char *uniformNames[] = {"uniformValue"};
1627*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint> uniformIndex;
1628*35238bceSAndroid Build Coastguard Worker glGetUniformIndices(program, 1, uniformNames, &uniformIndex);
1629*35238bceSAndroid Build Coastguard Worker uniformIndex.verifyValidity(m_testCtx);
1630*35238bceSAndroid Build Coastguard Worker
1631*35238bceSAndroid Build Coastguard Worker verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_TYPE,
1632*35238bceSAndroid Build Coastguard Worker uniformTypes[ndx].type);
1633*35238bceSAndroid Build Coastguard Worker verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_SIZE,
1634*35238bceSAndroid Build Coastguard Worker uniformTypes[ndx].size);
1635*35238bceSAndroid Build Coastguard Worker verifyActiveUniformParam(m_testCtx, *this, program, uniformIndex, GL_UNIFORM_IS_ROW_MAJOR,
1636*35238bceSAndroid Build Coastguard Worker uniformTypes[ndx].isRowMajor);
1637*35238bceSAndroid Build Coastguard Worker }
1638*35238bceSAndroid Build Coastguard Worker }
1639*35238bceSAndroid Build Coastguard Worker
1640*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1641*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1642*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1643*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1644*35238bceSAndroid Build Coastguard Worker }
1645*35238bceSAndroid Build Coastguard Worker };
1646*35238bceSAndroid Build Coastguard Worker
1647*35238bceSAndroid Build Coastguard Worker class ProgramActiveUniformBlocksCase : public ApiCase
1648*35238bceSAndroid Build Coastguard Worker {
1649*35238bceSAndroid Build Coastguard Worker public:
ProgramActiveUniformBlocksCase(Context & context,const char * name,const char * description)1650*35238bceSAndroid Build Coastguard Worker ProgramActiveUniformBlocksCase(Context &context, const char *name, const char *description)
1651*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1652*35238bceSAndroid Build Coastguard Worker {
1653*35238bceSAndroid Build Coastguard Worker }
1654*35238bceSAndroid Build Coastguard Worker
test(void)1655*35238bceSAndroid Build Coastguard Worker void test(void)
1656*35238bceSAndroid Build Coastguard Worker {
1657*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1658*35238bceSAndroid Build Coastguard Worker
1659*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
1660*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
1661*35238bceSAndroid Build Coastguard Worker "uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n"
1662*35238bceSAndroid Build Coastguard Worker "uniform shortUniformBlockName {highp vec2 vector2;highp vec4 vector4;} shortUniformInstanceName;\n"
1663*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1664*35238bceSAndroid Build Coastguard Worker "{\n"
1665*35238bceSAndroid Build Coastguard Worker " gl_Position = shortUniformInstanceName.vector4 + vec4(longlongUniformInstanceName.vector2.x) + "
1666*35238bceSAndroid Build Coastguard Worker "vec4(shortUniformInstanceName.vector2.x);\n"
1667*35238bceSAndroid Build Coastguard Worker "}\n\0";
1668*35238bceSAndroid Build Coastguard Worker static const char *testFragSource =
1669*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
1670*35238bceSAndroid Build Coastguard Worker "uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n"
1671*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
1672*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1673*35238bceSAndroid Build Coastguard Worker "{\n"
1674*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(longlongUniformInstanceName.vector2.y);\n"
1675*35238bceSAndroid Build Coastguard Worker "}\n\0";
1676*35238bceSAndroid Build Coastguard Worker
1677*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1678*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1679*35238bceSAndroid Build Coastguard Worker
1680*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
1681*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
1682*35238bceSAndroid Build Coastguard Worker
1683*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1684*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1685*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1686*35238bceSAndroid Build Coastguard Worker
1687*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1688*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1689*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1690*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1691*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1692*35238bceSAndroid Build Coastguard Worker
1693*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
1694*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
1695*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE);
1696*35238bceSAndroid Build Coastguard Worker
1697*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_BLOCKS, 2);
1698*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
1699*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longlongUniformBlockName").length() + 1); // including a null terminator
1700*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1701*35238bceSAndroid Build Coastguard Worker
1702*35238bceSAndroid Build Coastguard Worker GLint longlongUniformBlockIndex = glGetUniformBlockIndex(program, "longlongUniformBlockName");
1703*35238bceSAndroid Build Coastguard Worker GLint shortUniformBlockIndex = glGetUniformBlockIndex(program, "shortUniformBlockName");
1704*35238bceSAndroid Build Coastguard Worker
1705*35238bceSAndroid Build Coastguard Worker const char *uniformNames[] = {"longlongUniformBlockName.vector2", "shortUniformBlockName.vector2",
1706*35238bceSAndroid Build Coastguard Worker "shortUniformBlockName.vector4"};
1707*35238bceSAndroid Build Coastguard Worker
1708*35238bceSAndroid Build Coastguard Worker // test UNIFORM_BLOCK_INDEX
1709*35238bceSAndroid Build Coastguard Worker
1710*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(uniformNames) == 3);
1711*35238bceSAndroid Build Coastguard Worker
1712*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLuint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformIndices;
1713*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[DE_LENGTH_OF_ARRAY(uniformNames)]> uniformsBlockIndices;
1714*35238bceSAndroid Build Coastguard Worker
1715*35238bceSAndroid Build Coastguard Worker glGetUniformIndices(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformNames, uniformIndices);
1716*35238bceSAndroid Build Coastguard Worker uniformIndices.verifyValidity(m_testCtx);
1717*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1718*35238bceSAndroid Build Coastguard Worker
1719*35238bceSAndroid Build Coastguard Worker glGetActiveUniformsiv(program, DE_LENGTH_OF_ARRAY(uniformNames), uniformIndices, GL_UNIFORM_BLOCK_INDEX,
1720*35238bceSAndroid Build Coastguard Worker uniformsBlockIndices);
1721*35238bceSAndroid Build Coastguard Worker uniformsBlockIndices.verifyValidity(m_testCtx);
1722*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1723*35238bceSAndroid Build Coastguard Worker
1724*35238bceSAndroid Build Coastguard Worker if (uniformsBlockIndices[0] != longlongUniformBlockIndex || uniformsBlockIndices[1] != shortUniformBlockIndex ||
1725*35238bceSAndroid Build Coastguard Worker uniformsBlockIndices[2] != shortUniformBlockIndex)
1726*35238bceSAndroid Build Coastguard Worker {
1727*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected [" << longlongUniformBlockIndex << ", "
1728*35238bceSAndroid Build Coastguard Worker << shortUniformBlockIndex << ", " << shortUniformBlockIndex << "];"
1729*35238bceSAndroid Build Coastguard Worker << "got [" << uniformsBlockIndices[0] << ", " << uniformsBlockIndices[1] << ", "
1730*35238bceSAndroid Build Coastguard Worker << uniformsBlockIndices[2] << "]" << TestLog::EndMessage;
1731*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1732*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform block index");
1733*35238bceSAndroid Build Coastguard Worker }
1734*35238bceSAndroid Build Coastguard Worker
1735*35238bceSAndroid Build Coastguard Worker // test UNIFORM_BLOCK_NAME_LENGTH
1736*35238bceSAndroid Build Coastguard Worker
1737*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(
1738*35238bceSAndroid Build Coastguard Worker m_testCtx, *this, program, longlongUniformBlockIndex, GL_UNIFORM_BLOCK_NAME_LENGTH,
1739*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longlongUniformBlockName").length() + 1); // including null-terminator
1740*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex, GL_UNIFORM_BLOCK_NAME_LENGTH,
1741*35238bceSAndroid Build Coastguard Worker (GLint)std::string("shortUniformBlockName").length() +
1742*35238bceSAndroid Build Coastguard Worker 1); // including null-terminator
1743*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1744*35238bceSAndroid Build Coastguard Worker
1745*35238bceSAndroid Build Coastguard Worker // test UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER & UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
1746*35238bceSAndroid Build Coastguard Worker
1747*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,
1748*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, GL_TRUE);
1749*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,
1750*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, GL_TRUE);
1751*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,
1752*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, GL_TRUE);
1753*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,
1754*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, GL_FALSE);
1755*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1756*35238bceSAndroid Build Coastguard Worker
1757*35238bceSAndroid Build Coastguard Worker // test UNIFORM_BLOCK_ACTIVE_UNIFORMS
1758*35238bceSAndroid Build Coastguard Worker
1759*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, longlongUniformBlockIndex,
1760*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, 1);
1761*35238bceSAndroid Build Coastguard Worker verifyActiveUniformBlockParam(m_testCtx, *this, program, shortUniformBlockIndex,
1762*35238bceSAndroid Build Coastguard Worker GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, 2);
1763*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1764*35238bceSAndroid Build Coastguard Worker
1765*35238bceSAndroid Build Coastguard Worker // test UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
1766*35238bceSAndroid Build Coastguard Worker
1767*35238bceSAndroid Build Coastguard Worker {
1768*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> longlongUniformBlockUniforms;
1769*35238bceSAndroid Build Coastguard Worker glGetActiveUniformBlockiv(program, longlongUniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS,
1770*35238bceSAndroid Build Coastguard Worker &longlongUniformBlockUniforms);
1771*35238bceSAndroid Build Coastguard Worker longlongUniformBlockUniforms.verifyValidity(m_testCtx);
1772*35238bceSAndroid Build Coastguard Worker
1773*35238bceSAndroid Build Coastguard Worker if (longlongUniformBlockUniforms == 2)
1774*35238bceSAndroid Build Coastguard Worker {
1775*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[2]> longlongUniformBlockUniformIndices;
1776*35238bceSAndroid Build Coastguard Worker glGetActiveUniformBlockiv(program, longlongUniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
1777*35238bceSAndroid Build Coastguard Worker longlongUniformBlockUniformIndices);
1778*35238bceSAndroid Build Coastguard Worker longlongUniformBlockUniformIndices.verifyValidity(m_testCtx);
1779*35238bceSAndroid Build Coastguard Worker
1780*35238bceSAndroid Build Coastguard Worker if ((GLuint(longlongUniformBlockUniformIndices[0]) != uniformIndices[0] ||
1781*35238bceSAndroid Build Coastguard Worker GLuint(longlongUniformBlockUniformIndices[1]) != uniformIndices[1]) &&
1782*35238bceSAndroid Build Coastguard Worker (GLuint(longlongUniformBlockUniformIndices[1]) != uniformIndices[0] ||
1783*35238bceSAndroid Build Coastguard Worker GLuint(longlongUniformBlockUniformIndices[0]) != uniformIndices[1]))
1784*35238bceSAndroid Build Coastguard Worker {
1785*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected {" << uniformIndices[0] << ", "
1786*35238bceSAndroid Build Coastguard Worker << uniformIndices[1] << "};"
1787*35238bceSAndroid Build Coastguard Worker << "got {" << longlongUniformBlockUniformIndices[0] << ", "
1788*35238bceSAndroid Build Coastguard Worker << longlongUniformBlockUniformIndices[1] << "}" << TestLog::EndMessage;
1789*35238bceSAndroid Build Coastguard Worker
1790*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1791*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform indices");
1792*35238bceSAndroid Build Coastguard Worker }
1793*35238bceSAndroid Build Coastguard Worker }
1794*35238bceSAndroid Build Coastguard Worker }
1795*35238bceSAndroid Build Coastguard Worker
1796*35238bceSAndroid Build Coastguard Worker // check block names
1797*35238bceSAndroid Build Coastguard Worker
1798*35238bceSAndroid Build Coastguard Worker {
1799*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1800*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1801*35238bceSAndroid Build Coastguard Worker glGetActiveUniformBlockName(program, longlongUniformBlockIndex, DE_LENGTH_OF_ARRAY(buffer), &written,
1802*35238bceSAndroid Build Coastguard Worker buffer);
1803*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written, (GLint)std::string("longlongUniformBlockName").length());
1804*35238bceSAndroid Build Coastguard Worker
1805*35238bceSAndroid Build Coastguard Worker written = 0;
1806*35238bceSAndroid Build Coastguard Worker glGetActiveUniformBlockName(program, shortUniformBlockIndex, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
1807*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written, (GLint)std::string("shortUniformBlockName").length());
1808*35238bceSAndroid Build Coastguard Worker
1809*35238bceSAndroid Build Coastguard Worker // and one with too small buffer
1810*35238bceSAndroid Build Coastguard Worker written = 0;
1811*35238bceSAndroid Build Coastguard Worker glGetActiveUniformBlockName(program, longlongUniformBlockIndex, 1, &written, buffer);
1812*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written, 0);
1813*35238bceSAndroid Build Coastguard Worker }
1814*35238bceSAndroid Build Coastguard Worker
1815*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1816*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1817*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1818*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1819*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1820*35238bceSAndroid Build Coastguard Worker }
1821*35238bceSAndroid Build Coastguard Worker };
1822*35238bceSAndroid Build Coastguard Worker
1823*35238bceSAndroid Build Coastguard Worker class ProgramBinaryCase : public ApiCase
1824*35238bceSAndroid Build Coastguard Worker {
1825*35238bceSAndroid Build Coastguard Worker public:
ProgramBinaryCase(Context & context,const char * name,const char * description)1826*35238bceSAndroid Build Coastguard Worker ProgramBinaryCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
1827*35238bceSAndroid Build Coastguard Worker {
1828*35238bceSAndroid Build Coastguard Worker }
1829*35238bceSAndroid Build Coastguard Worker
test(void)1830*35238bceSAndroid Build Coastguard Worker void test(void)
1831*35238bceSAndroid Build Coastguard Worker {
1832*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1833*35238bceSAndroid Build Coastguard Worker
1834*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1835*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1836*35238bceSAndroid Build Coastguard Worker
1837*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1838*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
1839*35238bceSAndroid Build Coastguard Worker
1840*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1841*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1842*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1843*35238bceSAndroid Build Coastguard Worker
1844*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1845*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1846*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1847*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1848*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1849*35238bceSAndroid Build Coastguard Worker
1850*35238bceSAndroid Build Coastguard Worker // test PROGRAM_BINARY_RETRIEVABLE_HINT
1851*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_FALSE);
1852*35238bceSAndroid Build Coastguard Worker
1853*35238bceSAndroid Build Coastguard Worker glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
1854*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1855*35238bceSAndroid Build Coastguard Worker
1856*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1857*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1858*35238bceSAndroid Build Coastguard Worker
1859*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
1860*35238bceSAndroid Build Coastguard Worker
1861*35238bceSAndroid Build Coastguard Worker // test PROGRAM_BINARY_LENGTH does something
1862*35238bceSAndroid Build Coastguard Worker
1863*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> programLength;
1864*35238bceSAndroid Build Coastguard Worker glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &programLength);
1865*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1866*35238bceSAndroid Build Coastguard Worker programLength.verifyValidity(m_testCtx);
1867*35238bceSAndroid Build Coastguard Worker
1868*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1869*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1870*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1871*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1872*35238bceSAndroid Build Coastguard Worker }
1873*35238bceSAndroid Build Coastguard Worker };
1874*35238bceSAndroid Build Coastguard Worker
1875*35238bceSAndroid Build Coastguard Worker class TransformFeedbackCase : public ApiCase
1876*35238bceSAndroid Build Coastguard Worker {
1877*35238bceSAndroid Build Coastguard Worker public:
TransformFeedbackCase(Context & context,const char * name,const char * description)1878*35238bceSAndroid Build Coastguard Worker TransformFeedbackCase(Context &context, const char *name, const char *description)
1879*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1880*35238bceSAndroid Build Coastguard Worker {
1881*35238bceSAndroid Build Coastguard Worker }
1882*35238bceSAndroid Build Coastguard Worker
test(void)1883*35238bceSAndroid Build Coastguard Worker void test(void)
1884*35238bceSAndroid Build Coastguard Worker {
1885*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1886*35238bceSAndroid Build Coastguard Worker
1887*35238bceSAndroid Build Coastguard Worker static const char *transformFeedbackTestVertSource = "#version 300 es\n"
1888*35238bceSAndroid Build Coastguard Worker "out highp vec4 tfOutput2withLongName;\n"
1889*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1890*35238bceSAndroid Build Coastguard Worker "{\n"
1891*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
1892*35238bceSAndroid Build Coastguard Worker " tfOutput2withLongName = vec4(0.0);\n"
1893*35238bceSAndroid Build Coastguard Worker "}\n";
1894*35238bceSAndroid Build Coastguard Worker static const char *transformFeedbackTestFragSource = "#version 300 es\n"
1895*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out highp vec4 fragColor;\n"
1896*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1897*35238bceSAndroid Build Coastguard Worker "{\n"
1898*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
1899*35238bceSAndroid Build Coastguard Worker "}\n";
1900*35238bceSAndroid Build Coastguard Worker
1901*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1902*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1903*35238bceSAndroid Build Coastguard Worker GLuint shaderProg = glCreateProgram();
1904*35238bceSAndroid Build Coastguard Worker
1905*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_BUFFER_MODE, GL_INTERLEAVED_ATTRIBS);
1906*35238bceSAndroid Build Coastguard Worker
1907*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
1908*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
1909*35238bceSAndroid Build Coastguard Worker
1910*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1911*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1912*35238bceSAndroid Build Coastguard Worker
1913*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
1914*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
1915*35238bceSAndroid Build Coastguard Worker
1916*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderVert);
1917*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderFrag);
1918*35238bceSAndroid Build Coastguard Worker
1919*35238bceSAndroid Build Coastguard Worker // check TRANSFORM_FEEDBACK_BUFFER_MODE
1920*35238bceSAndroid Build Coastguard Worker
1921*35238bceSAndroid Build Coastguard Worker const char *transform_feedback_outputs[] = {"gl_Position", "tfOutput2withLongName"};
1922*35238bceSAndroid Build Coastguard Worker const char *longest_output = transform_feedback_outputs[1];
1923*35238bceSAndroid Build Coastguard Worker const GLenum bufferModes[] = {GL_SEPARATE_ATTRIBS, GL_INTERLEAVED_ATTRIBS};
1924*35238bceSAndroid Build Coastguard Worker
1925*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(bufferModes); ++ndx)
1926*35238bceSAndroid Build Coastguard Worker {
1927*35238bceSAndroid Build Coastguard Worker glTransformFeedbackVaryings(shaderProg, DE_LENGTH_OF_ARRAY(transform_feedback_outputs),
1928*35238bceSAndroid Build Coastguard Worker transform_feedback_outputs, bufferModes[ndx]);
1929*35238bceSAndroid Build Coastguard Worker glLinkProgram(shaderProg);
1930*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1931*35238bceSAndroid Build Coastguard Worker
1932*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
1933*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_BUFFER_MODE, bufferModes[ndx]);
1934*35238bceSAndroid Build Coastguard Worker }
1935*35238bceSAndroid Build Coastguard Worker
1936*35238bceSAndroid Build Coastguard Worker // TRANSFORM_FEEDBACK_VARYINGS
1937*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_TRANSFORM_FEEDBACK_VARYINGS, 2);
1938*35238bceSAndroid Build Coastguard Worker
1939*35238bceSAndroid Build Coastguard Worker // TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
1940*35238bceSAndroid Build Coastguard Worker {
1941*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> maxOutputLen;
1942*35238bceSAndroid Build Coastguard Worker glGetProgramiv(shaderProg, GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, &maxOutputLen);
1943*35238bceSAndroid Build Coastguard Worker
1944*35238bceSAndroid Build Coastguard Worker maxOutputLen.verifyValidity(m_testCtx);
1945*35238bceSAndroid Build Coastguard Worker
1946*35238bceSAndroid Build Coastguard Worker const GLint referenceLength = (GLint)std::string(longest_output).length() + 1;
1947*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, maxOutputLen, referenceLength);
1948*35238bceSAndroid Build Coastguard Worker }
1949*35238bceSAndroid Build Coastguard Worker
1950*35238bceSAndroid Build Coastguard Worker // check varyings
1951*35238bceSAndroid Build Coastguard Worker {
1952*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> varyings;
1953*35238bceSAndroid Build Coastguard Worker glGetProgramiv(shaderProg, GL_TRANSFORM_FEEDBACK_VARYINGS, &varyings);
1954*35238bceSAndroid Build Coastguard Worker
1955*35238bceSAndroid Build Coastguard Worker if (!varyings.isUndefined())
1956*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < varyings; ++index)
1957*35238bceSAndroid Build Coastguard Worker {
1958*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1959*35238bceSAndroid Build Coastguard Worker
1960*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1961*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1962*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1963*35238bceSAndroid Build Coastguard Worker glGetTransformFeedbackVarying(shaderProg, index, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type,
1964*35238bceSAndroid Build Coastguard Worker buffer);
1965*35238bceSAndroid Build Coastguard Worker
1966*35238bceSAndroid Build Coastguard Worker if (written < DE_LENGTH_OF_ARRAY(buffer) && buffer[written] != '\0')
1967*35238bceSAndroid Build Coastguard Worker {
1968*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog()
1969*35238bceSAndroid Build Coastguard Worker << TestLog::Message << "// ERROR: Expected null terminator" << TestLog::EndMessage;
1970*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1971*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid string terminator");
1972*35238bceSAndroid Build Coastguard Worker }
1973*35238bceSAndroid Build Coastguard Worker
1974*35238bceSAndroid Build Coastguard Worker // check with too small buffer
1975*35238bceSAndroid Build Coastguard Worker written = 0;
1976*35238bceSAndroid Build Coastguard Worker glGetTransformFeedbackVarying(shaderProg, index, 1, &written, &size, &type, buffer);
1977*35238bceSAndroid Build Coastguard Worker if (written != 0)
1978*35238bceSAndroid Build Coastguard Worker {
1979*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog()
1980*35238bceSAndroid Build Coastguard Worker << TestLog::Message << "// ERROR: Expected 0; got " << written << TestLog::EndMessage;
1981*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1982*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid write length");
1983*35238bceSAndroid Build Coastguard Worker }
1984*35238bceSAndroid Build Coastguard Worker }
1985*35238bceSAndroid Build Coastguard Worker }
1986*35238bceSAndroid Build Coastguard Worker
1987*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1988*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1989*35238bceSAndroid Build Coastguard Worker glDeleteProgram(shaderProg);
1990*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1991*35238bceSAndroid Build Coastguard Worker }
1992*35238bceSAndroid Build Coastguard Worker };
1993*35238bceSAndroid Build Coastguard Worker
1994*35238bceSAndroid Build Coastguard Worker class ActiveAttributesCase : public ApiCase
1995*35238bceSAndroid Build Coastguard Worker {
1996*35238bceSAndroid Build Coastguard Worker public:
ActiveAttributesCase(Context & context,const char * name,const char * description)1997*35238bceSAndroid Build Coastguard Worker ActiveAttributesCase(Context &context, const char *name, const char *description)
1998*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1999*35238bceSAndroid Build Coastguard Worker {
2000*35238bceSAndroid Build Coastguard Worker }
2001*35238bceSAndroid Build Coastguard Worker
test(void)2002*35238bceSAndroid Build Coastguard Worker void test(void)
2003*35238bceSAndroid Build Coastguard Worker {
2004*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
2005*35238bceSAndroid Build Coastguard Worker
2006*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "#version 300 es\n"
2007*35238bceSAndroid Build Coastguard Worker "in highp vec2 longInputAttributeName;\n"
2008*35238bceSAndroid Build Coastguard Worker "in highp vec2 shortName;\n"
2009*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2010*35238bceSAndroid Build Coastguard Worker "{\n"
2011*35238bceSAndroid Build Coastguard Worker " gl_Position = longInputAttributeName.yxxy + shortName.xyxy;\n"
2012*35238bceSAndroid Build Coastguard Worker "}\n\0";
2013*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
2014*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
2015*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2016*35238bceSAndroid Build Coastguard Worker "{\n"
2017*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
2018*35238bceSAndroid Build Coastguard Worker "}\n\0";
2019*35238bceSAndroid Build Coastguard Worker
2020*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
2021*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
2022*35238bceSAndroid Build Coastguard Worker
2023*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
2024*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
2025*35238bceSAndroid Build Coastguard Worker
2026*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
2027*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
2028*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2029*35238bceSAndroid Build Coastguard Worker
2030*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
2031*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
2032*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
2033*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
2034*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2035*35238bceSAndroid Build Coastguard Worker
2036*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTES, 2);
2037*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
2038*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longInputAttributeName").length() + 1); // does include null-terminator
2039*35238bceSAndroid Build Coastguard Worker
2040*35238bceSAndroid Build Coastguard Worker // check names
2041*35238bceSAndroid Build Coastguard Worker for (int attributeNdx = 0; attributeNdx < 2; ++attributeNdx)
2042*35238bceSAndroid Build Coastguard Worker {
2043*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
2044*35238bceSAndroid Build Coastguard Worker
2045*35238bceSAndroid Build Coastguard Worker GLint written = 0;
2046*35238bceSAndroid Build Coastguard Worker GLint size = 0;
2047*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
2048*35238bceSAndroid Build Coastguard Worker glGetActiveAttrib(program, attributeNdx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
2049*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2050*35238bceSAndroid Build Coastguard Worker
2051*35238bceSAndroid Build Coastguard Worker if (deStringBeginsWith(buffer, "longInputAttributeName"))
2052*35238bceSAndroid Build Coastguard Worker {
2053*35238bceSAndroid Build Coastguard Worker checkIntEquals(
2054*35238bceSAndroid Build Coastguard Worker m_testCtx, written,
2055*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longInputAttributeName").length()); // does NOT include null-terminator
2056*35238bceSAndroid Build Coastguard Worker }
2057*35238bceSAndroid Build Coastguard Worker else if (deStringBeginsWith(buffer, "shortName"))
2058*35238bceSAndroid Build Coastguard Worker {
2059*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written,
2060*35238bceSAndroid Build Coastguard Worker (GLint)std::string("shortName").length()); // does NOT include null-terminator
2061*35238bceSAndroid Build Coastguard Worker }
2062*35238bceSAndroid Build Coastguard Worker else
2063*35238bceSAndroid Build Coastguard Worker {
2064*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unexpected attribute name."
2065*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
2066*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
2067*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got unexpected name");
2068*35238bceSAndroid Build Coastguard Worker }
2069*35238bceSAndroid Build Coastguard Worker }
2070*35238bceSAndroid Build Coastguard Worker
2071*35238bceSAndroid Build Coastguard Worker // and with too short buffer
2072*35238bceSAndroid Build Coastguard Worker {
2073*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
2074*35238bceSAndroid Build Coastguard Worker
2075*35238bceSAndroid Build Coastguard Worker GLint written = 0;
2076*35238bceSAndroid Build Coastguard Worker GLint size = 0;
2077*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
2078*35238bceSAndroid Build Coastguard Worker
2079*35238bceSAndroid Build Coastguard Worker glGetActiveAttrib(program, 0, 1, &written, &size, &type, buffer);
2080*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2081*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written, 0);
2082*35238bceSAndroid Build Coastguard Worker }
2083*35238bceSAndroid Build Coastguard Worker
2084*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
2085*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
2086*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
2087*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2088*35238bceSAndroid Build Coastguard Worker }
2089*35238bceSAndroid Build Coastguard Worker };
2090*35238bceSAndroid Build Coastguard Worker
2091*35238bceSAndroid Build Coastguard Worker struct PointerData
2092*35238bceSAndroid Build Coastguard Worker {
2093*35238bceSAndroid Build Coastguard Worker GLint size;
2094*35238bceSAndroid Build Coastguard Worker GLenum type;
2095*35238bceSAndroid Build Coastguard Worker GLint stride;
2096*35238bceSAndroid Build Coastguard Worker GLboolean normalized;
2097*35238bceSAndroid Build Coastguard Worker const void *pointer;
2098*35238bceSAndroid Build Coastguard Worker };
2099*35238bceSAndroid Build Coastguard Worker
2100*35238bceSAndroid Build Coastguard Worker class VertexAttributeSizeCase : public ApiCase
2101*35238bceSAndroid Build Coastguard Worker {
2102*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeSizeCase(Context & context,const char * name,const char * description)2103*35238bceSAndroid Build Coastguard Worker VertexAttributeSizeCase(Context &context, const char *name, const char *description)
2104*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2105*35238bceSAndroid Build Coastguard Worker {
2106*35238bceSAndroid Build Coastguard Worker }
2107*35238bceSAndroid Build Coastguard Worker
test(void)2108*35238bceSAndroid Build Coastguard Worker void test(void)
2109*35238bceSAndroid Build Coastguard Worker {
2110*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
2111*35238bceSAndroid Build Coastguard Worker
2112*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2113*35238bceSAndroid Build Coastguard Worker // size test
2114*35238bceSAndroid Build Coastguard Worker {4, GL_FLOAT, 0, GL_FALSE, vertexData}, {3, GL_FLOAT, 0, GL_FALSE, vertexData},
2115*35238bceSAndroid Build Coastguard Worker {2, GL_FLOAT, 0, GL_FALSE, vertexData}, {1, GL_FLOAT, 0, GL_FALSE, vertexData},
2116*35238bceSAndroid Build Coastguard Worker {4, GL_INT, 0, GL_FALSE, vertexData}, {3, GL_INT, 0, GL_FALSE, vertexData},
2117*35238bceSAndroid Build Coastguard Worker {2, GL_INT, 0, GL_FALSE, vertexData}, {1, GL_INT, 0, GL_FALSE, vertexData},
2118*35238bceSAndroid Build Coastguard Worker };
2119*35238bceSAndroid Build Coastguard Worker
2120*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2121*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2122*35238bceSAndroid Build Coastguard Worker
2123*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2124*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2125*35238bceSAndroid Build Coastguard Worker {
2126*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2127*35238bceSAndroid Build Coastguard Worker
2128*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2129*35238bceSAndroid Build Coastguard Worker {
2130*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
2131*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
2132*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2133*35238bceSAndroid Build Coastguard Worker
2134*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[ndx].size);
2135*35238bceSAndroid Build Coastguard Worker }
2136*35238bceSAndroid Build Coastguard Worker }
2137*35238bceSAndroid Build Coastguard Worker
2138*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2139*35238bceSAndroid Build Coastguard Worker {
2140*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2141*35238bceSAndroid Build Coastguard Worker
2142*35238bceSAndroid Build Coastguard Worker GLuint buf = 0;
2143*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2144*35238bceSAndroid Build Coastguard Worker
2145*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2146*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &buf);
2147*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, buf);
2148*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2149*35238bceSAndroid Build Coastguard Worker
2150*35238bceSAndroid Build Coastguard Worker // initial
2151*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2152*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, 4);
2153*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2154*35238bceSAndroid Build Coastguard Worker
2155*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2156*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[0].size, pointers[0].type, pointers[0].normalized, pointers[0].stride,
2157*35238bceSAndroid Build Coastguard Worker DE_NULL);
2158*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2159*35238bceSAndroid Build Coastguard Worker
2160*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2161*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2162*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[1].size, pointers[1].type, pointers[1].normalized, pointers[1].stride,
2163*35238bceSAndroid Build Coastguard Worker DE_NULL);
2164*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2165*35238bceSAndroid Build Coastguard Worker
2166*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2167*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[1].size);
2168*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2169*35238bceSAndroid Build Coastguard Worker
2170*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2171*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2172*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[0].size);
2173*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2174*35238bceSAndroid Build Coastguard Worker
2175*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2176*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &buf);
2177*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2178*35238bceSAndroid Build Coastguard Worker }
2179*35238bceSAndroid Build Coastguard Worker }
2180*35238bceSAndroid Build Coastguard Worker };
2181*35238bceSAndroid Build Coastguard Worker
2182*35238bceSAndroid Build Coastguard Worker class VertexAttributeTypeCase : public ApiCase
2183*35238bceSAndroid Build Coastguard Worker {
2184*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeTypeCase(Context & context,const char * name,const char * description)2185*35238bceSAndroid Build Coastguard Worker VertexAttributeTypeCase(Context &context, const char *name, const char *description)
2186*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2187*35238bceSAndroid Build Coastguard Worker {
2188*35238bceSAndroid Build Coastguard Worker }
2189*35238bceSAndroid Build Coastguard Worker
test(void)2190*35238bceSAndroid Build Coastguard Worker void test(void)
2191*35238bceSAndroid Build Coastguard Worker {
2192*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2193*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2194*35238bceSAndroid Build Coastguard Worker
2195*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2196*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2197*35238bceSAndroid Build Coastguard Worker {
2198*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2199*35238bceSAndroid Build Coastguard Worker
2200*35238bceSAndroid Build Coastguard Worker const GLfloat vertexData[4] = {0.0f}; // never accessed
2201*35238bceSAndroid Build Coastguard Worker
2202*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
2203*35238bceSAndroid Build Coastguard Worker {
2204*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2205*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2206*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2207*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2208*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, GL_FALSE, vertexData},
2209*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, GL_FALSE, vertexData},
2210*35238bceSAndroid Build Coastguard Worker {1, GL_HALF_FLOAT, 0, GL_FALSE, vertexData},
2211*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2212*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2213*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2214*35238bceSAndroid Build Coastguard Worker {4, GL_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2215*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2216*35238bceSAndroid Build Coastguard Worker };
2217*35238bceSAndroid Build Coastguard Worker
2218*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2219*35238bceSAndroid Build Coastguard Worker {
2220*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
2221*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
2222*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2223*35238bceSAndroid Build Coastguard Worker
2224*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
2225*35238bceSAndroid Build Coastguard Worker }
2226*35238bceSAndroid Build Coastguard Worker }
2227*35238bceSAndroid Build Coastguard Worker
2228*35238bceSAndroid Build Coastguard Worker // test glVertexAttribIPointer
2229*35238bceSAndroid Build Coastguard Worker {
2230*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2231*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2232*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2233*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2234*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2235*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2236*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2237*35238bceSAndroid Build Coastguard Worker };
2238*35238bceSAndroid Build Coastguard Worker
2239*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2240*35238bceSAndroid Build Coastguard Worker {
2241*35238bceSAndroid Build Coastguard Worker glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride,
2242*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
2243*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2244*35238bceSAndroid Build Coastguard Worker
2245*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
2246*35238bceSAndroid Build Coastguard Worker }
2247*35238bceSAndroid Build Coastguard Worker }
2248*35238bceSAndroid Build Coastguard Worker }
2249*35238bceSAndroid Build Coastguard Worker
2250*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2251*35238bceSAndroid Build Coastguard Worker {
2252*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2253*35238bceSAndroid Build Coastguard Worker
2254*35238bceSAndroid Build Coastguard Worker GLuint buf = 0;
2255*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2256*35238bceSAndroid Build Coastguard Worker
2257*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2258*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &buf);
2259*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, buf);
2260*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2261*35238bceSAndroid Build Coastguard Worker
2262*35238bceSAndroid Build Coastguard Worker // initial
2263*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2264*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_FLOAT);
2265*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2266*35238bceSAndroid Build Coastguard Worker
2267*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2268*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, DE_NULL);
2269*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2270*35238bceSAndroid Build Coastguard Worker
2271*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2272*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2273*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_SHORT, GL_FALSE, 0, DE_NULL);
2274*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2275*35238bceSAndroid Build Coastguard Worker
2276*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2277*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_SHORT);
2278*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2279*35238bceSAndroid Build Coastguard Worker
2280*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2281*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2282*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, GL_FLOAT);
2283*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2284*35238bceSAndroid Build Coastguard Worker
2285*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2286*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &buf);
2287*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2288*35238bceSAndroid Build Coastguard Worker }
2289*35238bceSAndroid Build Coastguard Worker }
2290*35238bceSAndroid Build Coastguard Worker };
2291*35238bceSAndroid Build Coastguard Worker
2292*35238bceSAndroid Build Coastguard Worker class VertexAttributeStrideCase : public ApiCase
2293*35238bceSAndroid Build Coastguard Worker {
2294*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeStrideCase(Context & context,const char * name,const char * description)2295*35238bceSAndroid Build Coastguard Worker VertexAttributeStrideCase(Context &context, const char *name, const char *description)
2296*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2297*35238bceSAndroid Build Coastguard Worker {
2298*35238bceSAndroid Build Coastguard Worker }
2299*35238bceSAndroid Build Coastguard Worker
test(void)2300*35238bceSAndroid Build Coastguard Worker void test(void)
2301*35238bceSAndroid Build Coastguard Worker {
2302*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2303*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2304*35238bceSAndroid Build Coastguard Worker
2305*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2306*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2307*35238bceSAndroid Build Coastguard Worker {
2308*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2309*35238bceSAndroid Build Coastguard Worker
2310*35238bceSAndroid Build Coastguard Worker const GLfloat vertexData[4] = {0.0f}; // never accessed
2311*35238bceSAndroid Build Coastguard Worker
2312*35238bceSAndroid Build Coastguard Worker struct StridePointerData
2313*35238bceSAndroid Build Coastguard Worker {
2314*35238bceSAndroid Build Coastguard Worker GLint size;
2315*35238bceSAndroid Build Coastguard Worker GLenum type;
2316*35238bceSAndroid Build Coastguard Worker GLint stride;
2317*35238bceSAndroid Build Coastguard Worker const void *pointer;
2318*35238bceSAndroid Build Coastguard Worker };
2319*35238bceSAndroid Build Coastguard Worker
2320*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
2321*35238bceSAndroid Build Coastguard Worker {
2322*35238bceSAndroid Build Coastguard Worker const StridePointerData pointers[] = {
2323*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, vertexData}, {1, GL_FLOAT, 1, vertexData},
2324*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 4, vertexData}, {1, GL_HALF_FLOAT, 0, vertexData},
2325*35238bceSAndroid Build Coastguard Worker {1, GL_HALF_FLOAT, 1, vertexData}, {1, GL_HALF_FLOAT, 4, vertexData},
2326*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, vertexData}, {1, GL_FIXED, 1, vertexData},
2327*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 4, vertexData},
2328*35238bceSAndroid Build Coastguard Worker };
2329*35238bceSAndroid Build Coastguard Worker
2330*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2331*35238bceSAndroid Build Coastguard Worker {
2332*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, GL_FALSE, pointers[ndx].stride,
2333*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
2334*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2335*35238bceSAndroid Build Coastguard Worker
2336*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
2337*35238bceSAndroid Build Coastguard Worker }
2338*35238bceSAndroid Build Coastguard Worker }
2339*35238bceSAndroid Build Coastguard Worker
2340*35238bceSAndroid Build Coastguard Worker // test glVertexAttribIPointer
2341*35238bceSAndroid Build Coastguard Worker {
2342*35238bceSAndroid Build Coastguard Worker const StridePointerData pointers[] = {
2343*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, vertexData}, {1, GL_INT, 1, vertexData},
2344*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 4, vertexData}, {4, GL_UNSIGNED_BYTE, 0, vertexData},
2345*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_BYTE, 1, vertexData}, {4, GL_UNSIGNED_BYTE, 4, vertexData},
2346*35238bceSAndroid Build Coastguard Worker {2, GL_SHORT, 0, vertexData}, {2, GL_SHORT, 1, vertexData},
2347*35238bceSAndroid Build Coastguard Worker {2, GL_SHORT, 4, vertexData},
2348*35238bceSAndroid Build Coastguard Worker };
2349*35238bceSAndroid Build Coastguard Worker
2350*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2351*35238bceSAndroid Build Coastguard Worker {
2352*35238bceSAndroid Build Coastguard Worker glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride,
2353*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
2354*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2355*35238bceSAndroid Build Coastguard Worker
2356*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
2357*35238bceSAndroid Build Coastguard Worker }
2358*35238bceSAndroid Build Coastguard Worker }
2359*35238bceSAndroid Build Coastguard Worker }
2360*35238bceSAndroid Build Coastguard Worker
2361*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2362*35238bceSAndroid Build Coastguard Worker {
2363*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2364*35238bceSAndroid Build Coastguard Worker
2365*35238bceSAndroid Build Coastguard Worker GLuint buf = 0;
2366*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2367*35238bceSAndroid Build Coastguard Worker
2368*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2369*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &buf);
2370*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, buf);
2371*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2372*35238bceSAndroid Build Coastguard Worker
2373*35238bceSAndroid Build Coastguard Worker // initial
2374*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2375*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 0);
2376*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2377*35238bceSAndroid Build Coastguard Worker
2378*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2379*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 4, DE_NULL);
2380*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2381*35238bceSAndroid Build Coastguard Worker
2382*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2383*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2384*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_SHORT, GL_FALSE, 8, DE_NULL);
2385*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2386*35238bceSAndroid Build Coastguard Worker
2387*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2388*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 8);
2389*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2390*35238bceSAndroid Build Coastguard Worker
2391*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2392*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2393*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, 4);
2394*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2395*35238bceSAndroid Build Coastguard Worker
2396*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2397*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &buf);
2398*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2399*35238bceSAndroid Build Coastguard Worker }
2400*35238bceSAndroid Build Coastguard Worker }
2401*35238bceSAndroid Build Coastguard Worker };
2402*35238bceSAndroid Build Coastguard Worker
2403*35238bceSAndroid Build Coastguard Worker class VertexAttributeNormalizedCase : public ApiCase
2404*35238bceSAndroid Build Coastguard Worker {
2405*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeNormalizedCase(Context & context,const char * name,const char * description)2406*35238bceSAndroid Build Coastguard Worker VertexAttributeNormalizedCase(Context &context, const char *name, const char *description)
2407*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2408*35238bceSAndroid Build Coastguard Worker {
2409*35238bceSAndroid Build Coastguard Worker }
2410*35238bceSAndroid Build Coastguard Worker
test(void)2411*35238bceSAndroid Build Coastguard Worker void test(void)
2412*35238bceSAndroid Build Coastguard Worker {
2413*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2414*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2415*35238bceSAndroid Build Coastguard Worker
2416*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2417*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2418*35238bceSAndroid Build Coastguard Worker {
2419*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2420*35238bceSAndroid Build Coastguard Worker
2421*35238bceSAndroid Build Coastguard Worker const GLfloat vertexData[4] = {0.0f}; // never accessed
2422*35238bceSAndroid Build Coastguard Worker
2423*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
2424*35238bceSAndroid Build Coastguard Worker {
2425*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2426*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2427*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2428*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2429*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2430*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2431*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2432*35238bceSAndroid Build Coastguard Worker {4, GL_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2433*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2434*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_TRUE, vertexData},
2435*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_TRUE, vertexData},
2436*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_TRUE, vertexData},
2437*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_TRUE, vertexData},
2438*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_TRUE, vertexData},
2439*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_TRUE, vertexData},
2440*35238bceSAndroid Build Coastguard Worker {4, GL_INT_2_10_10_10_REV, 0, GL_TRUE, vertexData},
2441*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, GL_TRUE, vertexData},
2442*35238bceSAndroid Build Coastguard Worker };
2443*35238bceSAndroid Build Coastguard Worker
2444*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2445*35238bceSAndroid Build Coastguard Worker {
2446*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
2447*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
2448*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2449*35238bceSAndroid Build Coastguard Worker
2450*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED,
2451*35238bceSAndroid Build Coastguard Worker pointers[ndx].normalized);
2452*35238bceSAndroid Build Coastguard Worker }
2453*35238bceSAndroid Build Coastguard Worker }
2454*35238bceSAndroid Build Coastguard Worker
2455*35238bceSAndroid Build Coastguard Worker // test glVertexAttribIPointer
2456*35238bceSAndroid Build Coastguard Worker {
2457*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2458*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2459*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2460*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2461*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2462*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2463*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2464*35238bceSAndroid Build Coastguard Worker };
2465*35238bceSAndroid Build Coastguard Worker
2466*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2467*35238bceSAndroid Build Coastguard Worker {
2468*35238bceSAndroid Build Coastguard Worker glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride,
2469*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
2470*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2471*35238bceSAndroid Build Coastguard Worker
2472*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
2473*35238bceSAndroid Build Coastguard Worker }
2474*35238bceSAndroid Build Coastguard Worker }
2475*35238bceSAndroid Build Coastguard Worker }
2476*35238bceSAndroid Build Coastguard Worker
2477*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2478*35238bceSAndroid Build Coastguard Worker {
2479*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2480*35238bceSAndroid Build Coastguard Worker
2481*35238bceSAndroid Build Coastguard Worker GLuint buf = 0;
2482*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2483*35238bceSAndroid Build Coastguard Worker
2484*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2485*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &buf);
2486*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, buf);
2487*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2488*35238bceSAndroid Build Coastguard Worker
2489*35238bceSAndroid Build Coastguard Worker // initial
2490*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2491*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
2492*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2493*35238bceSAndroid Build Coastguard Worker
2494*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2495*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_INT, GL_TRUE, 0, DE_NULL);
2496*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2497*35238bceSAndroid Build Coastguard Worker
2498*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2499*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2500*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_INT, GL_FALSE, 0, DE_NULL);
2501*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2502*35238bceSAndroid Build Coastguard Worker
2503*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2504*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_FALSE);
2505*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2506*35238bceSAndroid Build Coastguard Worker
2507*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2508*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2509*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, GL_TRUE);
2510*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2511*35238bceSAndroid Build Coastguard Worker
2512*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2513*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &buf);
2514*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2515*35238bceSAndroid Build Coastguard Worker }
2516*35238bceSAndroid Build Coastguard Worker }
2517*35238bceSAndroid Build Coastguard Worker };
2518*35238bceSAndroid Build Coastguard Worker
2519*35238bceSAndroid Build Coastguard Worker class VertexAttributeIntegerCase : public ApiCase
2520*35238bceSAndroid Build Coastguard Worker {
2521*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeIntegerCase(Context & context,const char * name,const char * description)2522*35238bceSAndroid Build Coastguard Worker VertexAttributeIntegerCase(Context &context, const char *name, const char *description)
2523*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2524*35238bceSAndroid Build Coastguard Worker {
2525*35238bceSAndroid Build Coastguard Worker }
2526*35238bceSAndroid Build Coastguard Worker
test(void)2527*35238bceSAndroid Build Coastguard Worker void test(void)
2528*35238bceSAndroid Build Coastguard Worker {
2529*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2530*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2531*35238bceSAndroid Build Coastguard Worker
2532*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2533*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2534*35238bceSAndroid Build Coastguard Worker {
2535*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2536*35238bceSAndroid Build Coastguard Worker
2537*35238bceSAndroid Build Coastguard Worker const GLfloat vertexData[4] = {0.0f}; // never accessed
2538*35238bceSAndroid Build Coastguard Worker
2539*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
2540*35238bceSAndroid Build Coastguard Worker {
2541*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2542*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2543*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2544*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2545*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, GL_FALSE, vertexData},
2546*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, GL_FALSE, vertexData},
2547*35238bceSAndroid Build Coastguard Worker {1, GL_HALF_FLOAT, 0, GL_FALSE, vertexData},
2548*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2549*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2550*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2551*35238bceSAndroid Build Coastguard Worker {4, GL_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2552*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, GL_FALSE, vertexData},
2553*35238bceSAndroid Build Coastguard Worker };
2554*35238bceSAndroid Build Coastguard Worker
2555*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2556*35238bceSAndroid Build Coastguard Worker {
2557*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
2558*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
2559*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2560*35238bceSAndroid Build Coastguard Worker
2561*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
2562*35238bceSAndroid Build Coastguard Worker }
2563*35238bceSAndroid Build Coastguard Worker }
2564*35238bceSAndroid Build Coastguard Worker
2565*35238bceSAndroid Build Coastguard Worker // test glVertexAttribIPointer
2566*35238bceSAndroid Build Coastguard Worker {
2567*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2568*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData},
2569*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData},
2570*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, vertexData},
2571*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
2572*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
2573*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_INT, 0, GL_FALSE, vertexData},
2574*35238bceSAndroid Build Coastguard Worker };
2575*35238bceSAndroid Build Coastguard Worker
2576*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2577*35238bceSAndroid Build Coastguard Worker {
2578*35238bceSAndroid Build Coastguard Worker glVertexAttribIPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].stride,
2579*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
2580*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2581*35238bceSAndroid Build Coastguard Worker
2582*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_TRUE);
2583*35238bceSAndroid Build Coastguard Worker }
2584*35238bceSAndroid Build Coastguard Worker }
2585*35238bceSAndroid Build Coastguard Worker }
2586*35238bceSAndroid Build Coastguard Worker
2587*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2588*35238bceSAndroid Build Coastguard Worker {
2589*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2590*35238bceSAndroid Build Coastguard Worker
2591*35238bceSAndroid Build Coastguard Worker GLuint buf = 0;
2592*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2593*35238bceSAndroid Build Coastguard Worker
2594*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2595*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &buf);
2596*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, buf);
2597*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2598*35238bceSAndroid Build Coastguard Worker
2599*35238bceSAndroid Build Coastguard Worker // initial
2600*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2601*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
2602*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2603*35238bceSAndroid Build Coastguard Worker
2604*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2605*35238bceSAndroid Build Coastguard Worker glVertexAttribIPointer(0, 1, GL_INT, 0, DE_NULL);
2606*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2607*35238bceSAndroid Build Coastguard Worker
2608*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2609*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2610*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, DE_NULL);
2611*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2612*35238bceSAndroid Build Coastguard Worker
2613*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2614*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_FALSE);
2615*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2616*35238bceSAndroid Build Coastguard Worker
2617*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2618*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2619*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_INTEGER, GL_TRUE);
2620*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2621*35238bceSAndroid Build Coastguard Worker
2622*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2623*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &buf);
2624*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2625*35238bceSAndroid Build Coastguard Worker }
2626*35238bceSAndroid Build Coastguard Worker }
2627*35238bceSAndroid Build Coastguard Worker };
2628*35238bceSAndroid Build Coastguard Worker
2629*35238bceSAndroid Build Coastguard Worker class VertexAttributeEnabledCase : public ApiCase
2630*35238bceSAndroid Build Coastguard Worker {
2631*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeEnabledCase(Context & context,const char * name,const char * description)2632*35238bceSAndroid Build Coastguard Worker VertexAttributeEnabledCase(Context &context, const char *name, const char *description)
2633*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2634*35238bceSAndroid Build Coastguard Worker {
2635*35238bceSAndroid Build Coastguard Worker }
2636*35238bceSAndroid Build Coastguard Worker
test(void)2637*35238bceSAndroid Build Coastguard Worker void test(void)
2638*35238bceSAndroid Build Coastguard Worker {
2639*35238bceSAndroid Build Coastguard Worker // VERTEX_ATTRIB_ARRAY_ENABLED
2640*35238bceSAndroid Build Coastguard Worker
2641*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2642*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2643*35238bceSAndroid Build Coastguard Worker
2644*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2645*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2646*35238bceSAndroid Build Coastguard Worker {
2647*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2648*35238bceSAndroid Build Coastguard Worker
2649*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
2650*35238bceSAndroid Build Coastguard Worker glEnableVertexAttribArray(0);
2651*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
2652*35238bceSAndroid Build Coastguard Worker glDisableVertexAttribArray(0);
2653*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
2654*35238bceSAndroid Build Coastguard Worker }
2655*35238bceSAndroid Build Coastguard Worker
2656*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2657*35238bceSAndroid Build Coastguard Worker {
2658*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2659*35238bceSAndroid Build Coastguard Worker
2660*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2661*35238bceSAndroid Build Coastguard Worker
2662*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2663*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2664*35238bceSAndroid Build Coastguard Worker
2665*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2666*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2667*35238bceSAndroid Build Coastguard Worker glEnableVertexAttribArray(0);
2668*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2669*35238bceSAndroid Build Coastguard Worker
2670*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2671*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2672*35238bceSAndroid Build Coastguard Worker glDisableVertexAttribArray(0);
2673*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2674*35238bceSAndroid Build Coastguard Worker
2675*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2676*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
2677*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2678*35238bceSAndroid Build Coastguard Worker
2679*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2680*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2681*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
2682*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2683*35238bceSAndroid Build Coastguard Worker
2684*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2685*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2686*35238bceSAndroid Build Coastguard Worker }
2687*35238bceSAndroid Build Coastguard Worker }
2688*35238bceSAndroid Build Coastguard Worker };
2689*35238bceSAndroid Build Coastguard Worker
2690*35238bceSAndroid Build Coastguard Worker class VertexAttributeDivisorCase : public ApiCase
2691*35238bceSAndroid Build Coastguard Worker {
2692*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeDivisorCase(Context & context,const char * name,const char * description)2693*35238bceSAndroid Build Coastguard Worker VertexAttributeDivisorCase(Context &context, const char *name, const char *description)
2694*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2695*35238bceSAndroid Build Coastguard Worker {
2696*35238bceSAndroid Build Coastguard Worker }
2697*35238bceSAndroid Build Coastguard Worker
test(void)2698*35238bceSAndroid Build Coastguard Worker void test(void)
2699*35238bceSAndroid Build Coastguard Worker {
2700*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2701*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2702*35238bceSAndroid Build Coastguard Worker
2703*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2704*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2705*35238bceSAndroid Build Coastguard Worker {
2706*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2707*35238bceSAndroid Build Coastguard Worker
2708*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 0);
2709*35238bceSAndroid Build Coastguard Worker glVertexAttribDivisor(0, 1);
2710*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 1);
2711*35238bceSAndroid Build Coastguard Worker glVertexAttribDivisor(0, 5);
2712*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 5);
2713*35238bceSAndroid Build Coastguard Worker }
2714*35238bceSAndroid Build Coastguard Worker
2715*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2716*35238bceSAndroid Build Coastguard Worker {
2717*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2718*35238bceSAndroid Build Coastguard Worker
2719*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2720*35238bceSAndroid Build Coastguard Worker
2721*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2722*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2723*35238bceSAndroid Build Coastguard Worker
2724*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2725*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2726*35238bceSAndroid Build Coastguard Worker glVertexAttribDivisor(0, 1);
2727*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2728*35238bceSAndroid Build Coastguard Worker
2729*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2730*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2731*35238bceSAndroid Build Coastguard Worker glVertexAttribDivisor(0, 5);
2732*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2733*35238bceSAndroid Build Coastguard Worker
2734*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2735*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 5);
2736*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2737*35238bceSAndroid Build Coastguard Worker
2738*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2739*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2740*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, 1);
2741*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2742*35238bceSAndroid Build Coastguard Worker
2743*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2744*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2745*35238bceSAndroid Build Coastguard Worker }
2746*35238bceSAndroid Build Coastguard Worker }
2747*35238bceSAndroid Build Coastguard Worker };
2748*35238bceSAndroid Build Coastguard Worker
2749*35238bceSAndroid Build Coastguard Worker class VertexAttributeBufferBindingCase : public ApiCase
2750*35238bceSAndroid Build Coastguard Worker {
2751*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeBufferBindingCase(Context & context,const char * name,const char * description)2752*35238bceSAndroid Build Coastguard Worker VertexAttributeBufferBindingCase(Context &context, const char *name, const char *description)
2753*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2754*35238bceSAndroid Build Coastguard Worker {
2755*35238bceSAndroid Build Coastguard Worker }
2756*35238bceSAndroid Build Coastguard Worker
test(void)2757*35238bceSAndroid Build Coastguard Worker void test(void)
2758*35238bceSAndroid Build Coastguard Worker {
2759*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2760*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2761*35238bceSAndroid Build Coastguard Worker
2762*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2763*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2764*35238bceSAndroid Build Coastguard Worker {
2765*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2766*35238bceSAndroid Build Coastguard Worker
2767*35238bceSAndroid Build Coastguard Worker // initial
2768*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, 0);
2769*35238bceSAndroid Build Coastguard Worker
2770*35238bceSAndroid Build Coastguard Worker GLuint bufferID;
2771*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &bufferID);
2772*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufferID);
2773*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2774*35238bceSAndroid Build Coastguard Worker
2775*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
2776*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2777*35238bceSAndroid Build Coastguard Worker
2778*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufferID);
2779*35238bceSAndroid Build Coastguard Worker
2780*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &bufferID);
2781*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2782*35238bceSAndroid Build Coastguard Worker }
2783*35238bceSAndroid Build Coastguard Worker
2784*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2785*35238bceSAndroid Build Coastguard Worker {
2786*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2787*35238bceSAndroid Build Coastguard Worker
2788*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2789*35238bceSAndroid Build Coastguard Worker GLuint bufs[2] = {0};
2790*35238bceSAndroid Build Coastguard Worker
2791*35238bceSAndroid Build Coastguard Worker glGenBuffers(2, bufs);
2792*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2793*35238bceSAndroid Build Coastguard Worker
2794*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2795*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2796*35238bceSAndroid Build Coastguard Worker
2797*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2798*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2799*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufs[0]);
2800*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
2801*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2802*35238bceSAndroid Build Coastguard Worker
2803*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2804*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2805*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufs[1]);
2806*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
2807*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2808*35238bceSAndroid Build Coastguard Worker
2809*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2810*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufs[1]);
2811*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2812*35238bceSAndroid Build Coastguard Worker
2813*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2814*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2815*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufs[0]);
2816*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2817*35238bceSAndroid Build Coastguard Worker
2818*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2819*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(2, bufs);
2820*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2821*35238bceSAndroid Build Coastguard Worker }
2822*35238bceSAndroid Build Coastguard Worker }
2823*35238bceSAndroid Build Coastguard Worker };
2824*35238bceSAndroid Build Coastguard Worker
2825*35238bceSAndroid Build Coastguard Worker class VertexAttributePointerCase : public ApiCase
2826*35238bceSAndroid Build Coastguard Worker {
2827*35238bceSAndroid Build Coastguard Worker public:
VertexAttributePointerCase(Context & context,const char * name,const char * description)2828*35238bceSAndroid Build Coastguard Worker VertexAttributePointerCase(Context &context, const char *name, const char *description)
2829*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2830*35238bceSAndroid Build Coastguard Worker {
2831*35238bceSAndroid Build Coastguard Worker }
2832*35238bceSAndroid Build Coastguard Worker
test(void)2833*35238bceSAndroid Build Coastguard Worker void test(void)
2834*35238bceSAndroid Build Coastguard Worker {
2835*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
2836*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
2837*35238bceSAndroid Build Coastguard Worker
2838*35238bceSAndroid Build Coastguard Worker // Test with default VAO
2839*35238bceSAndroid Build Coastguard Worker if (!isCoreGL45)
2840*35238bceSAndroid Build Coastguard Worker {
2841*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "DefaultVAO", "Test with default VAO");
2842*35238bceSAndroid Build Coastguard Worker
2843*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> initialState;
2844*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &initialState);
2845*35238bceSAndroid Build Coastguard Worker initialState.verifyValidity(m_testCtx);
2846*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, initialState, 0);
2847*35238bceSAndroid Build Coastguard Worker
2848*35238bceSAndroid Build Coastguard Worker const GLfloat vertexData[4] = {0.0f}; // never accessed
2849*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
2850*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, &vertexData[2]}, {1, GL_SHORT, 0, GL_FALSE, &vertexData[1]},
2851*35238bceSAndroid Build Coastguard Worker {1, GL_INT, 0, GL_FALSE, &vertexData[2]}, {1, GL_FIXED, 0, GL_FALSE, &vertexData[2]},
2852*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, GL_FALSE, &vertexData[1]}, {1, GL_FLOAT, 0, GL_FALSE, &vertexData[0]},
2853*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, GL_FALSE, &vertexData[3]}, {1, GL_FLOAT, 0, GL_FALSE, &vertexData[2]},
2854*35238bceSAndroid Build Coastguard Worker {1, GL_HALF_FLOAT, 0, GL_FALSE, &vertexData[0]}, {4, GL_HALF_FLOAT, 0, GL_FALSE, &vertexData[1]},
2855*35238bceSAndroid Build Coastguard Worker {4, GL_HALF_FLOAT, 0, GL_FALSE, &vertexData[2]},
2856*35238bceSAndroid Build Coastguard Worker };
2857*35238bceSAndroid Build Coastguard Worker
2858*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
2859*35238bceSAndroid Build Coastguard Worker {
2860*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
2861*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
2862*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2863*35238bceSAndroid Build Coastguard Worker
2864*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> state;
2865*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
2866*35238bceSAndroid Build Coastguard Worker state.verifyValidity(m_testCtx);
2867*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, state, pointers[ndx].pointer);
2868*35238bceSAndroid Build Coastguard Worker }
2869*35238bceSAndroid Build Coastguard Worker }
2870*35238bceSAndroid Build Coastguard Worker
2871*35238bceSAndroid Build Coastguard Worker // Test with multiple VAOs
2872*35238bceSAndroid Build Coastguard Worker {
2873*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_log, "WithVAO", "Test with VAO");
2874*35238bceSAndroid Build Coastguard Worker
2875*35238bceSAndroid Build Coastguard Worker GLuint vaos[2] = {0};
2876*35238bceSAndroid Build Coastguard Worker GLuint bufs[2] = {0};
2877*35238bceSAndroid Build Coastguard Worker
2878*35238bceSAndroid Build Coastguard Worker glGenBuffers(2, bufs);
2879*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2880*35238bceSAndroid Build Coastguard Worker
2881*35238bceSAndroid Build Coastguard Worker glGenVertexArrays(2, vaos);
2882*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2883*35238bceSAndroid Build Coastguard Worker
2884*35238bceSAndroid Build Coastguard Worker // set vao 0 to some value
2885*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2886*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufs[0]);
2887*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, glu::BufferOffsetAsPointer(8));
2888*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2889*35238bceSAndroid Build Coastguard Worker
2890*35238bceSAndroid Build Coastguard Worker // set vao 1 to some other value
2891*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[1]);
2892*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufs[1]);
2893*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, glu::BufferOffsetAsPointer(4));
2894*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2895*35238bceSAndroid Build Coastguard Worker
2896*35238bceSAndroid Build Coastguard Worker // verify vao 1 state
2897*35238bceSAndroid Build Coastguard Worker {
2898*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> state;
2899*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
2900*35238bceSAndroid Build Coastguard Worker state.verifyValidity(m_testCtx);
2901*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, state, glu::BufferOffsetAsPointer(4));
2902*35238bceSAndroid Build Coastguard Worker }
2903*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2904*35238bceSAndroid Build Coastguard Worker
2905*35238bceSAndroid Build Coastguard Worker // verify vao 0 state
2906*35238bceSAndroid Build Coastguard Worker glBindVertexArray(vaos[0]);
2907*35238bceSAndroid Build Coastguard Worker {
2908*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> state;
2909*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
2910*35238bceSAndroid Build Coastguard Worker state.verifyValidity(m_testCtx);
2911*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, state, glu::BufferOffsetAsPointer(8));
2912*35238bceSAndroid Build Coastguard Worker }
2913*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2914*35238bceSAndroid Build Coastguard Worker
2915*35238bceSAndroid Build Coastguard Worker glDeleteVertexArrays(2, vaos);
2916*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(2, bufs);
2917*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2918*35238bceSAndroid Build Coastguard Worker }
2919*35238bceSAndroid Build Coastguard Worker }
2920*35238bceSAndroid Build Coastguard Worker };
2921*35238bceSAndroid Build Coastguard Worker
2922*35238bceSAndroid Build Coastguard Worker class UniformValueFloatCase : public ApiCase
2923*35238bceSAndroid Build Coastguard Worker {
2924*35238bceSAndroid Build Coastguard Worker public:
UniformValueFloatCase(Context & context,const char * name,const char * description)2925*35238bceSAndroid Build Coastguard Worker UniformValueFloatCase(Context &context, const char *name, const char *description)
2926*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2927*35238bceSAndroid Build Coastguard Worker {
2928*35238bceSAndroid Build Coastguard Worker }
2929*35238bceSAndroid Build Coastguard Worker
test(void)2930*35238bceSAndroid Build Coastguard Worker void test(void)
2931*35238bceSAndroid Build Coastguard Worker {
2932*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
2933*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
2934*35238bceSAndroid Build Coastguard Worker "uniform highp float floatUniform;\n"
2935*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 float2Uniform;\n"
2936*35238bceSAndroid Build Coastguard Worker "uniform highp vec3 float3Uniform;\n"
2937*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 float4Uniform;\n"
2938*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2939*35238bceSAndroid Build Coastguard Worker "{\n"
2940*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(floatUniform + float2Uniform.x + float3Uniform.x + float4Uniform.x);\n"
2941*35238bceSAndroid Build Coastguard Worker "}\n";
2942*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
2943*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
2944*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2945*35238bceSAndroid Build Coastguard Worker "{\n"
2946*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
2947*35238bceSAndroid Build Coastguard Worker "}\n";
2948*35238bceSAndroid Build Coastguard Worker
2949*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
2950*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
2951*35238bceSAndroid Build Coastguard Worker
2952*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
2953*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
2954*35238bceSAndroid Build Coastguard Worker
2955*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
2956*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
2957*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2958*35238bceSAndroid Build Coastguard Worker
2959*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
2960*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
2961*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
2962*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
2963*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
2964*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2965*35238bceSAndroid Build Coastguard Worker
2966*35238bceSAndroid Build Coastguard Worker GLint location;
2967*35238bceSAndroid Build Coastguard Worker
2968*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "floatUniform");
2969*35238bceSAndroid Build Coastguard Worker glUniform1f(location, 1.0f);
2970*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, location, 1.0f);
2971*35238bceSAndroid Build Coastguard Worker
2972*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "float2Uniform");
2973*35238bceSAndroid Build Coastguard Worker glUniform2f(location, 1.0f, 2.0f);
2974*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, location, 1.0f, 2.0f);
2975*35238bceSAndroid Build Coastguard Worker
2976*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "float3Uniform");
2977*35238bceSAndroid Build Coastguard Worker glUniform3f(location, 1.0f, 2.0f, 3.0f);
2978*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, location, 1.0f, 2.0f, 3.0f);
2979*35238bceSAndroid Build Coastguard Worker
2980*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "float4Uniform");
2981*35238bceSAndroid Build Coastguard Worker glUniform4f(location, 1.0f, 2.0f, 3.0f, 4.0f);
2982*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, location, 1.0f, 2.0f, 3.0f, 4.0f);
2983*35238bceSAndroid Build Coastguard Worker
2984*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
2985*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
2986*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
2987*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
2988*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2989*35238bceSAndroid Build Coastguard Worker }
2990*35238bceSAndroid Build Coastguard Worker };
2991*35238bceSAndroid Build Coastguard Worker
2992*35238bceSAndroid Build Coastguard Worker class UniformValueIntCase : public ApiCase
2993*35238bceSAndroid Build Coastguard Worker {
2994*35238bceSAndroid Build Coastguard Worker public:
UniformValueIntCase(Context & context,const char * name,const char * description)2995*35238bceSAndroid Build Coastguard Worker UniformValueIntCase(Context &context, const char *name, const char *description)
2996*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2997*35238bceSAndroid Build Coastguard Worker {
2998*35238bceSAndroid Build Coastguard Worker }
2999*35238bceSAndroid Build Coastguard Worker
test(void)3000*35238bceSAndroid Build Coastguard Worker void test(void)
3001*35238bceSAndroid Build Coastguard Worker {
3002*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
3003*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
3004*35238bceSAndroid Build Coastguard Worker "uniform highp int intUniform;\n"
3005*35238bceSAndroid Build Coastguard Worker "uniform highp ivec2 int2Uniform;\n"
3006*35238bceSAndroid Build Coastguard Worker "uniform highp ivec3 int3Uniform;\n"
3007*35238bceSAndroid Build Coastguard Worker "uniform highp ivec4 int4Uniform;\n"
3008*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3009*35238bceSAndroid Build Coastguard Worker "{\n"
3010*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(float(intUniform + int2Uniform.x + int3Uniform.x + int4Uniform.x));\n"
3011*35238bceSAndroid Build Coastguard Worker "}\n";
3012*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3013*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3014*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3015*35238bceSAndroid Build Coastguard Worker "{\n"
3016*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
3017*35238bceSAndroid Build Coastguard Worker "}\n";
3018*35238bceSAndroid Build Coastguard Worker
3019*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3020*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3021*35238bceSAndroid Build Coastguard Worker
3022*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3023*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3024*35238bceSAndroid Build Coastguard Worker
3025*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3026*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3027*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3028*35238bceSAndroid Build Coastguard Worker
3029*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3030*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3031*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3032*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3033*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3034*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3035*35238bceSAndroid Build Coastguard Worker
3036*35238bceSAndroid Build Coastguard Worker GLint location;
3037*35238bceSAndroid Build Coastguard Worker
3038*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "intUniform");
3039*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
3040*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program, location, 1);
3041*35238bceSAndroid Build Coastguard Worker
3042*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "int2Uniform");
3043*35238bceSAndroid Build Coastguard Worker glUniform2i(location, 1, 2);
3044*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program, location, 1, 2);
3045*35238bceSAndroid Build Coastguard Worker
3046*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "int3Uniform");
3047*35238bceSAndroid Build Coastguard Worker glUniform3i(location, 1, 2, 3);
3048*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program, location, 1, 2, 3);
3049*35238bceSAndroid Build Coastguard Worker
3050*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "int4Uniform");
3051*35238bceSAndroid Build Coastguard Worker glUniform4i(location, 1, 2, 3, 4);
3052*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program, location, 1, 2, 3, 4);
3053*35238bceSAndroid Build Coastguard Worker
3054*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3055*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3056*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3057*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3058*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3059*35238bceSAndroid Build Coastguard Worker }
3060*35238bceSAndroid Build Coastguard Worker };
3061*35238bceSAndroid Build Coastguard Worker
3062*35238bceSAndroid Build Coastguard Worker class UniformValueUintCase : public ApiCase
3063*35238bceSAndroid Build Coastguard Worker {
3064*35238bceSAndroid Build Coastguard Worker public:
UniformValueUintCase(Context & context,const char * name,const char * description)3065*35238bceSAndroid Build Coastguard Worker UniformValueUintCase(Context &context, const char *name, const char *description)
3066*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3067*35238bceSAndroid Build Coastguard Worker {
3068*35238bceSAndroid Build Coastguard Worker }
3069*35238bceSAndroid Build Coastguard Worker
test(void)3070*35238bceSAndroid Build Coastguard Worker void test(void)
3071*35238bceSAndroid Build Coastguard Worker {
3072*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
3073*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
3074*35238bceSAndroid Build Coastguard Worker "uniform highp uint uintUniform;\n"
3075*35238bceSAndroid Build Coastguard Worker "uniform highp uvec2 uint2Uniform;\n"
3076*35238bceSAndroid Build Coastguard Worker "uniform highp uvec3 uint3Uniform;\n"
3077*35238bceSAndroid Build Coastguard Worker "uniform highp uvec4 uint4Uniform;\n"
3078*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3079*35238bceSAndroid Build Coastguard Worker "{\n"
3080*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(float(uintUniform + uint2Uniform.x + uint3Uniform.x + uint4Uniform.x));\n"
3081*35238bceSAndroid Build Coastguard Worker "}\n";
3082*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3083*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3084*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3085*35238bceSAndroid Build Coastguard Worker "{\n"
3086*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
3087*35238bceSAndroid Build Coastguard Worker "}\n";
3088*35238bceSAndroid Build Coastguard Worker
3089*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3090*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3091*35238bceSAndroid Build Coastguard Worker
3092*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3093*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3094*35238bceSAndroid Build Coastguard Worker
3095*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3096*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3097*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3098*35238bceSAndroid Build Coastguard Worker
3099*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3100*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3101*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3102*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3103*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3104*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3105*35238bceSAndroid Build Coastguard Worker
3106*35238bceSAndroid Build Coastguard Worker GLint location;
3107*35238bceSAndroid Build Coastguard Worker
3108*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "uintUniform");
3109*35238bceSAndroid Build Coastguard Worker glUniform1ui(location, 1);
3110*35238bceSAndroid Build Coastguard Worker verifyUniformValue1ui(m_testCtx, *this, program, location, 1);
3111*35238bceSAndroid Build Coastguard Worker
3112*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "uint2Uniform");
3113*35238bceSAndroid Build Coastguard Worker glUniform2ui(location, 1, 2);
3114*35238bceSAndroid Build Coastguard Worker verifyUniformValue2ui(m_testCtx, *this, program, location, 1, 2);
3115*35238bceSAndroid Build Coastguard Worker
3116*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "uint3Uniform");
3117*35238bceSAndroid Build Coastguard Worker glUniform3ui(location, 1, 2, 3);
3118*35238bceSAndroid Build Coastguard Worker verifyUniformValue3ui(m_testCtx, *this, program, location, 1, 2, 3);
3119*35238bceSAndroid Build Coastguard Worker
3120*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "uint4Uniform");
3121*35238bceSAndroid Build Coastguard Worker glUniform4ui(location, 1, 2, 3, 4);
3122*35238bceSAndroid Build Coastguard Worker verifyUniformValue4ui(m_testCtx, *this, program, location, 1, 2, 3, 4);
3123*35238bceSAndroid Build Coastguard Worker
3124*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3125*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3126*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3127*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3128*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3129*35238bceSAndroid Build Coastguard Worker }
3130*35238bceSAndroid Build Coastguard Worker };
3131*35238bceSAndroid Build Coastguard Worker
3132*35238bceSAndroid Build Coastguard Worker class UniformValueBooleanCase : public ApiCase
3133*35238bceSAndroid Build Coastguard Worker {
3134*35238bceSAndroid Build Coastguard Worker public:
UniformValueBooleanCase(Context & context,const char * name,const char * description)3135*35238bceSAndroid Build Coastguard Worker UniformValueBooleanCase(Context &context, const char *name, const char *description)
3136*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3137*35238bceSAndroid Build Coastguard Worker {
3138*35238bceSAndroid Build Coastguard Worker }
3139*35238bceSAndroid Build Coastguard Worker
test(void)3140*35238bceSAndroid Build Coastguard Worker void test(void)
3141*35238bceSAndroid Build Coastguard Worker {
3142*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "#version 300 es\n"
3143*35238bceSAndroid Build Coastguard Worker "uniform bool boolUniform;\n"
3144*35238bceSAndroid Build Coastguard Worker "uniform bvec2 bool2Uniform;\n"
3145*35238bceSAndroid Build Coastguard Worker "uniform bvec3 bool3Uniform;\n"
3146*35238bceSAndroid Build Coastguard Worker "uniform bvec4 bool4Uniform;\n"
3147*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3148*35238bceSAndroid Build Coastguard Worker "{\n"
3149*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(float(boolUniform) + float(bool2Uniform.x) + "
3150*35238bceSAndroid Build Coastguard Worker "float(bool3Uniform.x) + float(bool4Uniform.x));\n"
3151*35238bceSAndroid Build Coastguard Worker "}\n";
3152*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3153*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3154*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3155*35238bceSAndroid Build Coastguard Worker "{\n"
3156*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
3157*35238bceSAndroid Build Coastguard Worker "}\n";
3158*35238bceSAndroid Build Coastguard Worker
3159*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3160*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3161*35238bceSAndroid Build Coastguard Worker
3162*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3163*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3164*35238bceSAndroid Build Coastguard Worker
3165*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3166*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3167*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3168*35238bceSAndroid Build Coastguard Worker
3169*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3170*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3171*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3172*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3173*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3174*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3175*35238bceSAndroid Build Coastguard Worker
3176*35238bceSAndroid Build Coastguard Worker GLint location;
3177*35238bceSAndroid Build Coastguard Worker
3178*35238bceSAndroid Build Coastguard Worker // int conversion
3179*35238bceSAndroid Build Coastguard Worker
3180*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "boolUniform");
3181*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
3182*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program, location, 1);
3183*35238bceSAndroid Build Coastguard Worker
3184*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool2Uniform");
3185*35238bceSAndroid Build Coastguard Worker glUniform2i(location, 1, 2);
3186*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program, location, 1, 1);
3187*35238bceSAndroid Build Coastguard Worker
3188*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool3Uniform");
3189*35238bceSAndroid Build Coastguard Worker glUniform3i(location, 0, 1, 2);
3190*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program, location, 0, 1, 1);
3191*35238bceSAndroid Build Coastguard Worker
3192*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool4Uniform");
3193*35238bceSAndroid Build Coastguard Worker glUniform4i(location, 1, 0, 1, -1);
3194*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program, location, 1, 0, 1, 1);
3195*35238bceSAndroid Build Coastguard Worker
3196*35238bceSAndroid Build Coastguard Worker // float conversion
3197*35238bceSAndroid Build Coastguard Worker
3198*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "boolUniform");
3199*35238bceSAndroid Build Coastguard Worker glUniform1f(location, 1.0f);
3200*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program, location, 1);
3201*35238bceSAndroid Build Coastguard Worker
3202*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool2Uniform");
3203*35238bceSAndroid Build Coastguard Worker glUniform2f(location, 1.0f, 0.1f);
3204*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program, location, 1, 1);
3205*35238bceSAndroid Build Coastguard Worker
3206*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool3Uniform");
3207*35238bceSAndroid Build Coastguard Worker glUniform3f(location, 0.0f, 0.1f, -0.1f);
3208*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program, location, 0, 1, 1);
3209*35238bceSAndroid Build Coastguard Worker
3210*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "bool4Uniform");
3211*35238bceSAndroid Build Coastguard Worker glUniform4f(location, 1.0f, 0.0f, 0.1f, -0.9f);
3212*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program, location, 1, 0, 1, 1);
3213*35238bceSAndroid Build Coastguard Worker
3214*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3215*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3216*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3217*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3218*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3219*35238bceSAndroid Build Coastguard Worker }
3220*35238bceSAndroid Build Coastguard Worker };
3221*35238bceSAndroid Build Coastguard Worker
3222*35238bceSAndroid Build Coastguard Worker class UniformValueSamplerCase : public ApiCase
3223*35238bceSAndroid Build Coastguard Worker {
3224*35238bceSAndroid Build Coastguard Worker public:
UniformValueSamplerCase(Context & context,const char * name,const char * description)3225*35238bceSAndroid Build Coastguard Worker UniformValueSamplerCase(Context &context, const char *name, const char *description)
3226*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3227*35238bceSAndroid Build Coastguard Worker {
3228*35238bceSAndroid Build Coastguard Worker }
3229*35238bceSAndroid Build Coastguard Worker
test(void)3230*35238bceSAndroid Build Coastguard Worker void test(void)
3231*35238bceSAndroid Build Coastguard Worker {
3232*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "#version 300 es\n"
3233*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3234*35238bceSAndroid Build Coastguard Worker "{\n"
3235*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
3236*35238bceSAndroid Build Coastguard Worker "}\n";
3237*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3238*35238bceSAndroid Build Coastguard Worker "uniform highp sampler2D uniformSampler;\n"
3239*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3240*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3241*35238bceSAndroid Build Coastguard Worker "{\n"
3242*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(textureSize(uniformSampler, 0).x);\n"
3243*35238bceSAndroid Build Coastguard Worker "}\n";
3244*35238bceSAndroid Build Coastguard Worker
3245*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3246*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3247*35238bceSAndroid Build Coastguard Worker
3248*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3249*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3250*35238bceSAndroid Build Coastguard Worker
3251*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3252*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3253*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3254*35238bceSAndroid Build Coastguard Worker
3255*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3256*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3257*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3258*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3259*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3260*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3261*35238bceSAndroid Build Coastguard Worker
3262*35238bceSAndroid Build Coastguard Worker GLint location;
3263*35238bceSAndroid Build Coastguard Worker
3264*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "uniformSampler");
3265*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
3266*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program, location, 1);
3267*35238bceSAndroid Build Coastguard Worker
3268*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3269*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3270*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3271*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3272*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3273*35238bceSAndroid Build Coastguard Worker }
3274*35238bceSAndroid Build Coastguard Worker };
3275*35238bceSAndroid Build Coastguard Worker
3276*35238bceSAndroid Build Coastguard Worker class UniformValueArrayCase : public ApiCase
3277*35238bceSAndroid Build Coastguard Worker {
3278*35238bceSAndroid Build Coastguard Worker public:
UniformValueArrayCase(Context & context,const char * name,const char * description)3279*35238bceSAndroid Build Coastguard Worker UniformValueArrayCase(Context &context, const char *name, const char *description)
3280*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3281*35238bceSAndroid Build Coastguard Worker {
3282*35238bceSAndroid Build Coastguard Worker }
3283*35238bceSAndroid Build Coastguard Worker
test(void)3284*35238bceSAndroid Build Coastguard Worker void test(void)
3285*35238bceSAndroid Build Coastguard Worker {
3286*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "#version 300 es\n"
3287*35238bceSAndroid Build Coastguard Worker "uniform highp float arrayUniform[5];"
3288*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 array2Uniform[5];"
3289*35238bceSAndroid Build Coastguard Worker "uniform highp vec3 array3Uniform[5];"
3290*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 array4Uniform[5];"
3291*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3292*35238bceSAndroid Build Coastguard Worker "{\n"
3293*35238bceSAndroid Build Coastguard Worker " gl_Position = \n"
3294*35238bceSAndroid Build Coastguard Worker " + vec4(arrayUniform[0] + arrayUniform[1] + "
3295*35238bceSAndroid Build Coastguard Worker "arrayUniform[2] + arrayUniform[3] + arrayUniform[4])\n"
3296*35238bceSAndroid Build Coastguard Worker " + vec4(array2Uniform[0].x + array2Uniform[1].x + "
3297*35238bceSAndroid Build Coastguard Worker "array2Uniform[2].x + array2Uniform[3].x + array2Uniform[4].x)\n"
3298*35238bceSAndroid Build Coastguard Worker " + vec4(array3Uniform[0].x + array3Uniform[1].x + "
3299*35238bceSAndroid Build Coastguard Worker "array3Uniform[2].x + array3Uniform[3].x + array3Uniform[4].x)\n"
3300*35238bceSAndroid Build Coastguard Worker " + vec4(array4Uniform[0].x + array4Uniform[1].x + "
3301*35238bceSAndroid Build Coastguard Worker "array4Uniform[2].x + array4Uniform[3].x + array4Uniform[4].x);\n"
3302*35238bceSAndroid Build Coastguard Worker "}\n";
3303*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3304*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3305*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3306*35238bceSAndroid Build Coastguard Worker "{\n"
3307*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
3308*35238bceSAndroid Build Coastguard Worker "}\n";
3309*35238bceSAndroid Build Coastguard Worker
3310*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3311*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3312*35238bceSAndroid Build Coastguard Worker
3313*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3314*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3315*35238bceSAndroid Build Coastguard Worker
3316*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3317*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3318*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3319*35238bceSAndroid Build Coastguard Worker
3320*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3321*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3322*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3323*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3324*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3325*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3326*35238bceSAndroid Build Coastguard Worker
3327*35238bceSAndroid Build Coastguard Worker GLint location;
3328*35238bceSAndroid Build Coastguard Worker
3329*35238bceSAndroid Build Coastguard Worker float uniformValue[5 * 4] = {-1.0f, 0.1f, 4.0f, 800.0f, 13.0f, 55.0f, 12.0f, 91.0f, -55.1f, 1.1f,
3330*35238bceSAndroid Build Coastguard Worker 98.0f, 19.0f, 41.0f, 65.0f, 4.0f, 12.2f, 95.0f, 77.0f, 32.0f, 48.0f};
3331*35238bceSAndroid Build Coastguard Worker
3332*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "arrayUniform");
3333*35238bceSAndroid Build Coastguard Worker glUniform1fv(location, 5, uniformValue);
3334*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3335*35238bceSAndroid Build Coastguard Worker
3336*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program, "arrayUniform[0]"),
3337*35238bceSAndroid Build Coastguard Worker uniformValue[0]);
3338*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program, "arrayUniform[1]"),
3339*35238bceSAndroid Build Coastguard Worker uniformValue[1]);
3340*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program, "arrayUniform[2]"),
3341*35238bceSAndroid Build Coastguard Worker uniformValue[2]);
3342*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program, "arrayUniform[3]"),
3343*35238bceSAndroid Build Coastguard Worker uniformValue[3]);
3344*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program, glGetUniformLocation(program, "arrayUniform[4]"),
3345*35238bceSAndroid Build Coastguard Worker uniformValue[4]);
3346*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3347*35238bceSAndroid Build Coastguard Worker
3348*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "array2Uniform");
3349*35238bceSAndroid Build Coastguard Worker glUniform2fv(location, 5, uniformValue);
3350*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3351*35238bceSAndroid Build Coastguard Worker
3352*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program, "array2Uniform[0]"),
3353*35238bceSAndroid Build Coastguard Worker uniformValue[2 * 0], uniformValue[(2 * 0) + 1]);
3354*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program, "array2Uniform[1]"),
3355*35238bceSAndroid Build Coastguard Worker uniformValue[2 * 1], uniformValue[(2 * 1) + 1]);
3356*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program, "array2Uniform[2]"),
3357*35238bceSAndroid Build Coastguard Worker uniformValue[2 * 2], uniformValue[(2 * 2) + 1]);
3358*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program, "array2Uniform[3]"),
3359*35238bceSAndroid Build Coastguard Worker uniformValue[2 * 3], uniformValue[(2 * 3) + 1]);
3360*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program, glGetUniformLocation(program, "array2Uniform[4]"),
3361*35238bceSAndroid Build Coastguard Worker uniformValue[2 * 4], uniformValue[(2 * 4) + 1]);
3362*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3363*35238bceSAndroid Build Coastguard Worker
3364*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "array3Uniform");
3365*35238bceSAndroid Build Coastguard Worker glUniform3fv(location, 5, uniformValue);
3366*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3367*35238bceSAndroid Build Coastguard Worker
3368*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program, "array3Uniform[0]"),
3369*35238bceSAndroid Build Coastguard Worker uniformValue[3 * 0], uniformValue[(3 * 0) + 1], uniformValue[(3 * 0) + 2]);
3370*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program, "array3Uniform[1]"),
3371*35238bceSAndroid Build Coastguard Worker uniformValue[3 * 1], uniformValue[(3 * 1) + 1], uniformValue[(3 * 1) + 2]);
3372*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program, "array3Uniform[2]"),
3373*35238bceSAndroid Build Coastguard Worker uniformValue[3 * 2], uniformValue[(3 * 2) + 1], uniformValue[(3 * 2) + 2]);
3374*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program, "array3Uniform[3]"),
3375*35238bceSAndroid Build Coastguard Worker uniformValue[3 * 3], uniformValue[(3 * 3) + 1], uniformValue[(3 * 3) + 2]);
3376*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program, glGetUniformLocation(program, "array3Uniform[4]"),
3377*35238bceSAndroid Build Coastguard Worker uniformValue[3 * 4], uniformValue[(3 * 4) + 1], uniformValue[(3 * 4) + 2]);
3378*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3379*35238bceSAndroid Build Coastguard Worker
3380*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "array4Uniform");
3381*35238bceSAndroid Build Coastguard Worker glUniform4fv(location, 5, uniformValue);
3382*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3383*35238bceSAndroid Build Coastguard Worker
3384*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program, "array4Uniform[0]"),
3385*35238bceSAndroid Build Coastguard Worker uniformValue[4 * 0], uniformValue[(4 * 0) + 1], uniformValue[(4 * 0) + 2],
3386*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 0) + 3]);
3387*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program, "array4Uniform[1]"),
3388*35238bceSAndroid Build Coastguard Worker uniformValue[4 * 1], uniformValue[(4 * 1) + 1], uniformValue[(4 * 1) + 2],
3389*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 1) + 3]);
3390*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program, "array4Uniform[2]"),
3391*35238bceSAndroid Build Coastguard Worker uniformValue[4 * 2], uniformValue[(4 * 2) + 1], uniformValue[(4 * 2) + 2],
3392*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 2) + 3]);
3393*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program, "array4Uniform[3]"),
3394*35238bceSAndroid Build Coastguard Worker uniformValue[4 * 3], uniformValue[(4 * 3) + 1], uniformValue[(4 * 3) + 2],
3395*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 3) + 3]);
3396*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program, glGetUniformLocation(program, "array4Uniform[4]"),
3397*35238bceSAndroid Build Coastguard Worker uniformValue[4 * 4], uniformValue[(4 * 4) + 1], uniformValue[(4 * 4) + 2],
3398*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 4) + 3]);
3399*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3400*35238bceSAndroid Build Coastguard Worker
3401*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3402*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3403*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3404*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3405*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3406*35238bceSAndroid Build Coastguard Worker }
3407*35238bceSAndroid Build Coastguard Worker };
3408*35238bceSAndroid Build Coastguard Worker
3409*35238bceSAndroid Build Coastguard Worker class UniformValueMatrixCase : public ApiCase
3410*35238bceSAndroid Build Coastguard Worker {
3411*35238bceSAndroid Build Coastguard Worker public:
UniformValueMatrixCase(Context & context,const char * name,const char * description)3412*35238bceSAndroid Build Coastguard Worker UniformValueMatrixCase(Context &context, const char *name, const char *description)
3413*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3414*35238bceSAndroid Build Coastguard Worker {
3415*35238bceSAndroid Build Coastguard Worker }
3416*35238bceSAndroid Build Coastguard Worker
test(void)3417*35238bceSAndroid Build Coastguard Worker void test(void)
3418*35238bceSAndroid Build Coastguard Worker {
3419*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
3420*35238bceSAndroid Build Coastguard Worker "#version 300 es\n"
3421*35238bceSAndroid Build Coastguard Worker "uniform highp mat2 mat2Uniform;"
3422*35238bceSAndroid Build Coastguard Worker "uniform highp mat3 mat3Uniform;"
3423*35238bceSAndroid Build Coastguard Worker "uniform highp mat4 mat4Uniform;"
3424*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3425*35238bceSAndroid Build Coastguard Worker "{\n"
3426*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(mat2Uniform[0][0] + mat3Uniform[0][0] + mat4Uniform[0][0]);\n"
3427*35238bceSAndroid Build Coastguard Worker "}\n";
3428*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "#version 300 es\n"
3429*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;"
3430*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
3431*35238bceSAndroid Build Coastguard Worker "{\n"
3432*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(0.0);\n"
3433*35238bceSAndroid Build Coastguard Worker "}\n";
3434*35238bceSAndroid Build Coastguard Worker
3435*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
3436*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
3437*35238bceSAndroid Build Coastguard Worker
3438*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
3439*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
3440*35238bceSAndroid Build Coastguard Worker
3441*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
3442*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
3443*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3444*35238bceSAndroid Build Coastguard Worker
3445*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
3446*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
3447*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
3448*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
3449*35238bceSAndroid Build Coastguard Worker glUseProgram(program);
3450*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3451*35238bceSAndroid Build Coastguard Worker
3452*35238bceSAndroid Build Coastguard Worker GLint location;
3453*35238bceSAndroid Build Coastguard Worker
3454*35238bceSAndroid Build Coastguard Worker float matrixValues[4 * 4] = {
3455*35238bceSAndroid Build Coastguard Worker -1.0f, 0.1f, 4.0f, 800.0f, 13.0f, 55.0f, 12.0f, 91.0f,
3456*35238bceSAndroid Build Coastguard Worker -55.1f, 1.1f, 98.0f, 19.0f, 41.0f, 65.0f, 4.0f, 12.2f,
3457*35238bceSAndroid Build Coastguard Worker };
3458*35238bceSAndroid Build Coastguard Worker
3459*35238bceSAndroid Build Coastguard Worker // the values of the matrix are returned in column major order but they can be given in either order
3460*35238bceSAndroid Build Coastguard Worker
3461*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "mat2Uniform");
3462*35238bceSAndroid Build Coastguard Worker glUniformMatrix2fv(location, 1, GL_FALSE, matrixValues);
3463*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<2>(m_testCtx, *this, program, location, matrixValues, false);
3464*35238bceSAndroid Build Coastguard Worker glUniformMatrix2fv(location, 1, GL_TRUE, matrixValues);
3465*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<2>(m_testCtx, *this, program, location, matrixValues, true);
3466*35238bceSAndroid Build Coastguard Worker
3467*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "mat3Uniform");
3468*35238bceSAndroid Build Coastguard Worker glUniformMatrix3fv(location, 1, GL_FALSE, matrixValues);
3469*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<3>(m_testCtx, *this, program, location, matrixValues, false);
3470*35238bceSAndroid Build Coastguard Worker glUniformMatrix3fv(location, 1, GL_TRUE, matrixValues);
3471*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<3>(m_testCtx, *this, program, location, matrixValues, true);
3472*35238bceSAndroid Build Coastguard Worker
3473*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program, "mat4Uniform");
3474*35238bceSAndroid Build Coastguard Worker glUniformMatrix4fv(location, 1, GL_FALSE, matrixValues);
3475*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<4>(m_testCtx, *this, program, location, matrixValues, false);
3476*35238bceSAndroid Build Coastguard Worker glUniformMatrix4fv(location, 1, GL_TRUE, matrixValues);
3477*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<4>(m_testCtx, *this, program, location, matrixValues, true);
3478*35238bceSAndroid Build Coastguard Worker
3479*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
3480*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
3481*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
3482*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
3483*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3484*35238bceSAndroid Build Coastguard Worker }
3485*35238bceSAndroid Build Coastguard Worker };
3486*35238bceSAndroid Build Coastguard Worker
3487*35238bceSAndroid Build Coastguard Worker class PrecisionFormatCase : public ApiCase
3488*35238bceSAndroid Build Coastguard Worker {
3489*35238bceSAndroid Build Coastguard Worker public:
3490*35238bceSAndroid Build Coastguard Worker struct RequiredFormat
3491*35238bceSAndroid Build Coastguard Worker {
3492*35238bceSAndroid Build Coastguard Worker int negativeRange;
3493*35238bceSAndroid Build Coastguard Worker int positiveRange;
3494*35238bceSAndroid Build Coastguard Worker int precision;
3495*35238bceSAndroid Build Coastguard Worker };
3496*35238bceSAndroid Build Coastguard Worker
PrecisionFormatCase(Context & context,const char * name,const char * description,glw::GLenum shaderType,glw::GLenum precisionType)3497*35238bceSAndroid Build Coastguard Worker PrecisionFormatCase(Context &context, const char *name, const char *description, glw::GLenum shaderType,
3498*35238bceSAndroid Build Coastguard Worker glw::GLenum precisionType)
3499*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
3500*35238bceSAndroid Build Coastguard Worker , m_shaderType(shaderType)
3501*35238bceSAndroid Build Coastguard Worker , m_precisionType(precisionType)
3502*35238bceSAndroid Build Coastguard Worker {
3503*35238bceSAndroid Build Coastguard Worker }
3504*35238bceSAndroid Build Coastguard Worker
3505*35238bceSAndroid Build Coastguard Worker private:
test(void)3506*35238bceSAndroid Build Coastguard Worker void test(void)
3507*35238bceSAndroid Build Coastguard Worker {
3508*35238bceSAndroid Build Coastguard Worker const RequiredFormat expected = getRequiredFormat();
3509*35238bceSAndroid Build Coastguard Worker bool error = false;
3510*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLboolean> shaderCompiler;
3511*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint[2]> range;
3512*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint> precision;
3513*35238bceSAndroid Build Coastguard Worker
3514*35238bceSAndroid Build Coastguard Worker // query values
3515*35238bceSAndroid Build Coastguard Worker glGetShaderPrecisionFormat(m_shaderType, m_precisionType, range, &precision);
3516*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
3517*35238bceSAndroid Build Coastguard Worker
3518*35238bceSAndroid Build Coastguard Worker if (!range.verifyValidity(m_testCtx))
3519*35238bceSAndroid Build Coastguard Worker return;
3520*35238bceSAndroid Build Coastguard Worker if (!precision.verifyValidity(m_testCtx))
3521*35238bceSAndroid Build Coastguard Worker return;
3522*35238bceSAndroid Build Coastguard Worker
3523*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "range[0] = " << range[0] << "\n"
3524*35238bceSAndroid Build Coastguard Worker << "range[1] = " << range[1] << "\n"
3525*35238bceSAndroid Build Coastguard Worker << "precision = " << precision << tcu::TestLog::EndMessage;
3526*35238bceSAndroid Build Coastguard Worker
3527*35238bceSAndroid Build Coastguard Worker // verify values
3528*35238bceSAndroid Build Coastguard Worker
3529*35238bceSAndroid Build Coastguard Worker if (m_precisionType == GL_HIGH_FLOAT)
3530*35238bceSAndroid Build Coastguard Worker {
3531*35238bceSAndroid Build Coastguard Worker // highp float must be IEEE 754 single
3532*35238bceSAndroid Build Coastguard Worker
3533*35238bceSAndroid Build Coastguard Worker if (range[0] != expected.negativeRange || range[1] != expected.positiveRange ||
3534*35238bceSAndroid Build Coastguard Worker precision != expected.precision)
3535*35238bceSAndroid Build Coastguard Worker {
3536*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid precision format, expected:\n"
3537*35238bceSAndroid Build Coastguard Worker << "\trange[0] = " << expected.negativeRange << "\n"
3538*35238bceSAndroid Build Coastguard Worker << "\trange[1] = " << expected.positiveRange << "\n"
3539*35238bceSAndroid Build Coastguard Worker << "\tprecision = " << expected.precision << tcu::TestLog::EndMessage;
3540*35238bceSAndroid Build Coastguard Worker error = true;
3541*35238bceSAndroid Build Coastguard Worker }
3542*35238bceSAndroid Build Coastguard Worker }
3543*35238bceSAndroid Build Coastguard Worker else
3544*35238bceSAndroid Build Coastguard Worker {
3545*35238bceSAndroid Build Coastguard Worker if (range[0] < expected.negativeRange)
3546*35238bceSAndroid Build Coastguard Worker {
3547*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid range[0], expected greater or equal to "
3548*35238bceSAndroid Build Coastguard Worker << expected.negativeRange << tcu::TestLog::EndMessage;
3549*35238bceSAndroid Build Coastguard Worker error = true;
3550*35238bceSAndroid Build Coastguard Worker }
3551*35238bceSAndroid Build Coastguard Worker
3552*35238bceSAndroid Build Coastguard Worker if (range[1] < expected.positiveRange)
3553*35238bceSAndroid Build Coastguard Worker {
3554*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid range[1], expected greater or equal to "
3555*35238bceSAndroid Build Coastguard Worker << expected.positiveRange << tcu::TestLog::EndMessage;
3556*35238bceSAndroid Build Coastguard Worker error = true;
3557*35238bceSAndroid Build Coastguard Worker }
3558*35238bceSAndroid Build Coastguard Worker
3559*35238bceSAndroid Build Coastguard Worker if (precision < expected.precision)
3560*35238bceSAndroid Build Coastguard Worker {
3561*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid precision, expected greater or equal to "
3562*35238bceSAndroid Build Coastguard Worker << expected.precision << tcu::TestLog::EndMessage;
3563*35238bceSAndroid Build Coastguard Worker error = true;
3564*35238bceSAndroid Build Coastguard Worker }
3565*35238bceSAndroid Build Coastguard Worker }
3566*35238bceSAndroid Build Coastguard Worker
3567*35238bceSAndroid Build Coastguard Worker if (error)
3568*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid precision/range");
3569*35238bceSAndroid Build Coastguard Worker }
3570*35238bceSAndroid Build Coastguard Worker
getRequiredFormat(void) const3571*35238bceSAndroid Build Coastguard Worker RequiredFormat getRequiredFormat(void) const
3572*35238bceSAndroid Build Coastguard Worker {
3573*35238bceSAndroid Build Coastguard Worker // Precisions for different types.
3574*35238bceSAndroid Build Coastguard Worker const RequiredFormat requirements[] = {
3575*35238bceSAndroid Build Coastguard Worker {0, 0, 8}, //!< lowp float
3576*35238bceSAndroid Build Coastguard Worker {13, 13, 10}, //!< mediump float
3577*35238bceSAndroid Build Coastguard Worker {127, 127, 23}, //!< highp float
3578*35238bceSAndroid Build Coastguard Worker {8, 7, 0}, //!< lowp int
3579*35238bceSAndroid Build Coastguard Worker {15, 14, 0}, //!< mediump int
3580*35238bceSAndroid Build Coastguard Worker {31, 30, 0}, //!< highp int
3581*35238bceSAndroid Build Coastguard Worker };
3582*35238bceSAndroid Build Coastguard Worker const int ndx = (int)m_precisionType - (int)GL_LOW_FLOAT;
3583*35238bceSAndroid Build Coastguard Worker
3584*35238bceSAndroid Build Coastguard Worker DE_ASSERT(ndx >= 0);
3585*35238bceSAndroid Build Coastguard Worker DE_ASSERT(ndx < DE_LENGTH_OF_ARRAY(requirements));
3586*35238bceSAndroid Build Coastguard Worker return requirements[ndx];
3587*35238bceSAndroid Build Coastguard Worker }
3588*35238bceSAndroid Build Coastguard Worker
3589*35238bceSAndroid Build Coastguard Worker const glw::GLenum m_shaderType;
3590*35238bceSAndroid Build Coastguard Worker const glw::GLenum m_precisionType;
3591*35238bceSAndroid Build Coastguard Worker };
3592*35238bceSAndroid Build Coastguard Worker
3593*35238bceSAndroid Build Coastguard Worker } // namespace
3594*35238bceSAndroid Build Coastguard Worker
ShaderStateQueryTests(Context & context)3595*35238bceSAndroid Build Coastguard Worker ShaderStateQueryTests::ShaderStateQueryTests(Context &context)
3596*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "shader", "Shader State Query tests")
3597*35238bceSAndroid Build Coastguard Worker {
3598*35238bceSAndroid Build Coastguard Worker }
3599*35238bceSAndroid Build Coastguard Worker
init(void)3600*35238bceSAndroid Build Coastguard Worker void ShaderStateQueryTests::init(void)
3601*35238bceSAndroid Build Coastguard Worker {
3602*35238bceSAndroid Build Coastguard Worker // shader
3603*35238bceSAndroid Build Coastguard Worker addChild(new ShaderTypeCase(m_context, "shader_type", "SHADER_TYPE"));
3604*35238bceSAndroid Build Coastguard Worker addChild(new ShaderCompileStatusCase(m_context, "shader_compile_status", "COMPILE_STATUS"));
3605*35238bceSAndroid Build Coastguard Worker addChild(new ShaderInfoLogCase(m_context, "shader_info_log_length", "INFO_LOG_LENGTH"));
3606*35238bceSAndroid Build Coastguard Worker addChild(new ShaderSourceCase(m_context, "shader_source_length", "SHADER_SOURCE_LENGTH"));
3607*35238bceSAndroid Build Coastguard Worker
3608*35238bceSAndroid Build Coastguard Worker // shader and program
3609*35238bceSAndroid Build Coastguard Worker addChild(new DeleteStatusCase(m_context, "delete_status", "DELETE_STATUS"));
3610*35238bceSAndroid Build Coastguard Worker
3611*35238bceSAndroid Build Coastguard Worker // vertex-attrib
3612*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribInitialCase(m_context, "current_vertex_attrib_initial", "CURRENT_VERTEX_ATTRIB"));
3613*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribFloatCase(m_context, "current_vertex_attrib_float", "CURRENT_VERTEX_ATTRIB"));
3614*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribIntCase(m_context, "current_vertex_attrib_int", "CURRENT_VERTEX_ATTRIB"));
3615*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribUintCase(m_context, "current_vertex_attrib_uint", "CURRENT_VERTEX_ATTRIB"));
3616*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribConversionCase(m_context, "current_vertex_attrib_float_to_int",
3617*35238bceSAndroid Build Coastguard Worker "CURRENT_VERTEX_ATTRIB"));
3618*35238bceSAndroid Build Coastguard Worker
3619*35238bceSAndroid Build Coastguard Worker // program
3620*35238bceSAndroid Build Coastguard Worker addChild(new ProgramInfoLogCase(m_context, "program_info_log_length", "INFO_LOG_LENGTH",
3621*35238bceSAndroid Build Coastguard Worker ProgramInfoLogCase::BUILDERROR_COMPILE));
3622*35238bceSAndroid Build Coastguard Worker addChild(new ProgramInfoLogCase(m_context, "program_info_log_length_link_error", "INFO_LOG_LENGTH",
3623*35238bceSAndroid Build Coastguard Worker ProgramInfoLogCase::BUILDERROR_LINK));
3624*35238bceSAndroid Build Coastguard Worker addChild(new ProgramValidateStatusCase(m_context, "program_validate_status", "VALIDATE_STATUS"));
3625*35238bceSAndroid Build Coastguard Worker addChild(new ProgramAttachedShadersCase(m_context, "program_attached_shaders", "ATTACHED_SHADERS"));
3626*35238bceSAndroid Build Coastguard Worker
3627*35238bceSAndroid Build Coastguard Worker addChild(new ProgramActiveUniformNameCase(m_context, "program_active_uniform_name",
3628*35238bceSAndroid Build Coastguard Worker "ACTIVE_UNIFORMS and ACTIVE_UNIFORM_MAX_LENGTH"));
3629*35238bceSAndroid Build Coastguard Worker addChild(new ProgramUniformCase(m_context, "program_active_uniform_types",
3630*35238bceSAndroid Build Coastguard Worker "UNIFORM_TYPE, UNIFORM_SIZE, and UNIFORM_IS_ROW_MAJOR"));
3631*35238bceSAndroid Build Coastguard Worker addChild(new ProgramActiveUniformBlocksCase(m_context, "program_active_uniform_blocks", "ACTIVE_UNIFORM_BLOCK_x"));
3632*35238bceSAndroid Build Coastguard Worker addChild(new ProgramBinaryCase(m_context, "program_binary",
3633*35238bceSAndroid Build Coastguard Worker "PROGRAM_BINARY_LENGTH and PROGRAM_BINARY_RETRIEVABLE_HINT"));
3634*35238bceSAndroid Build Coastguard Worker
3635*35238bceSAndroid Build Coastguard Worker // transform feedback
3636*35238bceSAndroid Build Coastguard Worker addChild(new TransformFeedbackCase(
3637*35238bceSAndroid Build Coastguard Worker m_context, "transform_feedback",
3638*35238bceSAndroid Build Coastguard Worker "TRANSFORM_FEEDBACK_BUFFER_MODE, TRANSFORM_FEEDBACK_VARYINGS, TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH"));
3639*35238bceSAndroid Build Coastguard Worker
3640*35238bceSAndroid Build Coastguard Worker // attribute related
3641*35238bceSAndroid Build Coastguard Worker addChild(
3642*35238bceSAndroid Build Coastguard Worker new ActiveAttributesCase(m_context, "active_attributes", "ACTIVE_ATTRIBUTES and ACTIVE_ATTRIBUTE_MAX_LENGTH"));
3643*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeSizeCase(m_context, "vertex_attrib_size", "VERTEX_ATTRIB_ARRAY_SIZE"));
3644*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeTypeCase(m_context, "vertex_attrib_type", "VERTEX_ATTRIB_ARRAY_TYPE"));
3645*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeStrideCase(m_context, "vertex_attrib_stride", "VERTEX_ATTRIB_ARRAY_STRIDE"));
3646*35238bceSAndroid Build Coastguard Worker addChild(
3647*35238bceSAndroid Build Coastguard Worker new VertexAttributeNormalizedCase(m_context, "vertex_attrib_normalized", "VERTEX_ATTRIB_ARRAY_NORMALIZED"));
3648*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeIntegerCase(m_context, "vertex_attrib_integer", "VERTEX_ATTRIB_ARRAY_INTEGER"));
3649*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeEnabledCase(m_context, "vertex_attrib_array_enabled", "VERTEX_ATTRIB_ARRAY_ENABLED"));
3650*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeDivisorCase(m_context, "vertex_attrib_array_divisor", "VERTEX_ATTRIB_ARRAY_DIVISOR"));
3651*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeBufferBindingCase(m_context, "vertex_attrib_array_buffer_binding",
3652*35238bceSAndroid Build Coastguard Worker "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"));
3653*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributePointerCase(m_context, "vertex_attrib_pointerv", "GetVertexAttribPointerv"));
3654*35238bceSAndroid Build Coastguard Worker
3655*35238bceSAndroid Build Coastguard Worker // uniform values
3656*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueFloatCase(m_context, "uniform_value_float", "GetUniform*"));
3657*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueIntCase(m_context, "uniform_value_int", "GetUniform*"));
3658*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueUintCase(m_context, "uniform_value_uint", "GetUniform*"));
3659*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueBooleanCase(m_context, "uniform_value_boolean", "GetUniform*"));
3660*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueSamplerCase(m_context, "uniform_value_sampler", "GetUniform*"));
3661*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueArrayCase(m_context, "uniform_value_array", "GetUniform*"));
3662*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueMatrixCase(m_context, "uniform_value_matrix", "GetUniform*"));
3663*35238bceSAndroid Build Coastguard Worker
3664*35238bceSAndroid Build Coastguard Worker // precision format query
3665*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_lowp_float", "GetShaderPrecisionFormat",
3666*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_LOW_FLOAT));
3667*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_mediump_float", "GetShaderPrecisionFormat",
3668*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_MEDIUM_FLOAT));
3669*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_highp_float", "GetShaderPrecisionFormat",
3670*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_HIGH_FLOAT));
3671*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_lowp_int", "GetShaderPrecisionFormat",
3672*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_LOW_INT));
3673*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_mediump_int", "GetShaderPrecisionFormat",
3674*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_MEDIUM_INT));
3675*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_highp_int", "GetShaderPrecisionFormat",
3676*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_HIGH_INT));
3677*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_lowp_float", "GetShaderPrecisionFormat",
3678*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_LOW_FLOAT));
3679*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_mediump_float", "GetShaderPrecisionFormat",
3680*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT));
3681*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_highp_float", "GetShaderPrecisionFormat",
3682*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_HIGH_FLOAT));
3683*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_lowp_int", "GetShaderPrecisionFormat",
3684*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_LOW_INT));
3685*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_mediump_int", "GetShaderPrecisionFormat",
3686*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_MEDIUM_INT));
3687*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_highp_int", "GetShaderPrecisionFormat",
3688*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_HIGH_INT));
3689*35238bceSAndroid Build Coastguard Worker }
3690*35238bceSAndroid Build Coastguard Worker
3691*35238bceSAndroid Build Coastguard Worker } // namespace Functional
3692*35238bceSAndroid Build Coastguard Worker } // namespace gles3
3693*35238bceSAndroid Build Coastguard Worker } // namespace deqp
3694