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 {
173 "blend_support_multiply",
174 "blend_support_screen",
175 "blend_support_overlay",
176 "blend_support_darken",
177 "blend_support_lighten",
178 "blend_support_colordodge",
179 "blend_support_colorburn",
180 "blend_support_hardlight",
181 "blend_support_softlight",
182 "blend_support_difference",
183 "blend_support_exclusion",
184 "blend_support_hsl_hue",
185 "blend_support_hsl_saturation",
186 "blend_support_hsl_color",
187 "blend_support_hsl_luminosity",
188 };
189
190 ctx.beginSection("GL_KHR_blend_equation_advanced features require enabling the extension in 310 es shaders.");
191 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_qualifiers); ++ndx)
192 {
193 std::ostringstream source;
194 source << "#version 310 es\n"
195 "layout(" << s_qualifiers[ndx] << ") out;\n"
196 "void main()\n"
197 "{\n"
198 "}\n";
199 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
200 }
201 ctx.endSection();
202 }
203
sample_variables(NegativeTestContext & ctx)204 void sample_variables (NegativeTestContext& ctx)
205 {
206 TCU_CHECK_AND_THROW(NotSupportedError,
207 contextSupports(ctx.getRenderContext().getType() , glu::ApiType::es(3, 2)) || contextSupports(ctx.getRenderContext().getType() , glu::ApiType::core(4, 5)),
208 "Test requires a context version 3.2 or higher.");
209
210 static const char* const s_tests[] =
211 {
212 "int sampleId = gl_SampleID;",
213 "vec2 samplePos = gl_SamplePosition;",
214 "int sampleMaskIn0 = gl_SampleMaskIn[0];",
215 "int sampleMask0 = gl_SampleMask[0];",
216 "int numSamples = gl_NumSamples;",
217 };
218
219 ctx.beginSection("GL_OES_sample_variables features require enabling the extension in 310 es shaders.");
220 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_tests); ++ndx)
221 {
222 std::ostringstream source;
223 source << "#version 310 es\n"
224 "precision mediump float;\n"
225 "void main()\n"
226 "{\n"
227 " " << s_tests[ndx] << "\n"
228 "}\n";
229 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
230 }
231 ctx.endSection();
232 }
233
shader_image_atomic(NegativeTestContext & ctx)234 void shader_image_atomic (NegativeTestContext& ctx)
235 {
236 static const char* const s_tests[] =
237 {
238 "imageAtomicAdd(u_image, ivec2(1, 1), 1u);",
239 "imageAtomicMin(u_image, ivec2(1, 1), 1u);",
240 "imageAtomicMax(u_image, ivec2(1, 1), 1u);",
241 "imageAtomicAnd(u_image, ivec2(1, 1), 1u);",
242 "imageAtomicOr(u_image, ivec2(1, 1), 1u);",
243 "imageAtomicXor(u_image, ivec2(1, 1), 1u);",
244 "imageAtomicExchange(u_image, ivec2(1, 1), 1u);",
245 "imageAtomicCompSwap(u_image, ivec2(1, 1), 1u, 1u);",
246 };
247
248 ctx.beginSection("GL_OES_shader_image_atomic features require enabling the extension in 310 es shaders.");
249 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_tests); ++ndx)
250 {
251 std::ostringstream source;
252 source << "#version 310 es\n"
253 "layout(binding=0, r32ui) coherent uniform highp uimage2D u_image;\n"
254 "precision mediump float;\n"
255 "void main()\n"
256 "{\n"
257 " " << s_tests[ndx] << "\n"
258 "}\n";
259 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
260 }
261 ctx.endSection();
262 }
263
shader_multisample_interpolation(NegativeTestContext & ctx)264 void shader_multisample_interpolation (NegativeTestContext& ctx)
265 {
266 static const char* const s_sampleTests[] =
267 {
268 "sample in highp float v_var;",
269 "sample out highp float v_var;"
270 };
271
272 static const char* const s_interpolateAtTests[] =
273 {
274 "interpolateAtCentroid(interpolant);",
275 "interpolateAtSample(interpolant, 1);",
276 "interpolateAtOffset(interpolant, vec2(1.0, 0.0));"
277 };
278
279 ctx.beginSection("GL_OES_shader_multisample_interpolation features require enabling the extension in 310 es shaders.");
280 ctx.beginSection("Test sample in/out qualifiers.");
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 " " << s_sampleTests[ndx] << "\n"
286 "precision mediump float;\n"
287 "void main()\n"
288 "{\n"
289 "}\n";
290 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
291 }
292 ctx.endSection();
293
294 ctx.beginSection("Test interpolateAt* functions.");
295 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_sampleTests); ++ndx)
296 {
297 std::ostringstream source;
298 source << "#version 310 es\n"
299 "in mediump float interpolant;\n"
300 "precision mediump float;\n"
301 "void main()\n"
302 "{\n"
303 " " << s_interpolateAtTests[ndx] << "\n"
304 "}\n";
305 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
306 }
307 ctx.endSection();
308 ctx.endSection();
309 }
310
texture_storage_multisample_2d_array(NegativeTestContext & ctx)311 void texture_storage_multisample_2d_array (NegativeTestContext& ctx)
312 {
313 static const char* const s_samplerTypeTests[] =
314 {
315 "uniform mediump sampler2DMSArray u_sampler;",
316 "uniform mediump isampler2DMSArray u_sampler;",
317 "uniform mediump usampler2DMSArray u_sampler;",
318 };
319
320 ctx.beginSection("GL_OES_texture_storage_multisample_2d_array features require enabling the extension in 310 es shaders.");
321 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerTypeTests); ++ndx)
322 {
323 std::ostringstream source;
324 source << "#version 310 es\n"
325 " " << s_samplerTypeTests[ndx] << "\n"
326 "precision mediump float;\n"
327 "void main()\n"
328 "{\n"
329 "}\n";
330 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
331 }
332 ctx.endSection();
333 }
334
geometry_shader(NegativeTestContext & ctx)335 void geometry_shader (NegativeTestContext& ctx)
336 {
337 if (ctx.isShaderSupported(glu::SHADERTYPE_GEOMETRY))
338 {
339 const std::string simpleVtxFrag = "#version 310 es\n"
340 "void main()\n"
341 "{\n"
342 "}\n";
343 const std::string geometry = "#version 310 es\n"
344 "layout(points, invocations = 1) in;\n"
345 "layout(points, max_vertices = 3) out;\n"
346 "precision mediump float;\n"
347 "void main()\n"
348 "{\n"
349 " EmitVertex();\n"
350 " EndPrimitive();\n"
351 "}\n";
352 ctx.beginSection("GL_EXT_geometry_shader features require enabling the extension in 310 es shaders.");
353 verifyProgram(ctx, glu::ProgramSources() << glu::VertexSource(simpleVtxFrag) << glu::GeometrySource(geometry) << glu::FragmentSource(simpleVtxFrag), EXPECT_RESULT_FAIL);
354 ctx.endSection();
355 }
356 }
357
gpu_shader_5(NegativeTestContext & ctx)358 void gpu_shader_5 (NegativeTestContext& ctx)
359 {
360 ctx.beginSection("GL_EXT_gpu_shader5 features require enabling the extension in 310 es shaders.");
361 ctx.beginSection("Testing the precise qualifier.");
362 {
363 std::ostringstream source;
364 source << "#version 310 es\n"
365 "void main()\n"
366 "{\n"
367 " int low = 0;\n"
368 " int high = 10;\n"
369 " precise int middle = low + ((high - low) / 2);\n"
370 "}\n";
371 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
372 }
373 ctx.endSection();
374
375 ctx.beginSection("Testing fused multiply-add.");
376 {
377 std::ostringstream source;
378 source << "#version 310 es\n"
379 "in mediump float v_var;"
380 "void main()\n"
381 "{\n"
382 " float fmaResult = fma(v_var, v_var, v_var);"
383 "}\n";
384 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
385 }
386 ctx.endSection();
387
388 ctx.beginSection("Testing textureGatherOffsets.");
389 {
390 std::ostringstream source;
391 source << "#version 310 es\n"
392 "uniform mediump sampler2D u_tex;\n"
393 "void main()\n"
394 "{\n"
395 " highp vec2 coords = vec2(0.0, 1.0);\n"
396 " const ivec2 offsets[4] = ivec2[](ivec2(0,0), ivec2(1, 0), ivec2(0, 1), ivec2(1, 1));\n"
397 " textureGatherOffsets(u_tex, coords, offsets);\n"
398 "}\n";
399 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
400 }
401 ctx.endSection();
402
403 ctx.endSection();
404 }
405
shader_io_blocks(NegativeTestContext & ctx)406 void shader_io_blocks (NegativeTestContext& ctx)
407 {
408 ctx.beginSection("GL_EXT_shader_io_blocks features require enabling the extension in 310 es shaders.");
409 {
410 std::ostringstream source;
411 source << "#version 310 es\n"
412 "in Data\n"
413 "{\n"
414 " mediump vec3 a;\n"
415 "} data;\n"
416 "void main()\n"
417 "{\n"
418 "}\n";
419 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
420 }
421 ctx.endSection();
422 }
423
tessellation_shader(NegativeTestContext & ctx)424 void tessellation_shader (NegativeTestContext& ctx)
425 {
426 if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_CONTROL))
427 {
428 const std::string simpleVtxFrag = "#version 310 es\n"
429 "void main()\n"
430 "{\n"
431 "}\n";
432 const std::string tessControl = "#version 310 es\n"
433 "layout(vertices = 3) out;\n"
434 "void main()\n"
435 "{\n"
436 "}\n";
437 const std::string tessEvaluation = "#version 310 es\n"
438 "layout(triangles, equal_spacing, cw) in;\n"
439 "void main()\n"
440 "{\n"
441 "}\n";
442 ctx.beginSection("GL_EXT_tessellation_shader features require enabling the extension in 310 es shaders.");
443 glu::ProgramSources sources;
444 sources << glu::VertexSource(simpleVtxFrag)
445 << glu::TessellationControlSource(tessControl)
446 << glu::TessellationEvaluationSource(tessEvaluation)
447 << glu::FragmentSource(simpleVtxFrag);
448 verifyProgram(ctx, sources, EXPECT_RESULT_FAIL);
449 ctx.endSection();
450 }
451 }
452
texture_buffer(NegativeTestContext & ctx)453 void texture_buffer (NegativeTestContext& ctx)
454 {
455 static const char* const s_samplerBufferTypes[] =
456 {
457 "uniform mediump samplerBuffer",
458 "uniform mediump isamplerBuffer",
459 "uniform mediump usamplerBuffer",
460 "layout(rgba32f) uniform mediump writeonly imageBuffer",
461 "layout(rgba32i) uniform mediump writeonly iimageBuffer",
462 "layout(rgba32ui) uniform mediump writeonly uimageBuffer"
463 };
464
465 ctx.beginSection("GL_EXT_texture_buffer features require enabling the extension in 310 es shaders.");
466 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerBufferTypes); ++ndx)
467 {
468 std::ostringstream source;
469 source << "#version 310 es\n"
470 "" << s_samplerBufferTypes[ndx] << " u_buffer;\n"
471 "void main()\n"
472 "{\n"
473 "}\n";
474 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
475 }
476 ctx.endSection();
477 }
478
479
texture_cube_map_array(NegativeTestContext & ctx)480 void texture_cube_map_array (NegativeTestContext& ctx)
481 {
482 static const char* const s_samplerCubeArrayTypes[] =
483 {
484 "uniform mediump samplerCubeArray",
485 "uniform mediump isamplerCubeArray",
486 "uniform mediump usamplerCubeArray",
487 "uniform mediump samplerCubeArrayShadow",
488 "layout(rgba32f) uniform mediump writeonly imageCubeArray",
489 "layout(rgba32i) uniform mediump writeonly iimageCubeArray",
490 "layout(rgba32ui) uniform mediump writeonly uimageCubeArray"
491 };
492
493 ctx.beginSection("GL_EXT_texture_cube_map_array features require enabling the extension in 310 es shaders.");
494 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_samplerCubeArrayTypes); ++ndx)
495 {
496 std::ostringstream source;
497 source << "#version 310 es\n"
498 "" << s_samplerCubeArrayTypes[ndx] << " u_cube;\n"
499 "void main()\n"
500 "{\n"
501 "}\n";
502 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, source.str(), EXPECT_RESULT_FAIL);
503 }
504 ctx.endSection();
505 }
506
executeAccessingBoundingBoxType(NegativeTestContext & ctx,const std::string builtInTypeName,glu::GLSLVersion glslVersion)507 void executeAccessingBoundingBoxType (NegativeTestContext& ctx, const std::string builtInTypeName, glu::GLSLVersion glslVersion)
508 {
509 std::ostringstream sourceStream;
510 std::string version;
511 std::string extensionPrim;
512 std::string extensionTess;
513
514 if (glslVersion == glu::GLSL_VERSION_310_ES)
515 {
516 version = "#version 310 es\n";
517 extensionPrim = "#extension GL_EXT_primitive_bounding_box : require\n";
518 extensionTess = "#extension GL_EXT_tessellation_shader : require\n";
519 }
520 else if (glslVersion >= glu::GLSL_VERSION_320_ES)
521 {
522 version = "#version 320 es\n";
523 extensionPrim = "";
524 extensionTess = "";
525 }
526 else
527 {
528 DE_FATAL("error: context below 3.1 and not supported");
529 }
530
531 ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in vertex shader");
532 sourceStream << version
533 << extensionPrim
534 << "void main()\n"
535 << "{\n"
536 << " " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
537 << " gl_Position = " + builtInTypeName + "[0];\n"
538 << "}\n";
539 verifyShader(ctx, glu::SHADERTYPE_VERTEX, sourceStream.str(), EXPECT_RESULT_FAIL);
540 ctx.endSection();
541
542 sourceStream.str(std::string());
543
544 if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_EVALUATION))
545 {
546 ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in tessellation evaluation shader");
547 sourceStream << version
548 << extensionPrim
549 << extensionTess
550 << "layout (triangles, equal_spacing, ccw) in;\n"
551 << "void main()\n"
552 << "{\n"
553 << " " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
554 << " gl_Position = ( gl_TessCoord.x * " + builtInTypeName + "[0] +\n"
555 << " gl_TessCoord.y * " + builtInTypeName + "[0] +\n"
556 << " gl_TessCoord.z * " + builtInTypeName + "[0]);\n"
557 << "}\n";
558 verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_EVALUATION, sourceStream.str(), EXPECT_RESULT_FAIL);
559 ctx.endSection();
560
561 sourceStream.str(std::string());
562 }
563
564 if (ctx.isShaderSupported(glu::SHADERTYPE_GEOMETRY))
565 {
566 ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in geometry shader");
567 sourceStream << version
568 << extensionPrim
569 << "layout (triangles) in;\n"
570 << "layout (triangle_strip, max_vertices = 3) out;\n"
571 << "void main()\n"
572 << "{\n"
573 << " " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
574 << " for (int idx = 0; idx < 3; idx++)\n"
575 << " {\n"
576 << " gl_Position = gl_in[idx].gl_Position * " + builtInTypeName + "[0];\n"
577 << " EmitVertex();\n"
578 << " }\n"
579 << " EndPrimitive();\n"
580 << "}\n";
581 verifyShader(ctx, glu::SHADERTYPE_GEOMETRY, sourceStream.str(), EXPECT_RESULT_FAIL);
582 ctx.endSection();
583
584 sourceStream.str(std::string());
585 }
586
587 ctx.beginSection("cannot access built-in type " + builtInTypeName + "[]" + " in fragment shader");
588 sourceStream << version
589 << extensionPrim
590 << "layout (location = 0) out mediump vec4 fs_colour;\n"
591 << "void main()\n"
592 << "{\n"
593 << " " + builtInTypeName + "[0] = vec4(1.0, 1.0, 1.0, 1.0);\n"
594 << " fs_colour = " + builtInTypeName + "[0];\n"
595 << "}\n";
596 verifyShader(ctx, glu::SHADERTYPE_FRAGMENT, sourceStream.str(), EXPECT_RESULT_FAIL);
597 ctx.endSection();
598 }
599
accessing_bounding_box_type(NegativeTestContext & ctx)600 void accessing_bounding_box_type (NegativeTestContext& ctx)
601 {
602 // Extension requirements and name differences depending on the context
603 if ((ctx.getRenderContext().getType().getMajorVersion() == 3) && (ctx.getRenderContext().getType().getMinorVersion() == 1))
604 {
605 executeAccessingBoundingBoxType(ctx, "gl_BoundingBoxEXT", glu::GLSL_VERSION_310_ES);
606 }
607 else
608 {
609 executeAccessingBoundingBoxType(ctx, "gl_BoundingBox", glu::GLSL_VERSION_320_ES);
610 }
611
612 }
613
614 } // anonymous
615
getNegativeShaderDirectiveTestFunctions(void)616 std::vector<FunctionContainer> getNegativeShaderDirectiveTestFunctions (void)
617 {
618 const FunctionContainer funcs[] =
619 {
620 {primitive_bounding_box, "primitive_bounding_box", "GL_EXT_primitive_bounding_box required in 310 es shaders to use AEP features. Version 320 es shaders do not require suffixes." },
621 {blend_equation_advanced, "blend_equation_advanced", "GL_KHR_blend_equation_advanced is required in 310 es shaders to use AEP features" },
622 {sample_variables, "sample_variables", "GL_OES_sample_variables is required in 310 es shaders to use AEP features" },
623 {shader_image_atomic, "shader_image_atomic", "GL_OES_shader_image_atomic is required in 310 es shaders to use AEP features" },
624 {shader_multisample_interpolation, "shader_multisample_interpolation", "GL_OES_shader_multisample_interpolation is required in 310 es shaders to use AEP features" },
625 {texture_storage_multisample_2d_array, "texture_storage_multisample_2d_array", "GL_OES_texture_storage_multisample_2d_array is required in 310 es shaders to use AEP features" },
626 {geometry_shader, "geometry_shader", "GL_EXT_geometry_shader is required in 310 es shaders to use AEP features" },
627 {gpu_shader_5, "gpu_shader_5", "GL_EXT_gpu_shader5 is required in 310 es shaders to use AEP features" },
628 {shader_io_blocks, "shader_io_blocks", "GL_EXT_shader_io_blocks is required in 310 es shaders to use AEP features" },
629 {tessellation_shader, "tessellation_shader", "GL_EXT_tessellation_shader is required in 310 es shaders to use AEP features" },
630 {texture_buffer, "texture_buffer", "GL_EXT_texture_buffer is required in 310 es shaders to use AEP features" },
631 {texture_cube_map_array, "texture_cube_map_array", "GL_EXT_texture_cube_map_array is required in 310 es shaders to use AEP features" },
632 {accessing_bounding_box_type, "accessing_bounding_box_type", "Should not be able to access gl_BoundingBoxEXT[] and gl_BoundingBox[] in shaders other than tess control and evaluation" },
633 };
634
635 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
636 }
637
638 } // NegativeTestShared
639 } // Functional
640 } // gles31
641 } // deqp
642