xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fProgramStateQueryTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2015 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 Program State Query tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fProgramStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "es31fInfoLogQueryShared.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "tcuStringTemplate.hpp"
35*35238bceSAndroid Build Coastguard Worker 
36*35238bceSAndroid Build Coastguard Worker namespace deqp
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker using std::map;
40*35238bceSAndroid Build Coastguard Worker using std::string;
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker namespace gles31
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker namespace Functional
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker namespace
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker 
49*35238bceSAndroid Build Coastguard Worker using namespace gls::StateQueryUtil;
50*35238bceSAndroid Build Coastguard Worker 
getVerifierSuffix(QueryType type)51*35238bceSAndroid Build Coastguard Worker static const char *getVerifierSuffix(QueryType type)
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker     switch (type)
54*35238bceSAndroid Build Coastguard Worker     {
55*35238bceSAndroid Build Coastguard Worker     case QUERY_PROGRAM_INTEGER_VEC3:
56*35238bceSAndroid Build Coastguard Worker     case QUERY_PROGRAM_INTEGER:
57*35238bceSAndroid Build Coastguard Worker         return "get_programiv";
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker     default:
60*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
61*35238bceSAndroid Build Coastguard Worker         return DE_NULL;
62*35238bceSAndroid Build Coastguard Worker     }
63*35238bceSAndroid Build Coastguard Worker }
64*35238bceSAndroid Build Coastguard Worker 
checkSupport(Context & ctx)65*35238bceSAndroid Build Coastguard Worker static bool checkSupport(Context &ctx)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker     auto ctxType = ctx.getRenderContext().getType();
68*35238bceSAndroid Build Coastguard Worker     return contextSupports(ctxType, glu::ApiType::es(3, 2)) || contextSupports(ctxType, glu::ApiType::core(4, 5));
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker 
specializeShader(Context & context,const char * code)71*35238bceSAndroid Build Coastguard Worker static std::string specializeShader(Context &context, const char *code)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker     auto ctxType                       = context.getRenderContext().getType();
74*35238bceSAndroid Build Coastguard Worker     const glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(ctxType);
75*35238bceSAndroid Build Coastguard Worker     const bool isES32orGL45            = checkSupport(context);
76*35238bceSAndroid Build Coastguard Worker     const bool isES                    = isContextTypeES(ctxType);
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker     std::map<std::string, std::string> specializationMap = {
79*35238bceSAndroid Build Coastguard Worker         {"GLSL_VERSION_DECL", glu::getGLSLVersionDeclaration(glslVersion)},
80*35238bceSAndroid Build Coastguard Worker         {"GEOMETRY_SHADER_REQUIRE", (isES32orGL45 ? "" : "#extension GL_EXT_geometry_shader : require")},
81*35238bceSAndroid Build Coastguard Worker         {"TESSELLATION_SHADER_REQUIRE", (isES32orGL45 ? "" : "#extension GL_EXT_tessellation_shader : require")},
82*35238bceSAndroid Build Coastguard Worker         {"GL_POSITION_REDECL", (isES ? "" : "out gl_PerVertex { vec4 gl_Position;};")}};
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker     return tcu::StringTemplate(code).specialize(specializationMap);
85*35238bceSAndroid Build Coastguard Worker }
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker class GeometryShaderCase : public TestCase
88*35238bceSAndroid Build Coastguard Worker {
89*35238bceSAndroid Build Coastguard Worker public:
90*35238bceSAndroid Build Coastguard Worker     GeometryShaderCase(Context &context, QueryType verifier, const char *name, const char *desc);
91*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
92*35238bceSAndroid Build Coastguard Worker 
93*35238bceSAndroid Build Coastguard Worker private:
94*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
95*35238bceSAndroid Build Coastguard Worker };
96*35238bceSAndroid Build Coastguard Worker 
GeometryShaderCase(Context & context,QueryType verifier,const char * name,const char * desc)97*35238bceSAndroid Build Coastguard Worker GeometryShaderCase::GeometryShaderCase(Context &context, QueryType verifier, const char *name, const char *desc)
98*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
99*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
100*35238bceSAndroid Build Coastguard Worker {
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker 
iterate(void)103*35238bceSAndroid Build Coastguard Worker GeometryShaderCase::IterateResult GeometryShaderCase::iterate(void)
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker     const bool isES32orGL45 = checkSupport(m_context);
106*35238bceSAndroid Build Coastguard Worker 
107*35238bceSAndroid Build Coastguard Worker     if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader"))
108*35238bceSAndroid Build Coastguard Worker         TCU_THROW(
109*35238bceSAndroid Build Coastguard Worker             NotSupportedError,
110*35238bceSAndroid Build Coastguard Worker             "Geometry shader tests require GL_EXT_geometry_shader extension or an OpenGL ES 3.2 or higher context.");
111*35238bceSAndroid Build Coastguard Worker 
112*35238bceSAndroid Build Coastguard Worker     static const char *const s_vtxFragTemplate = "${GLSL_VERSION_DECL}\n"
113*35238bceSAndroid Build Coastguard Worker                                                  "void main()\n"
114*35238bceSAndroid Build Coastguard Worker                                                  "{\n"
115*35238bceSAndroid Build Coastguard Worker                                                  "}\n";
116*35238bceSAndroid Build Coastguard Worker 
117*35238bceSAndroid Build Coastguard Worker     static const char *const s_geometryTemplate1 = "${GLSL_VERSION_DECL}\n"
118*35238bceSAndroid Build Coastguard Worker                                                    "${GEOMETRY_SHADER_REQUIRE}\n"
119*35238bceSAndroid Build Coastguard Worker                                                    "layout(triangles) in;"
120*35238bceSAndroid Build Coastguard Worker                                                    "layout(triangle_strip, max_vertices = 3) out;\n"
121*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
122*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
123*35238bceSAndroid Build Coastguard Worker                                                    "   EndPrimitive();\n"
124*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
125*35238bceSAndroid Build Coastguard Worker 
126*35238bceSAndroid Build Coastguard Worker     static const char *const s_geometryTemplate2 = "${GLSL_VERSION_DECL}\n"
127*35238bceSAndroid Build Coastguard Worker                                                    "${GEOMETRY_SHADER_REQUIRE}\n"
128*35238bceSAndroid Build Coastguard Worker                                                    "layout(points) in;"
129*35238bceSAndroid Build Coastguard Worker                                                    "layout(line_strip, max_vertices = 5) out;\n"
130*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
131*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
132*35238bceSAndroid Build Coastguard Worker                                                    "   EndPrimitive();\n"
133*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
134*35238bceSAndroid Build Coastguard Worker 
135*35238bceSAndroid Build Coastguard Worker     static const char *const s_geometryTemplate3 = "${GLSL_VERSION_DECL}\n"
136*35238bceSAndroid Build Coastguard Worker                                                    "${GEOMETRY_SHADER_REQUIRE}\n"
137*35238bceSAndroid Build Coastguard Worker                                                    "layout(points) in;"
138*35238bceSAndroid Build Coastguard Worker                                                    "layout(points, max_vertices = 50) out;\n"
139*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
140*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
141*35238bceSAndroid Build Coastguard Worker                                                    "   EndPrimitive();\n"
142*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
143*35238bceSAndroid Build Coastguard Worker 
144*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
145*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
146*35238bceSAndroid Build Coastguard Worker 
147*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
148*35238bceSAndroid Build Coastguard Worker 
149*35238bceSAndroid Build Coastguard Worker     {
150*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Layout",
151*35238bceSAndroid Build Coastguard Worker                                             "triangles in, triangle strip out, 3 vertices");
152*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(),
153*35238bceSAndroid Build Coastguard Worker                                    glu::ProgramSources()
154*35238bceSAndroid Build Coastguard Worker                                        << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
155*35238bceSAndroid Build Coastguard Worker                                        << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
156*35238bceSAndroid Build Coastguard Worker                                        << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate1)));
157*35238bceSAndroid Build Coastguard Worker 
158*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
159*35238bceSAndroid Build Coastguard Worker 
160*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
161*35238bceSAndroid Build Coastguard Worker 
162*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 3, m_verifier);
163*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_TRIANGLES, m_verifier);
164*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_TRIANGLE_STRIP,
165*35238bceSAndroid Build Coastguard Worker                                   m_verifier);
166*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_SHADER_INVOCATIONS, 1, m_verifier);
167*35238bceSAndroid Build Coastguard Worker     }
168*35238bceSAndroid Build Coastguard Worker 
169*35238bceSAndroid Build Coastguard Worker     {
170*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Layout", "points in, line strip out, 5 vertices");
171*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(),
172*35238bceSAndroid Build Coastguard Worker                                    glu::ProgramSources()
173*35238bceSAndroid Build Coastguard Worker                                        << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
174*35238bceSAndroid Build Coastguard Worker                                        << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
175*35238bceSAndroid Build Coastguard Worker                                        << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate2)));
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
180*35238bceSAndroid Build Coastguard Worker 
181*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 5, m_verifier);
182*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_POINTS, m_verifier);
183*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_LINE_STRIP, m_verifier);
184*35238bceSAndroid Build Coastguard Worker     }
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     {
187*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Layout", "points in, points out, 50 vertices");
188*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(),
189*35238bceSAndroid Build Coastguard Worker                                    glu::ProgramSources()
190*35238bceSAndroid Build Coastguard Worker                                        << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
191*35238bceSAndroid Build Coastguard Worker                                        << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
192*35238bceSAndroid Build Coastguard Worker                                        << glu::GeometrySource(specializeShader(m_context, s_geometryTemplate3)));
193*35238bceSAndroid Build Coastguard Worker 
194*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
195*35238bceSAndroid Build Coastguard Worker 
196*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
197*35238bceSAndroid Build Coastguard Worker 
198*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_VERTICES_OUT, 50, m_verifier);
199*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_INPUT_TYPE, GL_POINTS, m_verifier);
200*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_GEOMETRY_OUTPUT_TYPE, GL_POINTS, m_verifier);
201*35238bceSAndroid Build Coastguard Worker     }
202*35238bceSAndroid Build Coastguard Worker 
203*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
204*35238bceSAndroid Build Coastguard Worker     return STOP;
205*35238bceSAndroid Build Coastguard Worker }
206*35238bceSAndroid Build Coastguard Worker 
207*35238bceSAndroid Build Coastguard Worker class TessellationShaderCase : public TestCase
208*35238bceSAndroid Build Coastguard Worker {
209*35238bceSAndroid Build Coastguard Worker public:
210*35238bceSAndroid Build Coastguard Worker     TessellationShaderCase(Context &context, QueryType verifier, const char *name, const char *desc);
211*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
212*35238bceSAndroid Build Coastguard Worker 
213*35238bceSAndroid Build Coastguard Worker private:
214*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
215*35238bceSAndroid Build Coastguard Worker };
216*35238bceSAndroid Build Coastguard Worker 
TessellationShaderCase(Context & context,QueryType verifier,const char * name,const char * desc)217*35238bceSAndroid Build Coastguard Worker TessellationShaderCase::TessellationShaderCase(Context &context, QueryType verifier, const char *name, const char *desc)
218*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
219*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
220*35238bceSAndroid Build Coastguard Worker {
221*35238bceSAndroid Build Coastguard Worker }
222*35238bceSAndroid Build Coastguard Worker 
iterate(void)223*35238bceSAndroid Build Coastguard Worker TessellationShaderCase::IterateResult TessellationShaderCase::iterate(void)
224*35238bceSAndroid Build Coastguard Worker {
225*35238bceSAndroid Build Coastguard Worker     const bool isES32orGL45 = checkSupport(m_context);
226*35238bceSAndroid Build Coastguard Worker 
227*35238bceSAndroid Build Coastguard Worker     if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader"))
228*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, "Tessellation shader tests require GL_EXT_tessellation_shader extension or an "
229*35238bceSAndroid Build Coastguard Worker                                      "OpenGL ES 3.2 or higher context.");
230*35238bceSAndroid Build Coastguard Worker 
231*35238bceSAndroid Build Coastguard Worker     static const char *const s_vtxFragTemplate = "${GLSL_VERSION_DECL}\n"
232*35238bceSAndroid Build Coastguard Worker                                                  "void main()\n"
233*35238bceSAndroid Build Coastguard Worker                                                  "{\n"
234*35238bceSAndroid Build Coastguard Worker                                                  "}\n";
235*35238bceSAndroid Build Coastguard Worker 
236*35238bceSAndroid Build Coastguard Worker     static const char *const s_tessCtrlTemplate1 = "${GLSL_VERSION_DECL}\n"
237*35238bceSAndroid Build Coastguard Worker                                                    "${TESSELLATION_SHADER_REQUIRE}\n"
238*35238bceSAndroid Build Coastguard Worker                                                    "layout(vertices = 3) out;\n"
239*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
240*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
241*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
242*35238bceSAndroid Build Coastguard Worker 
243*35238bceSAndroid Build Coastguard Worker     static const char *const s_tessEvalTemplate1 = "${GLSL_VERSION_DECL}\n"
244*35238bceSAndroid Build Coastguard Worker                                                    "${TESSELLATION_SHADER_REQUIRE}\n"
245*35238bceSAndroid Build Coastguard Worker                                                    "layout(triangles, equal_spacing, cw) in;\n"
246*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
247*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
248*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
249*35238bceSAndroid Build Coastguard Worker 
250*35238bceSAndroid Build Coastguard Worker     static const char *const s_tessCtrlTemplate2 = "${GLSL_VERSION_DECL}\n"
251*35238bceSAndroid Build Coastguard Worker                                                    "${TESSELLATION_SHADER_REQUIRE}\n"
252*35238bceSAndroid Build Coastguard Worker                                                    "layout(vertices = 5) out;\n"
253*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
254*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
255*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
256*35238bceSAndroid Build Coastguard Worker 
257*35238bceSAndroid Build Coastguard Worker     static const char *const s_tessEvalTemplate2 = "${GLSL_VERSION_DECL}\n"
258*35238bceSAndroid Build Coastguard Worker                                                    "${TESSELLATION_SHADER_REQUIRE}\n"
259*35238bceSAndroid Build Coastguard Worker                                                    "layout(quads, fractional_even_spacing, ccw) in;\n"
260*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
261*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
262*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
263*35238bceSAndroid Build Coastguard Worker 
264*35238bceSAndroid Build Coastguard Worker     static const char *const s_tessEvalTemplate3 = "${GLSL_VERSION_DECL}\n"
265*35238bceSAndroid Build Coastguard Worker                                                    "${TESSELLATION_SHADER_REQUIRE}\n"
266*35238bceSAndroid Build Coastguard Worker                                                    "layout(isolines, fractional_odd_spacing, ccw, point_mode) in;\n"
267*35238bceSAndroid Build Coastguard Worker                                                    "void main()\n"
268*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
269*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
270*35238bceSAndroid Build Coastguard Worker 
271*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
272*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
273*35238bceSAndroid Build Coastguard Worker 
274*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
275*35238bceSAndroid Build Coastguard Worker 
276*35238bceSAndroid Build Coastguard Worker     {
277*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Query State",
278*35238bceSAndroid Build Coastguard Worker                                             "3 vertices, triangles, equal_spacing, cw");
279*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(
280*35238bceSAndroid Build Coastguard Worker             m_context.getRenderContext(),
281*35238bceSAndroid Build Coastguard Worker             glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
282*35238bceSAndroid Build Coastguard Worker                                   << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
283*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate1))
284*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationEvaluationSource(
285*35238bceSAndroid Build Coastguard Worker                                          specializeShader(m_context, s_tessEvalTemplate1)));
286*35238bceSAndroid Build Coastguard Worker 
287*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
288*35238bceSAndroid Build Coastguard Worker 
289*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
290*35238bceSAndroid Build Coastguard Worker 
291*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 3, m_verifier);
292*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_TRIANGLES, m_verifier);
293*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_EQUAL, m_verifier);
294*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CW, m_verifier);
295*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_FALSE, m_verifier);
296*35238bceSAndroid Build Coastguard Worker     }
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker     {
299*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Query State",
300*35238bceSAndroid Build Coastguard Worker                                             "5 vertices, quads, fractional_even_spacing, ccw");
301*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(
302*35238bceSAndroid Build Coastguard Worker             m_context.getRenderContext(),
303*35238bceSAndroid Build Coastguard Worker             glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
304*35238bceSAndroid Build Coastguard Worker                                   << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
305*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate2))
306*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationEvaluationSource(
307*35238bceSAndroid Build Coastguard Worker                                          specializeShader(m_context, s_tessEvalTemplate2)));
308*35238bceSAndroid Build Coastguard Worker 
309*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
310*35238bceSAndroid Build Coastguard Worker 
311*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
312*35238bceSAndroid Build Coastguard Worker 
313*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 5, m_verifier);
314*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_QUADS, m_verifier);
315*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_FRACTIONAL_EVEN,
316*35238bceSAndroid Build Coastguard Worker                                   m_verifier);
317*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CCW, m_verifier);
318*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_FALSE, m_verifier);
319*35238bceSAndroid Build Coastguard Worker     }
320*35238bceSAndroid Build Coastguard Worker 
321*35238bceSAndroid Build Coastguard Worker     {
322*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Query State",
323*35238bceSAndroid Build Coastguard Worker                                             "5 vertices, isolines, fractional_odd_spacing, ccw, point_mode");
324*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(
325*35238bceSAndroid Build Coastguard Worker             m_context.getRenderContext(),
326*35238bceSAndroid Build Coastguard Worker             glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, s_vtxFragTemplate))
327*35238bceSAndroid Build Coastguard Worker                                   << glu::FragmentSource(specializeShader(m_context, s_vtxFragTemplate))
328*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationControlSource(specializeShader(m_context, s_tessCtrlTemplate2))
329*35238bceSAndroid Build Coastguard Worker                                   << glu::TessellationEvaluationSource(
330*35238bceSAndroid Build Coastguard Worker                                          specializeShader(m_context, s_tessEvalTemplate3)));
331*35238bceSAndroid Build Coastguard Worker 
332*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "Compile failed");
333*35238bceSAndroid Build Coastguard Worker 
334*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
335*35238bceSAndroid Build Coastguard Worker 
336*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_CONTROL_OUTPUT_VERTICES, 5, m_verifier);
337*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_MODE, GL_ISOLINES, m_verifier);
338*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_SPACING, GL_FRACTIONAL_ODD, m_verifier);
339*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_VERTEX_ORDER, GL_CCW, m_verifier);
340*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_TESS_GEN_POINT_MODE, GL_TRUE, m_verifier);
341*35238bceSAndroid Build Coastguard Worker     }
342*35238bceSAndroid Build Coastguard Worker 
343*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
344*35238bceSAndroid Build Coastguard Worker     return STOP;
345*35238bceSAndroid Build Coastguard Worker }
346*35238bceSAndroid Build Coastguard Worker 
347*35238bceSAndroid Build Coastguard Worker class ProgramSeparableCase : public TestCase
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker public:
350*35238bceSAndroid Build Coastguard Worker     ProgramSeparableCase(Context &context, QueryType verifier, const char *name, const char *desc);
351*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
352*35238bceSAndroid Build Coastguard Worker 
353*35238bceSAndroid Build Coastguard Worker private:
354*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
355*35238bceSAndroid Build Coastguard Worker };
356*35238bceSAndroid Build Coastguard Worker 
ProgramSeparableCase(Context & context,QueryType verifier,const char * name,const char * desc)357*35238bceSAndroid Build Coastguard Worker ProgramSeparableCase::ProgramSeparableCase(Context &context, QueryType verifier, const char *name, const char *desc)
358*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
359*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
360*35238bceSAndroid Build Coastguard Worker {
361*35238bceSAndroid Build Coastguard Worker }
362*35238bceSAndroid Build Coastguard Worker 
iterate(void)363*35238bceSAndroid Build Coastguard Worker ProgramSeparableCase::IterateResult ProgramSeparableCase::iterate(void)
364*35238bceSAndroid Build Coastguard Worker {
365*35238bceSAndroid Build Coastguard Worker     const string vtxTemplate =
366*35238bceSAndroid Build Coastguard Worker         "${GLSL_VERSION_DECL}\n"
367*35238bceSAndroid Build Coastguard Worker         "out highp vec4 v_color;\n"
368*35238bceSAndroid Build Coastguard Worker         // NOTE that core profile requires the gl_PerVertex block to be redeclared
369*35238bceSAndroid Build Coastguard Worker         // in case a separable program is enabled.
370*35238bceSAndroid Build Coastguard Worker         "${GL_POSITION_REDECL}\n"
371*35238bceSAndroid Build Coastguard Worker         "void main()\n"
372*35238bceSAndroid Build Coastguard Worker         "{\n"
373*35238bceSAndroid Build Coastguard Worker         "    gl_Position = vec4(float(gl_VertexID) * 0.5, float(gl_VertexID+1) * 0.5, 0.0, 1.0);\n"
374*35238bceSAndroid Build Coastguard Worker         "    v_color = vec4(float(gl_VertexID), 1.0, 0.0, 1.0);\n"
375*35238bceSAndroid Build Coastguard Worker         "}\n";
376*35238bceSAndroid Build Coastguard Worker     const string fragTemplate = "${GLSL_VERSION_DECL}\n"
377*35238bceSAndroid Build Coastguard Worker                                 "in highp vec4 v_color;\n"
378*35238bceSAndroid Build Coastguard Worker                                 "layout(location=0) out highp vec4 o_color;\n"
379*35238bceSAndroid Build Coastguard Worker                                 "void main()\n"
380*35238bceSAndroid Build Coastguard Worker                                 "{\n"
381*35238bceSAndroid Build Coastguard Worker                                 "    o_color = v_color;\n"
382*35238bceSAndroid Build Coastguard Worker                                 "}\n";
383*35238bceSAndroid Build Coastguard Worker 
384*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
385*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
386*35238bceSAndroid Build Coastguard Worker     glu::Shader vtxShader(m_context.getRenderContext(), glu::SHADERTYPE_VERTEX);
387*35238bceSAndroid Build Coastguard Worker     glu::Shader frgShader(m_context.getRenderContext(), glu::SHADERTYPE_FRAGMENT);
388*35238bceSAndroid Build Coastguard Worker 
389*35238bceSAndroid Build Coastguard Worker     const std::string vStr          = specializeShader(m_context, vtxTemplate.c_str());
390*35238bceSAndroid Build Coastguard Worker     const std::string fStr          = specializeShader(m_context, fragTemplate.c_str());
391*35238bceSAndroid Build Coastguard Worker     const char *const vtxSourcePtr  = vStr.c_str();
392*35238bceSAndroid Build Coastguard Worker     const char *const fragSourcePtr = fStr.c_str();
393*35238bceSAndroid Build Coastguard Worker 
394*35238bceSAndroid Build Coastguard Worker     vtxShader.setSources(1, &vtxSourcePtr, DE_NULL);
395*35238bceSAndroid Build Coastguard Worker     frgShader.setSources(1, &fragSourcePtr, DE_NULL);
396*35238bceSAndroid Build Coastguard Worker 
397*35238bceSAndroid Build Coastguard Worker     vtxShader.compile();
398*35238bceSAndroid Build Coastguard Worker     frgShader.compile();
399*35238bceSAndroid Build Coastguard Worker 
400*35238bceSAndroid Build Coastguard Worker     {
401*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "VtxShader", "Vertex shader");
402*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << vtxShader;
403*35238bceSAndroid Build Coastguard Worker     }
404*35238bceSAndroid Build Coastguard Worker 
405*35238bceSAndroid Build Coastguard Worker     {
406*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "FrgShader", "Fragment shader");
407*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << frgShader;
408*35238bceSAndroid Build Coastguard Worker     }
409*35238bceSAndroid Build Coastguard Worker 
410*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_MSG(vtxShader.getCompileStatus() && frgShader.getCompileStatus(), "failed to build shaders");
411*35238bceSAndroid Build Coastguard Worker 
412*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
413*35238bceSAndroid Build Coastguard Worker 
414*35238bceSAndroid Build Coastguard Worker     {
415*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
416*35238bceSAndroid Build Coastguard Worker         glu::Program program(m_context.getRenderContext());
417*35238bceSAndroid Build Coastguard Worker 
418*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, 0, m_verifier);
419*35238bceSAndroid Build Coastguard Worker     }
420*35238bceSAndroid Build Coastguard Worker 
421*35238bceSAndroid Build Coastguard Worker     {
422*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "SetFalse", "SetFalse");
423*35238bceSAndroid Build Coastguard Worker         glu::Program program(m_context.getRenderContext());
424*35238bceSAndroid Build Coastguard Worker         int linkStatus = 0;
425*35238bceSAndroid Build Coastguard Worker 
426*35238bceSAndroid Build Coastguard Worker         gl.glAttachShader(program.getProgram(), vtxShader.getShader());
427*35238bceSAndroid Build Coastguard Worker         gl.glAttachShader(program.getProgram(), frgShader.getShader());
428*35238bceSAndroid Build Coastguard Worker         gl.glProgramParameteri(program.getProgram(), GL_PROGRAM_SEPARABLE, GL_FALSE);
429*35238bceSAndroid Build Coastguard Worker         gl.glLinkProgram(program.getProgram());
430*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup program");
431*35238bceSAndroid Build Coastguard Worker 
432*35238bceSAndroid Build Coastguard Worker         gl.glGetProgramiv(program.getProgram(), GL_LINK_STATUS, &linkStatus);
433*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.glGetError(), "query link status");
434*35238bceSAndroid Build Coastguard Worker 
435*35238bceSAndroid Build Coastguard Worker         gl.glDetachShader(program.getProgram(), vtxShader.getShader());
436*35238bceSAndroid Build Coastguard Worker         gl.glDetachShader(program.getProgram(), frgShader.getShader());
437*35238bceSAndroid Build Coastguard Worker 
438*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(linkStatus == GL_TRUE, "failed to link program");
439*35238bceSAndroid Build Coastguard Worker 
440*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, 0, m_verifier);
441*35238bceSAndroid Build Coastguard Worker     }
442*35238bceSAndroid Build Coastguard Worker 
443*35238bceSAndroid Build Coastguard Worker     {
444*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "SetTrue", "SetTrue");
445*35238bceSAndroid Build Coastguard Worker         glu::Program program(m_context.getRenderContext());
446*35238bceSAndroid Build Coastguard Worker         int linkStatus = 0;
447*35238bceSAndroid Build Coastguard Worker 
448*35238bceSAndroid Build Coastguard Worker         gl.glAttachShader(program.getProgram(), vtxShader.getShader());
449*35238bceSAndroid Build Coastguard Worker         gl.glAttachShader(program.getProgram(), frgShader.getShader());
450*35238bceSAndroid Build Coastguard Worker         gl.glProgramParameteri(program.getProgram(), GL_PROGRAM_SEPARABLE, GL_TRUE);
451*35238bceSAndroid Build Coastguard Worker         gl.glLinkProgram(program.getProgram());
452*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup program");
453*35238bceSAndroid Build Coastguard Worker 
454*35238bceSAndroid Build Coastguard Worker         gl.glGetProgramiv(program.getProgram(), GL_LINK_STATUS, &linkStatus);
455*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.glGetError(), "query link status");
456*35238bceSAndroid Build Coastguard Worker 
457*35238bceSAndroid Build Coastguard Worker         gl.glDetachShader(program.getProgram(), vtxShader.getShader());
458*35238bceSAndroid Build Coastguard Worker         gl.glDetachShader(program.getProgram(), frgShader.getShader());
459*35238bceSAndroid Build Coastguard Worker 
460*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(linkStatus == GL_TRUE, "failed to link program");
461*35238bceSAndroid Build Coastguard Worker 
462*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_PROGRAM_SEPARABLE, GL_TRUE, m_verifier);
463*35238bceSAndroid Build Coastguard Worker     }
464*35238bceSAndroid Build Coastguard Worker 
465*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
466*35238bceSAndroid Build Coastguard Worker     return STOP;
467*35238bceSAndroid Build Coastguard Worker }
468*35238bceSAndroid Build Coastguard Worker 
469*35238bceSAndroid Build Coastguard Worker class ComputeWorkGroupSizeCase : public TestCase
470*35238bceSAndroid Build Coastguard Worker {
471*35238bceSAndroid Build Coastguard Worker public:
472*35238bceSAndroid Build Coastguard Worker     ComputeWorkGroupSizeCase(Context &context, QueryType verifier, const char *name, const char *desc);
473*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
474*35238bceSAndroid Build Coastguard Worker 
475*35238bceSAndroid Build Coastguard Worker private:
476*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
477*35238bceSAndroid Build Coastguard Worker };
478*35238bceSAndroid Build Coastguard Worker 
ComputeWorkGroupSizeCase(Context & context,QueryType verifier,const char * name,const char * desc)479*35238bceSAndroid Build Coastguard Worker ComputeWorkGroupSizeCase::ComputeWorkGroupSizeCase(Context &context, QueryType verifier, const char *name,
480*35238bceSAndroid Build Coastguard Worker                                                    const char *desc)
481*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
482*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
483*35238bceSAndroid Build Coastguard Worker {
484*35238bceSAndroid Build Coastguard Worker }
485*35238bceSAndroid Build Coastguard Worker 
iterate(void)486*35238bceSAndroid Build Coastguard Worker ComputeWorkGroupSizeCase::IterateResult ComputeWorkGroupSizeCase::iterate(void)
487*35238bceSAndroid Build Coastguard Worker {
488*35238bceSAndroid Build Coastguard Worker     static const char *const s_computeTemplate1D = "${GLSL_VERSION_DECL}\n"
489*35238bceSAndroid Build Coastguard Worker                                                    "layout (local_size_x = 3) in;\n"
490*35238bceSAndroid Build Coastguard Worker                                                    "layout(binding = 0) buffer Output\n"
491*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
492*35238bceSAndroid Build Coastguard Worker                                                    "    highp float val;\n"
493*35238bceSAndroid Build Coastguard Worker                                                    "} sb_out;\n"
494*35238bceSAndroid Build Coastguard Worker                                                    "\n"
495*35238bceSAndroid Build Coastguard Worker                                                    "void main (void)\n"
496*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
497*35238bceSAndroid Build Coastguard Worker                                                    "    sb_out.val = 1.0;\n"
498*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
499*35238bceSAndroid Build Coastguard Worker     static const char *const s_computeTemplate2D = "${GLSL_VERSION_DECL}\n"
500*35238bceSAndroid Build Coastguard Worker                                                    "layout (local_size_x = 3, local_size_y = 2) in;\n"
501*35238bceSAndroid Build Coastguard Worker                                                    "layout(binding = 0) buffer Output\n"
502*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
503*35238bceSAndroid Build Coastguard Worker                                                    "    highp float val;\n"
504*35238bceSAndroid Build Coastguard Worker                                                    "} sb_out;\n"
505*35238bceSAndroid Build Coastguard Worker                                                    "\n"
506*35238bceSAndroid Build Coastguard Worker                                                    "void main (void)\n"
507*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
508*35238bceSAndroid Build Coastguard Worker                                                    "    sb_out.val = 1.0;\n"
509*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
510*35238bceSAndroid Build Coastguard Worker     static const char *const s_computeTemplate3D = "${GLSL_VERSION_DECL}\n"
511*35238bceSAndroid Build Coastguard Worker                                                    "layout (local_size_x = 3, local_size_y = 2, local_size_z = 4) in;\n"
512*35238bceSAndroid Build Coastguard Worker                                                    "layout(binding = 0) buffer Output\n"
513*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
514*35238bceSAndroid Build Coastguard Worker                                                    "    highp float val;\n"
515*35238bceSAndroid Build Coastguard Worker                                                    "} sb_out;\n"
516*35238bceSAndroid Build Coastguard Worker                                                    "\n"
517*35238bceSAndroid Build Coastguard Worker                                                    "void main (void)\n"
518*35238bceSAndroid Build Coastguard Worker                                                    "{\n"
519*35238bceSAndroid Build Coastguard Worker                                                    "    sb_out.val = 1.0;\n"
520*35238bceSAndroid Build Coastguard Worker                                                    "}\n";
521*35238bceSAndroid Build Coastguard Worker 
522*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
523*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
524*35238bceSAndroid Build Coastguard Worker 
525*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
526*35238bceSAndroid Build Coastguard Worker 
527*35238bceSAndroid Build Coastguard Worker     {
528*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "OneDimensional", "1D");
529*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(
530*35238bceSAndroid Build Coastguard Worker                                                                      specializeShader(m_context, s_computeTemplate1D)));
531*35238bceSAndroid Build Coastguard Worker 
532*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
533*35238bceSAndroid Build Coastguard Worker 
534*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "failed to build program");
535*35238bceSAndroid Build Coastguard Worker 
536*35238bceSAndroid Build Coastguard Worker         verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 1, 1),
537*35238bceSAndroid Build Coastguard Worker                                       m_verifier);
538*35238bceSAndroid Build Coastguard Worker     }
539*35238bceSAndroid Build Coastguard Worker 
540*35238bceSAndroid Build Coastguard Worker     {
541*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "TwoDimensional", "2D");
542*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(
543*35238bceSAndroid Build Coastguard Worker                                                                      specializeShader(m_context, s_computeTemplate2D)));
544*35238bceSAndroid Build Coastguard Worker 
545*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
546*35238bceSAndroid Build Coastguard Worker 
547*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "failed to build program");
548*35238bceSAndroid Build Coastguard Worker 
549*35238bceSAndroid Build Coastguard Worker         verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 2, 1),
550*35238bceSAndroid Build Coastguard Worker                                       m_verifier);
551*35238bceSAndroid Build Coastguard Worker     }
552*35238bceSAndroid Build Coastguard Worker 
553*35238bceSAndroid Build Coastguard Worker     {
554*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "TreeDimensional", "3D");
555*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(
556*35238bceSAndroid Build Coastguard Worker                                                                      specializeShader(m_context, s_computeTemplate3D)));
557*35238bceSAndroid Build Coastguard Worker 
558*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
559*35238bceSAndroid Build Coastguard Worker 
560*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "failed to build program");
561*35238bceSAndroid Build Coastguard Worker 
562*35238bceSAndroid Build Coastguard Worker         verifyStateProgramIntegerVec3(result, gl, program.getProgram(), GL_COMPUTE_WORK_GROUP_SIZE, tcu::IVec3(3, 2, 4),
563*35238bceSAndroid Build Coastguard Worker                                       m_verifier);
564*35238bceSAndroid Build Coastguard Worker     }
565*35238bceSAndroid Build Coastguard Worker 
566*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
567*35238bceSAndroid Build Coastguard Worker     return STOP;
568*35238bceSAndroid Build Coastguard Worker }
569*35238bceSAndroid Build Coastguard Worker 
570*35238bceSAndroid Build Coastguard Worker class ActiveAtomicCounterBuffersCase : public TestCase
571*35238bceSAndroid Build Coastguard Worker {
572*35238bceSAndroid Build Coastguard Worker public:
573*35238bceSAndroid Build Coastguard Worker     ActiveAtomicCounterBuffersCase(Context &context, QueryType verifier, const char *name, const char *desc);
574*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
575*35238bceSAndroid Build Coastguard Worker 
576*35238bceSAndroid Build Coastguard Worker private:
577*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
578*35238bceSAndroid Build Coastguard Worker };
579*35238bceSAndroid Build Coastguard Worker 
ActiveAtomicCounterBuffersCase(Context & context,QueryType verifier,const char * name,const char * desc)580*35238bceSAndroid Build Coastguard Worker ActiveAtomicCounterBuffersCase::ActiveAtomicCounterBuffersCase(Context &context, QueryType verifier, const char *name,
581*35238bceSAndroid Build Coastguard Worker                                                                const char *desc)
582*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
583*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
584*35238bceSAndroid Build Coastguard Worker {
585*35238bceSAndroid Build Coastguard Worker }
586*35238bceSAndroid Build Coastguard Worker 
iterate(void)587*35238bceSAndroid Build Coastguard Worker ActiveAtomicCounterBuffersCase::IterateResult ActiveAtomicCounterBuffersCase::iterate(void)
588*35238bceSAndroid Build Coastguard Worker {
589*35238bceSAndroid Build Coastguard Worker     static const char *const s_computeTemplate0 = "${GLSL_VERSION_DECL}\n"
590*35238bceSAndroid Build Coastguard Worker                                                   "layout (local_size_x = 3) in;\n"
591*35238bceSAndroid Build Coastguard Worker                                                   "layout(binding = 0) buffer Output\n"
592*35238bceSAndroid Build Coastguard Worker                                                   "{\n"
593*35238bceSAndroid Build Coastguard Worker                                                   "    highp float val;\n"
594*35238bceSAndroid Build Coastguard Worker                                                   "} sb_out;\n"
595*35238bceSAndroid Build Coastguard Worker                                                   "\n"
596*35238bceSAndroid Build Coastguard Worker                                                   "void main (void)\n"
597*35238bceSAndroid Build Coastguard Worker                                                   "{\n"
598*35238bceSAndroid Build Coastguard Worker                                                   "    sb_out.val = 1.0;\n"
599*35238bceSAndroid Build Coastguard Worker                                                   "}\n";
600*35238bceSAndroid Build Coastguard Worker     static const char *const s_computeTemplate1 = "${GLSL_VERSION_DECL}\n"
601*35238bceSAndroid Build Coastguard Worker                                                   "layout (local_size_x = 3) in;\n"
602*35238bceSAndroid Build Coastguard Worker                                                   "layout(binding = 0) uniform highp atomic_uint u_counters[2];\n"
603*35238bceSAndroid Build Coastguard Worker                                                   "layout(binding = 0) buffer Output\n"
604*35238bceSAndroid Build Coastguard Worker                                                   "{\n"
605*35238bceSAndroid Build Coastguard Worker                                                   "    highp float val;\n"
606*35238bceSAndroid Build Coastguard Worker                                                   "} sb_out;\n"
607*35238bceSAndroid Build Coastguard Worker                                                   "\n"
608*35238bceSAndroid Build Coastguard Worker                                                   "void main (void)\n"
609*35238bceSAndroid Build Coastguard Worker                                                   "{\n"
610*35238bceSAndroid Build Coastguard Worker                                                   "    sb_out.val = float(atomicCounterIncrement(u_counters[0])) + "
611*35238bceSAndroid Build Coastguard Worker                                                   "float(atomicCounterIncrement(u_counters[1]));\n"
612*35238bceSAndroid Build Coastguard Worker                                                   "}\n";
613*35238bceSAndroid Build Coastguard Worker 
614*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
615*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
616*35238bceSAndroid Build Coastguard Worker 
617*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
618*35238bceSAndroid Build Coastguard Worker 
619*35238bceSAndroid Build Coastguard Worker     {
620*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
621*35238bceSAndroid Build Coastguard Worker         glu::Program program(m_context.getRenderContext());
622*35238bceSAndroid Build Coastguard Worker 
623*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 0, m_verifier);
624*35238bceSAndroid Build Coastguard Worker     }
625*35238bceSAndroid Build Coastguard Worker 
626*35238bceSAndroid Build Coastguard Worker     {
627*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "NoBuffers", "No buffers");
628*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(
629*35238bceSAndroid Build Coastguard Worker                                                                      specializeShader(m_context, s_computeTemplate0)));
630*35238bceSAndroid Build Coastguard Worker 
631*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
632*35238bceSAndroid Build Coastguard Worker 
633*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "failed to build program");
634*35238bceSAndroid Build Coastguard Worker 
635*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 0, m_verifier);
636*35238bceSAndroid Build Coastguard Worker     }
637*35238bceSAndroid Build Coastguard Worker 
638*35238bceSAndroid Build Coastguard Worker     {
639*35238bceSAndroid Build Coastguard Worker         const tcu::ScopedLogSection section(m_testCtx.getLog(), "OneBuffer", "One buffer");
640*35238bceSAndroid Build Coastguard Worker         glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources() << glu::ComputeSource(
641*35238bceSAndroid Build Coastguard Worker                                                                      specializeShader(m_context, s_computeTemplate1)));
642*35238bceSAndroid Build Coastguard Worker 
643*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << program;
644*35238bceSAndroid Build Coastguard Worker 
645*35238bceSAndroid Build Coastguard Worker         TCU_CHECK_MSG(program.isOk(), "failed to build program");
646*35238bceSAndroid Build Coastguard Worker 
647*35238bceSAndroid Build Coastguard Worker         verifyStateProgramInteger(result, gl, program.getProgram(), GL_ACTIVE_ATOMIC_COUNTER_BUFFERS, 1, m_verifier);
648*35238bceSAndroid Build Coastguard Worker     }
649*35238bceSAndroid Build Coastguard Worker 
650*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
651*35238bceSAndroid Build Coastguard Worker     return STOP;
652*35238bceSAndroid Build Coastguard Worker }
653*35238bceSAndroid Build Coastguard Worker 
654*35238bceSAndroid Build Coastguard Worker class ProgramLogCase : public TestCase
655*35238bceSAndroid Build Coastguard Worker {
656*35238bceSAndroid Build Coastguard Worker public:
657*35238bceSAndroid Build Coastguard Worker     enum BuildErrorType
658*35238bceSAndroid Build Coastguard Worker     {
659*35238bceSAndroid Build Coastguard Worker         BUILDERROR_VERTEX_FRAGMENT = 0,
660*35238bceSAndroid Build Coastguard Worker         BUILDERROR_COMPUTE,
661*35238bceSAndroid Build Coastguard Worker         BUILDERROR_GEOMETRY,
662*35238bceSAndroid Build Coastguard Worker         BUILDERROR_TESSELLATION,
663*35238bceSAndroid Build Coastguard Worker     };
664*35238bceSAndroid Build Coastguard Worker 
665*35238bceSAndroid Build Coastguard Worker     ProgramLogCase(Context &ctx, const char *name, const char *desc, BuildErrorType errorType);
666*35238bceSAndroid Build Coastguard Worker 
667*35238bceSAndroid Build Coastguard Worker private:
668*35238bceSAndroid Build Coastguard Worker     void init(void);
669*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
670*35238bceSAndroid Build Coastguard Worker     glu::ProgramSources getProgramSources(void) const;
671*35238bceSAndroid Build Coastguard Worker 
672*35238bceSAndroid Build Coastguard Worker     const BuildErrorType m_buildErrorType;
673*35238bceSAndroid Build Coastguard Worker };
674*35238bceSAndroid Build Coastguard Worker 
ProgramLogCase(Context & ctx,const char * name,const char * desc,BuildErrorType errorType)675*35238bceSAndroid Build Coastguard Worker ProgramLogCase::ProgramLogCase(Context &ctx, const char *name, const char *desc, BuildErrorType errorType)
676*35238bceSAndroid Build Coastguard Worker     : TestCase(ctx, name, desc)
677*35238bceSAndroid Build Coastguard Worker     , m_buildErrorType(errorType)
678*35238bceSAndroid Build Coastguard Worker {
679*35238bceSAndroid Build Coastguard Worker }
680*35238bceSAndroid Build Coastguard Worker 
init(void)681*35238bceSAndroid Build Coastguard Worker void ProgramLogCase::init(void)
682*35238bceSAndroid Build Coastguard Worker {
683*35238bceSAndroid Build Coastguard Worker     const bool supportsES32orGL45 = checkSupport(m_context);
684*35238bceSAndroid Build Coastguard Worker 
685*35238bceSAndroid Build Coastguard Worker     switch (m_buildErrorType)
686*35238bceSAndroid Build Coastguard Worker     {
687*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_VERTEX_FRAGMENT:
688*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_COMPUTE:
689*35238bceSAndroid Build Coastguard Worker         break;
690*35238bceSAndroid Build Coastguard Worker 
691*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_GEOMETRY:
692*35238bceSAndroid Build Coastguard Worker         if (!supportsES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader"))
693*35238bceSAndroid Build Coastguard Worker             TCU_THROW(NotSupportedError, "Test requires GL_EXT_geometry_shader extension");
694*35238bceSAndroid Build Coastguard Worker         break;
695*35238bceSAndroid Build Coastguard Worker 
696*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_TESSELLATION:
697*35238bceSAndroid Build Coastguard Worker         if (!supportsES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader"))
698*35238bceSAndroid Build Coastguard Worker             TCU_THROW(NotSupportedError, "Test requires GL_EXT_tessellation_shader extension");
699*35238bceSAndroid Build Coastguard Worker         break;
700*35238bceSAndroid Build Coastguard Worker 
701*35238bceSAndroid Build Coastguard Worker     default:
702*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
703*35238bceSAndroid Build Coastguard Worker         break;
704*35238bceSAndroid Build Coastguard Worker     }
705*35238bceSAndroid Build Coastguard Worker }
706*35238bceSAndroid Build Coastguard Worker 
iterate(void)707*35238bceSAndroid Build Coastguard Worker ProgramLogCase::IterateResult ProgramLogCase::iterate(void)
708*35238bceSAndroid Build Coastguard Worker {
709*35238bceSAndroid Build Coastguard Worker     using gls::StateQueryUtil::StateQueryMemoryWriteGuard;
710*35238bceSAndroid Build Coastguard Worker 
711*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog());
712*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
713*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(m_context.getRenderContext(), getProgramSources());
714*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<glw::GLint> logLen;
715*35238bceSAndroid Build Coastguard Worker 
716*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
717*35238bceSAndroid Build Coastguard Worker 
718*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << tcu::TestLog::Message << "Trying to link a broken program." << tcu::TestLog::EndMessage;
719*35238bceSAndroid Build Coastguard Worker 
720*35238bceSAndroid Build Coastguard Worker     gl.glGetProgramiv(program.getProgram(), GL_INFO_LOG_LENGTH, &logLen);
721*35238bceSAndroid Build Coastguard Worker     logLen.verifyValidity(result);
722*35238bceSAndroid Build Coastguard Worker 
723*35238bceSAndroid Build Coastguard Worker     if (logLen.verifyValidity(result))
724*35238bceSAndroid Build Coastguard Worker         verifyInfoLogQuery(result, gl, logLen, program.getProgram(), &glu::CallLogWrapper::glGetProgramInfoLog,
725*35238bceSAndroid Build Coastguard Worker                            "glGetProgramInfoLog");
726*35238bceSAndroid Build Coastguard Worker 
727*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
728*35238bceSAndroid Build Coastguard Worker     return STOP;
729*35238bceSAndroid Build Coastguard Worker }
730*35238bceSAndroid Build Coastguard Worker 
getProgramSources(void) const731*35238bceSAndroid Build Coastguard Worker glu::ProgramSources ProgramLogCase::getProgramSources(void) const
732*35238bceSAndroid Build Coastguard Worker {
733*35238bceSAndroid Build Coastguard Worker     const char *const vertexTemplate1   = "${GLSL_VERSION_DECL}\n"
734*35238bceSAndroid Build Coastguard Worker                                           "in highp vec4 a_pos;\n"
735*35238bceSAndroid Build Coastguard Worker                                           "uniform highp vec4 u_uniform;\n"
736*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
737*35238bceSAndroid Build Coastguard Worker                                           "{\n"
738*35238bceSAndroid Build Coastguard Worker                                           "    gl_Position = a_pos + u_uniform;\n"
739*35238bceSAndroid Build Coastguard Worker                                           "}\n";
740*35238bceSAndroid Build Coastguard Worker     const char *const vertexTemplate2   = "${GLSL_VERSION_DECL}\n"
741*35238bceSAndroid Build Coastguard Worker                                           "in highp vec4 a_pos;\n"
742*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
743*35238bceSAndroid Build Coastguard Worker                                           "{\n"
744*35238bceSAndroid Build Coastguard Worker                                           "    gl_Position = a_pos;\n"
745*35238bceSAndroid Build Coastguard Worker                                           "}\n";
746*35238bceSAndroid Build Coastguard Worker     const char *const fragmentTemplate1 = "${GLSL_VERSION_DECL}\n"
747*35238bceSAndroid Build Coastguard Worker                                           "in highp vec4 v_missingVar;\n"
748*35238bceSAndroid Build Coastguard Worker                                           "uniform highp int u_uniform;\n"
749*35238bceSAndroid Build Coastguard Worker                                           "layout(location = 0) out mediump vec4 fragColor;\n"
750*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
751*35238bceSAndroid Build Coastguard Worker                                           "{\n"
752*35238bceSAndroid Build Coastguard Worker                                           "    fragColor = v_missingVar + vec4(float(u_uniform));\n"
753*35238bceSAndroid Build Coastguard Worker                                           "}\n";
754*35238bceSAndroid Build Coastguard Worker 
755*35238bceSAndroid Build Coastguard Worker     const char *const fragmentTemplate2 = "${GLSL_VERSION_DECL}\n"
756*35238bceSAndroid Build Coastguard Worker                                           "layout(location = 0) out mediump vec4 fragColor;\n"
757*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
758*35238bceSAndroid Build Coastguard Worker                                           "{\n"
759*35238bceSAndroid Build Coastguard Worker                                           "    fragColor = vec4(1.0);\n"
760*35238bceSAndroid Build Coastguard Worker                                           "}\n";
761*35238bceSAndroid Build Coastguard Worker     const char *const computeTemplate1  = "${GLSL_VERSION_DECL}\n"
762*35238bceSAndroid Build Coastguard Worker                                           "layout (binding = 0) buffer IOBuffer { highp float buf_var; };\n"
763*35238bceSAndroid Build Coastguard Worker                                           "uniform highp vec4 u_uniform;\n"
764*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
765*35238bceSAndroid Build Coastguard Worker                                           "{\n"
766*35238bceSAndroid Build Coastguard Worker                                           "    buf_var = u_uniform.x;\n"
767*35238bceSAndroid Build Coastguard Worker                                           "}\n";
768*35238bceSAndroid Build Coastguard Worker     const char *const geometryTemplate1 =
769*35238bceSAndroid Build Coastguard Worker         "${GLSL_VERSION_DECL}\n"
770*35238bceSAndroid Build Coastguard Worker         "${GEOMETRY_SHADER_REQUIRE}\n"
771*35238bceSAndroid Build Coastguard Worker         "layout(triangles) in;\n"
772*35238bceSAndroid Build Coastguard Worker         "layout(max_vertices=1, points) out;\n"
773*35238bceSAndroid Build Coastguard Worker         "in highp vec4 v_missingVar[];\n"
774*35238bceSAndroid Build Coastguard Worker         "uniform highp int u_uniform;\n"
775*35238bceSAndroid Build Coastguard Worker         "void main()\n"
776*35238bceSAndroid Build Coastguard Worker         "{\n"
777*35238bceSAndroid Build Coastguard Worker         "    gl_Position = gl_in[0].gl_Position + v_missingVar[2] + vec4(float(u_uniform));\n"
778*35238bceSAndroid Build Coastguard Worker         "    EmitVertex();\n"
779*35238bceSAndroid Build Coastguard Worker         "}\n";
780*35238bceSAndroid Build Coastguard Worker     const char *const tessCtrlTemplate1 =
781*35238bceSAndroid Build Coastguard Worker         "${GLSL_VERSION_DECL}\n"
782*35238bceSAndroid Build Coastguard Worker         "${TESSELLATION_SHADER_REQUIRE}\n"
783*35238bceSAndroid Build Coastguard Worker         "layout(vertices=2) out;"
784*35238bceSAndroid Build Coastguard Worker         "patch out highp vec2 vp_var;\n"
785*35238bceSAndroid Build Coastguard Worker         "void main()\n"
786*35238bceSAndroid Build Coastguard Worker         "{\n"
787*35238bceSAndroid Build Coastguard Worker         "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position\n"
788*35238bceSAndroid Build Coastguard Worker         "    gl_TessLevelOuter[0] = 0.8;\n"
789*35238bceSAndroid Build Coastguard Worker         "    gl_TessLevelOuter[1] = 0.8;\n"
790*35238bceSAndroid Build Coastguard Worker         "    if (gl_InvocationID == 0)\n"
791*35238bceSAndroid Build Coastguard Worker         "        vp_var = gl_in[gl_InvocationID].gl_Position.xy;\n"
792*35238bceSAndroid Build Coastguard Worker         "}\n";
793*35238bceSAndroid Build Coastguard Worker     const char *const tessEvalTemplate1 = "${GLSL_VERSION_DECL}\n"
794*35238bceSAndroid Build Coastguard Worker                                           "${TESSELLATION_SHADER_REQUIRE}\n"
795*35238bceSAndroid Build Coastguard Worker                                           "layout(isolines) in;"
796*35238bceSAndroid Build Coastguard Worker                                           "in highp float vp_var[];\n"
797*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
798*35238bceSAndroid Build Coastguard Worker                                           "{\n"
799*35238bceSAndroid Build Coastguard Worker                                           "    gl_Position = gl_in[gl_InvocationID].gl_Position + vec4(vp_var[1]);\n"
800*35238bceSAndroid Build Coastguard Worker                                           "}\n";
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker     switch (m_buildErrorType)
803*35238bceSAndroid Build Coastguard Worker     {
804*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_VERTEX_FRAGMENT:
805*35238bceSAndroid Build Coastguard Worker         return glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, vertexTemplate1))
806*35238bceSAndroid Build Coastguard Worker                                      << glu::FragmentSource(specializeShader(m_context, fragmentTemplate1));
807*35238bceSAndroid Build Coastguard Worker 
808*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_COMPUTE:
809*35238bceSAndroid Build Coastguard Worker         return glu::ProgramSources() << glu::ComputeSource(specializeShader(m_context, computeTemplate1));
810*35238bceSAndroid Build Coastguard Worker 
811*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_GEOMETRY:
812*35238bceSAndroid Build Coastguard Worker         return glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, vertexTemplate1))
813*35238bceSAndroid Build Coastguard Worker                                      << glu::GeometrySource(specializeShader(m_context, geometryTemplate1))
814*35238bceSAndroid Build Coastguard Worker                                      << glu::FragmentSource(specializeShader(m_context, fragmentTemplate2));
815*35238bceSAndroid Build Coastguard Worker 
816*35238bceSAndroid Build Coastguard Worker     case BUILDERROR_TESSELLATION:
817*35238bceSAndroid Build Coastguard Worker         return glu::ProgramSources() << glu::VertexSource(specializeShader(m_context, vertexTemplate2))
818*35238bceSAndroid Build Coastguard Worker                                      << glu::TessellationControlSource(specializeShader(m_context, tessCtrlTemplate1))
819*35238bceSAndroid Build Coastguard Worker                                      << glu::TessellationEvaluationSource(
820*35238bceSAndroid Build Coastguard Worker                                             specializeShader(m_context, tessEvalTemplate1))
821*35238bceSAndroid Build Coastguard Worker                                      << glu::FragmentSource(specializeShader(m_context, fragmentTemplate2));
822*35238bceSAndroid Build Coastguard Worker 
823*35238bceSAndroid Build Coastguard Worker     default:
824*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
825*35238bceSAndroid Build Coastguard Worker         return glu::ProgramSources();
826*35238bceSAndroid Build Coastguard Worker     }
827*35238bceSAndroid Build Coastguard Worker }
828*35238bceSAndroid Build Coastguard Worker 
829*35238bceSAndroid Build Coastguard Worker } // namespace
830*35238bceSAndroid Build Coastguard Worker 
ProgramStateQueryTests(Context & context)831*35238bceSAndroid Build Coastguard Worker ProgramStateQueryTests::ProgramStateQueryTests(Context &context)
832*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "program", "Program State Query tests")
833*35238bceSAndroid Build Coastguard Worker {
834*35238bceSAndroid Build Coastguard Worker }
835*35238bceSAndroid Build Coastguard Worker 
~ProgramStateQueryTests(void)836*35238bceSAndroid Build Coastguard Worker ProgramStateQueryTests::~ProgramStateQueryTests(void)
837*35238bceSAndroid Build Coastguard Worker {
838*35238bceSAndroid Build Coastguard Worker }
839*35238bceSAndroid Build Coastguard Worker 
init(void)840*35238bceSAndroid Build Coastguard Worker void ProgramStateQueryTests::init(void)
841*35238bceSAndroid Build Coastguard Worker {
842*35238bceSAndroid Build Coastguard Worker     static const QueryType intVerifiers[] = {
843*35238bceSAndroid Build Coastguard Worker         QUERY_PROGRAM_INTEGER,
844*35238bceSAndroid Build Coastguard Worker     };
845*35238bceSAndroid Build Coastguard Worker     static const QueryType intVec3Verifiers[] = {
846*35238bceSAndroid Build Coastguard Worker         QUERY_PROGRAM_INTEGER_VEC3,
847*35238bceSAndroid Build Coastguard Worker     };
848*35238bceSAndroid Build Coastguard Worker 
849*35238bceSAndroid Build Coastguard Worker #define FOR_EACH_INT_VERIFIER(X)                                                                 \
850*35238bceSAndroid Build Coastguard Worker     do                                                                                           \
851*35238bceSAndroid Build Coastguard Worker     {                                                                                            \
852*35238bceSAndroid Build Coastguard Worker         for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(intVerifiers); ++verifierNdx) \
853*35238bceSAndroid Build Coastguard Worker         {                                                                                        \
854*35238bceSAndroid Build Coastguard Worker             const char *verifierSuffix = getVerifierSuffix(intVerifiers[verifierNdx]);           \
855*35238bceSAndroid Build Coastguard Worker             const QueryType verifier   = intVerifiers[verifierNdx];                              \
856*35238bceSAndroid Build Coastguard Worker             this->addChild(X);                                                                   \
857*35238bceSAndroid Build Coastguard Worker         }                                                                                        \
858*35238bceSAndroid Build Coastguard Worker     } while (0)
859*35238bceSAndroid Build Coastguard Worker 
860*35238bceSAndroid Build Coastguard Worker #define FOR_EACH_VEC_VERIFIER(X)                                                                     \
861*35238bceSAndroid Build Coastguard Worker     do                                                                                               \
862*35238bceSAndroid Build Coastguard Worker     {                                                                                                \
863*35238bceSAndroid Build Coastguard Worker         for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(intVec3Verifiers); ++verifierNdx) \
864*35238bceSAndroid Build Coastguard Worker         {                                                                                            \
865*35238bceSAndroid Build Coastguard Worker             const char *verifierSuffix = getVerifierSuffix(intVec3Verifiers[verifierNdx]);           \
866*35238bceSAndroid Build Coastguard Worker             const QueryType verifier   = intVec3Verifiers[verifierNdx];                              \
867*35238bceSAndroid Build Coastguard Worker             this->addChild(X);                                                                       \
868*35238bceSAndroid Build Coastguard Worker         }                                                                                            \
869*35238bceSAndroid Build Coastguard Worker     } while (0)
870*35238bceSAndroid Build Coastguard Worker 
871*35238bceSAndroid Build Coastguard Worker     FOR_EACH_INT_VERIFIER(new ProgramSeparableCase(
872*35238bceSAndroid Build Coastguard Worker         m_context, verifier, (std::string("program_separable_") + verifierSuffix).c_str(), "Test PROGRAM_SEPARABLE"));
873*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VEC_VERIFIER(new ComputeWorkGroupSizeCase(
874*35238bceSAndroid Build Coastguard Worker         m_context, verifier, (std::string("compute_work_group_size_") + verifierSuffix).c_str(),
875*35238bceSAndroid Build Coastguard Worker         "Test COMPUTE_WORK_GROUP_SIZE"));
876*35238bceSAndroid Build Coastguard Worker     FOR_EACH_INT_VERIFIER(new ActiveAtomicCounterBuffersCase(
877*35238bceSAndroid Build Coastguard Worker         m_context, verifier, (std::string("active_atomic_counter_buffers_") + verifierSuffix).c_str(),
878*35238bceSAndroid Build Coastguard Worker         "Test ACTIVE_ATOMIC_COUNTER_BUFFERS"));
879*35238bceSAndroid Build Coastguard Worker     FOR_EACH_INT_VERIFIER(new GeometryShaderCase(m_context, verifier,
880*35238bceSAndroid Build Coastguard Worker                                                  (std::string("geometry_shader_state_") + verifierSuffix).c_str(),
881*35238bceSAndroid Build Coastguard Worker                                                  "Test Geometry Shader State"));
882*35238bceSAndroid Build Coastguard Worker     FOR_EACH_INT_VERIFIER(new TessellationShaderCase(
883*35238bceSAndroid Build Coastguard Worker         m_context, verifier, (std::string("tesselation_shader_state_") + verifierSuffix).c_str(),
884*35238bceSAndroid Build Coastguard Worker         "Test Tesselation Shader State"));
885*35238bceSAndroid Build Coastguard Worker 
886*35238bceSAndroid Build Coastguard Worker #undef FOR_EACH_INT_VERIFIER
887*35238bceSAndroid Build Coastguard Worker #undef FOR_EACH_VEC_VERIFIER
888*35238bceSAndroid Build Coastguard Worker 
889*35238bceSAndroid Build Coastguard Worker     // program info log tests
890*35238bceSAndroid Build Coastguard Worker     // \note, there exists similar tests in gles3 module. However, the gles31 could use a different
891*35238bceSAndroid Build Coastguard Worker     //        shader compiler with different INFO_LOG bugs.
892*35238bceSAndroid Build Coastguard Worker     {
893*35238bceSAndroid Build Coastguard Worker         static const struct
894*35238bceSAndroid Build Coastguard Worker         {
895*35238bceSAndroid Build Coastguard Worker             const char *caseName;
896*35238bceSAndroid Build Coastguard Worker             ProgramLogCase::BuildErrorType caseType;
897*35238bceSAndroid Build Coastguard Worker         } shaderTypes[] = {
898*35238bceSAndroid Build Coastguard Worker             {"info_log_vertex_fragment_link_fail", ProgramLogCase::BUILDERROR_VERTEX_FRAGMENT},
899*35238bceSAndroid Build Coastguard Worker             {"info_log_compute_link_fail", ProgramLogCase::BUILDERROR_COMPUTE},
900*35238bceSAndroid Build Coastguard Worker             {"info_log_geometry_link_fail", ProgramLogCase::BUILDERROR_GEOMETRY},
901*35238bceSAndroid Build Coastguard Worker             {"info_log_tessellation_link_fail", ProgramLogCase::BUILDERROR_TESSELLATION},
902*35238bceSAndroid Build Coastguard Worker         };
903*35238bceSAndroid Build Coastguard Worker 
904*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
905*35238bceSAndroid Build Coastguard Worker             addChild(new ProgramLogCase(m_context, shaderTypes[ndx].caseName, "", shaderTypes[ndx].caseType));
906*35238bceSAndroid Build Coastguard Worker     }
907*35238bceSAndroid Build Coastguard Worker }
908*35238bceSAndroid Build Coastguard Worker 
909*35238bceSAndroid Build Coastguard Worker } // namespace Functional
910*35238bceSAndroid Build Coastguard Worker } // namespace gles31
911*35238bceSAndroid Build Coastguard Worker } // namespace deqp
912