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