• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2015-2016 The Khronos Group Inc.
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
22  */ /*-------------------------------------------------------------------*/
23 
24 /*!
25  * \file  esextcDrawBuffersIndexedNegative.hpp
26  * \brief Draw Buffers Indexed tests 6. Negative
27  */ /*-------------------------------------------------------------------*/
28 
29 #include "esextcDrawBuffersIndexedNegative.hpp"
30 #include "gluDefs.hpp"
31 #include "glwEnums.hpp"
32 #include "tcuTestLog.hpp"
33 
34 namespace glcts
35 {
36 
37 /** Constructor
38  *
39  *  @param context     Test context
40  *  @param name        Test case's name
41  *  @param description Test case's description
42  **/
DrawBuffersIndexedNegative(Context & context,const ExtParameters & extParams,const char * name,const char * description)43 DrawBuffersIndexedNegative::DrawBuffersIndexedNegative(Context& context, const ExtParameters& extParams,
44 													   const char* name, const char* description)
45 	: TestCaseBase(context, extParams, name, description)
46 {
47 	/* Left blank on purpose */
48 }
49 
init()50 void DrawBuffersIndexedNegative::init()
51 {
52 	if (!isExtensionSupported("GL_OES_draw_buffers_indexed"))
53 	{
54 		throw tcu::NotSupportedError(DRAW_BUFFERS_INDEXED_NOT_SUPPORTED);
55 	}
56 }
57 
iterate()58 tcu::TestNode::IterateResult DrawBuffersIndexedNegative::iterate()
59 {
60 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
61 
62 	glw::GLint	 data;
63 	glw::GLint64   data64;
64 	glw::GLboolean bData;
65 	glw::GLint	 maxDrawBuffers;
66 	gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
67 
68 	bool success = true;
69 
70 	// INVALID_VALUE
71 	gl.blendEquationi(maxDrawBuffers, GL_MIN);
72 	success &= ExpectedError(GL_INVALID_VALUE, "glBlendEquationi(0, maxDrawBuffers)");
73 
74 	gl.blendEquationSeparatei(maxDrawBuffers, GL_MIN, GL_MIN);
75 	success &= ExpectedError(GL_INVALID_VALUE, "glBlendEquationSeparatei(0, maxDrawBuffers)");
76 
77 	gl.blendFuncSeparatei(maxDrawBuffers, GL_CONSTANT_COLOR, GL_DST_ALPHA, GL_SRC_ALPHA, GL_ONE);
78 	success &=
79 		ExpectedError(GL_INVALID_VALUE,
80 					  "glBlendFuncSeparatei(maxDrawBuffers, GL_CONSTANT_COLOR, GL_DST_ALPHA, GL_SRC_ALPHA, GL_ONE)");
81 
82 	gl.blendFunci(maxDrawBuffers, GL_ZERO, GL_SRC_COLOR);
83 	success &= ExpectedError(GL_INVALID_VALUE, "glBlendFunci(maxDrawBuffers, GL_ZERO, GL_SRC_COLOR)");
84 
85 	gl.getIntegeri_v(GL_BLEND_EQUATION_RGB, maxDrawBuffers, &data);
86 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_EQUATION_RGB, maxDrawBuffers, &data)");
87 
88 	gl.getIntegeri_v(GL_BLEND_EQUATION_ALPHA, maxDrawBuffers, &data);
89 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_EQUATION_ALPHA, maxDrawBuffers, &data)");
90 
91 	gl.getIntegeri_v(GL_BLEND_SRC_RGB, maxDrawBuffers, &data);
92 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_SRC_RGB, maxDrawBuffers, &data)");
93 
94 	gl.getIntegeri_v(GL_BLEND_SRC_ALPHA, maxDrawBuffers, &data);
95 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_SRC_ALPHA, maxDrawBuffers, &data)");
96 
97 	gl.getIntegeri_v(GL_BLEND_DST_RGB, maxDrawBuffers, &data);
98 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_DST_RGB, maxDrawBuffers, &data)");
99 
100 	gl.getIntegeri_v(GL_BLEND_DST_ALPHA, maxDrawBuffers, &data);
101 	success &= ExpectedError(GL_INVALID_VALUE, "glGetIntegeri_v(GL_BLEND_DST_ALPHA, maxDrawBuffers, &data)");
102 
103 	gl.getInteger64i_v(GL_BLEND_EQUATION_RGB, maxDrawBuffers, &data64);
104 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_EQUATION_RGB, maxDrawBuffers, &data64)");
105 
106 	gl.getInteger64i_v(GL_BLEND_EQUATION_ALPHA, maxDrawBuffers, &data64);
107 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_EQUATION_ALPHA, maxDrawBuffers, &data64)");
108 
109 	gl.getInteger64i_v(GL_BLEND_SRC_RGB, maxDrawBuffers, &data64);
110 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_SRC_RGB, maxDrawBuffers, &data64)");
111 
112 	gl.getInteger64i_v(GL_BLEND_SRC_ALPHA, maxDrawBuffers, &data64);
113 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_SRC_ALPHA, maxDrawBuffers, &data64)");
114 
115 	gl.getInteger64i_v(GL_BLEND_DST_RGB, maxDrawBuffers, &data64);
116 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_DST_RGB, maxDrawBuffers, &data64)");
117 
118 	gl.getInteger64i_v(GL_BLEND_DST_ALPHA, maxDrawBuffers, &data64);
119 	success &= ExpectedError(GL_INVALID_VALUE, "glGetInteger64i_v(GL_BLEND_DST_ALPHA, maxDrawBuffers, &data64)");
120 
121 	gl.enablei(GL_BLEND, maxDrawBuffers);
122 	success &= ExpectedError(GL_INVALID_VALUE, "glEnablei(GL_BLEND, maxDrawBuffers)");
123 
124 	gl.disablei(GL_BLEND, maxDrawBuffers);
125 	success &= ExpectedError(GL_INVALID_VALUE, "glDisablei(GL_BLEND, maxDrawBuffers)");
126 
127 	gl.isEnabledi(GL_BLEND, maxDrawBuffers);
128 	success &= ExpectedError(GL_INVALID_VALUE, "glIsEnabledi(GL_BLEND, maxDrawBuffers)");
129 
130 	gl.colorMaski(maxDrawBuffers, GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE);
131 	success &= ExpectedError(GL_INVALID_VALUE, "glColorMaski(maxDrawBuffers, GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE)");
132 
133 	gl.getBooleani_v(GL_COLOR_WRITEMASK, maxDrawBuffers, &bData);
134 	success &= ExpectedError(GL_INVALID_VALUE, "glGetBooleani_v(GL_COLOR_WRITEMASK, maxDrawBuffers, &bData)");
135 
136 	// INVALID_ENUM
137 	gl.blendFunci(0, GL_MIN, GL_ONE_MINUS_SRC_ALPHA);
138 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFunci(0, GL_MIN, GL_ONE_MINUS_SRC_ALPHA)");
139 
140 	gl.blendFunci(0, GL_SRC_ALPHA, GL_MIN);
141 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFunci(0, GL_SRC_ALPHA, GL_MIN)");
142 
143 	gl.blendFuncSeparatei(0, GL_MIN, GL_ONE, GL_ONE, GL_ONE);
144 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFuncSeparatei(0, GL_MIN, GL_ONE, GL_ONE, GL_ONE)");
145 
146 	gl.blendFuncSeparatei(0, GL_ONE, GL_MIN, GL_ONE, GL_ONE);
147 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFuncSeparatei(0, GL_ONE, GL_MIN, GL_ONE, GL_ONE)");
148 
149 	gl.blendFuncSeparatei(0, GL_ONE, GL_ONE, GL_MIN, GL_ONE);
150 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFuncSeparatei(0, GL_ONE, GL_ONE, GL_MIN, GL_ONE)");
151 
152 	gl.blendFuncSeparatei(0, GL_ONE, GL_ONE, GL_ONE, GL_MIN);
153 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendFuncSeparatei(0, GL_ONE, GL_ONE, GL_ONE, GL_MIN)");
154 
155 	gl.blendEquationi(0, GL_SRC_ALPHA);
156 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendEquationi(0, GL_SRC_ALPHA)");
157 
158 	gl.blendEquationSeparatei(0, GL_SRC_ALPHA, GL_MIN);
159 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendEquationSeparatei(0, GL_SRC_ALPHA, GL_MIN)");
160 
161 	gl.blendEquationSeparatei(0, GL_MIN, GL_SRC_ALPHA);
162 	success &= ExpectedError(GL_INVALID_ENUM, "glBlendEquationSeparatei(0, GL_MIN, GL_SRC_ALPHA)");
163 
164 	gl.enablei(GL_FUNC_ADD, 0);
165 	success &= ExpectedError(GL_INVALID_ENUM, "glEnablei(GL_FUNC_ADD, 0)");
166 
167 	gl.disablei(GL_FUNC_ADD, 0);
168 	success &= ExpectedError(GL_INVALID_ENUM, "glDisablei(GL_FUNC_ADD, 0)");
169 
170 	gl.isEnabledi(GL_FUNC_ADD, 0);
171 	success &= ExpectedError(GL_INVALID_ENUM, "glIsEnabledi(GL_FUNC_ADD, 0)");
172 
173 	if (success)
174 	{
175 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
176 	}
177 	else
178 	{
179 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Negative test failed");
180 	}
181 	return STOP;
182 }
183 
ExpectedError(glw::GLenum expectedResult,const char * call)184 bool DrawBuffersIndexedNegative::ExpectedError(glw::GLenum expectedResult, const char* call)
185 {
186 	glw::GLenum error = m_context.getRenderContext().getFunctions().getError();
187 
188 	if (expectedResult != error)
189 	{
190 		m_testCtx.getLog() << tcu::TestLog::Message << "Error on " << call << " call.\n"
191 						   << "Expected " << expectedResult << " but found " << error << tcu::TestLog::EndMessage;
192 		return false;
193 	}
194 	return true;
195 }
196 
197 } // namespace glcts
198