summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/deqp/functional/gles3/es3fNegativeFragmentApiTests.js
blob: c3675d436f7198d3b510cd50c3da958fb5095aab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*-------------------------------------------------------------------------
 * drawElements Quality Program OpenGL ES 3.0 Module
 * -------------------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Negative Fragment Pipe API tests.
 *//*--------------------------------------------------------------------*/
'use strict';
goog.provide('functional.gles3.es3fNegativeFragmentApiTests');
goog.require('framework.common.tcuTestCase');
goog.require('functional.gles3.es3fApiCase');

goog.scope(function() {

    var es3fNegativeFragmentApiTests = functional.gles3.es3fNegativeFragmentApiTests;
    var es3fApiCase = functional.gles3.es3fApiCase;
    var tcuTestCase = framework.common.tcuTestCase;

    /**
     * @param {WebGL2RenderingContext} gl
     */
    es3fNegativeFragmentApiTests.init = function(gl) {

        var testGroup = tcuTestCase.runner.testCases;

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('scissor', 'Invalid gl.scissor() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_VALUE is generated if either width or height is negative.');
            gl.scissor(0, 0, -1, 0);
            this.expectError(gl.INVALID_VALUE);
            gl.scissor(0, 0, 0, -1);
            this.expectError(gl.INVALID_VALUE);
            gl.scissor(0, 0, -1, -1);
            this.expectError(gl.INVALID_VALUE);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('depth_func', 'Invalid gl.depthFunc() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not an accepted value.');
            gl.depthFunc(-1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('viewport', 'Invalid gl.viewport() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_VALUE is generated if either width or height is negative.');
            gl.viewport(0, 0, -1, 1);
            this.expectError(gl.INVALID_VALUE);
            gl.viewport(0, 0, 1, -1);
            this.expectError(gl.INVALID_VALUE);
            gl.viewport(0, 0, -1, -1);
            this.expectError(gl.INVALID_VALUE);

        }));

        // Stencil functions

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_func', 'Invalid gl.stencilFunc() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not one of the eight accepted values.');
            gl.stencilFunc(-1, 0, 1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_func_separate', 'Invalid gl.stencilFuncSeparate() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if face is not gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.');
            gl.stencilFuncSeparate(-1, gl.NEVER, 0, 1);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not one of the eight accepted values.');
            gl.stencilFuncSeparate(gl.FRONT, -1, 0, 1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_op', 'Invalid gl.stencilOp() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the defined symbolic constant values.');
            gl.stencilOp(-1, gl.ZERO, gl.REPLACE);
            this.expectError(gl.INVALID_ENUM);
            gl.stencilOp(gl.KEEP, -1, gl.REPLACE);
            this.expectError(gl.INVALID_ENUM);
            gl.stencilOp(gl.KEEP, gl.ZERO, -1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_op_separate', 'Invalid gl.stencilOpSeparate() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if face is any value other than gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.');
            gl.stencilOpSeparate(-1, gl.KEEP, gl.ZERO, gl.REPLACE);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.');
            gl.stencilOpSeparate(gl.FRONT, -1, gl.ZERO, gl.REPLACE);
            this.expectError(gl.INVALID_ENUM);
            gl.stencilOpSeparate(gl.FRONT, gl.KEEP, -1, gl.REPLACE);
            this.expectError(gl.INVALID_ENUM);
            gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.ZERO, -1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_mask_separate', 'Invalid gl.stencilMaskSeparate() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if face is not gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.');
            gl.stencilMaskSeparate(-1, 0);
            this.expectError(gl.INVALID_ENUM);

        }));

        // Blend functions

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_equation', 'Invalid gl.blendEquation() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.');
            gl.blendEquation(-1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_equation_separate', 'Invalid gl.blendEquationSeparate() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if modeRGB is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.');
            gl.blendEquationSeparate(-1, gl.FUNC_ADD);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_ENUM is generated if modeAlpha is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.');
            gl.blendEquationSeparate(gl.FUNC_ADD, -1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_func', 'Invalid gl.blendFunc() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.');
            gl.blendFunc(-1, gl.ONE);
            this.expectError(gl.INVALID_ENUM);
            gl.blendFunc(gl.ONE, -1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_func_separate', 'Invalid gl.blendFuncSeparate() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.');
            gl.blendFuncSeparate(-1, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR);
            this.expectError(gl.INVALID_ENUM);
            gl.blendFuncSeparate(gl.ZERO, -1, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR);
            this.expectError(gl.INVALID_ENUM);
            gl.blendFuncSeparate(gl.ZERO, gl.ONE, -1, gl.ONE_MINUS_SRC_COLOR);
            this.expectError(gl.INVALID_ENUM);
            gl.blendFuncSeparate(gl.ZERO, gl.ONE, gl.SRC_COLOR, -1);
            this.expectError(gl.INVALID_ENUM);

        }));

        // Rasterization API functions

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('cull_face', 'Invalid gl.cullFace() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not an accepted value.');
            gl.cullFace(-1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('front_face', 'Invalid gl.frontFace() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not an accepted value.');
            gl.frontFace(-1);
            this.expectError(gl.INVALID_ENUM);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('line_width', 'Invalid gl.lineWidth() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_VALUE is generated if width is less than or equal to 0.');
            gl.lineWidth(0);
            this.expectError(gl.INVALID_VALUE);
            gl.lineWidth(-1);
            this.expectError(gl.INVALID_VALUE);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('begin_query', 'Invalid gl.beginQuery() usage', gl, function() {
            /** @type{Array<WebGLQuery>} */ var ids = [];
            ids[0] = gl.createQuery();
            ids[1] = gl.createQuery();
            ids[2] = gl.createQuery();

            bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.');
            gl.beginQuery(-1, ids[0]);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.beginQuery is executed while a query object of the same target is already active.');
            gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[0]);
            this.expectError(gl.NO_ERROR);
            gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[1]);
            this.expectError(gl.INVALID_OPERATION);
            // \note gl.ANY_SAMPLES_PASSED and gl.ANY_SAMPLES_PASSED_CONSERVATIVE alias to the same target for the purposes of this error.
            gl.beginQuery(gl.ANY_SAMPLES_PASSED_CONSERVATIVE, ids[1]);
            this.expectError(gl.INVALID_OPERATION);
            gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[1]);
            this.expectError(gl.NO_ERROR);
            gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[2]);
            this.expectError(gl.INVALID_OPERATION);
            gl.endQuery(gl.ANY_SAMPLES_PASSED);
            gl.endQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
            this.expectError(gl.NO_ERROR);

            bufferedLogToConsole('An exception is thrown if the name is null.');
            this.expectThrowNoError(function() {
                gl.beginQuery(gl.ANY_SAMPLES_PASSED, null);
            });

            bufferedLogToConsole('gl.INVALID_OPERATION is generated if the name has since been deleted with gl.deleteQuery.');
            gl.deleteQuery(ids[2]);
            this.expectError(gl.NO_ERROR);
            gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[2]);
            this.expectError(gl.INVALID_OPERATION);

            bufferedLogToConsole('gl.INVALID_OPERATION is generated if id is the name of an already active query object.');
            gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[0]);
            this.expectError(gl.NO_ERROR);
            gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
            this.expectError(gl.INVALID_OPERATION);

            bufferedLogToConsole('gl.INVALID_OPERATION is generated if id refers to an existing query object whose type does not does not match target.');
            gl.endQuery(gl.ANY_SAMPLES_PASSED);
            this.expectError(gl.NO_ERROR);
            gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]);
            this.expectError(gl.INVALID_OPERATION);

            gl.deleteQuery(ids[0]);
            gl.deleteQuery(ids[1]);
            gl.deleteQuery(ids[2]);
            this.expectError(gl.NO_ERROR);
        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('end_query', 'Invalid gl.endQuery() usage', gl, function() {
            /** @type{WebGLQuery} */ var id;
            id = gl.createQuery();

            bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.');
            gl.endQuery(-1);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.endQuery is executed when a query object of the same target is not active.');
            gl.endQuery(gl.ANY_SAMPLES_PASSED);
            this.expectError(gl.INVALID_OPERATION);
            gl.beginQuery(gl.ANY_SAMPLES_PASSED, id);
            this.expectError(gl.NO_ERROR);
            gl.endQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
            this.expectError(gl.INVALID_OPERATION);
            gl.endQuery(gl.ANY_SAMPLES_PASSED);
            this.expectError(gl.NO_ERROR);

            gl.deleteQuery(id);
            this.expectError(gl.NO_ERROR);
        }));

        // Sync objects

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('fence_sync', 'Invalid gl.fenceSync() usage', gl, function() {
            bufferedLogToConsole('gl.INVALID_ENUM is generated if condition is not gl.SYNC_GPU_COMMANDS_COMPLETE.');
            gl.fenceSync(-1, 0);
            this.expectError(gl.INVALID_ENUM);

            bufferedLogToConsole('gl.INVALID_VALUE is generated if flags is not zero.');
            gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0x0010);
            this.expectError(gl.INVALID_VALUE);

        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('wait_sync', 'Invalid gl.waitSync() usage', gl, function() {
            /** @type{WebGLSync} */ var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);

            bufferedLogToConsole('An exception is thrown if sync is null.');
            this.expectThrowNoError(function() {
                gl.waitSync(null, 0, gl.TIMEOUT_IGNORED);
            });

            bufferedLogToConsole('gl.INVALID_VALUE is generated if flags is not zero.');
            gl.waitSync(sync, 0x0010, gl.TIMEOUT_IGNORED);
            this.expectError(gl.INVALID_VALUE);

            bufferedLogToConsole('gl.INVALID_VALUE is generated if timeout is not gl.TIMEOUT_IGNORED.');
            gl.waitSync(sync, 0, 0);
            this.expectError(gl.INVALID_VALUE);

            gl.deleteSync(sync);
        }));

        testGroup.addChild(new es3fApiCase.ApiCaseCallback('client_wait_sync', 'Invalid gl.clientWaitSync() usage', gl, function() {
            /** @type{WebGLSync} */ var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);

            bufferedLogToConsole('An exception is thrown if sync is null.');
            this.expectThrowNoError(function() {
                gl.clientWaitSync (null, 0, 0);
            });

            bufferedLogToConsole('gl.INVALID_VALUE is generated if flags contains any unsupported flag.');
            gl.clientWaitSync(sync, 0x00000004, 0);
            this.expectError(gl.INVALID_VALUE);

            gl.deleteSync(sync);
        }));

    };

    /**
     * @param {WebGL2RenderingContext} gl
     */
    es3fNegativeFragmentApiTests.run = function(gl) {
        var testName = 'negativeFragmentApi';
        var testDescription = 'Negative Fragment API tests';
        var state = tcuTestCase.runner;

        state.testName = testName;
        state.testCases = tcuTestCase.newTest(testName, testDescription, null);

        //Set up name and description of this test series.
        setCurrentTestName(testName);
        description(testDescription);
        try {
            es3fNegativeFragmentApiTests.init(gl);
            tcuTestCase.runner.runCallback(tcuTestCase.runTestCases);
        } catch (err) {
            bufferedLogToConsole(err);
            tcuTestCase.runner.terminate();
        }
    };

});