1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 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 "es3fNegativeFragmentApiTests.hpp"
25 #include "es3fApiCase.hpp"
26
27 #include "glwDefs.hpp"
28 #include "glwEnums.hpp"
29
30 using namespace glw; // GL types
31
32 namespace deqp
33 {
34 namespace gles3
35 {
36 namespace Functional
37 {
38
39 using tcu::TestLog;
40
NegativeFragmentApiTests(Context & context)41 NegativeFragmentApiTests::NegativeFragmentApiTests (Context& context)
42 : TestCaseGroup(context, "fragment", "Negative Fragment API Cases")
43 {
44 }
45
~NegativeFragmentApiTests(void)46 NegativeFragmentApiTests::~NegativeFragmentApiTests (void)
47 {
48 }
49
init(void)50 void NegativeFragmentApiTests::init (void)
51 {
52 ES3F_ADD_API_CASE(scissor, "Invalid glScissor() usage",
53 {
54 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
55 glScissor(0, 0, -1, 0);
56 expectError(GL_INVALID_VALUE);
57 glScissor(0, 0, 0, -1);
58 expectError(GL_INVALID_VALUE);
59 glScissor(0, 0, -1, -1);
60 expectError(GL_INVALID_VALUE);
61 m_log << TestLog::EndSection;
62 });
63 ES3F_ADD_API_CASE(depth_func, "Invalid glDepthFunc() usage",
64 {
65 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not an accepted value.");
66 glDepthFunc(-1);
67 expectError(GL_INVALID_ENUM);
68 m_log << TestLog::EndSection;
69 });
70 ES3F_ADD_API_CASE(viewport, "Invalid glViewport() usage",
71 {
72 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
73 glViewport(0, 0, -1, 1);
74 expectError(GL_INVALID_VALUE);
75 glViewport(0, 0, 1, -1);
76 expectError(GL_INVALID_VALUE);
77 glViewport(0, 0, -1, -1);
78 expectError(GL_INVALID_VALUE);
79 m_log << TestLog::EndSection;
80 });
81
82 // Stencil functions
83
84 ES3F_ADD_API_CASE(stencil_func, "Invalid glStencilFunc() usage",
85 {
86 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
87 glStencilFunc(-1, 0, 1);
88 expectError(GL_INVALID_ENUM);
89 m_log << TestLog::EndSection;
90 });
91 ES3F_ADD_API_CASE(stencil_func_separate, "Invalid glStencilFuncSeparate() usage",
92 {
93 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
94 glStencilFuncSeparate(-1, GL_NEVER, 0, 1);
95 expectError(GL_INVALID_ENUM);
96 m_log << TestLog::EndSection;
97
98 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
99 glStencilFuncSeparate(GL_FRONT, -1, 0, 1);
100 expectError(GL_INVALID_ENUM);
101 m_log << TestLog::EndSection;
102 });
103 ES3F_ADD_API_CASE(stencil_op, "Invalid glStencilOp() usage",
104 {
105 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the defined symbolic constant values.");
106 glStencilOp(-1, GL_ZERO, GL_REPLACE);
107 expectError(GL_INVALID_ENUM);
108 glStencilOp(GL_KEEP, -1, GL_REPLACE);
109 expectError(GL_INVALID_ENUM);
110 glStencilOp(GL_KEEP, GL_ZERO, -1);
111 expectError(GL_INVALID_ENUM);
112 m_log << TestLog::EndSection;
113 });
114 ES3F_ADD_API_CASE(stencil_op_separate, "Invalid glStencilOpSeparate() usage",
115 {
116 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is any value other than GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
117 glStencilOpSeparate(-1, GL_KEEP, GL_ZERO, GL_REPLACE);
118 expectError(GL_INVALID_ENUM);
119 m_log << TestLog::EndSection;
120
121 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.");
122 glStencilOpSeparate(GL_FRONT, -1, GL_ZERO, GL_REPLACE);
123 expectError(GL_INVALID_ENUM);
124 glStencilOpSeparate(GL_FRONT, GL_KEEP, -1, GL_REPLACE);
125 expectError(GL_INVALID_ENUM);
126 glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_ZERO, -1);
127 expectError(GL_INVALID_ENUM);
128 m_log << TestLog::EndSection;
129 });
130 ES3F_ADD_API_CASE(stencil_mask_separate, "Invalid glStencilMaskSeparate() usage",
131 {
132 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
133 glStencilMaskSeparate(-1, 0);
134 expectError(GL_INVALID_ENUM);
135 m_log << TestLog::EndSection;
136 });
137
138 // Blend functions
139
140 ES3F_ADD_API_CASE(blend_equation, "Invalid glBlendEquation() usage",
141 {
142 m_log << TestLog::Section("", "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 glBlendEquation(-1);
144 expectError(GL_INVALID_ENUM);
145 m_log << TestLog::EndSection;
146 });
147 ES3F_ADD_API_CASE(blend_equation_separate, "Invalid glBlendEquationSeparate() usage",
148 {
149 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if modeRGB is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
150 glBlendEquationSeparate(-1, GL_FUNC_ADD);
151 expectError(GL_INVALID_ENUM);
152 m_log << TestLog::EndSection;
153 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if modeAlpha is not GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MAX or GL_MIN.");
154 glBlendEquationSeparate(GL_FUNC_ADD, -1);
155 expectError(GL_INVALID_ENUM);
156 m_log << TestLog::EndSection;
157 });
158 ES3F_ADD_API_CASE(blend_func, "Invalid glBlendFunc() usage",
159 {
160 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
161 glBlendFunc(-1, GL_ONE);
162 expectError(GL_INVALID_ENUM);
163 glBlendFunc(GL_ONE, -1);
164 expectError(GL_INVALID_ENUM);
165 m_log << TestLog::EndSection;
166 });
167 ES3F_ADD_API_CASE(blend_func_separate, "Invalid glBlendFuncSeparate() usage",
168 {
169 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
170 glBlendFuncSeparate(-1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
171 expectError(GL_INVALID_ENUM);
172 glBlendFuncSeparate(GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
173 expectError(GL_INVALID_ENUM);
174 glBlendFuncSeparate(GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
175 expectError(GL_INVALID_ENUM);
176 glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
177 expectError(GL_INVALID_ENUM);
178 m_log << TestLog::EndSection;
179 });
180
181 // Rasterization API functions
182
183 ES3F_ADD_API_CASE(cull_face, "Invalid glCullFace() usage",
184 {
185 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
186 glCullFace(-1);
187 expectError(GL_INVALID_ENUM);
188 m_log << TestLog::EndSection;
189 });
190 ES3F_ADD_API_CASE(front_face, "Invalid glFrontFace() usage",
191 {
192 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
193 glFrontFace(-1);
194 expectError(GL_INVALID_ENUM);
195 m_log << TestLog::EndSection;
196 });
197 ES3F_ADD_API_CASE(line_width, "Invalid glLineWidth() usage",
198 {
199 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width is less than or equal to 0.");
200 glLineWidth(0);
201 expectError(GL_INVALID_VALUE);
202 glLineWidth(-1);
203 expectError(GL_INVALID_VALUE);
204 m_log << TestLog::EndSection;
205 });
206
207 // Asynchronous queries
208
209 ES3F_ADD_API_CASE(gen_queries, "Invalid glGenQueries() usage",
210 {
211 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
212 GLuint ids;
213 glGenQueries (-1, &ids);
214 expectError (GL_INVALID_VALUE);
215 m_log << TestLog::EndSection;
216 });
217 ES3F_ADD_API_CASE(begin_query, "Invalid glBeginQuery() usage",
218 {
219 GLuint ids[3];
220 glGenQueries (3, ids);
221
222 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
223 glBeginQuery (-1, ids[0]);
224 expectError (GL_INVALID_ENUM);
225 m_log << TestLog::EndSection;
226
227 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if glBeginQuery is executed while a query object of the same target is already active.");
228 glBeginQuery (GL_ANY_SAMPLES_PASSED, ids[0]);
229 expectError (GL_NO_ERROR);
230 glBeginQuery (GL_ANY_SAMPLES_PASSED, ids[1]);
231 expectError (GL_INVALID_OPERATION);
232 // \note GL_ANY_SAMPLES_PASSED and GL_ANY_SAMPLES_PASSED_CONSERVATIVE alias to the same target for the purposes of this error.
233 glBeginQuery (GL_ANY_SAMPLES_PASSED_CONSERVATIVE, ids[1]);
234 expectError (GL_INVALID_OPERATION);
235 glBeginQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[1]);
236 expectError (GL_NO_ERROR);
237 glBeginQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[2]);
238 expectError (GL_INVALID_OPERATION);
239 glEndQuery (GL_ANY_SAMPLES_PASSED);
240 glEndQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
241 expectError (GL_NO_ERROR);
242 m_log << TestLog::EndSection;
243
244 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is 0.");
245 glBeginQuery (GL_ANY_SAMPLES_PASSED, 0);
246 expectError (GL_INVALID_OPERATION);
247 m_log << TestLog::EndSection;
248
249 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id not a name returned from a previous call to glGenQueries, or if such a name has since been deleted with glDeleteQueries.");
250 glBeginQuery (GL_ANY_SAMPLES_PASSED, -1);
251 expectError (GL_INVALID_OPERATION);
252 glDeleteQueries (1, &ids[2]);
253 expectError (GL_NO_ERROR);
254 glBeginQuery (GL_ANY_SAMPLES_PASSED, ids[2]);
255 expectError (GL_INVALID_OPERATION);
256 m_log << TestLog::EndSection;
257
258 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is the name of an already active query object.");
259 glBeginQuery (GL_ANY_SAMPLES_PASSED, ids[0]);
260 expectError (GL_NO_ERROR);
261 glBeginQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
262 expectError (GL_INVALID_OPERATION);
263 m_log << TestLog::EndSection;
264
265 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id refers to an existing query object whose type does not does not match target.");
266 glEndQuery (GL_ANY_SAMPLES_PASSED);
267 expectError (GL_NO_ERROR);
268 glBeginQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
269 expectError (GL_INVALID_OPERATION);
270 m_log << TestLog::EndSection;
271
272 glDeleteQueries (2, &ids[0]);
273 expectError (GL_NO_ERROR);
274 });
275 ES3F_ADD_API_CASE(end_query, "Invalid glEndQuery() usage",
276 {
277 GLuint id;
278 glGenQueries (1, &id);
279
280 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
281 glEndQuery (-1);
282 expectError (GL_INVALID_ENUM);
283 m_log << TestLog::EndSection;
284
285 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if glEndQuery is executed when a query object of the same target is not active.");
286 glEndQuery (GL_ANY_SAMPLES_PASSED);
287 expectError (GL_INVALID_OPERATION);
288 glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
289 expectError (GL_NO_ERROR);
290 glEndQuery (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
291 expectError (GL_INVALID_OPERATION);
292 glEndQuery (GL_ANY_SAMPLES_PASSED);
293 expectError (GL_NO_ERROR);
294 m_log << TestLog::EndSection;
295
296 glDeleteQueries (1, &id);
297 expectError (GL_NO_ERROR);
298 });
299 ES3F_ADD_API_CASE(delete_queries, "Invalid glDeleteQueries() usage",
300 {
301 GLuint id;
302 glGenQueries (1, &id);
303
304 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
305 glDeleteQueries (-1, &id);
306 expectError (GL_INVALID_VALUE);
307 m_log << TestLog::EndSection;
308
309 glDeleteQueries (1, &id);
310 });
311
312 // Sync objects
313
314 ES3F_ADD_API_CASE(fence_sync, "Invalid glFenceSync() usage",
315 {
316 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if condition is not GL_SYNC_GPU_COMMANDS_COMPLETE.");
317 glFenceSync(-1, 0);
318 expectError(GL_INVALID_ENUM);
319 m_log << TestLog::EndSection;
320
321 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if flags is not zero.");
322 glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0x0010);
323 expectError(GL_INVALID_VALUE);
324 m_log << TestLog::EndSection;
325 });
326 ES3F_ADD_API_CASE(wait_sync, "Invalid glWaitSync() usage",
327 {
328 GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
329
330 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
331 glWaitSync(0, 0, GL_TIMEOUT_IGNORED);
332 expectError(GL_INVALID_VALUE);
333 m_log << TestLog::EndSection;
334
335 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if flags is not zero.");
336 glWaitSync(sync, 0x0010, GL_TIMEOUT_IGNORED);
337 expectError(GL_INVALID_VALUE);
338 m_log << TestLog::EndSection;
339
340 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if timeout is not GL_TIMEOUT_IGNORED.");
341 glWaitSync(sync, 0, 0);
342 expectError(GL_INVALID_VALUE);
343 m_log << TestLog::EndSection;
344
345 glDeleteSync(sync);
346 });
347 ES3F_ADD_API_CASE(client_wait_sync, "Invalid glClientWaitSync() usage",
348 {
349 GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
350
351 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is not the name of an existing sync object.");
352 glClientWaitSync (0, 0, 10000);
353 expectError(GL_INVALID_VALUE);
354 m_log << TestLog::EndSection;
355
356 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if flags contains any unsupported flag.");
357 glClientWaitSync(sync, 0x00000004, 10000);
358 expectError(GL_INVALID_VALUE);
359 m_log << TestLog::EndSection;
360
361 glDeleteSync(sync);
362 });
363 ES3F_ADD_API_CASE(delete_sync, "Invalid glDeleteSync() usage",
364 {
365 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is neither zero or the name of a sync object.");
366 glDeleteSync((GLsync)1);
367 expectError(GL_INVALID_VALUE);
368 glDeleteSync(0);
369 expectError(GL_NO_ERROR);
370 m_log << TestLog::EndSection;
371 });
372 }
373
374
375 } // Functional
376 } // gles3
377 } // deqp
378