xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fNegativeShaderDirectiveTests.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 2016 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 Negative Shader Directive Tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fNegativeShaderDirectiveTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
27*35238bceSAndroid Build Coastguard Worker 
28*35238bceSAndroid Build Coastguard Worker namespace deqp
29*35238bceSAndroid Build Coastguard Worker {
30*35238bceSAndroid Build Coastguard Worker namespace gles31
31*35238bceSAndroid Build Coastguard Worker {
32*35238bceSAndroid Build Coastguard Worker namespace Functional
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker namespace NegativeTestShared
35*35238bceSAndroid Build Coastguard Worker {
36*35238bceSAndroid Build Coastguard Worker namespace
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker enum ExpectResult
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker     EXPECT_RESULT_PASS = 0,
42*35238bceSAndroid Build Coastguard Worker     EXPECT_RESULT_FAIL,
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker     EXPECT_RESULT_LAST
45*35238bceSAndroid Build Coastguard Worker };
46*35238bceSAndroid Build Coastguard Worker 
verifyProgram(NegativeTestContext & ctx,glu::ProgramSources sources,ExpectResult expect)47*35238bceSAndroid Build Coastguard Worker void verifyProgram(NegativeTestContext &ctx, glu::ProgramSources sources, ExpectResult expect)
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(expect >= EXPECT_RESULT_PASS && expect < EXPECT_RESULT_LAST);
50*35238bceSAndroid Build Coastguard Worker 
51*35238bceSAndroid Build Coastguard Worker     tcu::TestLog &log = ctx.getLog();
52*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram program(ctx.getRenderContext(), sources);
53*35238bceSAndroid Build Coastguard Worker     bool testFailed = false;
54*35238bceSAndroid Build Coastguard Worker     std::string message;
55*35238bceSAndroid Build Coastguard Worker 
56*35238bceSAndroid Build Coastguard Worker     log << program;
57*35238bceSAndroid Build Coastguard Worker 
58*35238bceSAndroid Build Coastguard Worker     if (expect == EXPECT_RESULT_PASS)
59*35238bceSAndroid Build Coastguard Worker     {
60*35238bceSAndroid Build Coastguard Worker         testFailed = !program.getProgramInfo().linkOk;
61*35238bceSAndroid Build Coastguard Worker         message    = "Program did not link.";
62*35238bceSAndroid Build Coastguard Worker     }
63*35238bceSAndroid Build Coastguard Worker     else
64*35238bceSAndroid Build Coastguard Worker     {
65*35238bceSAndroid Build Coastguard Worker         testFailed = program.getProgramInfo().linkOk;
66*35238bceSAndroid Build Coastguard Worker         message    = "Program was not expected to link.";
67*35238bceSAndroid Build Coastguard Worker     }
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker     if (testFailed)
70*35238bceSAndroid Build Coastguard Worker     {
71*35238bceSAndroid Build Coastguard Worker         log << tcu::TestLog::Message << message << tcu::TestLog::EndMessage;
72*35238bceSAndroid Build Coastguard Worker         ctx.fail(message);
73*35238bceSAndroid Build Coastguard Worker     }
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker 
verifyShader(NegativeTestContext & ctx,glu::ShaderType shaderType,std::string shaderSource,ExpectResult expect)76*35238bceSAndroid Build Coastguard Worker void verifyShader(NegativeTestContext &ctx, glu::ShaderType shaderType, std::string shaderSource, ExpectResult expect)
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(expect >= EXPECT_RESULT_PASS && expect < EXPECT_RESULT_LAST);
79*35238bceSAndroid Build Coastguard Worker 
80*35238bceSAndroid Build Coastguard Worker     tcu::TestLog &log        = ctx.getLog();
81*35238bceSAndroid Build Coastguard Worker     bool testFailed          = false;
82*35238bceSAndroid Build Coastguard Worker     const char *const source = shaderSource.c_str();
83*35238bceSAndroid Build Coastguard Worker     const int length         = (int)shaderSource.size();
84*35238bceSAndroid Build Coastguard Worker     glu::Shader shader(ctx.getRenderContext(), shaderType);
85*35238bceSAndroid Build Coastguard Worker     std::string message;
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker     shader.setSources(1, &source, &length);
88*35238bceSAndroid Build Coastguard Worker     shader.compile();
89*35238bceSAndroid Build Coastguard Worker 
90*35238bceSAndroid Build Coastguard Worker     log << shader;
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker     if (expect == EXPECT_RESULT_PASS)
93*35238bceSAndroid Build Coastguard Worker     {
94*35238bceSAndroid Build Coastguard Worker         testFailed = !shader.getCompileStatus();
95*35238bceSAndroid Build Coastguard Worker         message    = "Shader did not compile.";
96*35238bceSAndroid Build Coastguard Worker     }
97*35238bceSAndroid Build Coastguard Worker     else
98*35238bceSAndroid Build Coastguard Worker     {
99*35238bceSAndroid Build Coastguard Worker         testFailed = shader.getCompileStatus();
100*35238bceSAndroid Build Coastguard Worker         message    = "Shader was not expected to compile.";
101*35238bceSAndroid Build Coastguard Worker     }
102*35238bceSAndroid Build Coastguard Worker 
103*35238bceSAndroid Build Coastguard Worker     if (testFailed)
104*35238bceSAndroid Build Coastguard Worker     {
105*35238bceSAndroid Build Coastguard Worker         log << tcu::TestLog::Message << message << tcu::TestLog::EndMessage;
106*35238bceSAndroid Build Coastguard Worker         ctx.fail(message);
107*35238bceSAndroid Build Coastguard Worker     }
108*35238bceSAndroid Build Coastguard Worker }
109*35238bceSAndroid Build Coastguard Worker 
primitive_bounding_box(NegativeTestContext & ctx)110*35238bceSAndroid Build Coastguard Worker void primitive_bounding_box(NegativeTestContext &ctx)
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker     if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_CONTROL))
113*35238bceSAndroid Build Coastguard Worker     {
114*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_EXT_primitive_bounding_box features require enabling the extension in 310 es shaders.");
115*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
116*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
117*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
118*35238bceSAndroid Build Coastguard Worker                   "{\n"
119*35238bceSAndroid Build Coastguard Worker                   "    gl_BoundingBoxEXT[0] = vec4(0.0, 0.0, 0.0, 0.0);\n"
120*35238bceSAndroid Build Coastguard Worker                   "    gl_BoundingBoxEXT[1] = vec4(1.0, 1.0, 1.0, 1.0);\n"
121*35238bceSAndroid Build Coastguard Worker                   "}\n";
122*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, source.str(), EXPECT_RESULT_FAIL);
123*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
124*35238bceSAndroid Build Coastguard Worker     }
125*35238bceSAndroid Build Coastguard Worker 
126*35238bceSAndroid Build Coastguard Worker     if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
127*35238bceSAndroid Build Coastguard Worker     {
128*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("gl_BoundingBox does not require the OES/EXT suffix in a 320 es shader.");
129*35238bceSAndroid Build Coastguard Worker         {
130*35238bceSAndroid Build Coastguard Worker             const std::string source = "#version 320 es\n"
131*35238bceSAndroid Build Coastguard Worker                                        "layout(vertices = 3) out;\n"
132*35238bceSAndroid Build Coastguard Worker                                        "void main()\n"
133*35238bceSAndroid Build Coastguard Worker                                        "{\n"
134*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[0] = vec4(0.0, 0.0, 0.0, 0.0);\n"
135*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[1] = vec4(0.0, 0.0, 0.0, 0.0);\n"
136*35238bceSAndroid Build Coastguard Worker                                        "}\n";
137*35238bceSAndroid Build Coastguard Worker             verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, source, EXPECT_RESULT_PASS);
138*35238bceSAndroid Build Coastguard Worker         }
139*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
140*35238bceSAndroid Build Coastguard Worker 
141*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("Invalid index used when assigning to gl_BoundingBox in 320 es shader.");
142*35238bceSAndroid Build Coastguard Worker         {
143*35238bceSAndroid Build Coastguard Worker             const std::string source = "#version 320 es\n"
144*35238bceSAndroid Build Coastguard Worker                                        "layout(vertices = 3) out;\n"
145*35238bceSAndroid Build Coastguard Worker                                        "void main()\n"
146*35238bceSAndroid Build Coastguard Worker                                        "{\n"
147*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[0] = vec4(0.0, 0.0, 0.0, 0.0);\n"
148*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[2] = vec4(0.0, 0.0, 0.0, 0.0);\n"
149*35238bceSAndroid Build Coastguard Worker                                        "}\n";
150*35238bceSAndroid Build Coastguard Worker             verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, source, EXPECT_RESULT_FAIL);
151*35238bceSAndroid Build Coastguard Worker         }
152*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("Invalid type assignment to per-patch output array in 320 es shader.");
155*35238bceSAndroid Build Coastguard Worker         {
156*35238bceSAndroid Build Coastguard Worker             const std::string source = "#version 320 es\n"
157*35238bceSAndroid Build Coastguard Worker                                        "layout(vertices = 3) out;\n"
158*35238bceSAndroid Build Coastguard Worker                                        "void main()\n"
159*35238bceSAndroid Build Coastguard Worker                                        "{\n"
160*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[0] = ivec4(0, 0, 0, 0);\n"
161*35238bceSAndroid Build Coastguard Worker                                        "    gl_BoundingBox[1] = ivec4(0, 0, 0, 0);\n"
162*35238bceSAndroid Build Coastguard Worker                                        "}\n";
163*35238bceSAndroid Build Coastguard Worker             verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, source, EXPECT_RESULT_FAIL);
164*35238bceSAndroid Build Coastguard Worker         }
165*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
166*35238bceSAndroid Build Coastguard Worker     }
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker 
blend_equation_advanced(NegativeTestContext & ctx)169*35238bceSAndroid Build Coastguard Worker void blend_equation_advanced(NegativeTestContext &ctx)
170*35238bceSAndroid Build Coastguard Worker {
171*35238bceSAndroid Build Coastguard Worker     static const char *const s_qualifiers[] = {
172*35238bceSAndroid Build Coastguard Worker         "blend_support_multiply",       "blend_support_screen",    "blend_support_overlay",
173*35238bceSAndroid Build Coastguard Worker         "blend_support_darken",         "blend_support_lighten",   "blend_support_colordodge",
174*35238bceSAndroid Build Coastguard Worker         "blend_support_colorburn",      "blend_support_hardlight", "blend_support_softlight",
175*35238bceSAndroid Build Coastguard Worker         "blend_support_difference",     "blend_support_exclusion", "blend_support_hsl_hue",
176*35238bceSAndroid Build Coastguard Worker         "blend_support_hsl_saturation", "blend_support_hsl_color", "blend_support_hsl_luminosity",
177*35238bceSAndroid Build Coastguard Worker     };
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_KHR_blend_equation_advanced features require enabling the extension in 310 es shaders.");
180*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_qualifiers); ++ndx)
181*35238bceSAndroid Build Coastguard Worker     {
182*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
183*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
184*35238bceSAndroid Build Coastguard Worker                   "layout("
185*35238bceSAndroid Build Coastguard Worker                << s_qualifiers[ndx]
186*35238bceSAndroid Build Coastguard Worker                << ") out;\n"
187*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
188*35238bceSAndroid Build Coastguard Worker                   "{\n"
189*35238bceSAndroid Build Coastguard Worker                   "}\n";
190*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
191*35238bceSAndroid Build Coastguard Worker     }
192*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
193*35238bceSAndroid Build Coastguard Worker }
194*35238bceSAndroid Build Coastguard Worker 
sample_variables(NegativeTestContext & ctx)195*35238bceSAndroid Build Coastguard Worker void sample_variables(NegativeTestContext &ctx)
196*35238bceSAndroid Build Coastguard Worker {
197*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError,
198*35238bceSAndroid Build Coastguard Worker                         contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
199*35238bceSAndroid Build Coastguard Worker                             contextSupports(ctx.getRenderContext().getType(), glu::ApiType::core(4, 5)),
200*35238bceSAndroid Build Coastguard Worker                         "Test requires a context version 3.2 or higher.");
201*35238bceSAndroid Build Coastguard Worker 
202*35238bceSAndroid Build Coastguard Worker     static const char *const s_tests[] = {
203*35238bceSAndroid Build Coastguard Worker         "int sampleId = gl_SampleID;",
204*35238bceSAndroid Build Coastguard Worker         "vec2 samplePos = gl_SamplePosition;",
205*35238bceSAndroid Build Coastguard Worker         "int sampleMaskIn0 = gl_SampleMaskIn[0];",
206*35238bceSAndroid Build Coastguard Worker         "int sampleMask0 = gl_SampleMask[0];",
207*35238bceSAndroid Build Coastguard Worker         "int numSamples = gl_NumSamples;",
208*35238bceSAndroid Build Coastguard Worker     };
209*35238bceSAndroid Build Coastguard Worker 
210*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_OES_sample_variables features require enabling the extension in 310 es shaders.");
211*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_tests); ++ndx)
212*35238bceSAndroid Build Coastguard Worker     {
213*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
214*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
215*35238bceSAndroid Build Coastguard Worker                   "precision mediump float;\n"
216*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
217*35238bceSAndroid Build Coastguard Worker                   "{\n"
218*35238bceSAndroid Build Coastguard Worker                   "    "
219*35238bceSAndroid Build Coastguard Worker                << s_tests[ndx]
220*35238bceSAndroid Build Coastguard Worker                << "\n"
221*35238bceSAndroid Build Coastguard Worker                   "}\n";
222*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
223*35238bceSAndroid Build Coastguard Worker     }
224*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
225*35238bceSAndroid Build Coastguard Worker }
226*35238bceSAndroid Build Coastguard Worker 
shader_image_atomic(NegativeTestContext & ctx)227*35238bceSAndroid Build Coastguard Worker void shader_image_atomic(NegativeTestContext &ctx)
228*35238bceSAndroid Build Coastguard Worker {
229*35238bceSAndroid Build Coastguard Worker     static const char *const s_tests[] = {
230*35238bceSAndroid Build Coastguard Worker         "imageAtomicAdd(u_image, ivec2(1, 1), 1u);",      "imageAtomicMin(u_image, ivec2(1, 1), 1u);",
231*35238bceSAndroid Build Coastguard Worker         "imageAtomicMax(u_image, ivec2(1, 1), 1u);",      "imageAtomicAnd(u_image, ivec2(1, 1), 1u);",
232*35238bceSAndroid Build Coastguard Worker         "imageAtomicOr(u_image, ivec2(1, 1), 1u);",       "imageAtomicXor(u_image, ivec2(1, 1), 1u);",
233*35238bceSAndroid Build Coastguard Worker         "imageAtomicExchange(u_image, ivec2(1, 1), 1u);", "imageAtomicCompSwap(u_image, ivec2(1, 1), 1u, 1u);",
234*35238bceSAndroid Build Coastguard Worker     };
235*35238bceSAndroid Build Coastguard Worker 
236*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_OES_shader_image_atomic features require enabling the extension in 310 es shaders.");
237*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_tests); ++ndx)
238*35238bceSAndroid Build Coastguard Worker     {
239*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
240*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
241*35238bceSAndroid Build Coastguard Worker                   "layout(binding=0, r32ui) coherent uniform highp uimage2D u_image;\n"
242*35238bceSAndroid Build Coastguard Worker                   "precision mediump float;\n"
243*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
244*35238bceSAndroid Build Coastguard Worker                   "{\n"
245*35238bceSAndroid Build Coastguard Worker                   "    "
246*35238bceSAndroid Build Coastguard Worker                << s_tests[ndx]
247*35238bceSAndroid Build Coastguard Worker                << "\n"
248*35238bceSAndroid Build Coastguard Worker                   "}\n";
249*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
250*35238bceSAndroid Build Coastguard Worker     }
251*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
252*35238bceSAndroid Build Coastguard Worker }
253*35238bceSAndroid Build Coastguard Worker 
shader_multisample_interpolation(NegativeTestContext & ctx)254*35238bceSAndroid Build Coastguard Worker void shader_multisample_interpolation(NegativeTestContext &ctx)
255*35238bceSAndroid Build Coastguard Worker {
256*35238bceSAndroid Build Coastguard Worker     static const char *const s_sampleTests[] = {"sample in highp float v_var;", "sample out highp float v_var;"};
257*35238bceSAndroid Build Coastguard Worker 
258*35238bceSAndroid Build Coastguard Worker     static const char *const s_interpolateAtTests[] = {"interpolateAtCentroid(interpolant);",
259*35238bceSAndroid Build Coastguard Worker                                                        "interpolateAtSample(interpolant, 1);",
260*35238bceSAndroid Build Coastguard Worker                                                        "interpolateAtOffset(interpolant, vec2(1.0, 0.0));"};
261*35238bceSAndroid Build Coastguard Worker 
262*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
263*35238bceSAndroid Build Coastguard Worker         "GL_OES_shader_multisample_interpolation features require enabling the extension in 310 es shaders.");
264*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("Test sample in/out qualifiers.");
265*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_sampleTests); ++ndx)
266*35238bceSAndroid Build Coastguard Worker     {
267*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
268*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
269*35238bceSAndroid Build Coastguard Worker                   "    "
270*35238bceSAndroid Build Coastguard Worker                << s_sampleTests[ndx]
271*35238bceSAndroid Build Coastguard Worker                << "\n"
272*35238bceSAndroid Build Coastguard Worker                   "precision mediump float;\n"
273*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
274*35238bceSAndroid Build Coastguard Worker                   "{\n"
275*35238bceSAndroid Build Coastguard Worker                   "}\n";
276*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
277*35238bceSAndroid Build Coastguard Worker     }
278*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
279*35238bceSAndroid Build Coastguard Worker 
280*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("Test interpolateAt* functions.");
281*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_sampleTests); ++ndx)
282*35238bceSAndroid Build Coastguard Worker     {
283*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
284*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
285*35238bceSAndroid Build Coastguard Worker                   "in mediump float interpolant;\n"
286*35238bceSAndroid Build Coastguard Worker                   "precision mediump float;\n"
287*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
288*35238bceSAndroid Build Coastguard Worker                   "{\n"
289*35238bceSAndroid Build Coastguard Worker                   "    "
290*35238bceSAndroid Build Coastguard Worker                << s_interpolateAtTests[ndx]
291*35238bceSAndroid Build Coastguard Worker                << "\n"
292*35238bceSAndroid Build Coastguard Worker                   "}\n";
293*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
294*35238bceSAndroid Build Coastguard Worker     }
295*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
296*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
297*35238bceSAndroid Build Coastguard Worker }
298*35238bceSAndroid Build Coastguard Worker 
texture_storage_multisample_2d_array(NegativeTestContext & ctx)299*35238bceSAndroid Build Coastguard Worker void texture_storage_multisample_2d_array(NegativeTestContext &ctx)
300*35238bceSAndroid Build Coastguard Worker {
301*35238bceSAndroid Build Coastguard Worker     static const char *const s_samplerTypeTests[] = {
302*35238bceSAndroid Build Coastguard Worker         "uniform mediump sampler2DMSArray u_sampler;",
303*35238bceSAndroid Build Coastguard Worker         "uniform mediump isampler2DMSArray u_sampler;",
304*35238bceSAndroid Build Coastguard Worker         "uniform mediump usampler2DMSArray u_sampler;",
305*35238bceSAndroid Build Coastguard Worker     };
306*35238bceSAndroid Build Coastguard Worker 
307*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
308*35238bceSAndroid Build Coastguard Worker         "GL_OES_texture_storage_multisample_2d_array features require enabling the extension in 310 es shaders.");
309*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerTypeTests); ++ndx)
310*35238bceSAndroid Build Coastguard Worker     {
311*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
312*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
313*35238bceSAndroid Build Coastguard Worker                   "    "
314*35238bceSAndroid Build Coastguard Worker                << s_samplerTypeTests[ndx]
315*35238bceSAndroid Build Coastguard Worker                << "\n"
316*35238bceSAndroid Build Coastguard Worker                   "precision mediump float;\n"
317*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
318*35238bceSAndroid Build Coastguard Worker                   "{\n"
319*35238bceSAndroid Build Coastguard Worker                   "}\n";
320*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
321*35238bceSAndroid Build Coastguard Worker     }
322*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker 
geometry_shader(NegativeTestContext & ctx)325*35238bceSAndroid Build Coastguard Worker void geometry_shader(NegativeTestContext &ctx)
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker     if (ctx.isShaderSupported(glu::SHADERTYPE_GEOMETRY))
328*35238bceSAndroid Build Coastguard Worker     {
329*35238bceSAndroid Build Coastguard Worker         const std::string simpleVtxFrag = "#version 310 es\n"
330*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
331*35238bceSAndroid Build Coastguard Worker                                           "{\n"
332*35238bceSAndroid Build Coastguard Worker                                           "}\n";
333*35238bceSAndroid Build Coastguard Worker         const std::string geometry      = "#version 310 es\n"
334*35238bceSAndroid Build Coastguard Worker                                           "layout(points, invocations = 1) in;\n"
335*35238bceSAndroid Build Coastguard Worker                                           "layout(points, max_vertices = 3) out;\n"
336*35238bceSAndroid Build Coastguard Worker                                           "precision mediump float;\n"
337*35238bceSAndroid Build Coastguard Worker                                           "void main()\n"
338*35238bceSAndroid Build Coastguard Worker                                           "{\n"
339*35238bceSAndroid Build Coastguard Worker                                           "    EmitVertex();\n"
340*35238bceSAndroid Build Coastguard Worker                                           "    EndPrimitive();\n"
341*35238bceSAndroid Build Coastguard Worker                                           "}\n";
342*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_EXT_geometry_shader features require enabling the extension in 310 es shaders.");
343*35238bceSAndroid Build Coastguard Worker         verifyProgram(ctx,
344*35238bceSAndroid Build Coastguard Worker                       glu::ProgramSources() << glu::VertexSource(simpleVtxFrag) << glu::GeometrySource(geometry)
345*35238bceSAndroid Build Coastguard Worker                                             << glu::FragmentSource(simpleVtxFrag),
346*35238bceSAndroid Build Coastguard Worker                       EXPECT_RESULT_FAIL);
347*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
348*35238bceSAndroid Build Coastguard Worker     }
349*35238bceSAndroid Build Coastguard Worker }
350*35238bceSAndroid Build Coastguard Worker 
gpu_shader_5(NegativeTestContext & ctx)351*35238bceSAndroid Build Coastguard Worker void gpu_shader_5(NegativeTestContext &ctx)
352*35238bceSAndroid Build Coastguard Worker {
353*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_EXT_gpu_shader5 features require enabling the extension in 310 es shaders.");
354*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("Testing the precise qualifier.");
355*35238bceSAndroid Build Coastguard Worker     {
356*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
357*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
358*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
359*35238bceSAndroid Build Coastguard Worker                   "{\n"
360*35238bceSAndroid Build Coastguard Worker                   "    int low = 0;\n"
361*35238bceSAndroid Build Coastguard Worker                   "    int high = 10;\n"
362*35238bceSAndroid Build Coastguard Worker                   "    precise int middle = low + ((high - low) / 2);\n"
363*35238bceSAndroid Build Coastguard Worker                   "}\n";
364*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
365*35238bceSAndroid Build Coastguard Worker     }
366*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
367*35238bceSAndroid Build Coastguard Worker 
368*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("Testing fused multiply-add.");
369*35238bceSAndroid Build Coastguard Worker     {
370*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
371*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
372*35238bceSAndroid Build Coastguard Worker                   "in mediump float v_var;"
373*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
374*35238bceSAndroid Build Coastguard Worker                   "{\n"
375*35238bceSAndroid Build Coastguard Worker                   "    float fmaResult = fma(v_var, v_var, v_var);"
376*35238bceSAndroid Build Coastguard Worker                   "}\n";
377*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
378*35238bceSAndroid Build Coastguard Worker     }
379*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("Testing textureGatherOffsets.");
382*35238bceSAndroid Build Coastguard Worker     {
383*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
384*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
385*35238bceSAndroid Build Coastguard Worker                   "uniform mediump sampler2D u_tex;\n"
386*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
387*35238bceSAndroid Build Coastguard Worker                   "{\n"
388*35238bceSAndroid Build Coastguard Worker                   "    highp vec2 coords = vec2(0.0, 1.0);\n"
389*35238bceSAndroid Build Coastguard Worker                   "    const ivec2 offsets[4] = ivec2[](ivec2(0,0), ivec2(1, 0), ivec2(0, 1), ivec2(1, 1));\n"
390*35238bceSAndroid Build Coastguard Worker                   "    textureGatherOffsets(u_tex, coords, offsets);\n"
391*35238bceSAndroid Build Coastguard Worker                   "}\n";
392*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
393*35238bceSAndroid Build Coastguard Worker     }
394*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
395*35238bceSAndroid Build Coastguard Worker 
396*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
397*35238bceSAndroid Build Coastguard Worker }
398*35238bceSAndroid Build Coastguard Worker 
shader_io_blocks(NegativeTestContext & ctx)399*35238bceSAndroid Build Coastguard Worker void shader_io_blocks(NegativeTestContext &ctx)
400*35238bceSAndroid Build Coastguard Worker {
401*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_EXT_shader_io_blocks features require enabling the extension in 310 es shaders.");
402*35238bceSAndroid Build Coastguard Worker     {
403*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
404*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
405*35238bceSAndroid Build Coastguard Worker                   "in Data\n"
406*35238bceSAndroid Build Coastguard Worker                   "{\n"
407*35238bceSAndroid Build Coastguard Worker                   "    mediump vec3 a;\n"
408*35238bceSAndroid Build Coastguard Worker                   "} data;\n"
409*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
410*35238bceSAndroid Build Coastguard Worker                   "{\n"
411*35238bceSAndroid Build Coastguard Worker                   "}\n";
412*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
413*35238bceSAndroid Build Coastguard Worker     }
414*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker 
tessellation_shader(NegativeTestContext & ctx)417*35238bceSAndroid Build Coastguard Worker void tessellation_shader(NegativeTestContext &ctx)
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker     if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_CONTROL))
420*35238bceSAndroid Build Coastguard Worker     {
421*35238bceSAndroid Build Coastguard Worker         const std::string simpleVtxFrag  = "#version 310 es\n"
422*35238bceSAndroid Build Coastguard Worker                                            "void main()\n"
423*35238bceSAndroid Build Coastguard Worker                                            "{\n"
424*35238bceSAndroid Build Coastguard Worker                                            "}\n";
425*35238bceSAndroid Build Coastguard Worker         const std::string tessControl    = "#version 310 es\n"
426*35238bceSAndroid Build Coastguard Worker                                            "layout(vertices = 3) out;\n"
427*35238bceSAndroid Build Coastguard Worker                                            "void main()\n"
428*35238bceSAndroid Build Coastguard Worker                                            "{\n"
429*35238bceSAndroid Build Coastguard Worker                                            "}\n";
430*35238bceSAndroid Build Coastguard Worker         const std::string tessEvaluation = "#version 310 es\n"
431*35238bceSAndroid Build Coastguard Worker                                            "layout(triangles, equal_spacing, cw) in;\n"
432*35238bceSAndroid Build Coastguard Worker                                            "void main()\n"
433*35238bceSAndroid Build Coastguard Worker                                            "{\n"
434*35238bceSAndroid Build Coastguard Worker                                            "}\n";
435*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_EXT_tessellation_shader features require enabling the extension in 310 es shaders.");
436*35238bceSAndroid Build Coastguard Worker         glu::ProgramSources sources;
437*35238bceSAndroid Build Coastguard Worker         sources << glu::VertexSource(simpleVtxFrag) << glu::TessellationControlSource(tessControl)
438*35238bceSAndroid Build Coastguard Worker                 << glu::TessellationEvaluationSource(tessEvaluation) << glu::FragmentSource(simpleVtxFrag);
439*35238bceSAndroid Build Coastguard Worker         verifyProgram(ctx, sources, EXPECT_RESULT_FAIL);
440*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
441*35238bceSAndroid Build Coastguard Worker     }
442*35238bceSAndroid Build Coastguard Worker }
443*35238bceSAndroid Build Coastguard Worker 
texture_buffer(NegativeTestContext & ctx)444*35238bceSAndroid Build Coastguard Worker void texture_buffer(NegativeTestContext &ctx)
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker     static const char *const s_samplerBufferTypes[] = {"uniform mediump samplerBuffer",
447*35238bceSAndroid Build Coastguard Worker                                                        "uniform mediump isamplerBuffer",
448*35238bceSAndroid Build Coastguard Worker                                                        "uniform mediump usamplerBuffer",
449*35238bceSAndroid Build Coastguard Worker                                                        "layout(rgba32f) uniform mediump writeonly imageBuffer",
450*35238bceSAndroid Build Coastguard Worker                                                        "layout(rgba32i) uniform mediump writeonly iimageBuffer",
451*35238bceSAndroid Build Coastguard Worker                                                        "layout(rgba32ui) uniform mediump writeonly uimageBuffer"};
452*35238bceSAndroid Build Coastguard Worker 
453*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_EXT_texture_buffer features require enabling the extension in 310 es shaders.");
454*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerBufferTypes); ++ndx)
455*35238bceSAndroid Build Coastguard Worker     {
456*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
457*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
458*35238bceSAndroid Build Coastguard Worker                   ""
459*35238bceSAndroid Build Coastguard Worker                << s_samplerBufferTypes[ndx]
460*35238bceSAndroid Build Coastguard Worker                << " u_buffer;\n"
461*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
462*35238bceSAndroid Build Coastguard Worker                   "{\n"
463*35238bceSAndroid Build Coastguard Worker                   "}\n";
464*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
465*35238bceSAndroid Build Coastguard Worker     }
466*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
467*35238bceSAndroid Build Coastguard Worker }
468*35238bceSAndroid Build Coastguard Worker 
texture_cube_map_array(NegativeTestContext & ctx)469*35238bceSAndroid Build Coastguard Worker void texture_cube_map_array(NegativeTestContext &ctx)
470*35238bceSAndroid Build Coastguard Worker {
471*35238bceSAndroid Build Coastguard Worker     static const char *const s_samplerCubeArrayTypes[] = {"uniform mediump samplerCubeArray",
472*35238bceSAndroid Build Coastguard Worker                                                           "uniform mediump isamplerCubeArray",
473*35238bceSAndroid Build Coastguard Worker                                                           "uniform mediump usamplerCubeArray",
474*35238bceSAndroid Build Coastguard Worker                                                           "uniform mediump samplerCubeArrayShadow",
475*35238bceSAndroid Build Coastguard Worker                                                           "layout(rgba32f) uniform mediump writeonly imageCubeArray",
476*35238bceSAndroid Build Coastguard Worker                                                           "layout(rgba32i) uniform mediump writeonly iimageCubeArray",
477*35238bceSAndroid Build Coastguard Worker                                                           "layout(rgba32ui) uniform mediump writeonly uimageCubeArray"};
478*35238bceSAndroid Build Coastguard Worker 
479*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_EXT_texture_cube_map_array features require enabling the extension in 310 es shaders.");
480*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerCubeArrayTypes); ++ndx)
481*35238bceSAndroid Build Coastguard Worker     {
482*35238bceSAndroid Build Coastguard Worker         std::ostringstream source;
483*35238bceSAndroid Build Coastguard Worker         source << "#version 310 es\n"
484*35238bceSAndroid Build Coastguard Worker                   ""
485*35238bceSAndroid Build Coastguard Worker                << s_samplerCubeArrayTypes[ndx]
486*35238bceSAndroid Build Coastguard Worker                << " u_cube;\n"
487*35238bceSAndroid Build Coastguard Worker                   "void main()\n"
488*35238bceSAndroid Build Coastguard Worker                   "{\n"
489*35238bceSAndroid Build Coastguard Worker                   "}\n";
490*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
491*35238bceSAndroid Build Coastguard Worker     }
492*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
493*35238bceSAndroid Build Coastguard Worker }
494*35238bceSAndroid Build Coastguard Worker 
executeAccessingBoundingBoxType(NegativeTestContext & ctx,const std::string builtInTypeName,glu::GLSLVersion glslVersion)495*35238bceSAndroid Build Coastguard Worker void executeAccessingBoundingBoxType(NegativeTestContext &ctx, const std::string builtInTypeName,
496*35238bceSAndroid Build Coastguard Worker                                      glu::GLSLVersion glslVersion)
497*35238bceSAndroid Build Coastguard Worker {
498*35238bceSAndroid Build Coastguard Worker     std::ostringstream sourceStream;
499*35238bceSAndroid Build Coastguard Worker     std::string version;
500*35238bceSAndroid Build Coastguard Worker     std::string extensionPrim;
501*35238bceSAndroid Build Coastguard Worker     std::string extensionTess;
502*35238bceSAndroid Build Coastguard Worker 
503*35238bceSAndroid Build Coastguard Worker     if (glslVersion == glu::GLSL_VERSION_310_ES)
504*35238bceSAndroid Build Coastguard Worker     {
505*35238bceSAndroid Build Coastguard Worker         version       = "#version 310 es\n";
506*35238bceSAndroid Build Coastguard Worker         extensionPrim = "#extension GL_EXT_primitive_bounding_box : require\n";
507*35238bceSAndroid Build Coastguard Worker         extensionTess = "#extension GL_EXT_tessellation_shader : require\n";
508*35238bceSAndroid Build Coastguard Worker     }
509*35238bceSAndroid Build Coastguard Worker     else if (glslVersion >= glu::GLSL_VERSION_320_ES)
510*35238bceSAndroid Build Coastguard Worker     {
511*35238bceSAndroid Build Coastguard Worker         version       = "#version 320 es\n";
512*35238bceSAndroid Build Coastguard Worker         extensionPrim = "";
513*35238bceSAndroid Build Coastguard Worker         extensionTess = "";
514*35238bceSAndroid Build Coastguard Worker     }
515*35238bceSAndroid Build Coastguard Worker     else
516*35238bceSAndroid Build Coastguard Worker     {
517*35238bceSAndroid Build Coastguard Worker         DE_FATAL("error: context below 3.1 and not supported");
518*35238bceSAndroid Build Coastguard Worker     }
519*35238bceSAndroid Build Coastguard Worker 
520*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in vertex shader");
521*35238bceSAndroid Build Coastguard Worker     sourceStream << version << extensionPrim << "void main()\n"
522*35238bceSAndroid Build Coastguard Worker                  << "{\n"
523*35238bceSAndroid Build Coastguard Worker                  << "    " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
524*35238bceSAndroid Build Coastguard Worker                  << "    gl_Position = " + builtInTypeName + "[0];\n"
525*35238bceSAndroid Build Coastguard Worker                  << "}\n";
526*35238bceSAndroid Build Coastguard Worker     verifyShader(ctx, glu::SHADERTYPE_VERTEX, sourceStream.str(), EXPECT_RESULT_FAIL);
527*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
528*35238bceSAndroid Build Coastguard Worker 
529*35238bceSAndroid Build Coastguard Worker     sourceStream.str(std::string());
530*35238bceSAndroid Build Coastguard Worker 
531*35238bceSAndroid Build Coastguard Worker     if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_EVALUATION))
532*35238bceSAndroid Build Coastguard Worker     {
533*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" +
534*35238bceSAndroid Build Coastguard Worker                          " in tessellation evaluation shader");
535*35238bceSAndroid Build Coastguard Worker         sourceStream << version << extensionPrim << extensionTess << "layout (triangles, equal_spacing, ccw) in;\n"
536*35238bceSAndroid Build Coastguard Worker                      << "void main()\n"
537*35238bceSAndroid Build Coastguard Worker                      << "{\n"
538*35238bceSAndroid Build Coastguard Worker                      << "    " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
539*35238bceSAndroid Build Coastguard Worker                      << "    gl_Position = (    gl_TessCoord.x * " + builtInTypeName + "[0] +\n"
540*35238bceSAndroid Build Coastguard Worker                      << "                    gl_TessCoord.y * " + builtInTypeName + "[0] +\n"
541*35238bceSAndroid Build Coastguard Worker                      << "                    gl_TessCoord.z * " + builtInTypeName + "[0]);\n"
542*35238bceSAndroid Build Coastguard Worker                      << "}\n";
543*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_EVALUATION, sourceStream.str(), EXPECT_RESULT_FAIL);
544*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
545*35238bceSAndroid Build Coastguard Worker 
546*35238bceSAndroid Build Coastguard Worker         sourceStream.str(std::string());
547*35238bceSAndroid Build Coastguard Worker     }
548*35238bceSAndroid Build Coastguard Worker 
549*35238bceSAndroid Build Coastguard Worker     if (ctx.isShaderSupported(glu::SHADERTYPE_GEOMETRY))
550*35238bceSAndroid Build Coastguard Worker     {
551*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in geometry shader");
552*35238bceSAndroid Build Coastguard Worker         sourceStream << version << extensionPrim << "layout (triangles) in;\n"
553*35238bceSAndroid Build Coastguard Worker                      << "layout (triangle_strip, max_vertices = 3) out;\n"
554*35238bceSAndroid Build Coastguard Worker                      << "void main()\n"
555*35238bceSAndroid Build Coastguard Worker                      << "{\n"
556*35238bceSAndroid Build Coastguard Worker                      << "    " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
557*35238bceSAndroid Build Coastguard Worker                      << "    for (int idx = 0; idx < 3; idx++)\n"
558*35238bceSAndroid Build Coastguard Worker                      << "    {\n"
559*35238bceSAndroid Build Coastguard Worker                      << "        gl_Position = gl_in[idx].gl_Position * " + builtInTypeName + "[0];\n"
560*35238bceSAndroid Build Coastguard Worker                      << "        EmitVertex();\n"
561*35238bceSAndroid Build Coastguard Worker                      << "    }\n"
562*35238bceSAndroid Build Coastguard Worker                      << "    EndPrimitive();\n"
563*35238bceSAndroid Build Coastguard Worker                      << "}\n";
564*35238bceSAndroid Build Coastguard Worker         verifyShader(ctx, glu::SHADERTYPE_GEOMETRY, sourceStream.str(), EXPECT_RESULT_FAIL);
565*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
566*35238bceSAndroid Build Coastguard Worker 
567*35238bceSAndroid Build Coastguard Worker         sourceStream.str(std::string());
568*35238bceSAndroid Build Coastguard Worker     }
569*35238bceSAndroid Build Coastguard Worker 
570*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in fragment shader");
571*35238bceSAndroid Build Coastguard Worker     sourceStream << version << extensionPrim << "layout (location = 0) out mediump vec4 fs_colour;\n"
572*35238bceSAndroid Build Coastguard Worker                  << "void main()\n"
573*35238bceSAndroid Build Coastguard Worker                  << "{\n"
574*35238bceSAndroid Build Coastguard Worker                  << "    " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
575*35238bceSAndroid Build Coastguard Worker                  << "    fs_colour = " + builtInTypeName + "[0];\n"
576*35238bceSAndroid Build Coastguard Worker                  << "}\n";
577*35238bceSAndroid Build Coastguard Worker     verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, sourceStream.str(), EXPECT_RESULT_FAIL);
578*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
579*35238bceSAndroid Build Coastguard Worker }
580*35238bceSAndroid Build Coastguard Worker 
accessing_bounding_box_type(NegativeTestContext & ctx)581*35238bceSAndroid Build Coastguard Worker void accessing_bounding_box_type(NegativeTestContext &ctx)
582*35238bceSAndroid Build Coastguard Worker {
583*35238bceSAndroid Build Coastguard Worker     // Extension requirements and name differences depending on the context
584*35238bceSAndroid Build Coastguard Worker     if ((ctx.getRenderContext().getType().getMajorVersion() == 3) &&
585*35238bceSAndroid Build Coastguard Worker         (ctx.getRenderContext().getType().getMinorVersion() == 1))
586*35238bceSAndroid Build Coastguard Worker     {
587*35238bceSAndroid Build Coastguard Worker         executeAccessingBoundingBoxType(ctx, "gl_BoundingBoxEXT", glu::GLSL_VERSION_310_ES);
588*35238bceSAndroid Build Coastguard Worker     }
589*35238bceSAndroid Build Coastguard Worker     else
590*35238bceSAndroid Build Coastguard Worker     {
591*35238bceSAndroid Build Coastguard Worker         executeAccessingBoundingBoxType(ctx, "gl_BoundingBox", glu::GLSL_VERSION_320_ES);
592*35238bceSAndroid Build Coastguard Worker     }
593*35238bceSAndroid Build Coastguard Worker }
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker } // namespace
596*35238bceSAndroid Build Coastguard Worker 
getNegativeShaderDirectiveTestFunctions(void)597*35238bceSAndroid Build Coastguard Worker std::vector<FunctionContainer> getNegativeShaderDirectiveTestFunctions(void)
598*35238bceSAndroid Build Coastguard Worker {
599*35238bceSAndroid Build Coastguard Worker     const FunctionContainer funcs[] = {
600*35238bceSAndroid Build Coastguard Worker         {primitive_bounding_box, "primitive_bounding_box",
601*35238bceSAndroid Build Coastguard Worker          "GL_EXT_primitive_bounding_box required in 310 es shaders to use AEP features. Version 320 es shaders do not "
602*35238bceSAndroid Build Coastguard Worker          "require suffixes."},
603*35238bceSAndroid Build Coastguard Worker         {blend_equation_advanced, "blend_equation_advanced",
604*35238bceSAndroid Build Coastguard Worker          "GL_KHR_blend_equation_advanced is required in 310 es shaders to use AEP features"},
605*35238bceSAndroid Build Coastguard Worker         {sample_variables, "sample_variables",
606*35238bceSAndroid Build Coastguard Worker          "GL_OES_sample_variables is required in 310 es shaders to use AEP features"},
607*35238bceSAndroid Build Coastguard Worker         {shader_image_atomic, "shader_image_atomic",
608*35238bceSAndroid Build Coastguard Worker          "GL_OES_shader_image_atomic is required in 310 es shaders to use AEP features"},
609*35238bceSAndroid Build Coastguard Worker         {shader_multisample_interpolation, "shader_multisample_interpolation",
610*35238bceSAndroid Build Coastguard Worker          "GL_OES_shader_multisample_interpolation is required in 310 es shaders to use AEP features"},
611*35238bceSAndroid Build Coastguard Worker         {texture_storage_multisample_2d_array, "texture_storage_multisample_2d_array",
612*35238bceSAndroid Build Coastguard Worker          "GL_OES_texture_storage_multisample_2d_array is required in 310 es shaders to use AEP features"},
613*35238bceSAndroid Build Coastguard Worker         {geometry_shader, "geometry_shader",
614*35238bceSAndroid Build Coastguard Worker          "GL_EXT_geometry_shader is required in 310 es shaders to use AEP features"},
615*35238bceSAndroid Build Coastguard Worker         {gpu_shader_5, "gpu_shader_5", "GL_EXT_gpu_shader5 is required in 310 es shaders to use AEP features"},
616*35238bceSAndroid Build Coastguard Worker         {shader_io_blocks, "shader_io_blocks",
617*35238bceSAndroid Build Coastguard Worker          "GL_EXT_shader_io_blocks is required in 310 es shaders to use AEP features"},
618*35238bceSAndroid Build Coastguard Worker         {tessellation_shader, "tessellation_shader",
619*35238bceSAndroid Build Coastguard Worker          "GL_EXT_tessellation_shader is required in 310 es shaders to use AEP features"},
620*35238bceSAndroid Build Coastguard Worker         {texture_buffer, "texture_buffer", "GL_EXT_texture_buffer is required in 310 es shaders to use AEP features"},
621*35238bceSAndroid Build Coastguard Worker         {texture_cube_map_array, "texture_cube_map_array",
622*35238bceSAndroid Build Coastguard Worker          "GL_EXT_texture_cube_map_array is required in 310 es shaders to use AEP features"},
623*35238bceSAndroid Build Coastguard Worker         {accessing_bounding_box_type, "accessing_bounding_box_type",
624*35238bceSAndroid Build Coastguard Worker          "Should not be able to access gl_BoundingBoxEXT[] and gl_BoundingBox[] in shaders other than tess control and "
625*35238bceSAndroid Build Coastguard Worker          "evaluation"},
626*35238bceSAndroid Build Coastguard Worker     };
627*35238bceSAndroid Build Coastguard Worker 
628*35238bceSAndroid Build Coastguard Worker     return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
629*35238bceSAndroid Build Coastguard Worker }
630*35238bceSAndroid Build Coastguard Worker 
631*35238bceSAndroid Build Coastguard Worker } // namespace NegativeTestShared
632*35238bceSAndroid Build Coastguard Worker } // namespace Functional
633*35238bceSAndroid Build Coastguard Worker } // namespace gles31
634*35238bceSAndroid Build Coastguard Worker } // namespace deqp
635