1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.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 "es2fShaderStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "es2fApiCase.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
33*35238bceSAndroid Build Coastguard Worker #include "deString.h"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
36*35238bceSAndroid Build Coastguard Worker using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker namespace deqp
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace gles2
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace Functional
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker namespace
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker
47*35238bceSAndroid Build Coastguard Worker static const char *commonTestVertSource = "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";
51*35238bceSAndroid Build Coastguard Worker static const char *commonTestFragSource = "void main (void)\n"
52*35238bceSAndroid Build Coastguard Worker "{\n"
53*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
54*35238bceSAndroid Build Coastguard Worker "}\n";
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker static const char *brokenShader = "broken, this should not compile!\n"
57*35238bceSAndroid Build Coastguard Worker "\n";
58*35238bceSAndroid Build Coastguard Worker
59*35238bceSAndroid Build Coastguard Worker // rounds x.1 to x+1
60*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerUp(GLfloat val)61*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerUp(GLfloat val)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker return (T)(ceil(val));
64*35238bceSAndroid Build Coastguard Worker }
65*35238bceSAndroid Build Coastguard Worker
66*35238bceSAndroid Build Coastguard Worker // rounds x.9 to x
67*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerDown(GLfloat val)68*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerDown(GLfloat val)
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker return (T)(floor(val));
71*35238bceSAndroid Build Coastguard Worker }
72*35238bceSAndroid Build Coastguard Worker
checkIntEquals(tcu::TestContext & testCtx,GLint got,GLint expected)73*35238bceSAndroid Build Coastguard Worker bool checkIntEquals(tcu::TestContext &testCtx, GLint got, GLint expected)
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker if (got != expected)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got
80*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
81*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
82*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
83*35238bceSAndroid Build Coastguard Worker return false;
84*35238bceSAndroid Build Coastguard Worker }
85*35238bceSAndroid Build Coastguard Worker return true;
86*35238bceSAndroid Build Coastguard Worker }
87*35238bceSAndroid Build Coastguard Worker
checkPointerEquals(tcu::TestContext & testCtx,const void * got,const void * expected)88*35238bceSAndroid Build Coastguard Worker void checkPointerEquals(tcu::TestContext &testCtx, const void *got, const void *expected)
89*35238bceSAndroid Build Coastguard Worker {
90*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
91*35238bceSAndroid Build Coastguard Worker
92*35238bceSAndroid Build Coastguard Worker if (got != expected)
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got
95*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
96*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
97*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
98*35238bceSAndroid Build Coastguard Worker }
99*35238bceSAndroid Build Coastguard Worker }
100*35238bceSAndroid Build Coastguard Worker
verifyShaderParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint shader,GLenum pname,GLenum reference)101*35238bceSAndroid Build Coastguard Worker void verifyShaderParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint shader, GLenum pname,
102*35238bceSAndroid Build Coastguard Worker GLenum reference)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
105*35238bceSAndroid Build Coastguard Worker gl.glGetShaderiv(shader, pname, &state);
106*35238bceSAndroid Build Coastguard Worker
107*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
108*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
109*35238bceSAndroid Build Coastguard Worker }
110*35238bceSAndroid Build Coastguard Worker
verifyProgramParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLenum pname,GLenum reference)111*35238bceSAndroid Build Coastguard Worker bool verifyProgramParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLenum pname,
112*35238bceSAndroid Build Coastguard Worker GLenum reference)
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
115*35238bceSAndroid Build Coastguard Worker gl.glGetProgramiv(program, pname, &state);
116*35238bceSAndroid Build Coastguard Worker
117*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
118*35238bceSAndroid Build Coastguard Worker return checkIntEquals(testCtx, state, reference);
119*35238bceSAndroid Build Coastguard Worker return false;
120*35238bceSAndroid Build Coastguard Worker }
121*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribf(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)122*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribf(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLfloat x, GLfloat y,
123*35238bceSAndroid Build Coastguard Worker GLfloat z, GLfloat w)
124*35238bceSAndroid Build Coastguard Worker {
125*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
126*35238bceSAndroid Build Coastguard Worker
127*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
128*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
131*35238bceSAndroid Build Coastguard Worker
132*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != x || attribValue[1] != y || attribValue[2] != z || attribValue[3] != w)
133*35238bceSAndroid Build Coastguard Worker {
134*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected [" << x << "," << y << "," << z << "," << w << "];"
135*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
136*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
137*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
138*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
139*35238bceSAndroid Build Coastguard Worker }
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker
verifyCurrentVertexAttribConversion(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)142*35238bceSAndroid Build Coastguard Worker void verifyCurrentVertexAttribConversion(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLfloat x,
143*35238bceSAndroid Build Coastguard Worker GLfloat y, GLfloat z, GLfloat w)
144*35238bceSAndroid Build Coastguard Worker {
145*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
146*35238bceSAndroid Build Coastguard Worker
147*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[4]> attribValue;
148*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(testCtx);
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker const GLint referenceAsGLintMin[] = {
153*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerDown<GLint>(x), roundGLfloatToNearestIntegerDown<GLint>(y),
154*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerDown<GLint>(z), roundGLfloatToNearestIntegerDown<GLint>(w)};
155*35238bceSAndroid Build Coastguard Worker const GLint referenceAsGLintMax[] = {
156*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerUp<GLint>(x), roundGLfloatToNearestIntegerUp<GLint>(y),
157*35238bceSAndroid Build Coastguard Worker roundGLfloatToNearestIntegerUp<GLint>(z), roundGLfloatToNearestIntegerUp<GLint>(w)};
158*35238bceSAndroid Build Coastguard Worker
159*35238bceSAndroid Build Coastguard Worker if (attribValue[0] < referenceAsGLintMin[0] || attribValue[0] > referenceAsGLintMax[0] ||
160*35238bceSAndroid Build Coastguard Worker attribValue[1] < referenceAsGLintMin[1] || attribValue[1] > referenceAsGLintMax[1] ||
161*35238bceSAndroid Build Coastguard Worker attribValue[2] < referenceAsGLintMin[2] || attribValue[2] > referenceAsGLintMax[2] ||
162*35238bceSAndroid Build Coastguard Worker attribValue[3] < referenceAsGLintMin[3] || attribValue[3] > referenceAsGLintMax[3])
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected in range "
165*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[0] << " " << referenceAsGLintMax[0] << "], "
166*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[1] << " " << referenceAsGLintMax[1] << "], "
167*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[2] << " " << referenceAsGLintMax[2] << "], "
168*35238bceSAndroid Build Coastguard Worker << "[" << referenceAsGLintMin[3] << " " << referenceAsGLintMax[3] << "]"
169*35238bceSAndroid Build Coastguard Worker << "; got " << attribValue[0] << ", " << attribValue[1] << ", " << attribValue[2] << ", "
170*35238bceSAndroid Build Coastguard Worker << attribValue[3] << " "
171*35238bceSAndroid Build Coastguard Worker << "; Input=" << x << "; " << y << "; " << z << "; " << w << " " << TestLog::EndMessage;
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
174*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid attribute value");
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker }
177*35238bceSAndroid Build Coastguard Worker
verifyVertexAttrib(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLint index,GLenum pname,GLenum reference)178*35238bceSAndroid Build Coastguard Worker void verifyVertexAttrib(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLint index, GLenum pname, GLenum reference)
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
181*35238bceSAndroid Build Coastguard Worker gl.glGetVertexAttribiv(index, pname, &state);
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
184*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
185*35238bceSAndroid Build Coastguard Worker }
186*35238bceSAndroid Build Coastguard Worker
verifyUniformValue1f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x)187*35238bceSAndroid Build Coastguard Worker void verifyUniformValue1f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x)
188*35238bceSAndroid Build Coastguard Worker {
189*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[1]> state;
192*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
193*35238bceSAndroid Build Coastguard Worker
194*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
195*35238bceSAndroid Build Coastguard Worker return;
196*35238bceSAndroid Build Coastguard Worker
197*35238bceSAndroid Build Coastguard Worker if (state[0] != x)
198*35238bceSAndroid Build Coastguard Worker {
199*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << "]; got [" << state[0] << "]"
200*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
203*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker }
206*35238bceSAndroid Build Coastguard Worker
verifyUniformValue2f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y)207*35238bceSAndroid Build Coastguard Worker void verifyUniformValue2f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
208*35238bceSAndroid Build Coastguard Worker float y)
209*35238bceSAndroid Build Coastguard Worker {
210*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
211*35238bceSAndroid Build Coastguard Worker
212*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[2]> state;
213*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
214*35238bceSAndroid Build Coastguard Worker
215*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
216*35238bceSAndroid Build Coastguard Worker return;
217*35238bceSAndroid Build Coastguard Worker
218*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y)
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << "]; got [" << state[0]
221*35238bceSAndroid Build Coastguard Worker << ", " << state[1] << "]" << TestLog::EndMessage;
222*35238bceSAndroid Build Coastguard Worker
223*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
224*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
225*35238bceSAndroid Build Coastguard Worker }
226*35238bceSAndroid Build Coastguard Worker }
227*35238bceSAndroid Build Coastguard Worker
verifyUniformValue3f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y,float z)228*35238bceSAndroid Build Coastguard Worker void verifyUniformValue3f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
229*35238bceSAndroid Build Coastguard Worker float y, float z)
230*35238bceSAndroid Build Coastguard Worker {
231*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
232*35238bceSAndroid Build Coastguard Worker
233*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[3]> state;
234*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
235*35238bceSAndroid Build Coastguard Worker
236*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
237*35238bceSAndroid Build Coastguard Worker return;
238*35238bceSAndroid Build Coastguard Worker
239*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z)
240*35238bceSAndroid Build Coastguard Worker {
241*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << "]; got ["
242*35238bceSAndroid Build Coastguard Worker << state[0] << ", " << state[1] << ", " << state[2] << "]" << TestLog::EndMessage;
243*35238bceSAndroid Build Coastguard Worker
244*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
245*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
246*35238bceSAndroid Build Coastguard Worker }
247*35238bceSAndroid Build Coastguard Worker }
248*35238bceSAndroid Build Coastguard Worker
verifyUniformValue4f(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,float x,float y,float z,float w)249*35238bceSAndroid Build Coastguard Worker void verifyUniformValue4f(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, float x,
250*35238bceSAndroid Build Coastguard Worker float y, float z, float w)
251*35238bceSAndroid Build Coastguard Worker {
252*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
253*35238bceSAndroid Build Coastguard Worker
254*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> state;
255*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
256*35238bceSAndroid Build Coastguard Worker
257*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
258*35238bceSAndroid Build Coastguard Worker return;
259*35238bceSAndroid Build Coastguard Worker
260*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z || state[3] != w)
261*35238bceSAndroid Build Coastguard Worker {
262*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << ", " << w
263*35238bceSAndroid Build Coastguard Worker << "]; got [" << state[0] << ", " << state[1] << ", " << state[2] << ", " << state[3] << "]"
264*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
265*35238bceSAndroid Build Coastguard Worker
266*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
267*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
268*35238bceSAndroid Build Coastguard Worker }
269*35238bceSAndroid Build Coastguard Worker }
270*35238bceSAndroid Build Coastguard Worker
verifyUniformValue1i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x)271*35238bceSAndroid Build Coastguard Worker void verifyUniformValue1i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x)
272*35238bceSAndroid Build Coastguard Worker {
273*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
274*35238bceSAndroid Build Coastguard Worker
275*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[1]> state;
276*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
277*35238bceSAndroid Build Coastguard Worker
278*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
279*35238bceSAndroid Build Coastguard Worker return;
280*35238bceSAndroid Build Coastguard Worker
281*35238bceSAndroid Build Coastguard Worker if (state[0] != x)
282*35238bceSAndroid Build Coastguard Worker {
283*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << "]; got [" << state[0] << "]"
284*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
285*35238bceSAndroid Build Coastguard Worker
286*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
287*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
288*35238bceSAndroid Build Coastguard Worker }
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker
verifyUniformValue2i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y)291*35238bceSAndroid Build Coastguard Worker void verifyUniformValue2i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
292*35238bceSAndroid Build Coastguard Worker GLint y)
293*35238bceSAndroid Build Coastguard Worker {
294*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
295*35238bceSAndroid Build Coastguard Worker
296*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[2]> state;
297*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
298*35238bceSAndroid Build Coastguard Worker
299*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
300*35238bceSAndroid Build Coastguard Worker return;
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y)
303*35238bceSAndroid Build Coastguard Worker {
304*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << "]; got [" << state[0]
305*35238bceSAndroid Build Coastguard Worker << ", " << state[1] << "]" << TestLog::EndMessage;
306*35238bceSAndroid Build Coastguard Worker
307*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
308*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
309*35238bceSAndroid Build Coastguard Worker }
310*35238bceSAndroid Build Coastguard Worker }
311*35238bceSAndroid Build Coastguard Worker
verifyUniformValue3i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y,GLint z)312*35238bceSAndroid Build Coastguard Worker void verifyUniformValue3i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
313*35238bceSAndroid Build Coastguard Worker GLint y, GLint z)
314*35238bceSAndroid Build Coastguard Worker {
315*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
316*35238bceSAndroid Build Coastguard Worker
317*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[3]> state;
318*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
319*35238bceSAndroid Build Coastguard Worker
320*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
321*35238bceSAndroid Build Coastguard Worker return;
322*35238bceSAndroid Build Coastguard Worker
323*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z)
324*35238bceSAndroid Build Coastguard Worker {
325*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << "]; got ["
326*35238bceSAndroid Build Coastguard Worker << state[0] << ", " << state[1] << ", " << state[2] << "]" << TestLog::EndMessage;
327*35238bceSAndroid Build Coastguard Worker
328*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
329*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
330*35238bceSAndroid Build Coastguard Worker }
331*35238bceSAndroid Build Coastguard Worker }
332*35238bceSAndroid Build Coastguard Worker
verifyUniformValue4i(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,GLint x,GLint y,GLint z,GLint w)333*35238bceSAndroid Build Coastguard Worker void verifyUniformValue4i(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location, GLint x,
334*35238bceSAndroid Build Coastguard Worker GLint y, GLint z, GLint w)
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
337*35238bceSAndroid Build Coastguard Worker
338*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint[4]> state;
339*35238bceSAndroid Build Coastguard Worker gl.glGetUniformiv(program, location, state);
340*35238bceSAndroid Build Coastguard Worker
341*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
342*35238bceSAndroid Build Coastguard Worker return;
343*35238bceSAndroid Build Coastguard Worker
344*35238bceSAndroid Build Coastguard Worker if (state[0] != x || state[1] != y || state[2] != z || state[3] != w)
345*35238bceSAndroid Build Coastguard Worker {
346*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: expected [" << x << ", " << y << ", " << z << ", " << w
347*35238bceSAndroid Build Coastguard Worker << "]; got [" << state[0] << ", " << state[1] << ", " << state[2] << ", " << state[3] << "]"
348*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
349*35238bceSAndroid Build Coastguard Worker
350*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
351*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker }
354*35238bceSAndroid Build Coastguard Worker
355*35238bceSAndroid Build Coastguard Worker template <int Count>
verifyUniformValues(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,const GLfloat * values)356*35238bceSAndroid Build Coastguard Worker void verifyUniformValues(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location,
357*35238bceSAndroid Build Coastguard Worker const GLfloat *values)
358*35238bceSAndroid Build Coastguard Worker {
359*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[Count]> state;
362*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
363*35238bceSAndroid Build Coastguard Worker
364*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
365*35238bceSAndroid Build Coastguard Worker return;
366*35238bceSAndroid Build Coastguard Worker
367*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < Count; ++ndx)
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker if (values[ndx] != state[ndx])
370*35238bceSAndroid Build Coastguard Worker {
371*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: at index " << ndx << " expected " << values[ndx]
372*35238bceSAndroid Build Coastguard Worker << "; got " << state[ndx] << TestLog::EndMessage;
373*35238bceSAndroid Build Coastguard Worker
374*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
375*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
376*35238bceSAndroid Build Coastguard Worker }
377*35238bceSAndroid Build Coastguard Worker }
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker template <int N>
verifyUniformMatrixValues(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLuint program,GLint location,const GLfloat * values,bool transpose)381*35238bceSAndroid Build Coastguard Worker void verifyUniformMatrixValues(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLuint program, GLint location,
382*35238bceSAndroid Build Coastguard Worker const GLfloat *values, bool transpose)
383*35238bceSAndroid Build Coastguard Worker {
384*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
385*35238bceSAndroid Build Coastguard Worker
386*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[N * N]> state;
387*35238bceSAndroid Build Coastguard Worker gl.glGetUniformfv(program, location, state);
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
390*35238bceSAndroid Build Coastguard Worker return;
391*35238bceSAndroid Build Coastguard Worker
392*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < N; ++y)
393*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < N; ++x)
394*35238bceSAndroid Build Coastguard Worker {
395*35238bceSAndroid Build Coastguard Worker const int refIndex = y * N + x;
396*35238bceSAndroid Build Coastguard Worker const int stateIndex = transpose ? (x * N + y) : (y * N + x);
397*35238bceSAndroid Build Coastguard Worker
398*35238bceSAndroid Build Coastguard Worker if (values[refIndex] != state[stateIndex])
399*35238bceSAndroid Build Coastguard Worker {
400*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: at index [" << y << "][" << x << "] expected "
401*35238bceSAndroid Build Coastguard Worker << values[refIndex] << "; got " << state[stateIndex] << TestLog::EndMessage;
402*35238bceSAndroid Build Coastguard Worker
403*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
404*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid uniform value");
405*35238bceSAndroid Build Coastguard Worker }
406*35238bceSAndroid Build Coastguard Worker }
407*35238bceSAndroid Build Coastguard Worker }
408*35238bceSAndroid Build Coastguard Worker
requireShaderCompiler(tcu::TestContext & testCtx,glu::CallLogWrapper & gl)409*35238bceSAndroid Build Coastguard Worker void requireShaderCompiler(tcu::TestContext &testCtx, glu::CallLogWrapper &gl)
410*35238bceSAndroid Build Coastguard Worker {
411*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLboolean> state;
412*35238bceSAndroid Build Coastguard Worker gl.glGetBooleanv(GL_SHADER_COMPILER, &state);
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx) || state != GL_TRUE)
415*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires SHADER_COMPILER = TRUE");
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker
418*35238bceSAndroid Build Coastguard Worker class ShaderTypeCase : public ApiCase
419*35238bceSAndroid Build Coastguard Worker {
420*35238bceSAndroid Build Coastguard Worker public:
ShaderTypeCase(Context & context,const char * name,const char * description)421*35238bceSAndroid Build Coastguard Worker ShaderTypeCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
422*35238bceSAndroid Build Coastguard Worker {
423*35238bceSAndroid Build Coastguard Worker }
424*35238bceSAndroid Build Coastguard Worker
test(void)425*35238bceSAndroid Build Coastguard Worker void test(void)
426*35238bceSAndroid Build Coastguard Worker {
427*35238bceSAndroid Build Coastguard Worker const GLenum shaderTypes[] = {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER};
428*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
429*35238bceSAndroid Build Coastguard Worker {
430*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(shaderTypes[ndx]);
431*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_TYPE, shaderTypes[ndx]);
432*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
433*35238bceSAndroid Build Coastguard Worker }
434*35238bceSAndroid Build Coastguard Worker }
435*35238bceSAndroid Build Coastguard Worker };
436*35238bceSAndroid Build Coastguard Worker
437*35238bceSAndroid Build Coastguard Worker class ShaderCompileStatusCase : public ApiCase
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker public:
ShaderCompileStatusCase(Context & context,const char * name,const char * description)440*35238bceSAndroid Build Coastguard Worker ShaderCompileStatusCase(Context &context, const char *name, const char *description)
441*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
442*35238bceSAndroid Build Coastguard Worker {
443*35238bceSAndroid Build Coastguard Worker }
444*35238bceSAndroid Build Coastguard Worker
test(void)445*35238bceSAndroid Build Coastguard Worker void test(void)
446*35238bceSAndroid Build Coastguard Worker {
447*35238bceSAndroid Build Coastguard Worker requireShaderCompiler(m_testCtx, *this);
448*35238bceSAndroid Build Coastguard Worker
449*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
450*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
451*35238bceSAndroid Build Coastguard Worker
452*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_FALSE);
453*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
454*35238bceSAndroid Build Coastguard Worker
455*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
456*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
457*35238bceSAndroid Build Coastguard Worker
458*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
459*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
460*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
461*35238bceSAndroid Build Coastguard Worker
462*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
463*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
464*35238bceSAndroid Build Coastguard Worker
465*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
466*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
467*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
468*35238bceSAndroid Build Coastguard Worker }
469*35238bceSAndroid Build Coastguard Worker };
470*35238bceSAndroid Build Coastguard Worker
471*35238bceSAndroid Build Coastguard Worker class ShaderInfoLogCase : public ApiCase
472*35238bceSAndroid Build Coastguard Worker {
473*35238bceSAndroid Build Coastguard Worker public:
ShaderInfoLogCase(Context & context,const char * name,const char * description)474*35238bceSAndroid Build Coastguard Worker ShaderInfoLogCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
475*35238bceSAndroid Build Coastguard Worker {
476*35238bceSAndroid Build Coastguard Worker }
477*35238bceSAndroid Build Coastguard Worker
test(void)478*35238bceSAndroid Build Coastguard Worker void test(void)
479*35238bceSAndroid Build Coastguard Worker {
480*35238bceSAndroid Build Coastguard Worker requireShaderCompiler(m_testCtx, *this);
481*35238bceSAndroid Build Coastguard Worker
482*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker // INFO_LOG_LENGTH is 0 by default and it includes null-terminator
485*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
486*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_INFO_LOG_LENGTH, 0);
487*35238bceSAndroid Build Coastguard Worker
488*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 1, &brokenShader, DE_NULL);
489*35238bceSAndroid Build Coastguard Worker glCompileShader(shader);
490*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
491*35238bceSAndroid Build Coastguard Worker
492*35238bceSAndroid Build Coastguard Worker // check the log length
493*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> logLength;
494*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
495*35238bceSAndroid Build Coastguard Worker if (!logLength.verifyValidity(m_testCtx))
496*35238bceSAndroid Build Coastguard Worker {
497*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
498*35238bceSAndroid Build Coastguard Worker return;
499*35238bceSAndroid Build Coastguard Worker }
500*35238bceSAndroid Build Coastguard Worker if (logLength == 0)
501*35238bceSAndroid Build Coastguard Worker {
502*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
503*35238bceSAndroid Build Coastguard Worker return;
504*35238bceSAndroid Build Coastguard Worker }
505*35238bceSAndroid Build Coastguard Worker
506*35238bceSAndroid Build Coastguard Worker // check normal case
507*35238bceSAndroid Build Coastguard Worker {
508*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'}; // non-zero initialization
509*35238bceSAndroid Build Coastguard Worker
510*35238bceSAndroid Build Coastguard Worker GLint written = 0; // written does not include null terminator
511*35238bceSAndroid Build Coastguard Worker glGetShaderInfoLog(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
512*35238bceSAndroid Build Coastguard Worker
513*35238bceSAndroid Build Coastguard Worker // check lengths are consistent
514*35238bceSAndroid Build Coastguard Worker if (logLength <= DE_LENGTH_OF_ARRAY(buffer))
515*35238bceSAndroid Build Coastguard Worker {
516*35238bceSAndroid Build Coastguard Worker if (written != logLength - 1)
517*35238bceSAndroid Build Coastguard Worker {
518*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << logLength - 1 << "; got "
519*35238bceSAndroid Build Coastguard Worker << written << TestLog::EndMessage;
520*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
521*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
522*35238bceSAndroid Build Coastguard Worker }
523*35238bceSAndroid Build Coastguard Worker }
524*35238bceSAndroid Build Coastguard Worker
525*35238bceSAndroid Build Coastguard Worker // check null-terminator, either at end of buffer or at buffer[written]
526*35238bceSAndroid Build Coastguard Worker const char *terminator = &buffer[DE_LENGTH_OF_ARRAY(buffer) - 1];
527*35238bceSAndroid Build Coastguard Worker if (logLength < DE_LENGTH_OF_ARRAY(buffer))
528*35238bceSAndroid Build Coastguard Worker terminator = &buffer[written];
529*35238bceSAndroid Build Coastguard Worker
530*35238bceSAndroid Build Coastguard Worker if (*terminator != '\0')
531*35238bceSAndroid Build Coastguard Worker {
532*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)*terminator
533*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
534*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
535*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
536*35238bceSAndroid Build Coastguard Worker }
537*35238bceSAndroid Build Coastguard Worker }
538*35238bceSAndroid Build Coastguard Worker
539*35238bceSAndroid Build Coastguard Worker // check with too small buffer
540*35238bceSAndroid Build Coastguard Worker {
541*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'}; // non-zero initialization
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker // check string always ends with \0, even with small buffers
544*35238bceSAndroid Build Coastguard Worker GLint written = 0;
545*35238bceSAndroid Build Coastguard Worker glGetShaderInfoLog(shader, 1, &written, buffer);
546*35238bceSAndroid Build Coastguard Worker if (written != 0)
547*35238bceSAndroid Build Coastguard Worker {
548*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length 0; got " << written
549*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
550*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
551*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
552*35238bceSAndroid Build Coastguard Worker }
553*35238bceSAndroid Build Coastguard Worker if (buffer[0] != '\0')
554*35238bceSAndroid Build Coastguard Worker {
555*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator, got " << (int)buffer[0]
556*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
557*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
558*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log terminator");
559*35238bceSAndroid Build Coastguard Worker }
560*35238bceSAndroid Build Coastguard Worker }
561*35238bceSAndroid Build Coastguard Worker
562*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
563*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
564*35238bceSAndroid Build Coastguard Worker }
565*35238bceSAndroid Build Coastguard Worker };
566*35238bceSAndroid Build Coastguard Worker
567*35238bceSAndroid Build Coastguard Worker class ShaderSourceCase : public ApiCase
568*35238bceSAndroid Build Coastguard Worker {
569*35238bceSAndroid Build Coastguard Worker public:
ShaderSourceCase(Context & context,const char * name,const char * description)570*35238bceSAndroid Build Coastguard Worker ShaderSourceCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
571*35238bceSAndroid Build Coastguard Worker {
572*35238bceSAndroid Build Coastguard Worker }
573*35238bceSAndroid Build Coastguard Worker
test(void)574*35238bceSAndroid Build Coastguard Worker void test(void)
575*35238bceSAndroid Build Coastguard Worker {
576*35238bceSAndroid Build Coastguard Worker requireShaderCompiler(m_testCtx, *this);
577*35238bceSAndroid Build Coastguard Worker
578*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
579*35238bceSAndroid Build Coastguard Worker
580*35238bceSAndroid Build Coastguard Worker // SHADER_SOURCE_LENGTH does include 0-terminator
581*35238bceSAndroid Build Coastguard Worker const GLuint shader = glCreateShader(GL_VERTEX_SHADER);
582*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shader, GL_SHADER_SOURCE_LENGTH, 0);
583*35238bceSAndroid Build Coastguard Worker
584*35238bceSAndroid Build Coastguard Worker // check the SHADER_SOURCE_LENGTH
585*35238bceSAndroid Build Coastguard Worker {
586*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 1, &brokenShader, DE_NULL);
587*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
588*35238bceSAndroid Build Coastguard Worker
589*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sourceLength;
590*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
591*35238bceSAndroid Build Coastguard Worker
592*35238bceSAndroid Build Coastguard Worker sourceLength.verifyValidity(m_testCtx);
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker const GLint referenceLength =
595*35238bceSAndroid Build Coastguard Worker (GLint)std::string(brokenShader).length() + 1; // including the null terminator
596*35238bceSAndroid Build Coastguard Worker if (sourceLength != referenceLength)
597*35238bceSAndroid Build Coastguard Worker {
598*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got "
599*35238bceSAndroid Build Coastguard Worker << sourceLength << TestLog::EndMessage;
600*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
601*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
602*35238bceSAndroid Build Coastguard Worker }
603*35238bceSAndroid Build Coastguard Worker }
604*35238bceSAndroid Build Coastguard Worker
605*35238bceSAndroid Build Coastguard Worker // check the concat source SHADER_SOURCE_LENGTH
606*35238bceSAndroid Build Coastguard Worker {
607*35238bceSAndroid Build Coastguard Worker const char *shaders[] = {brokenShader, brokenShader};
608*35238bceSAndroid Build Coastguard Worker glShaderSource(shader, 2, shaders, DE_NULL);
609*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
610*35238bceSAndroid Build Coastguard Worker
611*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sourceLength;
612*35238bceSAndroid Build Coastguard Worker glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLength);
613*35238bceSAndroid Build Coastguard Worker
614*35238bceSAndroid Build Coastguard Worker sourceLength.verifyValidity(m_testCtx);
615*35238bceSAndroid Build Coastguard Worker
616*35238bceSAndroid Build Coastguard Worker const GLint referenceLength =
617*35238bceSAndroid Build Coastguard Worker 2 * (GLint)std::string(brokenShader).length() + 1; // including the null terminator
618*35238bceSAndroid Build Coastguard Worker if (sourceLength != referenceLength)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected length " << referenceLength << "; got "
621*35238bceSAndroid Build Coastguard Worker << sourceLength << TestLog::EndMessage;
622*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
623*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
624*35238bceSAndroid Build Coastguard Worker }
625*35238bceSAndroid Build Coastguard Worker }
626*35238bceSAndroid Build Coastguard Worker
627*35238bceSAndroid Build Coastguard Worker // check the string length
628*35238bceSAndroid Build Coastguard Worker {
629*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
630*35238bceSAndroid Build Coastguard Worker DE_ASSERT(DE_LENGTH_OF_ARRAY(buffer) > 2 * (int)std::string(brokenShader).length());
631*35238bceSAndroid Build Coastguard Worker
632*35238bceSAndroid Build Coastguard Worker GLint written = 0; // not inluding null-terminator
633*35238bceSAndroid Build Coastguard Worker glGetShaderSource(shader, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
634*35238bceSAndroid Build Coastguard Worker
635*35238bceSAndroid Build Coastguard Worker const GLint referenceLength = 2 * (GLint)std::string(brokenShader).length();
636*35238bceSAndroid Build Coastguard Worker if (written != referenceLength)
637*35238bceSAndroid Build Coastguard Worker {
638*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length " << referenceLength
639*35238bceSAndroid Build Coastguard Worker << "; got " << written << TestLog::EndMessage;
640*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
641*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
642*35238bceSAndroid Build Coastguard Worker }
643*35238bceSAndroid Build Coastguard Worker // check null pointer at
644*35238bceSAndroid Build Coastguard Worker else
645*35238bceSAndroid Build Coastguard Worker {
646*35238bceSAndroid Build Coastguard Worker if (buffer[referenceLength] != '\0')
647*35238bceSAndroid Build Coastguard Worker {
648*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator at "
649*35238bceSAndroid Build Coastguard Worker << referenceLength << TestLog::EndMessage;
650*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
651*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "did not get a null terminator");
652*35238bceSAndroid Build Coastguard Worker }
653*35238bceSAndroid Build Coastguard Worker }
654*35238bceSAndroid Build Coastguard Worker }
655*35238bceSAndroid Build Coastguard Worker
656*35238bceSAndroid Build Coastguard Worker // check with small buffer
657*35238bceSAndroid Build Coastguard Worker {
658*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
659*35238bceSAndroid Build Coastguard Worker
660*35238bceSAndroid Build Coastguard Worker GLint written = 0;
661*35238bceSAndroid Build Coastguard Worker glGetShaderSource(shader, 1, &written, buffer);
662*35238bceSAndroid Build Coastguard Worker
663*35238bceSAndroid Build Coastguard Worker if (written != 0)
664*35238bceSAndroid Build Coastguard Worker {
665*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written
666*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
667*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
668*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid source length");
669*35238bceSAndroid Build Coastguard Worker }
670*35238bceSAndroid Build Coastguard Worker if (buffer[0] != '\0')
671*35238bceSAndroid Build Coastguard Worker {
672*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected null terminator; got=" << int(buffer[0])
673*35238bceSAndroid Build Coastguard Worker << ", char=" << buffer[0] << TestLog::EndMessage;
674*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
675*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid terminator");
676*35238bceSAndroid Build Coastguard Worker }
677*35238bceSAndroid Build Coastguard Worker }
678*35238bceSAndroid Build Coastguard Worker
679*35238bceSAndroid Build Coastguard Worker glDeleteShader(shader);
680*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
681*35238bceSAndroid Build Coastguard Worker }
682*35238bceSAndroid Build Coastguard Worker };
683*35238bceSAndroid Build Coastguard Worker
684*35238bceSAndroid Build Coastguard Worker class DeleteStatusCase : public ApiCase
685*35238bceSAndroid Build Coastguard Worker {
686*35238bceSAndroid Build Coastguard Worker public:
DeleteStatusCase(Context & context,const char * name,const char * description)687*35238bceSAndroid Build Coastguard Worker DeleteStatusCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
688*35238bceSAndroid Build Coastguard Worker {
689*35238bceSAndroid Build Coastguard Worker }
690*35238bceSAndroid Build Coastguard Worker
test(void)691*35238bceSAndroid Build Coastguard Worker void test(void)
692*35238bceSAndroid Build Coastguard Worker {
693*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
694*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
695*35238bceSAndroid Build Coastguard Worker
696*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
697*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
698*35238bceSAndroid Build Coastguard Worker
699*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
700*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
701*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
702*35238bceSAndroid Build Coastguard Worker
703*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
704*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
705*35238bceSAndroid Build Coastguard Worker
706*35238bceSAndroid Build Coastguard Worker GLuint shaderProg = glCreateProgram();
707*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderVert);
708*35238bceSAndroid Build Coastguard Worker glAttachShader(shaderProg, shaderFrag);
709*35238bceSAndroid Build Coastguard Worker glLinkProgram(shaderProg);
710*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
711*35238bceSAndroid Build Coastguard Worker
712*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_LINK_STATUS, GL_TRUE);
713*35238bceSAndroid Build Coastguard Worker
714*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_FALSE);
715*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_FALSE);
716*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_FALSE);
717*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
718*35238bceSAndroid Build Coastguard Worker
719*35238bceSAndroid Build Coastguard Worker glUseProgram(shaderProg);
720*35238bceSAndroid Build Coastguard Worker
721*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
722*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
723*35238bceSAndroid Build Coastguard Worker glDeleteProgram(shaderProg);
724*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
725*35238bceSAndroid Build Coastguard Worker
726*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_DELETE_STATUS, GL_TRUE);
727*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_DELETE_STATUS, GL_TRUE);
728*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, shaderProg, GL_DELETE_STATUS, GL_TRUE);
729*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
730*35238bceSAndroid Build Coastguard Worker
731*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
732*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
733*35238bceSAndroid Build Coastguard Worker }
734*35238bceSAndroid Build Coastguard Worker };
735*35238bceSAndroid Build Coastguard Worker
736*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribInitialCase : public ApiCase
737*35238bceSAndroid Build Coastguard Worker {
738*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribInitialCase(Context & context,const char * name,const char * description)739*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribInitialCase(Context &context, const char *name, const char *description)
740*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
741*35238bceSAndroid Build Coastguard Worker {
742*35238bceSAndroid Build Coastguard Worker }
743*35238bceSAndroid Build Coastguard Worker
test(void)744*35238bceSAndroid Build Coastguard Worker void test(void)
745*35238bceSAndroid Build Coastguard Worker {
746*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
747*35238bceSAndroid Build Coastguard Worker
748*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
749*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
750*35238bceSAndroid Build Coastguard Worker
751*35238bceSAndroid Build Coastguard Worker // initial
752*35238bceSAndroid Build Coastguard Worker
753*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
754*35238bceSAndroid Build Coastguard Worker {
755*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLfloat[4]> attribValue;
756*35238bceSAndroid Build Coastguard Worker glGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, attribValue);
757*35238bceSAndroid Build Coastguard Worker attribValue.verifyValidity(m_testCtx);
758*35238bceSAndroid Build Coastguard Worker
759*35238bceSAndroid Build Coastguard Worker if (attribValue[0] != 0.0f || attribValue[1] != 0.0f || attribValue[2] != 0.0f || attribValue[3] != 1.0f)
760*35238bceSAndroid Build Coastguard Worker {
761*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected [0, 0, 0, 1];"
762*35238bceSAndroid Build Coastguard Worker << "got [" << attribValue[0] << "," << attribValue[1] << "," << attribValue[2] << ","
763*35238bceSAndroid Build Coastguard Worker << attribValue[3] << "]" << TestLog::EndMessage;
764*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
765*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid attribute value");
766*35238bceSAndroid Build Coastguard Worker }
767*35238bceSAndroid Build Coastguard Worker }
768*35238bceSAndroid Build Coastguard Worker }
769*35238bceSAndroid Build Coastguard Worker };
770*35238bceSAndroid Build Coastguard Worker
771*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribFloatCase : public ApiCase
772*35238bceSAndroid Build Coastguard Worker {
773*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribFloatCase(Context & context,const char * name,const char * description)774*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribFloatCase(Context &context, const char *name, const char *description)
775*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
776*35238bceSAndroid Build Coastguard Worker {
777*35238bceSAndroid Build Coastguard Worker }
778*35238bceSAndroid Build Coastguard Worker
test(void)779*35238bceSAndroid Build Coastguard Worker void test(void)
780*35238bceSAndroid Build Coastguard Worker {
781*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
782*35238bceSAndroid Build Coastguard Worker
783*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
784*35238bceSAndroid Build Coastguard Worker
785*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
786*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
787*35238bceSAndroid Build Coastguard Worker
788*35238bceSAndroid Build Coastguard Worker // test write float/read float
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
791*35238bceSAndroid Build Coastguard Worker {
792*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
793*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
794*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
795*35238bceSAndroid Build Coastguard Worker const GLfloat w = rnd.getFloat(-64000, 64000);
796*35238bceSAndroid Build Coastguard Worker
797*35238bceSAndroid Build Coastguard Worker glVertexAttrib4f(index, x, y, z, w);
798*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
799*35238bceSAndroid Build Coastguard Worker }
800*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
801*35238bceSAndroid Build Coastguard Worker {
802*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
803*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
804*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
805*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
806*35238bceSAndroid Build Coastguard Worker
807*35238bceSAndroid Build Coastguard Worker glVertexAttrib3f(index, x, y, z);
808*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
809*35238bceSAndroid Build Coastguard Worker }
810*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
811*35238bceSAndroid Build Coastguard Worker {
812*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
813*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
814*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
815*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
816*35238bceSAndroid Build Coastguard Worker
817*35238bceSAndroid Build Coastguard Worker glVertexAttrib2f(index, x, y);
818*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
819*35238bceSAndroid Build Coastguard Worker }
820*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
821*35238bceSAndroid Build Coastguard Worker {
822*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
823*35238bceSAndroid Build Coastguard Worker const GLfloat y = 0.0f;
824*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
825*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
826*35238bceSAndroid Build Coastguard Worker
827*35238bceSAndroid Build Coastguard Worker glVertexAttrib1f(index, x);
828*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribf(m_testCtx, *this, index, x, y, z, w);
829*35238bceSAndroid Build Coastguard Worker }
830*35238bceSAndroid Build Coastguard Worker }
831*35238bceSAndroid Build Coastguard Worker };
832*35238bceSAndroid Build Coastguard Worker
833*35238bceSAndroid Build Coastguard Worker class CurrentVertexAttribConversionCase : public ApiCase
834*35238bceSAndroid Build Coastguard Worker {
835*35238bceSAndroid Build Coastguard Worker public:
CurrentVertexAttribConversionCase(Context & context,const char * name,const char * description)836*35238bceSAndroid Build Coastguard Worker CurrentVertexAttribConversionCase(Context &context, const char *name, const char *description)
837*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
838*35238bceSAndroid Build Coastguard Worker {
839*35238bceSAndroid Build Coastguard Worker }
840*35238bceSAndroid Build Coastguard Worker
test(void)841*35238bceSAndroid Build Coastguard Worker void test(void)
842*35238bceSAndroid Build Coastguard Worker {
843*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
844*35238bceSAndroid Build Coastguard Worker
845*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
846*35238bceSAndroid Build Coastguard Worker
847*35238bceSAndroid Build Coastguard Worker int attribute_count = 16;
848*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attribute_count);
849*35238bceSAndroid Build Coastguard Worker
850*35238bceSAndroid Build Coastguard Worker // test write float/read float
851*35238bceSAndroid Build Coastguard Worker
852*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
853*35238bceSAndroid Build Coastguard Worker {
854*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
855*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
856*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
857*35238bceSAndroid Build Coastguard Worker const GLfloat w = rnd.getFloat(-64000, 64000);
858*35238bceSAndroid Build Coastguard Worker
859*35238bceSAndroid Build Coastguard Worker glVertexAttrib4f(index, x, y, z, w);
860*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
861*35238bceSAndroid Build Coastguard Worker }
862*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
863*35238bceSAndroid Build Coastguard Worker {
864*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
865*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
866*35238bceSAndroid Build Coastguard Worker const GLfloat z = rnd.getFloat(-64000, 64000);
867*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
868*35238bceSAndroid Build Coastguard Worker
869*35238bceSAndroid Build Coastguard Worker glVertexAttrib3f(index, x, y, z);
870*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
871*35238bceSAndroid Build Coastguard Worker }
872*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
873*35238bceSAndroid Build Coastguard Worker {
874*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
875*35238bceSAndroid Build Coastguard Worker const GLfloat y = rnd.getFloat(-64000, 64000);
876*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
877*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
878*35238bceSAndroid Build Coastguard Worker
879*35238bceSAndroid Build Coastguard Worker glVertexAttrib2f(index, x, y);
880*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
881*35238bceSAndroid Build Coastguard Worker }
882*35238bceSAndroid Build Coastguard Worker for (int index = 0; index < attribute_count; ++index)
883*35238bceSAndroid Build Coastguard Worker {
884*35238bceSAndroid Build Coastguard Worker const GLfloat x = rnd.getFloat(-64000, 64000);
885*35238bceSAndroid Build Coastguard Worker const GLfloat y = 0.0f;
886*35238bceSAndroid Build Coastguard Worker const GLfloat z = 0.0f;
887*35238bceSAndroid Build Coastguard Worker const GLfloat w = 1.0f;
888*35238bceSAndroid Build Coastguard Worker
889*35238bceSAndroid Build Coastguard Worker glVertexAttrib1f(index, x);
890*35238bceSAndroid Build Coastguard Worker verifyCurrentVertexAttribConversion(m_testCtx, *this, index, x, y, z, w);
891*35238bceSAndroid Build Coastguard Worker }
892*35238bceSAndroid Build Coastguard Worker }
893*35238bceSAndroid Build Coastguard Worker };
894*35238bceSAndroid Build Coastguard Worker
895*35238bceSAndroid Build Coastguard Worker class ProgramInfoLogCase : public ApiCase
896*35238bceSAndroid Build Coastguard Worker {
897*35238bceSAndroid Build Coastguard Worker public:
ProgramInfoLogCase(Context & context,const char * name,const char * description)898*35238bceSAndroid Build Coastguard Worker ProgramInfoLogCase(Context &context, const char *name, const char *description)
899*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
900*35238bceSAndroid Build Coastguard Worker {
901*35238bceSAndroid Build Coastguard Worker }
902*35238bceSAndroid Build Coastguard Worker
test(void)903*35238bceSAndroid Build Coastguard Worker void test(void)
904*35238bceSAndroid Build Coastguard Worker {
905*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
906*35238bceSAndroid Build Coastguard Worker
907*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
908*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
909*35238bceSAndroid Build Coastguard Worker
910*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &brokenShader, DE_NULL);
911*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &brokenShader, DE_NULL);
912*35238bceSAndroid Build Coastguard Worker
913*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
914*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
915*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
916*35238bceSAndroid Build Coastguard Worker
917*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
918*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
919*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
920*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
921*35238bceSAndroid Build Coastguard Worker
922*35238bceSAndroid Build Coastguard Worker // check INFO_LOG_LENGTH == GetProgramInfoLog len
923*35238bceSAndroid Build Coastguard Worker {
924*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
925*35238bceSAndroid Build Coastguard Worker
926*35238bceSAndroid Build Coastguard Worker GLint written = 0;
927*35238bceSAndroid Build Coastguard Worker glGetProgramInfoLog(program, DE_LENGTH_OF_ARRAY(buffer), &written, buffer);
928*35238bceSAndroid Build Coastguard Worker
929*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> logLength;
930*35238bceSAndroid Build Coastguard Worker glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
931*35238bceSAndroid Build Coastguard Worker logLength.verifyValidity(m_testCtx);
932*35238bceSAndroid Build Coastguard Worker
933*35238bceSAndroid Build Coastguard Worker if (logLength != 0 && written + 1 != logLength) // INFO_LOG_LENGTH contains 0-terminator
934*35238bceSAndroid Build Coastguard Worker {
935*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected INFO_LOG_LENGTH " << written + 1
936*35238bceSAndroid Build Coastguard Worker << "; got " << logLength << TestLog::EndMessage;
937*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
938*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
939*35238bceSAndroid Build Coastguard Worker }
940*35238bceSAndroid Build Coastguard Worker }
941*35238bceSAndroid Build Coastguard Worker
942*35238bceSAndroid Build Coastguard Worker // check GetProgramInfoLog works with too small buffer
943*35238bceSAndroid Build Coastguard Worker {
944*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
945*35238bceSAndroid Build Coastguard Worker
946*35238bceSAndroid Build Coastguard Worker GLint written = 0;
947*35238bceSAndroid Build Coastguard Worker glGetProgramInfoLog(program, 1, &written, buffer);
948*35238bceSAndroid Build Coastguard Worker
949*35238bceSAndroid Build Coastguard Worker if (written != 0)
950*35238bceSAndroid Build Coastguard Worker {
951*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected write length 0; got " << written
952*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
953*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
954*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid log length");
955*35238bceSAndroid Build Coastguard Worker }
956*35238bceSAndroid Build Coastguard Worker }
957*35238bceSAndroid Build Coastguard Worker
958*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
959*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
960*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
961*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
962*35238bceSAndroid Build Coastguard Worker }
963*35238bceSAndroid Build Coastguard Worker };
964*35238bceSAndroid Build Coastguard Worker
965*35238bceSAndroid Build Coastguard Worker class ProgramValidateStatusCase : public ApiCase
966*35238bceSAndroid Build Coastguard Worker {
967*35238bceSAndroid Build Coastguard Worker public:
ProgramValidateStatusCase(Context & context,const char * name,const char * description)968*35238bceSAndroid Build Coastguard Worker ProgramValidateStatusCase(Context &context, const char *name, const char *description)
969*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
970*35238bceSAndroid Build Coastguard Worker {
971*35238bceSAndroid Build Coastguard Worker }
972*35238bceSAndroid Build Coastguard Worker
test(void)973*35238bceSAndroid Build Coastguard Worker void test(void)
974*35238bceSAndroid Build Coastguard Worker {
975*35238bceSAndroid Build Coastguard Worker // test validate ok
976*35238bceSAndroid Build Coastguard Worker {
977*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
978*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
979*35238bceSAndroid Build Coastguard Worker
980*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
981*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
982*35238bceSAndroid Build Coastguard Worker
983*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
984*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
985*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
986*35238bceSAndroid Build Coastguard Worker
987*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
988*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
989*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
990*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
991*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
992*35238bceSAndroid Build Coastguard Worker
993*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
994*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_TRUE);
995*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE);
996*35238bceSAndroid Build Coastguard Worker
997*35238bceSAndroid Build Coastguard Worker glValidateProgram(program);
998*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_TRUE);
999*35238bceSAndroid Build Coastguard Worker
1000*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1001*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1002*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1003*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1004*35238bceSAndroid Build Coastguard Worker }
1005*35238bceSAndroid Build Coastguard Worker
1006*35238bceSAndroid Build Coastguard Worker // test with broken shader
1007*35238bceSAndroid Build Coastguard Worker {
1008*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1009*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1010*35238bceSAndroid Build Coastguard Worker
1011*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1012*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &brokenShader, DE_NULL);
1013*35238bceSAndroid Build Coastguard Worker
1014*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1015*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1016*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1017*35238bceSAndroid Build Coastguard Worker
1018*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1019*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1020*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1021*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1022*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1023*35238bceSAndroid Build Coastguard Worker
1024*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderVert, GL_COMPILE_STATUS, GL_TRUE);
1025*35238bceSAndroid Build Coastguard Worker verifyShaderParam(m_testCtx, *this, shaderFrag, GL_COMPILE_STATUS, GL_FALSE);
1026*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_FALSE);
1027*35238bceSAndroid Build Coastguard Worker
1028*35238bceSAndroid Build Coastguard Worker glValidateProgram(program);
1029*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_VALIDATE_STATUS, GL_FALSE);
1030*35238bceSAndroid Build Coastguard Worker
1031*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1032*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1033*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1034*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1035*35238bceSAndroid Build Coastguard Worker }
1036*35238bceSAndroid Build Coastguard Worker }
1037*35238bceSAndroid Build Coastguard Worker };
1038*35238bceSAndroid Build Coastguard Worker
1039*35238bceSAndroid Build Coastguard Worker class ProgramAttachedShadersCase : public ApiCase
1040*35238bceSAndroid Build Coastguard Worker {
1041*35238bceSAndroid Build Coastguard Worker public:
ProgramAttachedShadersCase(Context & context,const char * name,const char * description)1042*35238bceSAndroid Build Coastguard Worker ProgramAttachedShadersCase(Context &context, const char *name, const char *description)
1043*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1044*35238bceSAndroid Build Coastguard Worker {
1045*35238bceSAndroid Build Coastguard Worker }
1046*35238bceSAndroid Build Coastguard Worker
test(void)1047*35238bceSAndroid Build Coastguard Worker void test(void)
1048*35238bceSAndroid Build Coastguard Worker {
1049*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1050*35238bceSAndroid Build Coastguard Worker
1051*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1052*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1053*35238bceSAndroid Build Coastguard Worker
1054*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &commonTestVertSource, DE_NULL);
1055*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &commonTestFragSource, DE_NULL);
1056*35238bceSAndroid Build Coastguard Worker
1057*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1058*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1059*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1060*35238bceSAndroid Build Coastguard Worker
1061*35238bceSAndroid Build Coastguard Worker // check ATTACHED_SHADERS
1062*35238bceSAndroid Build Coastguard Worker
1063*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1064*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 0);
1065*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1066*35238bceSAndroid Build Coastguard Worker
1067*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1068*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 1);
1069*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1070*35238bceSAndroid Build Coastguard Worker
1071*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1072*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ATTACHED_SHADERS, 2);
1073*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1074*35238bceSAndroid Build Coastguard Worker
1075*35238bceSAndroid Build Coastguard Worker // check GetAttachedShaders
1076*35238bceSAndroid Build Coastguard Worker {
1077*35238bceSAndroid Build Coastguard Worker GLuint shaders[2] = {0, 0};
1078*35238bceSAndroid Build Coastguard Worker GLint count = 0;
1079*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, DE_LENGTH_OF_ARRAY(shaders), &count, shaders);
1080*35238bceSAndroid Build Coastguard Worker
1081*35238bceSAndroid Build Coastguard Worker if (count != 2)
1082*35238bceSAndroid Build Coastguard Worker {
1083*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 2; got " << count << TestLog::EndMessage;
1084*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1085*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1086*35238bceSAndroid Build Coastguard Worker }
1087*35238bceSAndroid Build Coastguard Worker // shaders are the attached shaders?
1088*35238bceSAndroid Build Coastguard Worker if (!((shaders[0] == shaderVert && shaders[1] == shaderFrag) ||
1089*35238bceSAndroid Build Coastguard Worker (shaders[0] == shaderFrag && shaders[1] == shaderVert)))
1090*35238bceSAndroid Build Coastguard Worker {
1091*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected {" << shaderVert << ", " << shaderFrag
1092*35238bceSAndroid Build Coastguard Worker << "}; got {" << shaders[0] << ", " << shaders[1] << "}" << TestLog::EndMessage;
1093*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1094*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1095*35238bceSAndroid Build Coastguard Worker }
1096*35238bceSAndroid Build Coastguard Worker }
1097*35238bceSAndroid Build Coastguard Worker
1098*35238bceSAndroid Build Coastguard Worker // check GetAttachedShaders with too small buffer
1099*35238bceSAndroid Build Coastguard Worker {
1100*35238bceSAndroid Build Coastguard Worker GLuint shaders[2] = {0, 0};
1101*35238bceSAndroid Build Coastguard Worker GLint count = 0;
1102*35238bceSAndroid Build Coastguard Worker
1103*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, 0, &count, shaders);
1104*35238bceSAndroid Build Coastguard Worker if (count != 0)
1105*35238bceSAndroid Build Coastguard Worker {
1106*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0; got " << count << TestLog::EndMessage;
1107*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1108*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1109*35238bceSAndroid Build Coastguard Worker }
1110*35238bceSAndroid Build Coastguard Worker
1111*35238bceSAndroid Build Coastguard Worker count = 0;
1112*35238bceSAndroid Build Coastguard Worker glGetAttachedShaders(program, 1, &count, shaders);
1113*35238bceSAndroid Build Coastguard Worker if (count != 1)
1114*35238bceSAndroid Build Coastguard Worker {
1115*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 1; got " << count << TestLog::EndMessage;
1116*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1117*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong shader count");
1118*35238bceSAndroid Build Coastguard Worker }
1119*35238bceSAndroid Build Coastguard Worker }
1120*35238bceSAndroid Build Coastguard Worker
1121*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1122*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1123*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1124*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1125*35238bceSAndroid Build Coastguard Worker }
1126*35238bceSAndroid Build Coastguard Worker };
1127*35238bceSAndroid Build Coastguard Worker
1128*35238bceSAndroid Build Coastguard Worker class ProgramActiveUniformNameCase : public ApiCase
1129*35238bceSAndroid Build Coastguard Worker {
1130*35238bceSAndroid Build Coastguard Worker public:
ProgramActiveUniformNameCase(Context & context,const char * name,const char * description)1131*35238bceSAndroid Build Coastguard Worker ProgramActiveUniformNameCase(Context &context, const char *name, const char *description)
1132*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1133*35238bceSAndroid Build Coastguard Worker {
1134*35238bceSAndroid Build Coastguard Worker }
1135*35238bceSAndroid Build Coastguard Worker
test(void)1136*35238bceSAndroid Build Coastguard Worker void test(void)
1137*35238bceSAndroid Build Coastguard Worker {
1138*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1139*35238bceSAndroid Build Coastguard Worker
1140*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "uniform highp float uniformNameWithLength23;\n"
1141*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 uniformVec2;\n"
1142*35238bceSAndroid Build Coastguard Worker "uniform highp mat4 uniformMat4;\n"
1143*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1144*35238bceSAndroid Build Coastguard Worker "{\n"
1145*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0) + vec4(uniformNameWithLength23) + "
1146*35238bceSAndroid Build Coastguard Worker "vec4(uniformVec2.x) + vec4(uniformMat4[2][3]);\n"
1147*35238bceSAndroid Build Coastguard Worker "}\n\0";
1148*35238bceSAndroid Build Coastguard Worker static const char *testFragSource =
1149*35238bceSAndroid Build Coastguard Worker
1150*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1151*35238bceSAndroid Build Coastguard Worker "{\n"
1152*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1153*35238bceSAndroid Build Coastguard Worker "}\n\0";
1154*35238bceSAndroid Build Coastguard Worker
1155*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1156*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1157*35238bceSAndroid Build Coastguard Worker
1158*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
1159*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
1160*35238bceSAndroid Build Coastguard Worker
1161*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1162*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1163*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1164*35238bceSAndroid Build Coastguard Worker
1165*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1166*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1167*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1168*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1169*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1170*35238bceSAndroid Build Coastguard Worker
1171*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORMS, 3);
1172*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_UNIFORM_MAX_LENGTH,
1173*35238bceSAndroid Build Coastguard Worker (GLint)std::string("uniformNameWithLength23").length() + 1); // including a null terminator
1174*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1175*35238bceSAndroid Build Coastguard Worker
1176*35238bceSAndroid Build Coastguard Worker const char *uniformNames[] = {"uniformNameWithLength23", "uniformVec2", "uniformMat4"};
1177*35238bceSAndroid Build Coastguard Worker
1178*35238bceSAndroid Build Coastguard Worker // check names
1179*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformNames); ++ndx)
1180*35238bceSAndroid Build Coastguard Worker {
1181*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1182*35238bceSAndroid Build Coastguard Worker char *bufferEnd = (buffer + 1);
1183*35238bceSAndroid Build Coastguard Worker
1184*35238bceSAndroid Build Coastguard Worker GLint written = 0; // null terminator not included
1185*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1186*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1187*35238bceSAndroid Build Coastguard Worker glGetActiveUniform(program, ndx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
1188*35238bceSAndroid Build Coastguard Worker
1189*35238bceSAndroid Build Coastguard Worker if (written < DE_LENGTH_OF_ARRAY(buffer))
1190*35238bceSAndroid Build Coastguard Worker bufferEnd = &buffer[written];
1191*35238bceSAndroid Build Coastguard Worker
1192*35238bceSAndroid Build Coastguard Worker // find matching uniform
1193*35238bceSAndroid Build Coastguard Worker {
1194*35238bceSAndroid Build Coastguard Worker const std::string uniformName(buffer, bufferEnd);
1195*35238bceSAndroid Build Coastguard Worker bool found = false;
1196*35238bceSAndroid Build Coastguard Worker
1197*35238bceSAndroid Build Coastguard Worker for (int uniformNdx = 0; uniformNdx < DE_LENGTH_OF_ARRAY(uniformNames); ++uniformNdx)
1198*35238bceSAndroid Build Coastguard Worker {
1199*35238bceSAndroid Build Coastguard Worker if (uniformName == uniformNames[uniformNdx])
1200*35238bceSAndroid Build Coastguard Worker {
1201*35238bceSAndroid Build Coastguard Worker found = true;
1202*35238bceSAndroid Build Coastguard Worker break;
1203*35238bceSAndroid Build Coastguard Worker }
1204*35238bceSAndroid Build Coastguard Worker }
1205*35238bceSAndroid Build Coastguard Worker
1206*35238bceSAndroid Build Coastguard Worker if (!found)
1207*35238bceSAndroid Build Coastguard Worker {
1208*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unknown uniform name: " << uniformName
1209*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1210*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1211*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name");
1212*35238bceSAndroid Build Coastguard Worker }
1213*35238bceSAndroid Build Coastguard Worker }
1214*35238bceSAndroid Build Coastguard Worker
1215*35238bceSAndroid Build Coastguard Worker // and with too small buffer
1216*35238bceSAndroid Build Coastguard Worker written = 0;
1217*35238bceSAndroid Build Coastguard Worker glGetActiveUniform(program, ndx, 1, &written, &size, &type, buffer);
1218*35238bceSAndroid Build Coastguard Worker
1219*35238bceSAndroid Build Coastguard Worker if (written != 0)
1220*35238bceSAndroid Build Coastguard Worker {
1221*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected 0 got " << written << TestLog::EndMessage;
1222*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1223*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got wrong uniform name length");
1224*35238bceSAndroid Build Coastguard Worker }
1225*35238bceSAndroid Build Coastguard Worker }
1226*35238bceSAndroid Build Coastguard Worker
1227*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1228*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1229*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1230*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1231*35238bceSAndroid Build Coastguard Worker }
1232*35238bceSAndroid Build Coastguard Worker };
1233*35238bceSAndroid Build Coastguard Worker
1234*35238bceSAndroid Build Coastguard Worker class ProgramUniformCase : public ApiCase
1235*35238bceSAndroid Build Coastguard Worker {
1236*35238bceSAndroid Build Coastguard Worker public:
ProgramUniformCase(Context & context,const char * name,const char * description)1237*35238bceSAndroid Build Coastguard Worker ProgramUniformCase(Context &context, const char *name, const char *description)
1238*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1239*35238bceSAndroid Build Coastguard Worker {
1240*35238bceSAndroid Build Coastguard Worker }
1241*35238bceSAndroid Build Coastguard Worker
test(void)1242*35238bceSAndroid Build Coastguard Worker void test(void)
1243*35238bceSAndroid Build Coastguard Worker {
1244*35238bceSAndroid Build Coastguard Worker const struct UniformType
1245*35238bceSAndroid Build Coastguard Worker {
1246*35238bceSAndroid Build Coastguard Worker const char *declaration;
1247*35238bceSAndroid Build Coastguard Worker const char *postDeclaration;
1248*35238bceSAndroid Build Coastguard Worker const char *precision;
1249*35238bceSAndroid Build Coastguard Worker const char *layout;
1250*35238bceSAndroid Build Coastguard Worker const char *getter;
1251*35238bceSAndroid Build Coastguard Worker GLenum type;
1252*35238bceSAndroid Build Coastguard Worker GLint size;
1253*35238bceSAndroid Build Coastguard Worker GLint isRowMajor;
1254*35238bceSAndroid Build Coastguard Worker } uniformTypes[] = {
1255*35238bceSAndroid Build Coastguard Worker {"float", "", "highp", "", "uniformValue", GL_FLOAT, 1, GL_FALSE},
1256*35238bceSAndroid Build Coastguard Worker {"float", "[2]", "highp", "", "uniformValue[1]", GL_FLOAT, 2, GL_FALSE},
1257*35238bceSAndroid Build Coastguard Worker {"vec2", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC2, 1, GL_FALSE},
1258*35238bceSAndroid Build Coastguard Worker {"vec3", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC3, 1, GL_FALSE},
1259*35238bceSAndroid Build Coastguard Worker {"vec4", "", "highp", "", "uniformValue.x", GL_FLOAT_VEC4, 1, GL_FALSE},
1260*35238bceSAndroid Build Coastguard Worker {"int", "", "highp", "", "float(uniformValue)", GL_INT, 1, GL_FALSE},
1261*35238bceSAndroid Build Coastguard Worker {"ivec2", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC2, 1, GL_FALSE},
1262*35238bceSAndroid Build Coastguard Worker {"ivec3", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC3, 1, GL_FALSE},
1263*35238bceSAndroid Build Coastguard Worker {"ivec4", "", "highp", "", "float(uniformValue.x)", GL_INT_VEC4, 1, GL_FALSE},
1264*35238bceSAndroid Build Coastguard Worker {"bool", "", "", "", "float(uniformValue)", GL_BOOL, 1, GL_FALSE},
1265*35238bceSAndroid Build Coastguard Worker {"bvec2", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC2, 1, GL_FALSE},
1266*35238bceSAndroid Build Coastguard Worker {"bvec3", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC3, 1, GL_FALSE},
1267*35238bceSAndroid Build Coastguard Worker {"bvec4", "", "", "", "float(uniformValue.x)", GL_BOOL_VEC4, 1, GL_FALSE},
1268*35238bceSAndroid Build Coastguard Worker {"mat2", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT2, 1, GL_FALSE},
1269*35238bceSAndroid Build Coastguard Worker {"mat3", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT3, 1, GL_FALSE},
1270*35238bceSAndroid Build Coastguard Worker {"mat4", "", "highp", "", "float(uniformValue[0][0])", GL_FLOAT_MAT4, 1, GL_FALSE},
1271*35238bceSAndroid Build Coastguard Worker {"sampler2D", "", "highp", "", "float(texture2D(uniformValue, vec2(0.0, 0.0)).r)", GL_SAMPLER_2D, 1,
1272*35238bceSAndroid Build Coastguard Worker GL_FALSE},
1273*35238bceSAndroid Build Coastguard Worker {"samplerCube", "", "highp", "", "float(textureCube(uniformValue, vec3(0.0, 0.0, 0.0)).r)", GL_SAMPLER_CUBE,
1274*35238bceSAndroid Build Coastguard Worker 1, GL_FALSE},
1275*35238bceSAndroid Build Coastguard Worker };
1276*35238bceSAndroid Build Coastguard Worker
1277*35238bceSAndroid Build Coastguard Worker static const char *vertSource = "void main (void)\n"
1278*35238bceSAndroid Build Coastguard Worker "{\n"
1279*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
1280*35238bceSAndroid Build Coastguard Worker "}\n\0";
1281*35238bceSAndroid Build Coastguard Worker
1282*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1283*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1284*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1285*35238bceSAndroid Build Coastguard Worker
1286*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1287*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1288*35238bceSAndroid Build Coastguard Worker
1289*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &vertSource, DE_NULL);
1290*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1291*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1292*35238bceSAndroid Build Coastguard Worker
1293*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(uniformTypes); ++ndx)
1294*35238bceSAndroid Build Coastguard Worker {
1295*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection(m_log, uniformTypes[ndx].declaration,
1296*35238bceSAndroid Build Coastguard Worker std::string("Verify type of ") + uniformTypes[ndx].declaration + " variable" +
1297*35238bceSAndroid Build Coastguard Worker uniformTypes[ndx].postDeclaration);
1298*35238bceSAndroid Build Coastguard Worker
1299*35238bceSAndroid Build Coastguard Worker // gen fragment shader
1300*35238bceSAndroid Build Coastguard Worker
1301*35238bceSAndroid Build Coastguard Worker std::ostringstream frag;
1302*35238bceSAndroid Build Coastguard Worker frag << uniformTypes[ndx].layout << "uniform " << uniformTypes[ndx].precision << " "
1303*35238bceSAndroid Build Coastguard Worker << uniformTypes[ndx].declaration << " uniformValue" << uniformTypes[ndx].postDeclaration << ";\n";
1304*35238bceSAndroid Build Coastguard Worker frag << "void main (void)\n";
1305*35238bceSAndroid Build Coastguard Worker frag << "{\n";
1306*35238bceSAndroid Build Coastguard Worker frag << " gl_FragColor = vec4(" << uniformTypes[ndx].getter << ");\n";
1307*35238bceSAndroid Build Coastguard Worker frag << "}\n";
1308*35238bceSAndroid Build Coastguard Worker
1309*35238bceSAndroid Build Coastguard Worker {
1310*35238bceSAndroid Build Coastguard Worker std::string fragmentSource = frag.str();
1311*35238bceSAndroid Build Coastguard Worker const char *fragmentSourceCStr = fragmentSource.c_str();
1312*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &fragmentSourceCStr, DE_NULL);
1313*35238bceSAndroid Build Coastguard Worker }
1314*35238bceSAndroid Build Coastguard Worker
1315*35238bceSAndroid Build Coastguard Worker // compile & link
1316*35238bceSAndroid Build Coastguard Worker
1317*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1318*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1319*35238bceSAndroid Build Coastguard Worker
1320*35238bceSAndroid Build Coastguard Worker // test
1321*35238bceSAndroid Build Coastguard Worker if (verifyProgramParam(m_testCtx, *this, program, GL_LINK_STATUS, GL_TRUE))
1322*35238bceSAndroid Build Coastguard Worker {
1323*35238bceSAndroid Build Coastguard Worker const GLint index = 0; // first and only active uniform
1324*35238bceSAndroid Build Coastguard Worker
1325*35238bceSAndroid Build Coastguard Worker char buffer[] = "not written to"; // not written to
1326*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1327*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1328*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1329*35238bceSAndroid Build Coastguard Worker glGetActiveUniform(program, index, 0, &written, &size, &type, buffer);
1330*35238bceSAndroid Build Coastguard Worker
1331*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, type, uniformTypes[ndx].type);
1332*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, size, uniformTypes[ndx].size);
1333*35238bceSAndroid Build Coastguard Worker }
1334*35238bceSAndroid Build Coastguard Worker }
1335*35238bceSAndroid Build Coastguard Worker
1336*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1337*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1338*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1339*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1340*35238bceSAndroid Build Coastguard Worker }
1341*35238bceSAndroid Build Coastguard Worker };
1342*35238bceSAndroid Build Coastguard Worker
1343*35238bceSAndroid Build Coastguard Worker class ActiveAttributesCase : public ApiCase
1344*35238bceSAndroid Build Coastguard Worker {
1345*35238bceSAndroid Build Coastguard Worker public:
ActiveAttributesCase(Context & context,const char * name,const char * description)1346*35238bceSAndroid Build Coastguard Worker ActiveAttributesCase(Context &context, const char *name, const char *description)
1347*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1348*35238bceSAndroid Build Coastguard Worker {
1349*35238bceSAndroid Build Coastguard Worker }
1350*35238bceSAndroid Build Coastguard Worker
test(void)1351*35238bceSAndroid Build Coastguard Worker void test(void)
1352*35238bceSAndroid Build Coastguard Worker {
1353*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1354*35238bceSAndroid Build Coastguard Worker
1355*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "attribute highp vec2 longInputAttributeName;\n"
1356*35238bceSAndroid Build Coastguard Worker "attribute highp vec2 shortName;\n"
1357*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1358*35238bceSAndroid Build Coastguard Worker "{\n"
1359*35238bceSAndroid Build Coastguard Worker " gl_Position = longInputAttributeName.yxxy + shortName.xyxy;\n"
1360*35238bceSAndroid Build Coastguard Worker "}\n\0";
1361*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "void main (void)\n"
1362*35238bceSAndroid Build Coastguard Worker "{\n"
1363*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1364*35238bceSAndroid Build Coastguard Worker "}\n\0";
1365*35238bceSAndroid Build Coastguard Worker
1366*35238bceSAndroid Build Coastguard Worker GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
1367*35238bceSAndroid Build Coastguard Worker GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
1368*35238bceSAndroid Build Coastguard Worker
1369*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
1370*35238bceSAndroid Build Coastguard Worker glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
1371*35238bceSAndroid Build Coastguard Worker
1372*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderVert);
1373*35238bceSAndroid Build Coastguard Worker glCompileShader(shaderFrag);
1374*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1375*35238bceSAndroid Build Coastguard Worker
1376*35238bceSAndroid Build Coastguard Worker GLuint program = glCreateProgram();
1377*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderVert);
1378*35238bceSAndroid Build Coastguard Worker glAttachShader(program, shaderFrag);
1379*35238bceSAndroid Build Coastguard Worker glLinkProgram(program);
1380*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1381*35238bceSAndroid Build Coastguard Worker
1382*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTES, 2);
1383*35238bceSAndroid Build Coastguard Worker verifyProgramParam(m_testCtx, *this, program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
1384*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longInputAttributeName").length() + 1); // does include null-terminator
1385*35238bceSAndroid Build Coastguard Worker
1386*35238bceSAndroid Build Coastguard Worker // check names
1387*35238bceSAndroid Build Coastguard Worker for (int attributeNdx = 0; attributeNdx < 2; ++attributeNdx)
1388*35238bceSAndroid Build Coastguard Worker {
1389*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1390*35238bceSAndroid Build Coastguard Worker
1391*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1392*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1393*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1394*35238bceSAndroid Build Coastguard Worker glGetActiveAttrib(program, attributeNdx, DE_LENGTH_OF_ARRAY(buffer), &written, &size, &type, buffer);
1395*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1396*35238bceSAndroid Build Coastguard Worker
1397*35238bceSAndroid Build Coastguard Worker if (deStringBeginsWith(buffer, "longInputAttributeName"))
1398*35238bceSAndroid Build Coastguard Worker {
1399*35238bceSAndroid Build Coastguard Worker checkIntEquals(
1400*35238bceSAndroid Build Coastguard Worker m_testCtx, written,
1401*35238bceSAndroid Build Coastguard Worker (GLint)std::string("longInputAttributeName").length()); // does NOT include null-terminator
1402*35238bceSAndroid Build Coastguard Worker }
1403*35238bceSAndroid Build Coastguard Worker else if (deStringBeginsWith(buffer, "shortName"))
1404*35238bceSAndroid Build Coastguard Worker {
1405*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written,
1406*35238bceSAndroid Build Coastguard Worker (GLint)std::string("shortName").length()); // does NOT include null-terminator
1407*35238bceSAndroid Build Coastguard Worker }
1408*35238bceSAndroid Build Coastguard Worker else
1409*35238bceSAndroid Build Coastguard Worker {
1410*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Got unexpected attribute name."
1411*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1412*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1413*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got unexpected name");
1414*35238bceSAndroid Build Coastguard Worker }
1415*35238bceSAndroid Build Coastguard Worker }
1416*35238bceSAndroid Build Coastguard Worker
1417*35238bceSAndroid Build Coastguard Worker // and with too short buffer
1418*35238bceSAndroid Build Coastguard Worker {
1419*35238bceSAndroid Build Coastguard Worker char buffer[2048] = {'x'};
1420*35238bceSAndroid Build Coastguard Worker
1421*35238bceSAndroid Build Coastguard Worker GLint written = 0;
1422*35238bceSAndroid Build Coastguard Worker GLint size = 0;
1423*35238bceSAndroid Build Coastguard Worker GLenum type = 0;
1424*35238bceSAndroid Build Coastguard Worker
1425*35238bceSAndroid Build Coastguard Worker glGetActiveAttrib(program, 0, 1, &written, &size, &type, buffer);
1426*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1427*35238bceSAndroid Build Coastguard Worker checkIntEquals(m_testCtx, written, 0);
1428*35238bceSAndroid Build Coastguard Worker }
1429*35238bceSAndroid Build Coastguard Worker
1430*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderVert);
1431*35238bceSAndroid Build Coastguard Worker glDeleteShader(shaderFrag);
1432*35238bceSAndroid Build Coastguard Worker glDeleteProgram(program);
1433*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1434*35238bceSAndroid Build Coastguard Worker }
1435*35238bceSAndroid Build Coastguard Worker };
1436*35238bceSAndroid Build Coastguard Worker
1437*35238bceSAndroid Build Coastguard Worker struct PointerData
1438*35238bceSAndroid Build Coastguard Worker {
1439*35238bceSAndroid Build Coastguard Worker GLint size;
1440*35238bceSAndroid Build Coastguard Worker GLenum type;
1441*35238bceSAndroid Build Coastguard Worker GLint stride;
1442*35238bceSAndroid Build Coastguard Worker GLboolean normalized;
1443*35238bceSAndroid Build Coastguard Worker void *pointer;
1444*35238bceSAndroid Build Coastguard Worker };
1445*35238bceSAndroid Build Coastguard Worker
1446*35238bceSAndroid Build Coastguard Worker class VertexAttributeSizeCase : public ApiCase
1447*35238bceSAndroid Build Coastguard Worker {
1448*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeSizeCase(Context & context,const char * name,const char * description)1449*35238bceSAndroid Build Coastguard Worker VertexAttributeSizeCase(Context &context, const char *name, const char *description)
1450*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1451*35238bceSAndroid Build Coastguard Worker {
1452*35238bceSAndroid Build Coastguard Worker }
1453*35238bceSAndroid Build Coastguard Worker
test(void)1454*35238bceSAndroid Build Coastguard Worker void test(void)
1455*35238bceSAndroid Build Coastguard Worker {
1456*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
1457*35238bceSAndroid Build Coastguard Worker
1458*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
1459*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
1460*35238bceSAndroid Build Coastguard Worker // size test
1461*35238bceSAndroid Build Coastguard Worker {4, GL_FLOAT, 0, GL_FALSE, vertexData}, {3, GL_FLOAT, 0, GL_FALSE, vertexData},
1462*35238bceSAndroid Build Coastguard Worker {2, GL_FLOAT, 0, GL_FALSE, vertexData}, {1, GL_FLOAT, 0, GL_FALSE, vertexData},
1463*35238bceSAndroid Build Coastguard Worker {4, GL_SHORT, 0, GL_FALSE, vertexData}, {3, GL_SHORT, 0, GL_FALSE, vertexData},
1464*35238bceSAndroid Build Coastguard Worker {2, GL_SHORT, 0, GL_FALSE, vertexData}, {1, GL_SHORT, 0, GL_FALSE, vertexData},
1465*35238bceSAndroid Build Coastguard Worker };
1466*35238bceSAndroid Build Coastguard Worker
1467*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
1468*35238bceSAndroid Build Coastguard Worker {
1469*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
1470*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
1471*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1472*35238bceSAndroid Build Coastguard Worker
1473*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_SIZE, pointers[ndx].size);
1474*35238bceSAndroid Build Coastguard Worker }
1475*35238bceSAndroid Build Coastguard Worker }
1476*35238bceSAndroid Build Coastguard Worker };
1477*35238bceSAndroid Build Coastguard Worker
1478*35238bceSAndroid Build Coastguard Worker class VertexAttributeTypeCase : public ApiCase
1479*35238bceSAndroid Build Coastguard Worker {
1480*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeTypeCase(Context & context,const char * name,const char * description)1481*35238bceSAndroid Build Coastguard Worker VertexAttributeTypeCase(Context &context, const char *name, const char *description)
1482*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1483*35238bceSAndroid Build Coastguard Worker {
1484*35238bceSAndroid Build Coastguard Worker }
1485*35238bceSAndroid Build Coastguard Worker
test(void)1486*35238bceSAndroid Build Coastguard Worker void test(void)
1487*35238bceSAndroid Build Coastguard Worker {
1488*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
1489*35238bceSAndroid Build Coastguard Worker
1490*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
1491*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData}, {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData},
1492*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 0, GL_FALSE, vertexData}, {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
1493*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, GL_FALSE, vertexData}, {1, GL_FLOAT, 0, GL_FALSE, vertexData},
1494*35238bceSAndroid Build Coastguard Worker };
1495*35238bceSAndroid Build Coastguard Worker
1496*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
1497*35238bceSAndroid Build Coastguard Worker {
1498*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
1499*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
1500*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1501*35238bceSAndroid Build Coastguard Worker
1502*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx].type);
1503*35238bceSAndroid Build Coastguard Worker }
1504*35238bceSAndroid Build Coastguard Worker }
1505*35238bceSAndroid Build Coastguard Worker };
1506*35238bceSAndroid Build Coastguard Worker
1507*35238bceSAndroid Build Coastguard Worker class VertexAttributeStrideCase : public ApiCase
1508*35238bceSAndroid Build Coastguard Worker {
1509*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeStrideCase(Context & context,const char * name,const char * description)1510*35238bceSAndroid Build Coastguard Worker VertexAttributeStrideCase(Context &context, const char *name, const char *description)
1511*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1512*35238bceSAndroid Build Coastguard Worker {
1513*35238bceSAndroid Build Coastguard Worker }
1514*35238bceSAndroid Build Coastguard Worker
test(void)1515*35238bceSAndroid Build Coastguard Worker void test(void)
1516*35238bceSAndroid Build Coastguard Worker {
1517*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
1518*35238bceSAndroid Build Coastguard Worker
1519*35238bceSAndroid Build Coastguard Worker struct StridePointerData
1520*35238bceSAndroid Build Coastguard Worker {
1521*35238bceSAndroid Build Coastguard Worker GLint size;
1522*35238bceSAndroid Build Coastguard Worker GLenum type;
1523*35238bceSAndroid Build Coastguard Worker GLint stride;
1524*35238bceSAndroid Build Coastguard Worker void *pointer;
1525*35238bceSAndroid Build Coastguard Worker };
1526*35238bceSAndroid Build Coastguard Worker
1527*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
1528*35238bceSAndroid Build Coastguard Worker {
1529*35238bceSAndroid Build Coastguard Worker const StridePointerData pointers[] = {
1530*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, vertexData}, {1, GL_FLOAT, 1, vertexData},
1531*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 4, vertexData}, {1, GL_SHORT, 0, vertexData},
1532*35238bceSAndroid Build Coastguard Worker {1, GL_SHORT, 1, vertexData}, {1, GL_SHORT, 4, vertexData},
1533*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, vertexData}, {1, GL_FIXED, 1, vertexData},
1534*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 4, vertexData}, {1, GL_BYTE, 0, vertexData},
1535*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_SHORT, 1, vertexData}, {1, GL_UNSIGNED_SHORT, 4, vertexData},
1536*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_BYTE, 0, vertexData}, {4, GL_UNSIGNED_BYTE, 1, vertexData},
1537*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_BYTE, 4, vertexData},
1538*35238bceSAndroid Build Coastguard Worker };
1539*35238bceSAndroid Build Coastguard Worker
1540*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
1541*35238bceSAndroid Build Coastguard Worker {
1542*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, GL_FALSE, pointers[ndx].stride,
1543*35238bceSAndroid Build Coastguard Worker pointers[ndx].pointer);
1544*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1545*35238bceSAndroid Build Coastguard Worker
1546*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx].stride);
1547*35238bceSAndroid Build Coastguard Worker }
1548*35238bceSAndroid Build Coastguard Worker }
1549*35238bceSAndroid Build Coastguard Worker }
1550*35238bceSAndroid Build Coastguard Worker };
1551*35238bceSAndroid Build Coastguard Worker
1552*35238bceSAndroid Build Coastguard Worker class VertexAttributeNormalizedCase : public ApiCase
1553*35238bceSAndroid Build Coastguard Worker {
1554*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeNormalizedCase(Context & context,const char * name,const char * description)1555*35238bceSAndroid Build Coastguard Worker VertexAttributeNormalizedCase(Context &context, const char *name, const char *description)
1556*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1557*35238bceSAndroid Build Coastguard Worker {
1558*35238bceSAndroid Build Coastguard Worker }
1559*35238bceSAndroid Build Coastguard Worker
test(void)1560*35238bceSAndroid Build Coastguard Worker void test(void)
1561*35238bceSAndroid Build Coastguard Worker {
1562*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
1563*35238bceSAndroid Build Coastguard Worker
1564*35238bceSAndroid Build Coastguard Worker // test VertexAttribPointer
1565*35238bceSAndroid Build Coastguard Worker {
1566*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
1567*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, vertexData}, {1, GL_SHORT, 0, GL_FALSE, vertexData},
1568*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_FALSE, vertexData}, {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, vertexData},
1569*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_TRUE, vertexData}, {1, GL_SHORT, 0, GL_TRUE, vertexData},
1570*35238bceSAndroid Build Coastguard Worker {1, GL_UNSIGNED_BYTE, 0, GL_TRUE, vertexData}, {1, GL_UNSIGNED_SHORT, 0, GL_TRUE, vertexData},
1571*35238bceSAndroid Build Coastguard Worker };
1572*35238bceSAndroid Build Coastguard Worker
1573*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
1574*35238bceSAndroid Build Coastguard Worker {
1575*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
1576*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
1577*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1578*35238bceSAndroid Build Coastguard Worker
1579*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, pointers[ndx].normalized);
1580*35238bceSAndroid Build Coastguard Worker }
1581*35238bceSAndroid Build Coastguard Worker }
1582*35238bceSAndroid Build Coastguard Worker }
1583*35238bceSAndroid Build Coastguard Worker };
1584*35238bceSAndroid Build Coastguard Worker
1585*35238bceSAndroid Build Coastguard Worker class VertexAttributeEnabledCase : public ApiCase
1586*35238bceSAndroid Build Coastguard Worker {
1587*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeEnabledCase(Context & context,const char * name,const char * description)1588*35238bceSAndroid Build Coastguard Worker VertexAttributeEnabledCase(Context &context, const char *name, const char *description)
1589*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1590*35238bceSAndroid Build Coastguard Worker {
1591*35238bceSAndroid Build Coastguard Worker }
1592*35238bceSAndroid Build Coastguard Worker
test(void)1593*35238bceSAndroid Build Coastguard Worker void test(void)
1594*35238bceSAndroid Build Coastguard Worker {
1595*35238bceSAndroid Build Coastguard Worker // VERTEX_ATTRIB_ARRAY_ENABLED
1596*35238bceSAndroid Build Coastguard Worker
1597*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
1598*35238bceSAndroid Build Coastguard Worker glEnableVertexAttribArray(0);
1599*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE);
1600*35238bceSAndroid Build Coastguard Worker glDisableVertexAttribArray(0);
1601*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE);
1602*35238bceSAndroid Build Coastguard Worker }
1603*35238bceSAndroid Build Coastguard Worker };
1604*35238bceSAndroid Build Coastguard Worker
1605*35238bceSAndroid Build Coastguard Worker class VertexAttributeBufferBindingCase : public ApiCase
1606*35238bceSAndroid Build Coastguard Worker {
1607*35238bceSAndroid Build Coastguard Worker public:
VertexAttributeBufferBindingCase(Context & context,const char * name,const char * description)1608*35238bceSAndroid Build Coastguard Worker VertexAttributeBufferBindingCase(Context &context, const char *name, const char *description)
1609*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1610*35238bceSAndroid Build Coastguard Worker {
1611*35238bceSAndroid Build Coastguard Worker }
1612*35238bceSAndroid Build Coastguard Worker
test(void)1613*35238bceSAndroid Build Coastguard Worker void test(void)
1614*35238bceSAndroid Build Coastguard Worker {
1615*35238bceSAndroid Build Coastguard Worker // initial
1616*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, 0);
1617*35238bceSAndroid Build Coastguard Worker
1618*35238bceSAndroid Build Coastguard Worker GLuint bufferID;
1619*35238bceSAndroid Build Coastguard Worker glGenBuffers(1, &bufferID);
1620*35238bceSAndroid Build Coastguard Worker glBindBuffer(GL_ARRAY_BUFFER, bufferID);
1621*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1622*35238bceSAndroid Build Coastguard Worker
1623*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
1624*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1625*35238bceSAndroid Build Coastguard Worker
1626*35238bceSAndroid Build Coastguard Worker verifyVertexAttrib(m_testCtx, *this, 0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, bufferID);
1627*35238bceSAndroid Build Coastguard Worker
1628*35238bceSAndroid Build Coastguard Worker glDeleteBuffers(1, &bufferID);
1629*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1630*35238bceSAndroid Build Coastguard Worker }
1631*35238bceSAndroid Build Coastguard Worker };
1632*35238bceSAndroid Build Coastguard Worker
1633*35238bceSAndroid Build Coastguard Worker class VertexAttributePointerCase : public ApiCase
1634*35238bceSAndroid Build Coastguard Worker {
1635*35238bceSAndroid Build Coastguard Worker public:
VertexAttributePointerCase(Context & context,const char * name,const char * description)1636*35238bceSAndroid Build Coastguard Worker VertexAttributePointerCase(Context &context, const char *name, const char *description)
1637*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1638*35238bceSAndroid Build Coastguard Worker {
1639*35238bceSAndroid Build Coastguard Worker }
1640*35238bceSAndroid Build Coastguard Worker
test(void)1641*35238bceSAndroid Build Coastguard Worker void test(void)
1642*35238bceSAndroid Build Coastguard Worker {
1643*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> initialState;
1644*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &initialState);
1645*35238bceSAndroid Build Coastguard Worker initialState.verifyValidity(m_testCtx);
1646*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, initialState, 0);
1647*35238bceSAndroid Build Coastguard Worker
1648*35238bceSAndroid Build Coastguard Worker GLfloat vertexData[4] = {0.0f}; // never accessed
1649*35238bceSAndroid Build Coastguard Worker const PointerData pointers[] = {
1650*35238bceSAndroid Build Coastguard Worker {1, GL_BYTE, 0, GL_FALSE, &vertexData[2]}, {1, GL_SHORT, 0, GL_FALSE, &vertexData[1]},
1651*35238bceSAndroid Build Coastguard Worker {1, GL_FIXED, 0, GL_FALSE, &vertexData[2]}, {1, GL_FIXED, 0, GL_FALSE, &vertexData[1]},
1652*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, GL_FALSE, &vertexData[0]}, {1, GL_FLOAT, 0, GL_FALSE, &vertexData[3]},
1653*35238bceSAndroid Build Coastguard Worker {1, GL_FLOAT, 0, GL_FALSE, &vertexData[2]}, {1, GL_UNSIGNED_SHORT, 0, GL_FALSE, &vertexData[0]},
1654*35238bceSAndroid Build Coastguard Worker {4, GL_UNSIGNED_SHORT, 0, GL_FALSE, &vertexData[1]}, {4, GL_UNSIGNED_SHORT, 0, GL_FALSE, &vertexData[2]},
1655*35238bceSAndroid Build Coastguard Worker };
1656*35238bceSAndroid Build Coastguard Worker
1657*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pointers); ++ndx)
1658*35238bceSAndroid Build Coastguard Worker {
1659*35238bceSAndroid Build Coastguard Worker glVertexAttribPointer(0, pointers[ndx].size, pointers[ndx].type, pointers[ndx].normalized,
1660*35238bceSAndroid Build Coastguard Worker pointers[ndx].stride, pointers[ndx].pointer);
1661*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1662*35238bceSAndroid Build Coastguard Worker
1663*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLvoid *> state;
1664*35238bceSAndroid Build Coastguard Worker glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
1665*35238bceSAndroid Build Coastguard Worker state.verifyValidity(m_testCtx);
1666*35238bceSAndroid Build Coastguard Worker checkPointerEquals(m_testCtx, state, pointers[ndx].pointer);
1667*35238bceSAndroid Build Coastguard Worker }
1668*35238bceSAndroid Build Coastguard Worker }
1669*35238bceSAndroid Build Coastguard Worker };
1670*35238bceSAndroid Build Coastguard Worker
1671*35238bceSAndroid Build Coastguard Worker class UniformValueFloatCase : public ApiCase
1672*35238bceSAndroid Build Coastguard Worker {
1673*35238bceSAndroid Build Coastguard Worker public:
UniformValueFloatCase(Context & context,const char * name,const char * description)1674*35238bceSAndroid Build Coastguard Worker UniformValueFloatCase(Context &context, const char *name, const char *description)
1675*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1676*35238bceSAndroid Build Coastguard Worker {
1677*35238bceSAndroid Build Coastguard Worker }
1678*35238bceSAndroid Build Coastguard Worker
test(void)1679*35238bceSAndroid Build Coastguard Worker void test(void)
1680*35238bceSAndroid Build Coastguard Worker {
1681*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
1682*35238bceSAndroid Build Coastguard Worker "uniform highp float floatUniform;\n"
1683*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 float2Uniform;\n"
1684*35238bceSAndroid Build Coastguard Worker "uniform highp vec3 float3Uniform;\n"
1685*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 float4Uniform;\n"
1686*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1687*35238bceSAndroid Build Coastguard Worker "{\n"
1688*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(floatUniform + float2Uniform.x + float3Uniform.x + float4Uniform.x);\n"
1689*35238bceSAndroid Build Coastguard Worker "}\n";
1690*35238bceSAndroid Build Coastguard Worker static const char *testFragSource =
1691*35238bceSAndroid Build Coastguard Worker
1692*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1693*35238bceSAndroid Build Coastguard Worker "{\n"
1694*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1695*35238bceSAndroid Build Coastguard Worker "}\n";
1696*35238bceSAndroid Build Coastguard Worker
1697*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
1698*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
1699*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
1700*35238bceSAndroid Build Coastguard Worker {
1701*35238bceSAndroid Build Coastguard Worker m_log << program;
1702*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
1703*35238bceSAndroid Build Coastguard Worker return;
1704*35238bceSAndroid Build Coastguard Worker }
1705*35238bceSAndroid Build Coastguard Worker
1706*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
1707*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1708*35238bceSAndroid Build Coastguard Worker
1709*35238bceSAndroid Build Coastguard Worker GLint location;
1710*35238bceSAndroid Build Coastguard Worker
1711*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "floatUniform");
1712*35238bceSAndroid Build Coastguard Worker glUniform1f(location, 1.0f);
1713*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(), location, 1.0f);
1714*35238bceSAndroid Build Coastguard Worker
1715*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "float2Uniform");
1716*35238bceSAndroid Build Coastguard Worker glUniform2f(location, 1.0f, 2.0f);
1717*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f);
1718*35238bceSAndroid Build Coastguard Worker
1719*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "float3Uniform");
1720*35238bceSAndroid Build Coastguard Worker glUniform3f(location, 1.0f, 2.0f, 3.0f);
1721*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f, 3.0f);
1722*35238bceSAndroid Build Coastguard Worker
1723*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "float4Uniform");
1724*35238bceSAndroid Build Coastguard Worker glUniform4f(location, 1.0f, 2.0f, 3.0f, 4.0f);
1725*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(), location, 1.0f, 2.0f, 3.0f, 4.0f);
1726*35238bceSAndroid Build Coastguard Worker
1727*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
1728*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1729*35238bceSAndroid Build Coastguard Worker }
1730*35238bceSAndroid Build Coastguard Worker };
1731*35238bceSAndroid Build Coastguard Worker
1732*35238bceSAndroid Build Coastguard Worker class UniformValueIntCase : public ApiCase
1733*35238bceSAndroid Build Coastguard Worker {
1734*35238bceSAndroid Build Coastguard Worker public:
UniformValueIntCase(Context & context,const char * name,const char * description)1735*35238bceSAndroid Build Coastguard Worker UniformValueIntCase(Context &context, const char *name, const char *description)
1736*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1737*35238bceSAndroid Build Coastguard Worker {
1738*35238bceSAndroid Build Coastguard Worker }
1739*35238bceSAndroid Build Coastguard Worker
test(void)1740*35238bceSAndroid Build Coastguard Worker void test(void)
1741*35238bceSAndroid Build Coastguard Worker {
1742*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
1743*35238bceSAndroid Build Coastguard Worker "uniform highp int intUniform;\n"
1744*35238bceSAndroid Build Coastguard Worker "uniform highp ivec2 int2Uniform;\n"
1745*35238bceSAndroid Build Coastguard Worker "uniform highp ivec3 int3Uniform;\n"
1746*35238bceSAndroid Build Coastguard Worker "uniform highp ivec4 int4Uniform;\n"
1747*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1748*35238bceSAndroid Build Coastguard Worker "{\n"
1749*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(float(intUniform + int2Uniform.x + int3Uniform.x + int4Uniform.x));\n"
1750*35238bceSAndroid Build Coastguard Worker "}\n";
1751*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "void main (void)\n"
1752*35238bceSAndroid Build Coastguard Worker "{\n"
1753*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1754*35238bceSAndroid Build Coastguard Worker "}\n";
1755*35238bceSAndroid Build Coastguard Worker
1756*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
1757*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
1758*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
1759*35238bceSAndroid Build Coastguard Worker {
1760*35238bceSAndroid Build Coastguard Worker m_log << program;
1761*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
1762*35238bceSAndroid Build Coastguard Worker return;
1763*35238bceSAndroid Build Coastguard Worker }
1764*35238bceSAndroid Build Coastguard Worker
1765*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
1766*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1767*35238bceSAndroid Build Coastguard Worker
1768*35238bceSAndroid Build Coastguard Worker GLint location;
1769*35238bceSAndroid Build Coastguard Worker
1770*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "intUniform");
1771*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
1772*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
1773*35238bceSAndroid Build Coastguard Worker
1774*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "int2Uniform");
1775*35238bceSAndroid Build Coastguard Worker glUniform2i(location, 1, 2);
1776*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 2);
1777*35238bceSAndroid Build Coastguard Worker
1778*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "int3Uniform");
1779*35238bceSAndroid Build Coastguard Worker glUniform3i(location, 1, 2, 3);
1780*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 1, 2, 3);
1781*35238bceSAndroid Build Coastguard Worker
1782*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "int4Uniform");
1783*35238bceSAndroid Build Coastguard Worker glUniform4i(location, 1, 2, 3, 4);
1784*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 2, 3, 4);
1785*35238bceSAndroid Build Coastguard Worker
1786*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
1787*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1788*35238bceSAndroid Build Coastguard Worker }
1789*35238bceSAndroid Build Coastguard Worker };
1790*35238bceSAndroid Build Coastguard Worker
1791*35238bceSAndroid Build Coastguard Worker class UniformValueBooleanCase : public ApiCase
1792*35238bceSAndroid Build Coastguard Worker {
1793*35238bceSAndroid Build Coastguard Worker public:
UniformValueBooleanCase(Context & context,const char * name,const char * description)1794*35238bceSAndroid Build Coastguard Worker UniformValueBooleanCase(Context &context, const char *name, const char *description)
1795*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1796*35238bceSAndroid Build Coastguard Worker {
1797*35238bceSAndroid Build Coastguard Worker }
1798*35238bceSAndroid Build Coastguard Worker
test(void)1799*35238bceSAndroid Build Coastguard Worker void test(void)
1800*35238bceSAndroid Build Coastguard Worker {
1801*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "uniform bool boolUniform;\n"
1802*35238bceSAndroid Build Coastguard Worker "uniform bvec2 bool2Uniform;\n"
1803*35238bceSAndroid Build Coastguard Worker "uniform bvec3 bool3Uniform;\n"
1804*35238bceSAndroid Build Coastguard Worker "uniform bvec4 bool4Uniform;\n"
1805*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1806*35238bceSAndroid Build Coastguard Worker "{\n"
1807*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(float(boolUniform) + float(bool2Uniform.x) + "
1808*35238bceSAndroid Build Coastguard Worker "float(bool3Uniform.x) + float(bool4Uniform.x));\n"
1809*35238bceSAndroid Build Coastguard Worker "}\n";
1810*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "void main (void)\n"
1811*35238bceSAndroid Build Coastguard Worker "{\n"
1812*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1813*35238bceSAndroid Build Coastguard Worker "}\n";
1814*35238bceSAndroid Build Coastguard Worker
1815*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
1816*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
1817*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
1818*35238bceSAndroid Build Coastguard Worker {
1819*35238bceSAndroid Build Coastguard Worker m_log << program;
1820*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
1821*35238bceSAndroid Build Coastguard Worker return;
1822*35238bceSAndroid Build Coastguard Worker }
1823*35238bceSAndroid Build Coastguard Worker
1824*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
1825*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1826*35238bceSAndroid Build Coastguard Worker
1827*35238bceSAndroid Build Coastguard Worker GLint location;
1828*35238bceSAndroid Build Coastguard Worker
1829*35238bceSAndroid Build Coastguard Worker // int conversion
1830*35238bceSAndroid Build Coastguard Worker
1831*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "boolUniform");
1832*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
1833*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
1834*35238bceSAndroid Build Coastguard Worker
1835*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool2Uniform");
1836*35238bceSAndroid Build Coastguard Worker glUniform2i(location, 1, 2);
1837*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 1);
1838*35238bceSAndroid Build Coastguard Worker
1839*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool3Uniform");
1840*35238bceSAndroid Build Coastguard Worker glUniform3i(location, 0, 1, 2);
1841*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 0, 1, 1);
1842*35238bceSAndroid Build Coastguard Worker
1843*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool4Uniform");
1844*35238bceSAndroid Build Coastguard Worker glUniform4i(location, 1, 0, 1, -1);
1845*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 0, 1, 1);
1846*35238bceSAndroid Build Coastguard Worker
1847*35238bceSAndroid Build Coastguard Worker // float conversion
1848*35238bceSAndroid Build Coastguard Worker
1849*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "boolUniform");
1850*35238bceSAndroid Build Coastguard Worker glUniform1f(location, 1.0f);
1851*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
1852*35238bceSAndroid Build Coastguard Worker
1853*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool2Uniform");
1854*35238bceSAndroid Build Coastguard Worker glUniform2f(location, 1.0f, 0.1f);
1855*35238bceSAndroid Build Coastguard Worker verifyUniformValue2i(m_testCtx, *this, program.getProgram(), location, 1, 1);
1856*35238bceSAndroid Build Coastguard Worker
1857*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool3Uniform");
1858*35238bceSAndroid Build Coastguard Worker glUniform3f(location, 0.0f, 0.1f, -0.1f);
1859*35238bceSAndroid Build Coastguard Worker verifyUniformValue3i(m_testCtx, *this, program.getProgram(), location, 0, 1, 1);
1860*35238bceSAndroid Build Coastguard Worker
1861*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "bool4Uniform");
1862*35238bceSAndroid Build Coastguard Worker glUniform4f(location, 1.0f, 0.0f, 0.1f, -0.9f);
1863*35238bceSAndroid Build Coastguard Worker verifyUniformValue4i(m_testCtx, *this, program.getProgram(), location, 1, 0, 1, 1);
1864*35238bceSAndroid Build Coastguard Worker
1865*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
1866*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1867*35238bceSAndroid Build Coastguard Worker }
1868*35238bceSAndroid Build Coastguard Worker };
1869*35238bceSAndroid Build Coastguard Worker
1870*35238bceSAndroid Build Coastguard Worker class UniformValueSamplerCase : public ApiCase
1871*35238bceSAndroid Build Coastguard Worker {
1872*35238bceSAndroid Build Coastguard Worker public:
UniformValueSamplerCase(Context & context,const char * name,const char * description)1873*35238bceSAndroid Build Coastguard Worker UniformValueSamplerCase(Context &context, const char *name, const char *description)
1874*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1875*35238bceSAndroid Build Coastguard Worker {
1876*35238bceSAndroid Build Coastguard Worker }
1877*35238bceSAndroid Build Coastguard Worker
test(void)1878*35238bceSAndroid Build Coastguard Worker void test(void)
1879*35238bceSAndroid Build Coastguard Worker {
1880*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "void main (void)\n"
1881*35238bceSAndroid Build Coastguard Worker "{\n"
1882*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(0.0);\n"
1883*35238bceSAndroid Build Coastguard Worker "}\n";
1884*35238bceSAndroid Build Coastguard Worker static const char *testFragSource = "uniform highp sampler2D uniformSampler;\n"
1885*35238bceSAndroid Build Coastguard Worker
1886*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1887*35238bceSAndroid Build Coastguard Worker "{\n"
1888*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(texture2D(uniformSampler, vec2(0.0, 0.0)).x);\n"
1889*35238bceSAndroid Build Coastguard Worker "}\n";
1890*35238bceSAndroid Build Coastguard Worker
1891*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
1892*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
1893*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
1894*35238bceSAndroid Build Coastguard Worker {
1895*35238bceSAndroid Build Coastguard Worker m_log << program;
1896*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
1897*35238bceSAndroid Build Coastguard Worker return;
1898*35238bceSAndroid Build Coastguard Worker }
1899*35238bceSAndroid Build Coastguard Worker
1900*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
1901*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1902*35238bceSAndroid Build Coastguard Worker
1903*35238bceSAndroid Build Coastguard Worker GLint location;
1904*35238bceSAndroid Build Coastguard Worker
1905*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "uniformSampler");
1906*35238bceSAndroid Build Coastguard Worker glUniform1i(location, 1);
1907*35238bceSAndroid Build Coastguard Worker verifyUniformValue1i(m_testCtx, *this, program.getProgram(), location, 1);
1908*35238bceSAndroid Build Coastguard Worker
1909*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
1910*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1911*35238bceSAndroid Build Coastguard Worker }
1912*35238bceSAndroid Build Coastguard Worker };
1913*35238bceSAndroid Build Coastguard Worker
1914*35238bceSAndroid Build Coastguard Worker class UniformValueArrayCase : public ApiCase
1915*35238bceSAndroid Build Coastguard Worker {
1916*35238bceSAndroid Build Coastguard Worker public:
UniformValueArrayCase(Context & context,const char * name,const char * description)1917*35238bceSAndroid Build Coastguard Worker UniformValueArrayCase(Context &context, const char *name, const char *description)
1918*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
1919*35238bceSAndroid Build Coastguard Worker {
1920*35238bceSAndroid Build Coastguard Worker }
1921*35238bceSAndroid Build Coastguard Worker
test(void)1922*35238bceSAndroid Build Coastguard Worker void test(void)
1923*35238bceSAndroid Build Coastguard Worker {
1924*35238bceSAndroid Build Coastguard Worker static const char *testVertSource = "uniform highp float arrayUniform[5];"
1925*35238bceSAndroid Build Coastguard Worker "uniform highp vec2 array2Uniform[5];"
1926*35238bceSAndroid Build Coastguard Worker "uniform highp vec3 array3Uniform[5];"
1927*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 array4Uniform[5];"
1928*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1929*35238bceSAndroid Build Coastguard Worker "{\n"
1930*35238bceSAndroid Build Coastguard Worker " gl_Position = \n"
1931*35238bceSAndroid Build Coastguard Worker " + vec4(arrayUniform[0] + arrayUniform[1] + "
1932*35238bceSAndroid Build Coastguard Worker "arrayUniform[2] + arrayUniform[3] + arrayUniform[4])\n"
1933*35238bceSAndroid Build Coastguard Worker " + vec4(array2Uniform[0].x + array2Uniform[1].x + "
1934*35238bceSAndroid Build Coastguard Worker "array2Uniform[2].x + array2Uniform[3].x + array2Uniform[4].x)\n"
1935*35238bceSAndroid Build Coastguard Worker " + vec4(array3Uniform[0].x + array3Uniform[1].x + "
1936*35238bceSAndroid Build Coastguard Worker "array3Uniform[2].x + array3Uniform[3].x + array3Uniform[4].x)\n"
1937*35238bceSAndroid Build Coastguard Worker " + vec4(array4Uniform[0].x + array4Uniform[1].x + "
1938*35238bceSAndroid Build Coastguard Worker "array4Uniform[2].x + array4Uniform[3].x + array4Uniform[4].x);\n"
1939*35238bceSAndroid Build Coastguard Worker "}\n";
1940*35238bceSAndroid Build Coastguard Worker static const char *testFragSource =
1941*35238bceSAndroid Build Coastguard Worker
1942*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
1943*35238bceSAndroid Build Coastguard Worker "{\n"
1944*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
1945*35238bceSAndroid Build Coastguard Worker "}\n";
1946*35238bceSAndroid Build Coastguard Worker
1947*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
1948*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
1949*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
1950*35238bceSAndroid Build Coastguard Worker {
1951*35238bceSAndroid Build Coastguard Worker m_log << program;
1952*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
1953*35238bceSAndroid Build Coastguard Worker return;
1954*35238bceSAndroid Build Coastguard Worker }
1955*35238bceSAndroid Build Coastguard Worker
1956*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
1957*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1958*35238bceSAndroid Build Coastguard Worker
1959*35238bceSAndroid Build Coastguard Worker GLint location;
1960*35238bceSAndroid Build Coastguard Worker
1961*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,
1962*35238bceSAndroid Build Coastguard Worker 98.0f, 19.0f, 41.0f, 65.0f, 4.0f, 12.2f, 95.0f, 77.0f, 32.0f, 48.0f};
1963*35238bceSAndroid Build Coastguard Worker
1964*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "arrayUniform");
1965*35238bceSAndroid Build Coastguard Worker glUniform1fv(location, 5, uniformValue);
1966*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1967*35238bceSAndroid Build Coastguard Worker
1968*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(),
1969*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "arrayUniform[0]"), uniformValue[0]);
1970*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(),
1971*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "arrayUniform[1]"), uniformValue[1]);
1972*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(),
1973*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "arrayUniform[2]"), uniformValue[2]);
1974*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(),
1975*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "arrayUniform[3]"), uniformValue[3]);
1976*35238bceSAndroid Build Coastguard Worker verifyUniformValue1f(m_testCtx, *this, program.getProgram(),
1977*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "arrayUniform[4]"), uniformValue[4]);
1978*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1979*35238bceSAndroid Build Coastguard Worker
1980*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "array2Uniform");
1981*35238bceSAndroid Build Coastguard Worker glUniform2fv(location, 5, uniformValue);
1982*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
1983*35238bceSAndroid Build Coastguard Worker
1984*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(),
1985*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array2Uniform[0]"), uniformValue[2 * 0],
1986*35238bceSAndroid Build Coastguard Worker uniformValue[(2 * 0) + 1]);
1987*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(),
1988*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array2Uniform[1]"), uniformValue[2 * 1],
1989*35238bceSAndroid Build Coastguard Worker uniformValue[(2 * 1) + 1]);
1990*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(),
1991*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array2Uniform[2]"), uniformValue[2 * 2],
1992*35238bceSAndroid Build Coastguard Worker uniformValue[(2 * 2) + 1]);
1993*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(),
1994*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array2Uniform[3]"), uniformValue[2 * 3],
1995*35238bceSAndroid Build Coastguard Worker uniformValue[(2 * 3) + 1]);
1996*35238bceSAndroid Build Coastguard Worker verifyUniformValue2f(m_testCtx, *this, program.getProgram(),
1997*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array2Uniform[4]"), uniformValue[2 * 4],
1998*35238bceSAndroid Build Coastguard Worker uniformValue[(2 * 4) + 1]);
1999*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2000*35238bceSAndroid Build Coastguard Worker
2001*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "array3Uniform");
2002*35238bceSAndroid Build Coastguard Worker glUniform3fv(location, 5, uniformValue);
2003*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2004*35238bceSAndroid Build Coastguard Worker
2005*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(),
2006*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array3Uniform[0]"), uniformValue[3 * 0],
2007*35238bceSAndroid Build Coastguard Worker uniformValue[(3 * 0) + 1], uniformValue[(3 * 0) + 2]);
2008*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(),
2009*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array3Uniform[1]"), uniformValue[3 * 1],
2010*35238bceSAndroid Build Coastguard Worker uniformValue[(3 * 1) + 1], uniformValue[(3 * 1) + 2]);
2011*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(),
2012*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array3Uniform[2]"), uniformValue[3 * 2],
2013*35238bceSAndroid Build Coastguard Worker uniformValue[(3 * 2) + 1], uniformValue[(3 * 2) + 2]);
2014*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(),
2015*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array3Uniform[3]"), uniformValue[3 * 3],
2016*35238bceSAndroid Build Coastguard Worker uniformValue[(3 * 3) + 1], uniformValue[(3 * 3) + 2]);
2017*35238bceSAndroid Build Coastguard Worker verifyUniformValue3f(m_testCtx, *this, program.getProgram(),
2018*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array3Uniform[4]"), uniformValue[3 * 4],
2019*35238bceSAndroid Build Coastguard Worker uniformValue[(3 * 4) + 1], uniformValue[(3 * 4) + 2]);
2020*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2021*35238bceSAndroid Build Coastguard Worker
2022*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "array4Uniform");
2023*35238bceSAndroid Build Coastguard Worker glUniform4fv(location, 5, uniformValue);
2024*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2025*35238bceSAndroid Build Coastguard Worker
2026*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(),
2027*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array4Uniform[0]"), uniformValue[4 * 0],
2028*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 0) + 1], uniformValue[(4 * 0) + 2], uniformValue[(4 * 0) + 3]);
2029*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(),
2030*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array4Uniform[1]"), uniformValue[4 * 1],
2031*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 1) + 1], uniformValue[(4 * 1) + 2], uniformValue[(4 * 1) + 3]);
2032*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(),
2033*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array4Uniform[2]"), uniformValue[4 * 2],
2034*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 2) + 1], uniformValue[(4 * 2) + 2], uniformValue[(4 * 2) + 3]);
2035*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(),
2036*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array4Uniform[3]"), uniformValue[4 * 3],
2037*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 3) + 1], uniformValue[(4 * 3) + 2], uniformValue[(4 * 3) + 3]);
2038*35238bceSAndroid Build Coastguard Worker verifyUniformValue4f(m_testCtx, *this, program.getProgram(),
2039*35238bceSAndroid Build Coastguard Worker glGetUniformLocation(program.getProgram(), "array4Uniform[4]"), uniformValue[4 * 4],
2040*35238bceSAndroid Build Coastguard Worker uniformValue[(4 * 4) + 1], uniformValue[(4 * 4) + 2], uniformValue[(4 * 4) + 3]);
2041*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2042*35238bceSAndroid Build Coastguard Worker
2043*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
2044*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2045*35238bceSAndroid Build Coastguard Worker }
2046*35238bceSAndroid Build Coastguard Worker };
2047*35238bceSAndroid Build Coastguard Worker
2048*35238bceSAndroid Build Coastguard Worker class UniformValueMatrixCase : public ApiCase
2049*35238bceSAndroid Build Coastguard Worker {
2050*35238bceSAndroid Build Coastguard Worker public:
UniformValueMatrixCase(Context & context,const char * name,const char * description)2051*35238bceSAndroid Build Coastguard Worker UniformValueMatrixCase(Context &context, const char *name, const char *description)
2052*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2053*35238bceSAndroid Build Coastguard Worker {
2054*35238bceSAndroid Build Coastguard Worker }
2055*35238bceSAndroid Build Coastguard Worker
test(void)2056*35238bceSAndroid Build Coastguard Worker void test(void)
2057*35238bceSAndroid Build Coastguard Worker {
2058*35238bceSAndroid Build Coastguard Worker static const char *testVertSource =
2059*35238bceSAndroid Build Coastguard Worker "uniform highp mat2 mat2Uniform;"
2060*35238bceSAndroid Build Coastguard Worker "uniform highp mat3 mat3Uniform;"
2061*35238bceSAndroid Build Coastguard Worker "uniform highp mat4 mat4Uniform;"
2062*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2063*35238bceSAndroid Build Coastguard Worker "{\n"
2064*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(mat2Uniform[0][0] + mat3Uniform[0][0] + mat4Uniform[0][0]);\n"
2065*35238bceSAndroid Build Coastguard Worker "}\n";
2066*35238bceSAndroid Build Coastguard Worker static const char *testFragSource =
2067*35238bceSAndroid Build Coastguard Worker
2068*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
2069*35238bceSAndroid Build Coastguard Worker "{\n"
2070*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(0.0);\n"
2071*35238bceSAndroid Build Coastguard Worker "}\n";
2072*35238bceSAndroid Build Coastguard Worker
2073*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(),
2074*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(testVertSource, testFragSource));
2075*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
2076*35238bceSAndroid Build Coastguard Worker {
2077*35238bceSAndroid Build Coastguard Worker m_log << program;
2078*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to compile shader");
2079*35238bceSAndroid Build Coastguard Worker return;
2080*35238bceSAndroid Build Coastguard Worker }
2081*35238bceSAndroid Build Coastguard Worker
2082*35238bceSAndroid Build Coastguard Worker glUseProgram(program.getProgram());
2083*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2084*35238bceSAndroid Build Coastguard Worker
2085*35238bceSAndroid Build Coastguard Worker GLint location;
2086*35238bceSAndroid Build Coastguard Worker
2087*35238bceSAndroid Build Coastguard Worker float matrixValues[4 * 4] = {
2088*35238bceSAndroid Build Coastguard Worker -1.0f, 0.1f, 4.0f, 800.0f, 13.0f, 55.0f, 12.0f, 91.0f,
2089*35238bceSAndroid Build Coastguard Worker -55.1f, 1.1f, 98.0f, 19.0f, 41.0f, 65.0f, 4.0f, 12.2f,
2090*35238bceSAndroid Build Coastguard Worker };
2091*35238bceSAndroid Build Coastguard Worker
2092*35238bceSAndroid Build Coastguard Worker // the values of the matrix are returned in column major order but they can be given in either order
2093*35238bceSAndroid Build Coastguard Worker
2094*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "mat2Uniform");
2095*35238bceSAndroid Build Coastguard Worker glUniformMatrix2fv(location, 1, GL_FALSE, matrixValues);
2096*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<2>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
2097*35238bceSAndroid Build Coastguard Worker
2098*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "mat3Uniform");
2099*35238bceSAndroid Build Coastguard Worker glUniformMatrix3fv(location, 1, GL_FALSE, matrixValues);
2100*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<3>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
2101*35238bceSAndroid Build Coastguard Worker
2102*35238bceSAndroid Build Coastguard Worker location = glGetUniformLocation(program.getProgram(), "mat4Uniform");
2103*35238bceSAndroid Build Coastguard Worker glUniformMatrix4fv(location, 1, GL_FALSE, matrixValues);
2104*35238bceSAndroid Build Coastguard Worker verifyUniformMatrixValues<4>(m_testCtx, *this, program.getProgram(), location, matrixValues, false);
2105*35238bceSAndroid Build Coastguard Worker
2106*35238bceSAndroid Build Coastguard Worker glUseProgram(0);
2107*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2108*35238bceSAndroid Build Coastguard Worker }
2109*35238bceSAndroid Build Coastguard Worker };
2110*35238bceSAndroid Build Coastguard Worker
2111*35238bceSAndroid Build Coastguard Worker class PrecisionFormatCase : public ApiCase
2112*35238bceSAndroid Build Coastguard Worker {
2113*35238bceSAndroid Build Coastguard Worker public:
2114*35238bceSAndroid Build Coastguard Worker struct RequiredFormat
2115*35238bceSAndroid Build Coastguard Worker {
2116*35238bceSAndroid Build Coastguard Worker int negativeRange;
2117*35238bceSAndroid Build Coastguard Worker int positiveRange;
2118*35238bceSAndroid Build Coastguard Worker int precision;
2119*35238bceSAndroid Build Coastguard Worker };
2120*35238bceSAndroid Build Coastguard Worker
PrecisionFormatCase(Context & context,const char * name,const char * description,glw::GLenum shaderType,glw::GLenum precisionType)2121*35238bceSAndroid Build Coastguard Worker PrecisionFormatCase(Context &context, const char *name, const char *description, glw::GLenum shaderType,
2122*35238bceSAndroid Build Coastguard Worker glw::GLenum precisionType)
2123*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
2124*35238bceSAndroid Build Coastguard Worker , m_shaderType(shaderType)
2125*35238bceSAndroid Build Coastguard Worker , m_precisionType(precisionType)
2126*35238bceSAndroid Build Coastguard Worker {
2127*35238bceSAndroid Build Coastguard Worker }
2128*35238bceSAndroid Build Coastguard Worker
2129*35238bceSAndroid Build Coastguard Worker private:
test(void)2130*35238bceSAndroid Build Coastguard Worker void test(void)
2131*35238bceSAndroid Build Coastguard Worker {
2132*35238bceSAndroid Build Coastguard Worker const RequiredFormat expected = getRequiredFormat();
2133*35238bceSAndroid Build Coastguard Worker bool error = false;
2134*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLboolean> shaderCompiler;
2135*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint[2]> range;
2136*35238bceSAndroid Build Coastguard Worker gls::StateQueryUtil::StateQueryMemoryWriteGuard<glw::GLint> precision;
2137*35238bceSAndroid Build Coastguard Worker
2138*35238bceSAndroid Build Coastguard Worker // requires SHADER_COMPILER = true
2139*35238bceSAndroid Build Coastguard Worker glGetBooleanv(GL_SHADER_COMPILER, &shaderCompiler);
2140*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2141*35238bceSAndroid Build Coastguard Worker
2142*35238bceSAndroid Build Coastguard Worker if (!shaderCompiler.verifyValidity(m_testCtx))
2143*35238bceSAndroid Build Coastguard Worker return;
2144*35238bceSAndroid Build Coastguard Worker if (shaderCompiler != GL_TRUE)
2145*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("SHADER_COMPILER = TRUE required");
2146*35238bceSAndroid Build Coastguard Worker
2147*35238bceSAndroid Build Coastguard Worker // query values
2148*35238bceSAndroid Build Coastguard Worker glGetShaderPrecisionFormat(m_shaderType, m_precisionType, range, &precision);
2149*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
2150*35238bceSAndroid Build Coastguard Worker
2151*35238bceSAndroid Build Coastguard Worker if (!range.verifyValidity(m_testCtx))
2152*35238bceSAndroid Build Coastguard Worker return;
2153*35238bceSAndroid Build Coastguard Worker if (!precision.verifyValidity(m_testCtx))
2154*35238bceSAndroid Build Coastguard Worker return;
2155*35238bceSAndroid Build Coastguard Worker
2156*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "range[0] = " << range[0] << "\n"
2157*35238bceSAndroid Build Coastguard Worker << "range[1] = " << range[1] << "\n"
2158*35238bceSAndroid Build Coastguard Worker << "precision = " << precision << tcu::TestLog::EndMessage;
2159*35238bceSAndroid Build Coastguard Worker
2160*35238bceSAndroid Build Coastguard Worker // special case for highp and fragment shader
2161*35238bceSAndroid Build Coastguard Worker
2162*35238bceSAndroid Build Coastguard Worker if (m_shaderType == GL_FRAGMENT_SHADER && (m_precisionType == GL_HIGH_FLOAT || m_precisionType == GL_HIGH_INT))
2163*35238bceSAndroid Build Coastguard Worker {
2164*35238bceSAndroid Build Coastguard Worker // not supported is a valid return value
2165*35238bceSAndroid Build Coastguard Worker if (range[0] == 0 && range[1] == 0 && precision == 0)
2166*35238bceSAndroid Build Coastguard Worker return;
2167*35238bceSAndroid Build Coastguard Worker }
2168*35238bceSAndroid Build Coastguard Worker
2169*35238bceSAndroid Build Coastguard Worker // verify the returned values
2170*35238bceSAndroid Build Coastguard Worker
2171*35238bceSAndroid Build Coastguard Worker if (range[0] < expected.negativeRange)
2172*35238bceSAndroid Build Coastguard Worker {
2173*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid range[0], expected greater or equal to "
2174*35238bceSAndroid Build Coastguard Worker << expected.negativeRange << tcu::TestLog::EndMessage;
2175*35238bceSAndroid Build Coastguard Worker error = true;
2176*35238bceSAndroid Build Coastguard Worker }
2177*35238bceSAndroid Build Coastguard Worker
2178*35238bceSAndroid Build Coastguard Worker if (range[1] < expected.positiveRange)
2179*35238bceSAndroid Build Coastguard Worker {
2180*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid range[1], expected greater or equal to "
2181*35238bceSAndroid Build Coastguard Worker << expected.positiveRange << tcu::TestLog::EndMessage;
2182*35238bceSAndroid Build Coastguard Worker error = true;
2183*35238bceSAndroid Build Coastguard Worker }
2184*35238bceSAndroid Build Coastguard Worker
2185*35238bceSAndroid Build Coastguard Worker if (precision < expected.precision)
2186*35238bceSAndroid Build Coastguard Worker {
2187*35238bceSAndroid Build Coastguard Worker m_log << tcu::TestLog::Message << "// ERROR: Invalid precision, expected greater or equal to "
2188*35238bceSAndroid Build Coastguard Worker << expected.precision << tcu::TestLog::EndMessage;
2189*35238bceSAndroid Build Coastguard Worker error = true;
2190*35238bceSAndroid Build Coastguard Worker }
2191*35238bceSAndroid Build Coastguard Worker
2192*35238bceSAndroid Build Coastguard Worker if (error)
2193*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid precision/range");
2194*35238bceSAndroid Build Coastguard Worker }
2195*35238bceSAndroid Build Coastguard Worker
getRequiredFormat(void) const2196*35238bceSAndroid Build Coastguard Worker RequiredFormat getRequiredFormat(void) const
2197*35238bceSAndroid Build Coastguard Worker {
2198*35238bceSAndroid Build Coastguard Worker // Precisions for different types.
2199*35238bceSAndroid Build Coastguard Worker // For example highp float: range: (-2^62, 2^62) => min = -2^62 + e, max = 2^62 - e
2200*35238bceSAndroid Build Coastguard Worker const RequiredFormat requirements[] = {
2201*35238bceSAndroid Build Coastguard Worker {0, 0, 8}, //!< lowp float
2202*35238bceSAndroid Build Coastguard Worker {13, 13, 10}, //!< mediump float
2203*35238bceSAndroid Build Coastguard Worker {61, 61, 16}, //!< highp float
2204*35238bceSAndroid Build Coastguard Worker {7, 7, 0}, //!< lowp int
2205*35238bceSAndroid Build Coastguard Worker {9, 9, 0}, //!< mediump int
2206*35238bceSAndroid Build Coastguard Worker {15, 15, 0}, //!< highp int
2207*35238bceSAndroid Build Coastguard Worker };
2208*35238bceSAndroid Build Coastguard Worker const int ndx = (int)m_precisionType - (int)GL_LOW_FLOAT;
2209*35238bceSAndroid Build Coastguard Worker
2210*35238bceSAndroid Build Coastguard Worker DE_ASSERT(ndx >= 0);
2211*35238bceSAndroid Build Coastguard Worker DE_ASSERT(ndx < DE_LENGTH_OF_ARRAY(requirements));
2212*35238bceSAndroid Build Coastguard Worker return requirements[ndx];
2213*35238bceSAndroid Build Coastguard Worker }
2214*35238bceSAndroid Build Coastguard Worker
2215*35238bceSAndroid Build Coastguard Worker const glw::GLenum m_shaderType;
2216*35238bceSAndroid Build Coastguard Worker const glw::GLenum m_precisionType;
2217*35238bceSAndroid Build Coastguard Worker };
2218*35238bceSAndroid Build Coastguard Worker
2219*35238bceSAndroid Build Coastguard Worker } // namespace
2220*35238bceSAndroid Build Coastguard Worker
ShaderStateQueryTests(Context & context)2221*35238bceSAndroid Build Coastguard Worker ShaderStateQueryTests::ShaderStateQueryTests(Context &context)
2222*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "shader", "Shader State Query tests")
2223*35238bceSAndroid Build Coastguard Worker {
2224*35238bceSAndroid Build Coastguard Worker }
2225*35238bceSAndroid Build Coastguard Worker
init(void)2226*35238bceSAndroid Build Coastguard Worker void ShaderStateQueryTests::init(void)
2227*35238bceSAndroid Build Coastguard Worker {
2228*35238bceSAndroid Build Coastguard Worker // shader
2229*35238bceSAndroid Build Coastguard Worker addChild(new ShaderTypeCase(m_context, "shader_type", "SHADER_TYPE"));
2230*35238bceSAndroid Build Coastguard Worker addChild(new ShaderCompileStatusCase(m_context, "shader_compile_status", "COMPILE_STATUS"));
2231*35238bceSAndroid Build Coastguard Worker addChild(new ShaderInfoLogCase(m_context, "shader_info_log_length", "INFO_LOG_LENGTH"));
2232*35238bceSAndroid Build Coastguard Worker addChild(new ShaderSourceCase(m_context, "shader_source_length", "SHADER_SOURCE_LENGTH"));
2233*35238bceSAndroid Build Coastguard Worker
2234*35238bceSAndroid Build Coastguard Worker // shader and program
2235*35238bceSAndroid Build Coastguard Worker addChild(new DeleteStatusCase(m_context, "delete_status", "DELETE_STATUS"));
2236*35238bceSAndroid Build Coastguard Worker
2237*35238bceSAndroid Build Coastguard Worker // vertex-attrib
2238*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribInitialCase(m_context, "current_vertex_attrib_initial", "CURRENT_VERTEX_ATTRIB"));
2239*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribFloatCase(m_context, "current_vertex_attrib_float", "CURRENT_VERTEX_ATTRIB"));
2240*35238bceSAndroid Build Coastguard Worker addChild(new CurrentVertexAttribConversionCase(m_context, "current_vertex_attrib_float_to_int",
2241*35238bceSAndroid Build Coastguard Worker "CURRENT_VERTEX_ATTRIB"));
2242*35238bceSAndroid Build Coastguard Worker
2243*35238bceSAndroid Build Coastguard Worker // program
2244*35238bceSAndroid Build Coastguard Worker addChild(new ProgramInfoLogCase(m_context, "program_info_log_length", "INFO_LOG_LENGTH"));
2245*35238bceSAndroid Build Coastguard Worker addChild(new ProgramValidateStatusCase(m_context, "program_validate_status", "VALIDATE_STATUS"));
2246*35238bceSAndroid Build Coastguard Worker addChild(new ProgramAttachedShadersCase(m_context, "program_attached_shaders", "ATTACHED_SHADERS"));
2247*35238bceSAndroid Build Coastguard Worker
2248*35238bceSAndroid Build Coastguard Worker addChild(new ProgramActiveUniformNameCase(m_context, "program_active_uniform_name",
2249*35238bceSAndroid Build Coastguard Worker "ACTIVE_UNIFORMS and ACTIVE_UNIFORM_MAX_LENGTH"));
2250*35238bceSAndroid Build Coastguard Worker addChild(new ProgramUniformCase(m_context, "program_active_uniform_types", "UNIFORM_TYPE and UNIFORM_SIZE"));
2251*35238bceSAndroid Build Coastguard Worker
2252*35238bceSAndroid Build Coastguard Worker // attribute related
2253*35238bceSAndroid Build Coastguard Worker addChild(
2254*35238bceSAndroid Build Coastguard Worker new ActiveAttributesCase(m_context, "active_attributes", "ACTIVE_ATTRIBUTES and ACTIVE_ATTRIBUTE_MAX_LENGTH"));
2255*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeSizeCase(m_context, "vertex_attrib_size", "VERTEX_ATTRIB_ARRAY_SIZE"));
2256*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeTypeCase(m_context, "vertex_attrib_type", "VERTEX_ATTRIB_ARRAY_TYPE"));
2257*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeStrideCase(m_context, "vertex_attrib_stride", "VERTEX_ATTRIB_ARRAY_STRIDE"));
2258*35238bceSAndroid Build Coastguard Worker addChild(
2259*35238bceSAndroid Build Coastguard Worker new VertexAttributeNormalizedCase(m_context, "vertex_attrib_normalized", "VERTEX_ATTRIB_ARRAY_NORMALIZED"));
2260*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeEnabledCase(m_context, "vertex_attrib_array_enabled", "VERTEX_ATTRIB_ARRAY_ENABLED"));
2261*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributeBufferBindingCase(m_context, "vertex_attrib_array_buffer_binding",
2262*35238bceSAndroid Build Coastguard Worker "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"));
2263*35238bceSAndroid Build Coastguard Worker addChild(new VertexAttributePointerCase(m_context, "vertex_attrib_pointerv", "GetVertexAttribPointerv"));
2264*35238bceSAndroid Build Coastguard Worker
2265*35238bceSAndroid Build Coastguard Worker // uniform values
2266*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueFloatCase(m_context, "uniform_value_float", "GetUniform*"));
2267*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueIntCase(m_context, "uniform_value_int", "GetUniform*"));
2268*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueBooleanCase(m_context, "uniform_value_boolean", "GetUniform*"));
2269*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueSamplerCase(m_context, "uniform_value_sampler", "GetUniform*"));
2270*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueArrayCase(m_context, "uniform_value_array", "GetUniform*"));
2271*35238bceSAndroid Build Coastguard Worker addChild(new UniformValueMatrixCase(m_context, "uniform_value_matrix", "GetUniform*"));
2272*35238bceSAndroid Build Coastguard Worker
2273*35238bceSAndroid Build Coastguard Worker // precision format query
2274*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_lowp_float", "GetShaderPrecisionFormat",
2275*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_LOW_FLOAT));
2276*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_mediump_float", "GetShaderPrecisionFormat",
2277*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_MEDIUM_FLOAT));
2278*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_highp_float", "GetShaderPrecisionFormat",
2279*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_HIGH_FLOAT));
2280*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_lowp_int", "GetShaderPrecisionFormat",
2281*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_LOW_INT));
2282*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_mediump_int", "GetShaderPrecisionFormat",
2283*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_MEDIUM_INT));
2284*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_vertex_highp_int", "GetShaderPrecisionFormat",
2285*35238bceSAndroid Build Coastguard Worker GL_VERTEX_SHADER, GL_HIGH_INT));
2286*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_lowp_float", "GetShaderPrecisionFormat",
2287*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_LOW_FLOAT));
2288*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_mediump_float", "GetShaderPrecisionFormat",
2289*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT));
2290*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_highp_float", "GetShaderPrecisionFormat",
2291*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_HIGH_FLOAT));
2292*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_lowp_int", "GetShaderPrecisionFormat",
2293*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_LOW_INT));
2294*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_mediump_int", "GetShaderPrecisionFormat",
2295*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_MEDIUM_INT));
2296*35238bceSAndroid Build Coastguard Worker addChild(new PrecisionFormatCase(m_context, "precision_fragment_highp_int", "GetShaderPrecisionFormat",
2297*35238bceSAndroid Build Coastguard Worker GL_FRAGMENT_SHADER, GL_HIGH_INT));
2298*35238bceSAndroid Build Coastguard Worker }
2299*35238bceSAndroid Build Coastguard Worker
2300*35238bceSAndroid Build Coastguard Worker } // namespace Functional
2301*35238bceSAndroid Build Coastguard Worker } // namespace gles2
2302*35238bceSAndroid Build Coastguard Worker } // namespace deqp
2303