13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Negative Fragment Pipe API tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fNegativeFragmentApiTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
275ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe#include "gluContextInfo.hpp"
285ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe#include "gluRenderContext.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace NegativeTestShared
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::CallLogWrapper;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid scissor (NegativeTestContext& ctx)
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glScissor(0, 0, -1, 0);
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glScissor(0, 0, 0, -1);
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glScissor(0, 0, -1, -1);
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid depth_func (NegativeTestContext& ctx)
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if func is not an accepted value.");
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDepthFunc(-1);
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid viewport (NegativeTestContext& ctx)
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glViewport(0, 0, -1, 1);
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glViewport(0, 0, 1, -1);
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glViewport(0, 0, -1, -1);
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Stencil functions
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid stencil_func (NegativeTestContext& ctx)
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilFunc(-1, 0, 1);
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid stencil_func_separate (NegativeTestContext& ctx)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilFuncSeparate(-1, GL_NEVER, 0, 1);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilFuncSeparate(GL_FRONT, -1, 0, 1);
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid stencil_op (NegativeTestContext& ctx)
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the defined symbolic constant values.");
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOp(-1, GL_ZERO, GL_REPLACE);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOp(GL_KEEP, -1, GL_REPLACE);
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOp(GL_KEEP, GL_ZERO, -1);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid stencil_op_separate (NegativeTestContext& ctx)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if face is any value other than GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOpSeparate(-1, GL_KEEP, GL_ZERO, GL_REPLACE);
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.");
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOpSeparate(GL_FRONT, -1, GL_ZERO, GL_REPLACE);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOpSeparate(GL_FRONT, GL_KEEP, -1, GL_REPLACE);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_ZERO, -1);
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid stencil_mask_separate (NegativeTestContext& ctx)
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glStencilMaskSeparate(-1, 0);
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Blend functions
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid blend_equation (NegativeTestContext& ctx)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendEquation(-1);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid blend_equation_separate (NegativeTestContext& ctx)
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendEquationSeparate(-1, GL_FUNC_ADD);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendEquationSeparate(GL_FUNC_ADD, -1);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1605ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppevoid blend_equationi (NegativeTestContext& ctx)
1615ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe{
1625ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	glw::GLint maxDrawBuffers = -1;
1635ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
1645ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_KHR_blend_equation_advanced"))
1655ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		throw tcu::NotSupportedError("GL_KHR_blend_equation_advanced is not supported", DE_NULL, __FILE__, __LINE__);
1665ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
1675ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1685ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	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.");
1695ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationi(0, -1);
1705ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1715ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
1725ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
1735ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationi(-1, GL_FUNC_ADD);
1745ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1755ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationi(maxDrawBuffers, GL_FUNC_ADD);
1765ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1775ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
1785ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe}
1795ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
1805ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppevoid blend_equation_separatei (NegativeTestContext& ctx)
1815ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe{
1825ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	glw::GLint maxDrawBuffers = -1;
1835ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
1845ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_KHR_blend_equation_advanced"))
1855ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		throw tcu::NotSupportedError("GL_KHR_blend_equation_advanced is not supported", DE_NULL, __FILE__, __LINE__);
1865ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
1875ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1885ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	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.");
1895ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationSeparatei(0, -1, GL_FUNC_ADD);
1905ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1915ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
1925ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	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.");
1935ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationSeparatei(0, GL_FUNC_ADD, -1);
1945ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
1955ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
1965ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
1975ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationSeparatei(-1, GL_FUNC_ADD, GL_FUNC_ADD);
1985ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
1995ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendEquationSeparatei(maxDrawBuffers, GL_FUNC_ADD, GL_FUNC_ADD);
2005ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2015ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
2025ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe}
2035ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid blend_func (NegativeTestContext& ctx)
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFunc(-1, GL_ONE);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFunc(GL_ONE, -1);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid blend_func_separate (NegativeTestContext& ctx)
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFuncSeparate(-1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFuncSeparate(GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFuncSeparate(GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2285ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppevoid blend_funci (NegativeTestContext& ctx)
2295ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe{
2305ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	glw::GLint maxDrawBuffers = -1;
2315ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2325ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_KHR_blend_equation_advanced"))
2335ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		throw tcu::NotSupportedError("GL_KHR_blend_equation_advanced is not supported", DE_NULL, __FILE__, __LINE__);
2345ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2355ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
2365ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
2375ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFunci(0, -1, GL_ONE);
2385ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2395ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFunci(0, GL_ONE, -1);
2405ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2415ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
2425ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
2435ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFunci(-1, GL_ONE, GL_ONE);
2445ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2455ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFunci(maxDrawBuffers, GL_ONE, GL_ONE);
2465ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2475ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
2485ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe}
2495ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2505ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppevoid blend_func_separatei (NegativeTestContext& ctx)
2515ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe{
2525ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	glw::GLint maxDrawBuffers = -1;
2535ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2545ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	if (!glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !ctx.getContextInfo().isExtensionSupported("GL_KHR_blend_equation_advanced"))
2555ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		throw tcu::NotSupportedError("GL_KHR_blend_equation_advanced is not supported", DE_NULL, __FILE__, __LINE__);
2565ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2575ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
2585ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
2595ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(0, -1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2605ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2615ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(0, GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2625ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2635ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(0, GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
2645ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2655ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(0, GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
2665ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_ENUM);
2675ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
2685ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.beginSection("GL_INVALID_VALUE is generated if buf is not in the range zero to the value of MAX_DRAW_BUFFERS minus one.");
2695ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(-1, GL_ONE, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2705ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2715ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.glBlendFuncSeparatei(maxDrawBuffers, GL_ONE, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2725ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.expectError(GL_INVALID_VALUE);
2735ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe	ctx.endSection();
2745ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe}
2755ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Rasterization API functions
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid cull_face (NegativeTestContext& ctx)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCullFace(-1);
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid front_face (NegativeTestContext& ctx)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glFrontFace(-1);
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid line_width (NegativeTestContext& ctx)
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if width is less than or equal to 0.");
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLineWidth(0);
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glLineWidth(-1);
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Asynchronous queries
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid gen_queries (NegativeTestContext& ctx)
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint ids = 0;
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenQueries	(-1, &ids);
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_VALUE);
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid begin_query (NegativeTestContext& ctx)
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint ids[3];
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenQueries	(3, ids);
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(-1, ids[0]);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_ENUM);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glBeginQuery is executed while a query object of the same target is already active.");
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[0]);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[1]);
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note GL_ANY_SAMPLES_PASSED and GL_ANY_SAMPLES_PASSED_CONSERVATIVE alias to the same target for the purposes of this error.
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, ids[1]);
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[1]);
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[2]);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if id is 0.");
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, 0);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, -1);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteQueries	(1, &ids[2]);
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[2]);
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of an already active query object.");
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, ids[0]);
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if id refers to an existing query object whose type does not does not match target.");
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteQueries	(2, &ids[0]);
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid end_query (NegativeTestContext& ctx)
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint id = 0;
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenQueries	(1, &id);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(-1);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_ENUM);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glEndQuery is executed when a query object of the same target is not active.");
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBeginQuery	(GL_ANY_SAMPLES_PASSED, id);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_OPERATION);
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEndQuery		(GL_ANY_SAMPLES_PASSED);
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteQueries	(1, &id);
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_NO_ERROR);
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_queries (NegativeTestContext& ctx)
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint id = 0;
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenQueries	(1, &id);
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteQueries	(-1, &id);
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError		(GL_INVALID_VALUE);
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteQueries	(1, &id);
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Sync objects
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid fence_sync (NegativeTestContext& ctx)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if condition is not GL_SYNC_GPU_COMMANDS_COMPLETE.");
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glFenceSync(-1, 0);
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if flags is not zero.");
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0x0010);
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid wait_sync (NegativeTestContext& ctx)
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsync sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glWaitSync(0, 0, GL_TIMEOUT_IGNORED);
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if flags is not zero.");
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glWaitSync(sync, 0x0010, GL_TIMEOUT_IGNORED);
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if timeout is not GL_TIMEOUT_IGNORED.");
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glWaitSync(sync, 0, 0);
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSync(sync);
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid client_wait_sync (NegativeTestContext& ctx)
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsync sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of an existing sync object.");
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glClientWaitSync (0, 0, 10000);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if flags contains any unsupported flag.");
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glClientWaitSync(sync, 0x00000004, 10000);
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSync(sync);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_sync (NegativeTestContext& ctx)
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if sync is neither zero or the name of a sync object.");
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSync((GLsync)1);
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteSync(0);
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<FunctionContainer> getNegativeFragmentApiTestFunctions ()
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FunctionContainer funcs[] =
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4775ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{scissor,					"scissor",					"Invalid glScissor() usage"				 	},
4785ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{depth_func,				"depth_func",				"Invalid glDepthFunc() usage"			 	},
4795ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{viewport,					"viewport",					"Invalid glViewport() usage"			 	},
4805ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{stencil_func,				"stencil_func",				"Invalid glStencilFunc() usage"			 	},
4815ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{stencil_func_separate,		"stencil_func_separate",	"Invalid glStencilFuncSeparate() usage"	 	},
4825ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{stencil_op,				"stencil_op",				"Invalid glStencilOp() usage"			 	},
4835ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{stencil_op_separate,		"stencil_op_separate",		"Invalid glStencilOpSeparate() usage"	 	},
4845ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{stencil_mask_separate,		"stencil_mask_separate",	"Invalid glStencilMaskSeparate() usage"	 	},
4855ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_equation,			"blend_equation",			"Invalid glBlendEquation() usage"		 	},
4865ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_equationi,			"blend_equationi",			"Invalid glBlendEquationi() usage"		 	},
4875ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_equation_separate,	"blend_equation_separate",	"Invalid glBlendEquationSeparate() usage"	},
4885ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_equation_separatei,	"blend_equation_separatei",	"Invalid glBlendEquationSeparatei() usage"	},
4895ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_func,				"blend_func",				"Invalid glBlendFunc() usage"			 	},
4905ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_funci,				"blend_funci",				"Invalid glBlendFunci() usage"			 	},
4915ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_func_separate,		"blend_func_separate",		"Invalid glBlendFuncSeparate() usage"	 	},
4925ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{blend_func_separatei,		"blend_func_separatei",		"Invalid glBlendFuncSeparatei() usage"	 	},
4935ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{cull_face,					"cull_face",				"Invalid glCullFace() usage"			 	},
4945ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{front_face,				"front_face",				"Invalid glFrontFace() usage"			 	},
4955ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{line_width,				"line_width",				"Invalid glLineWidth() usage"			 	},
4965ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{gen_queries,				"gen_queries",				"Invalid glGenQueries() usage"			 	},
4975ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{begin_query,				"begin_query",				"Invalid glBeginQuery() usage"			 	},
4985ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{end_query,					"end_query",				"Invalid glEndQuery() usage"			 	},
4995ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{delete_queries,			"delete_queries",			"Invalid glDeleteQueries() usage"		 	},
5005ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{fence_sync,				"fence_sync",				"Invalid glFenceSync() usage"			 	},
5015ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{wait_sync,					"wait_sync",				"Invalid glWaitSync() usage"			 	},
5025ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{client_wait_sync,			"client_wait_sync",			"Invalid glClientWaitSync() usage"		 	},
5035ed2b23bea6e56762a7aef8c8a086ec724517f26Daniel Andrade Groppe		{delete_sync,				"delete_sync",				"Invalid glDeleteSync() usage"			 	},
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // NegativeTestShared
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
513