1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 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 Fragment Pipe API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fNegativeFragmentApiTests.hpp"
25 
26 #include "gluCallLogWrapper.hpp"
27 #include "gluContextInfo.hpp"
28 #include "gluRenderContext.hpp"
29 
30 #include "glwDefs.hpp"
31 #include "glwEnums.hpp"
32 
33 namespace deqp
34 {
35 namespace gles31
36 {
37 namespace Functional
38 {
39 namespace NegativeTestShared
40 {
41 
42 using tcu::TestLog;
43 using glu::CallLogWrapper;
44 using namespace glw;
45 
46 using tcu::TestLog;
47 
scissor(NegativeTestContext & ctx)48 void scissor (NegativeTestContext& ctx)
49 {
50 	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
51 	ctx.glScissor(0, 0, -1, 0);
52 	ctx.expectError(GL_INVALID_VALUE);
53 	ctx.glScissor(0, 0, 0, -1);
54 	ctx.expectError(GL_INVALID_VALUE);
55 	ctx.glScissor(0, 0, -1, -1);
56 	ctx.expectError(GL_INVALID_VALUE);
57 	ctx.endSection();
58 }
59 
depth_func(NegativeTestContext & ctx)60 void depth_func (NegativeTestContext& ctx)
61 {
62 	ctx.beginSection("GL_INVALID_ENUM is generated if func is not an accepted value.");
63 	ctx.glDepthFunc(-1);
64 	ctx.expectError(GL_INVALID_ENUM);
65 	ctx.endSection();
66 }
67 
viewport(NegativeTestContext & ctx)68 void viewport (NegativeTestContext& ctx)
69 {
70 	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
71 	ctx.glViewport(0, 0, -1, 1);
72 	ctx.expectError(GL_INVALID_VALUE);
73 	ctx.glViewport(0, 0, 1, -1);
74 	ctx.expectError(GL_INVALID_VALUE);
75 	ctx.glViewport(0, 0, -1, -1);
76 	ctx.expectError(GL_INVALID_VALUE);
77 	ctx.endSection();
78 }
79 
80 // Stencil functions
stencil_func(NegativeTestContext & ctx)81 void stencil_func (NegativeTestContext& ctx)
82 {
83 	ctx.beginSection("GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
84 	ctx.glStencilFunc(-1, 0, 1);
85 	ctx.expectError(GL_INVALID_ENUM);
86 	ctx.endSection();
87 }
88 
stencil_func_separate(NegativeTestContext & ctx)89 void stencil_func_separate (NegativeTestContext& ctx)
90 {
91 	ctx.beginSection("GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
92 	ctx.glStencilFuncSeparate(-1, GL_NEVER, 0, 1);
93 	ctx.expectError(GL_INVALID_ENUM);
94 	ctx.endSection();
95 
96 	ctx.beginSection("GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
97 	ctx.glStencilFuncSeparate(GL_FRONT, -1, 0, 1);
98 	ctx.expectError(GL_INVALID_ENUM);
99 	ctx.endSection();
100 }
101 
stencil_op(NegativeTestContext & ctx)102 void stencil_op (NegativeTestContext& ctx)
103 {
104 	ctx.beginSection("GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the defined symbolic constant values.");
105 	ctx.glStencilOp(-1, GL_ZERO, GL_REPLACE);
106 	ctx.expectError(GL_INVALID_ENUM);
107 	ctx.glStencilOp(GL_KEEP, -1, GL_REPLACE);
108 	ctx.expectError(GL_INVALID_ENUM);
109 	ctx.glStencilOp(GL_KEEP, GL_ZERO, -1);
110 	ctx.expectError(GL_INVALID_ENUM);
111 	ctx.endSection();
112 }
113 
stencil_op_separate(NegativeTestContext & ctx)114 void stencil_op_separate (NegativeTestContext& ctx)
115 {
116 	ctx.beginSection("GL_INVALID_ENUM is generated if face is any value other than GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
117 	ctx.glStencilOpSeparate(-1, GL_KEEP, GL_ZERO, GL_REPLACE);
118 	ctx.expectError(GL_INVALID_ENUM);
119 	ctx.endSection();
120 
121 	ctx.beginSection("GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.");
122 	ctx.glStencilOpSeparate(GL_FRONT, -1, GL_ZERO, GL_REPLACE);
123 	ctx.expectError(GL_INVALID_ENUM);
124 	ctx.glStencilOpSeparate(GL_FRONT, GL_KEEP, -1, GL_REPLACE);
125 	ctx.expectError(GL_INVALID_ENUM);
126 	ctx.glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_ZERO, -1);
127 	ctx.expectError(GL_INVALID_ENUM);
128 	ctx.endSection();
129 }
130 
stencil_mask_separate(NegativeTestContext & ctx)131 void stencil_mask_separate (NegativeTestContext& ctx)
132 {
133 	ctx.beginSection("GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
134 	ctx.glStencilMaskSeparate(-1, 0);
135 	ctx.expectError(GL_INVALID_ENUM);
136 	ctx.endSection();
137 }
138 
139 // Blend functions
blend_equation(NegativeTestContext & ctx)140 void blend_equation (NegativeTestContext& ctx)
141 {
142 	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
143 	ctx.glBlendEquation(-1);
144 	ctx.expectError(GL_INVALID_ENUM);
145 	ctx.endSection();
146 }
147 
blend_equation_separate(NegativeTestContext & ctx)148 void blend_equation_separate (NegativeTestContext& ctx)
149 {
150 	ctx.beginSection("GL_INVALID_ENUM is generated if modeRGB is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
151 	ctx.glBlendEquationSeparate(-1, GL_FUNC_ADD);
152 	ctx.expectError(GL_INVALID_ENUM);
153 	ctx.endSection();
154 	ctx.beginSection("GL_INVALID_ENUM is generated if modeAlpha is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
155 	ctx.glBlendEquationSeparate(GL_FUNC_ADD, -1);
156 	ctx.expectError(GL_INVALID_ENUM);
157 	ctx.endSection();
158 }
159 
blend_equationi(NegativeTestContext & ctx)160 void blend_equationi (NegativeTestContext& ctx)
161 {
162 	glw::GLint maxDrawBuffers = -1;
163 
164 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_EXT_draw_buffers_indexed"))
165 		throw tcu::NotSupportedError("GL_EXT_draw_buffers_indexed is not supported", DE_NULL, __FILE__, __LINE__);
166 
167 	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
168 	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
169 	ctx.glBlendEquationi(0, -1);
170 	ctx.expectError(GL_INVALID_ENUM);
171 	ctx.endSection();
172 	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
173 	ctx.glBlendEquationi(-1, GL_FUNC_ADD);
174 	ctx.expectError(GL_INVALID_VALUE);
175 	ctx.glBlendEquationi(maxDrawBuffers, GL_FUNC_ADD);
176 	ctx.expectError(GL_INVALID_VALUE);
177 	ctx.endSection();
178 }
179 
blend_equation_separatei(NegativeTestContext & ctx)180 void blend_equation_separatei (NegativeTestContext& ctx)
181 {
182 	glw::GLint maxDrawBuffers = -1;
183 
184 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_EXT_draw_buffers_indexed"))
185 		throw tcu::NotSupportedError("GL_EXT_draw_buffers_indexed is not supported", DE_NULL, __FILE__, __LINE__);
186 
187 	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
188 	ctx.beginSection("GL_INVALID_ENUM is generated if modeRGB is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
189 	ctx.glBlendEquationSeparatei(0, -1, GL_FUNC_ADD);
190 	ctx.expectError(GL_INVALID_ENUM);
191 	ctx.endSection();
192 	ctx.beginSection("GL_INVALID_ENUM is generated if modeAlpha is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
193 	ctx.glBlendEquationSeparatei(0, GL_FUNC_ADD, -1);
194 	ctx.expectError(GL_INVALID_ENUM);
195 	ctx.endSection();
196 	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
197 	ctx.glBlendEquationSeparatei(-1, GL_FUNC_ADD, GL_FUNC_ADD);
198 	ctx.expectError(GL_INVALID_VALUE);
199 	ctx.glBlendEquationSeparatei(maxDrawBuffers, GL_FUNC_ADD, GL_FUNC_ADD);
200 	ctx.expectError(GL_INVALID_VALUE);
201 	ctx.endSection();
202 }
203 
blend_func(NegativeTestContext & ctx)204 void blend_func (NegativeTestContext& ctx)
205 {
206 	ctx.beginSection("GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
207 	ctx.glBlendFunc(-1, GL_ONE);
208 	ctx.expectError(GL_INVALID_ENUM);
209 	ctx.glBlendFunc(GL_ONE, -1);
210 	ctx.expectError(GL_INVALID_ENUM);
211 	ctx.endSection();
212 }
213 
blend_func_separate(NegativeTestContext & ctx)214 void blend_func_separate (NegativeTestContext& ctx)
215 {
216 	ctx.beginSection("GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
217 	ctx.glBlendFuncSeparate(-1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
218 	ctx.expectError(GL_INVALID_ENUM);
219 	ctx.glBlendFuncSeparate(GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
220 	ctx.expectError(GL_INVALID_ENUM);
221 	ctx.glBlendFuncSeparate(GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
222 	ctx.expectError(GL_INVALID_ENUM);
223 	ctx.glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
224 	ctx.expectError(GL_INVALID_ENUM);
225 	ctx.endSection();
226 }
227 
blend_funci(NegativeTestContext & ctx)228 void blend_funci (NegativeTestContext& ctx)
229 {
230 	glw::GLint maxDrawBuffers = -1;
231 
232 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_EXT_draw_buffers_indexed"))
233 		throw tcu::NotSupportedError("GL_EXT_draw_buffers_indexed is not supported", DE_NULL, __FILE__, __LINE__);
234 
235 	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
236 	ctx.beginSection("GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
237 	ctx.glBlendFunci(0, -1, GL_ONE);
238 	ctx.expectError(GL_INVALID_ENUM);
239 	ctx.glBlendFunci(0, GL_ONE, -1);
240 	ctx.expectError(GL_INVALID_ENUM);
241 	ctx.endSection();
242 	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
243 	ctx.glBlendFunci(-1, GL_ONE, GL_ONE);
244 	ctx.expectError(GL_INVALID_VALUE);
245 	ctx.glBlendFunci(maxDrawBuffers, GL_ONE, GL_ONE);
246 	ctx.expectError(GL_INVALID_VALUE);
247 	ctx.endSection();
248 }
249 
blend_func_separatei(NegativeTestContext & ctx)250 void blend_func_separatei (NegativeTestContext& ctx)
251 {
252 	glw::GLint maxDrawBuffers = -1;
253 
254 	if (!glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_EXT_draw_buffers_indexed"))
255 		throw tcu::NotSupportedError("GL_EXT_draw_buffers_indexed is not supported", DE_NULL, __FILE__, __LINE__);
256 
257 	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
258 	ctx.beginSection("GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
259 	ctx.glBlendFuncSeparatei(0, -1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
260 	ctx.expectError(GL_INVALID_ENUM);
261 	ctx.glBlendFuncSeparatei(0, GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
262 	ctx.expectError(GL_INVALID_ENUM);
263 	ctx.glBlendFuncSeparatei(0, GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
264 	ctx.expectError(GL_INVALID_ENUM);
265 	ctx.glBlendFuncSeparatei(0, GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
266 	ctx.expectError(GL_INVALID_ENUM);
267 	ctx.endSection();
268 	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
269 	ctx.glBlendFuncSeparatei(-1, GL_ONE, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
270 	ctx.expectError(GL_INVALID_VALUE);
271 	ctx.glBlendFuncSeparatei(maxDrawBuffers, GL_ONE, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
272 	ctx.expectError(GL_INVALID_VALUE);
273 	ctx.endSection();
274 }
275 
276 // Rasterization API functions
cull_face(NegativeTestContext & ctx)277 void cull_face (NegativeTestContext& ctx)
278 {
279 	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
280 	ctx.glCullFace(-1);
281 	ctx.expectError(GL_INVALID_ENUM);
282 	ctx.endSection();
283 }
284 
front_face(NegativeTestContext & ctx)285 void front_face (NegativeTestContext& ctx)
286 {
287 	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
288 	ctx.glFrontFace(-1);
289 	ctx.expectError(GL_INVALID_ENUM);
290 	ctx.endSection();
291 }
292 
line_width(NegativeTestContext & ctx)293 void line_width (NegativeTestContext& ctx)
294 {
295 	ctx.beginSection("GL_INVALID_VALUE is generated if width is less than or equal to 0.");
296 	ctx.glLineWidth(0);
297 	ctx.expectError(GL_INVALID_VALUE);
298 	ctx.glLineWidth(-1);
299 	ctx.expectError(GL_INVALID_VALUE);
300 	ctx.endSection();
301 }
302 
303 // Asynchronous queries
gen_queries(NegativeTestContext & ctx)304 void gen_queries (NegativeTestContext& ctx)
305 {
306 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
307 	GLuint ids = 0;
308 	ctx.glGenQueries	(-1, &ids);
309 	ctx.expectError		(GL_INVALID_VALUE);
310 	ctx.endSection();
311 }
312 
begin_query(NegativeTestContext & ctx)313 void begin_query (NegativeTestContext& ctx)
314 {
315 	GLuint ids[3];
316 	ctx.glGenQueries	(3, ids);
317 
318 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
319 	ctx.glBeginQuery	(-1, ids[0]);
320 	ctx.expectError		(GL_INVALID_ENUM);
321 	ctx.endSection();
322 
323 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glBeginQuery is executed while a query object of the same target is already active.");
324 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[0]);
325 	ctx.expectError		(GL_NO_ERROR);
326 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[1]);
327 	ctx.expectError		(GL_INVALID_OPERATION);
328 	// \note GL_ANY_SAMPLES_PASSED and GL_ANY_SAMPLES_PASSED_CONSERVATIVE alias to the same target for the purposes of this error.
329 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, ids[1]);
330 	ctx.expectError		(GL_INVALID_OPERATION);
331 	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[1]);
332 	ctx.expectError		(GL_NO_ERROR);
333 	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[2]);
334 	ctx.expectError		(GL_INVALID_OPERATION);
335 	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
336 	ctx.glEndQuery		(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
337 	ctx.expectError		(GL_NO_ERROR);
338 	ctx.endSection();
339 
340 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is 0.");
341 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, 0);
342 	ctx.expectError		(GL_INVALID_OPERATION);
343 	ctx.endSection();
344 
345 	ctx.beginSection("GL_INVALID_OPERATION is generated if id not a name returned from a previous call to ctx.glGenQueries, or if such a name has since been deleted with ctx.glDeleteQueries.");
346 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, -1);
347 	ctx.expectError		(GL_INVALID_OPERATION);
348 	ctx.glDeleteQueries	(1, &ids[2]);
349 	ctx.expectError		(GL_NO_ERROR);
350 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[2]);
351 	ctx.expectError		(GL_INVALID_OPERATION);
352 	ctx.endSection();
353 
354 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of an already active query object.");
355 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[0]);
356 	ctx.expectError		(GL_NO_ERROR);
357 	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
358 	ctx.expectError		(GL_INVALID_OPERATION);
359 	ctx.endSection();
360 
361 	ctx.beginSection("GL_INVALID_OPERATION is generated if id refers to an existing query object whose type does not does not match target.");
362 	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
363 	ctx.expectError		(GL_NO_ERROR);
364 	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
365 	ctx.expectError		(GL_INVALID_OPERATION);
366 	ctx.endSection();
367 
368 	ctx.glDeleteQueries	(2, &ids[0]);
369 	ctx.expectError		(GL_NO_ERROR);
370 }
371 
end_query(NegativeTestContext & ctx)372 void end_query (NegativeTestContext& ctx)
373 {
374 	GLuint id = 0;
375 	ctx.glGenQueries	(1, &id);
376 
377 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
378 	ctx.glEndQuery		(-1);
379 	ctx.expectError		(GL_INVALID_ENUM);
380 	ctx.endSection();
381 
382 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glEndQuery is executed when a query object of the same target is not active.");
383 	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
384 	ctx.expectError		(GL_INVALID_OPERATION);
385 	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, id);
386 	ctx.expectError		(GL_NO_ERROR);
387 	ctx.glEndQuery		(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
388 	ctx.expectError		(GL_INVALID_OPERATION);
389 	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
390 	ctx.expectError		(GL_NO_ERROR);
391 	ctx.endSection();
392 
393 	ctx.glDeleteQueries	(1, &id);
394 	ctx.expectError		(GL_NO_ERROR);
395 }
396 
delete_queries(NegativeTestContext & ctx)397 void delete_queries (NegativeTestContext& ctx)
398 {
399 	GLuint id = 0;
400 	ctx.glGenQueries	(1, &id);
401 
402 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
403 	ctx.glDeleteQueries	(-1, &id);
404 	ctx.expectError		(GL_INVALID_VALUE);
405 	ctx.endSection();
406 
407 	ctx.glDeleteQueries	(1, &id);
408 }
409 
410 // Sync objects
fence_sync(NegativeTestContext & ctx)411 void fence_sync (NegativeTestContext& ctx)
412 {
413 	ctx.beginSection("GL_INVALID_ENUM is generated if condition is not GL_SYNC_GPU_COMMANDS_COMPLETE.");
414 	ctx.glFenceSync(-1, 0);
415 	ctx.expectError(GL_INVALID_ENUM);
416 	ctx.endSection();
417 
418 	ctx.beginSection("GL_INVALID_VALUE is generated if flags is not zero.");
419 	ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0x0010);
420 	ctx.expectError(GL_INVALID_VALUE);
421 	ctx.endSection();
422 }
423 
wait_sync(NegativeTestContext & ctx)424 void wait_sync (NegativeTestContext& ctx)
425 {
426 	GLsync sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
427 
428 	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
429 	ctx.glWaitSync(0, 0, GL_TIMEOUT_IGNORED);
430 	ctx.expectError(GL_INVALID_VALUE);
431 	ctx.endSection();
432 
433 	ctx.beginSection("GL_INVALID_VALUE is generated if flags is not zero.");
434 	ctx.glWaitSync(sync, 0x0010, GL_TIMEOUT_IGNORED);
435 	ctx.expectError(GL_INVALID_VALUE);
436 	ctx.endSection();
437 
438 	ctx.beginSection("GL_INVALID_VALUE is generated if timeout is not GL_TIMEOUT_IGNORED.");
439 	ctx.glWaitSync(sync, 0, 0);
440 	ctx.expectError(GL_INVALID_VALUE);
441 	ctx.endSection();
442 
443 	ctx.glDeleteSync(sync);
444 }
445 
client_wait_sync(NegativeTestContext & ctx)446 void client_wait_sync (NegativeTestContext& ctx)
447 {
448 	GLsync sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
449 
450 	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of an existing sync object.");
451 	ctx.glClientWaitSync (0, 0, 10000);
452 	ctx.expectError(GL_INVALID_VALUE);
453 	ctx.endSection();
454 
455 	ctx.beginSection("GL_INVALID_VALUE is generated if flags contains any unsupported flag.");
456 	ctx.glClientWaitSync(sync, 0x00000004, 10000);
457 	ctx.expectError(GL_INVALID_VALUE);
458 	ctx.endSection();
459 
460 	ctx.glDeleteSync(sync);
461 }
462 
delete_sync(NegativeTestContext & ctx)463 void delete_sync (NegativeTestContext& ctx)
464 {
465 	ctx.beginSection("GL_INVALID_VALUE is generated if sync is neither zero or the name of a sync object.");
466 	ctx.glDeleteSync((GLsync)1);
467 	ctx.expectError(GL_INVALID_VALUE);
468 	ctx.glDeleteSync(0);
469 	ctx.expectError(GL_NO_ERROR);
470 	ctx.endSection();
471 }
472 
getNegativeFragmentApiTestFunctions()473 std::vector<FunctionContainer> getNegativeFragmentApiTestFunctions ()
474 {
475 	FunctionContainer funcs[] =
476 	{
477 		{scissor,					"scissor",					"Invalid glScissor() usage"					},
478 		{depth_func,				"depth_func",				"Invalid glDepthFunc() usage"				},
479 		{viewport,					"viewport",					"Invalid glViewport() usage"				},
480 		{stencil_func,				"stencil_func",				"Invalid glStencilFunc() usage"				},
481 		{stencil_func_separate,		"stencil_func_separate",	"Invalid glStencilFuncSeparate() usage"		},
482 		{stencil_op,				"stencil_op",				"Invalid glStencilOp() usage"				},
483 		{stencil_op_separate,		"stencil_op_separate",		"Invalid glStencilOpSeparate() usage"		},
484 		{stencil_mask_separate,		"stencil_mask_separate",	"Invalid glStencilMaskSeparate() usage"		},
485 		{blend_equation,			"blend_equation",			"Invalid glBlendEquation() usage"			},
486 		{blend_equationi,			"blend_equationi",			"Invalid glBlendEquationi() usage"			},
487 		{blend_equation_separate,	"blend_equation_separate",	"Invalid glBlendEquationSeparate() usage"	},
488 		{blend_equation_separatei,	"blend_equation_separatei",	"Invalid glBlendEquationSeparatei() usage"	},
489 		{blend_func,				"blend_func",				"Invalid glBlendFunc() usage"				},
490 		{blend_funci,				"blend_funci",				"Invalid glBlendFunci() usage"				},
491 		{blend_func_separate,		"blend_func_separate",		"Invalid glBlendFuncSeparate() usage"		},
492 		{blend_func_separatei,		"blend_func_separatei",		"Invalid glBlendFuncSeparatei() usage"		},
493 		{cull_face,					"cull_face",				"Invalid glCullFace() usage"				},
494 		{front_face,				"front_face",				"Invalid glFrontFace() usage"				},
495 		{line_width,				"line_width",				"Invalid glLineWidth() usage"				},
496 		{gen_queries,				"gen_queries",				"Invalid glGenQueries() usage"				},
497 		{begin_query,				"begin_query",				"Invalid glBeginQuery() usage"				},
498 		{end_query,					"end_query",				"Invalid glEndQuery() usage"				},
499 		{delete_queries,			"delete_queries",			"Invalid glDeleteQueries() usage"			},
500 		{fence_sync,				"fence_sync",				"Invalid glFenceSync() usage"				},
501 		{wait_sync,					"wait_sync",				"Invalid glWaitSync() usage"				},
502 		{client_wait_sync,			"client_wait_sync",			"Invalid glClientWaitSync() usage"			},
503 		{delete_sync,				"delete_sync",				"Invalid glDeleteSync() usage"				},
504 	};
505 
506 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
507 }
508 
509 } // NegativeTestShared
510 } // Functional
511 } // gles31
512 } // deqp
513