Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: third_party/webgl/sdk/tests/conformance/textures/tex-input-validation.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
33 <script src="../../resources/js-test-pre.js"></script>
34 <script src="../resources/webgl-test.js"></script>
35 <script src="../resources/webgl-test-utils.js"></script>
36 </head>
37 <body>
38 <div id="description"></div>
39 <div id="console"></div>
40
41 <script>
42 var wtu = WebGLTestUtils;
43 var gl = null;
44 var tex = null;
45 var error = 0;
46
47 function enumToString(value) {
48 return wtu.glEnumToString(gl, value);
49 }
50
51 function testTexImage2D(testCase)
52 {
53 var level = 0;
54 var width = 16;
55 var height = 16;
56 var msg = "" +
57 " internalFormat: " + enumToString(testCase.internalFormat) +
58 " target: " + enumToString(testCase.target) +
59 " format: " + enumToString(testCase.format) +
60 " type: " + enumToString(testCase.type) +
61 " border: " + testCase.border;
62
63 gl.texImage2D(testCase.target, level, testCase.internalFormat, width, height , testCase.border, testCase.format, testCase.type, null);
64 error = testCase.expectedError;
65 glErrorShouldBe(gl, error, msg);
66 }
67
68 function testTexSubImage2D(testCase)
69 {
70 var level = 0;
71 var xoffset = 0;
72 var yoffset = 0;
73 var width = 16;
74 var height = 16;
75 var msg = ""+
76 " format: " + enumToString(testCase.format) +
77 " type: " + enumToString(testCase.type);
78 var array = new Uint8Array(width * height * 4);
79 gl.texSubImage2D(testCase.target, level, xoffset, yoffset, width, height, te stCase.format, testCase.type, array);
80 error = testCase.expectedError;
81 glErrorShouldBe(gl, error, msg);
82 }
83
84 function testTexParameter(testCase)
85 {
86 var msg = "paramName: " + enumToString(testCase.pname);
87 error = testCase.expectedError;
88 gl.texParameteri(testCase.target, testCase.pname, testCase.param);
89 glErrorShouldBe(gl, error, msg);
90 gl.texParameterf(testCase.target, testCase.pname, testCase.param);
91 glErrorShouldBe(gl, error, msg);
92 }
93
94 function testGetTexParameter(testCase)
95 {
96 var msg = "paramName: " + enumToString(testCase.pname);
97 error = testCase.expectedError;
98 gl.getTexParameter(testCase.target, testCase.pname);
99 glErrorShouldBe(gl, error, msg);
100 }
101
102 function testCopyTexImage2D(testCase)
103 {
104 var level = 0;
105 var x = 0;
106 var y = 0;
107 var width = 16;
108 var height = 16;
109
110 var msg = "" +
111 " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) +
112 " internalFormat: " + enumToString(testCase.internalFormat) +
113 " target: " + enumToString(testCase.target) +
114 " border: " + testCase.border;
115
116 gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, h eight);
117 glErrorShouldBe(gl, gl.NO_ERROR);
118 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLE TE");
119
120 gl.copyTexImage2D(testCase.target, level, testCase.internalFormat, x, y, wid th, height, testCase.border);
121 error = testCase.expectedError;
122 glErrorShouldBe(gl, error, msg);
123 }
124
125 function testCopyTexSubImage2D(testCase)
126 {
127 var level = 0;
128 var x = 0;
129 var y = 0;
130 var width = 16;
131 var height = 16;
132 var xoffset = 0;
133 var yoffset = 0;
134 var border = 0;
135 var type = gl.UNSIGNED_BYTE;
136 var msg = "" +
137 " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) +
138 " internalFormat: " + enumToString(testCase.internalFormat) +
139 " target: " + enumToString(testCase.target);
140
141 gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, h eight);
142 glErrorShouldBe(gl, gl.NO_ERROR);
143 shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLE TE");
144
145 gl.texImage2D(testCase.target, level, testCase.internalFormat, xoffset + wid th, yoffset + height, border, testCase.internalFormat, type, null);
146 glErrorShouldBe(gl, gl.NO_ERROR);
147
148 gl.copyTexSubImage2D(testCase.target, level, xoffset, yoffset, x, y, width, height);
149 error = testCase.expectedError;
150 glErrorShouldBe(gl, error, msg);
151 }
152
153 function testCopyFromInternalFBO(testCase)
154 {
155 var target = gl.TEXTURE_2D;
156 var level = 0;
157 var x = 0;
158 var y = 0;
159 var width = 16;
160 var height = 16;
161 var xoffset = 0;
162 var yoffset = 0;
163 var border = 0;
164 var type = gl.UNSIGNED_BYTE;
165 var msg = "" +
166 " colorBufferFormat: " + enumToString(testCase.contextAlpha ? gl.RGBA : gl .RGB) +
167 " internalFormat: " + enumToString(testCase.internalFormat);
168
169 if (testCase.contextAlpha)
170 gl = create3DContext(null, { alpha: true });
171 else
172 gl = create3DContext(null, { alpha: false });
173 shouldBeNonNull("gl");
174 shouldBeNonNull("tex = gl.createTexture()");
175 gl.bindTexture(target, tex);
176 if (testCase.subImage) {
177 gl.texImage2D(target, level, testCase.internalFormat, xoffset + width, y offset + height, border, testCase.internalFormat, type, null);
178 glErrorShouldBe(gl, gl.NO_ERROR);
179 gl.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, heigh t);
180 } else {
181 glErrorShouldBe(gl, gl.NO_ERROR);
182 gl.copyTexImage2D(target, level, testCase.internalFormat, x, y, width, h eight, border);
183 }
184 error = testCase.expectedError;
185 glErrorShouldBe(gl, error, msg);
186 }
187
188 description("Validate tex functions input parameters");
189
190 shouldBeNonNull("gl = create3DContext()");
191 shouldBeNonNull("tex = gl.createTexture()");
192 gl.bindTexture(gl.TEXTURE_2D, tex);
193 glErrorShouldBe(gl, gl.NO_ERROR);
194
195 debug("");
196 debug("Checking TexImage2D: a set of inputs that are valid in GL but invalid in GLES2");
197
198 var testCases =
199 [ {target: 0x8064, // GL_PROXY_TEXTURE_2D
200 internalFormat: gl.RGBA,
201 border: 0,
202 format: gl.RGBA,
203 type: gl.UNSIGNED_BYTE,
204 expectedError: gl.INVALID_ENUM},
205 {target: gl.TEXTURE_2D,
206 internalFormat: 0x1903, // GL_RED
207 border: 0,
208 format: 0x1903, // GL_RED
209 type: gl.UNSIGNED_BYTE,
210 expectedError: gl.INVALID_ENUM},
211 {target: gl.TEXTURE_2D,
212 internalFormat: gl.RGBA,
213 border: 1,
214 format: gl.RGBA,
215 type: gl.UNSIGNED_BYTE,
216 expectedError: gl.INVALID_VALUE},
217 {target: gl.TEXTURE_2D,
218 internalFormat: gl.RGBA,
219 border: 0,
220 format: gl.RGB,
221 type: gl.UNSIGNED_BYTE,
222 expectedError: gl.INVALID_OPERATION},
223 {target: gl.TEXTURE_2D,
224 internalFormat: gl.RGBA,
225 border: 0,
226 format: gl.RGBA,
227 type: gl.BYTE,
228 expectedError: gl.INVALID_ENUM},
229 {target: gl.TEXTURE_2D,
230 internalFormat: gl.RGBA,
231 border: 0,
232 format: gl.RGBA,
233 type: gl.UNSIGNED_BYTE,
234 expectedError: gl.NO_ERROR} ];
235
236 for (var ii = 0; ii < testCases.length; ++ii)
237 testTexImage2D(testCases[ii]);
238
239 debug("");
240 debug("Checking TexSubImage2D: a set of inputs that are valid in GL but invalid in GLES2");
241
242 testCases =
243 [ {target: gl.TEXTURE_2D,
244 format: 0x1903, // GL_RED
245 type: gl.UNSIGNED_BYTE,
246 expectedError: gl.INVALID_ENUM},
247 {target: gl.TEXTURE_2D,
248 format: gl.RGBA,
249 type: gl.BYTE,
250 expectedError: gl.INVALID_ENUM},
251 {target: gl.TEXTURE_2D,
252 format: gl.RGBA,
253 type: gl.UNSIGNED_BYTE,
254 expectedError: gl.NO_ERROR} ];
255
256 for (var ii = 0; ii < testCases.length; ++ii)
257 testTexSubImage2D(testCases[ii]);
258
259 debug("");
260 debug("Checking TexParameter: a set of inputs that are valid in GL but invalid i n GLES2");
261
262 testCases =
263 [ {target: 0x0DE0, // GL_TEXTURE_1D
264 pname: gl.TEXTURE_WRAP_T,
265 param: gl.REPEAT,
266 expectedError: gl.INVALID_ENUM},
267 {target: gl.TEXTURE_2D,
268 pname: 0x813A, // GL_TEXTURE_MIN_LOD
269 param: 0,
270 expectedError: gl.INVALID_ENUM},
271 {target: gl.TEXTURE_2D,
272 pname: gl.TEXTURE_WRAP_T,
273 param: 0x2900, // GL_CLAMP
274 expectedError: gl.INVALID_ENUM},
275 {target: gl.TEXTURE_2D,
276 pname: gl.TEXTURE_WRAP_T,
277 param: gl.REPEAT,
278 expectedError: gl.NO_ERROR} ];
279
280 for (var ii = 0; ii < testCases.length; ++ii)
281 testTexParameter(testCases[ii]);
282
283 debug("");
284 debug("Checking GetTexParameter: a set of inputs that are valid in GL but invali d in GLES2");
285
286 testCases =
287 [ {target: 0x0DE0, // GL_TEXTURE_1D
288 pname: gl.TEXTURE_WRAP_T,
289 expectedError: gl.INVALID_ENUM},
290 {target: gl.TEXTURE_2D,
291 pname: 0x813A, // GL_TEXTURE_MIN_LOD
292 expectedError: gl.INVALID_ENUM},
293 {target: gl.TEXTURE_2D,
294 pname: gl.TEXTURE_WRAP_T,
295 expectedError: gl.NO_ERROR} ];
296
297 for (var ii = 0; ii < testCases.length; ++ii)
298 testGetTexParameter(testCases[ii]);
299
300 debug("");
301 debug("Checking CopyTexImage2D: a set of inputs that are valid in GL but invalid in GLES2");
302
303 var colorBuffer = null;
304 var fbo = null;
305
306 shouldBeNonNull("fbo = gl.createFramebuffer()");
307 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
308 shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
309 gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
310 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER , colorBuffer);
311 glErrorShouldBe(gl, gl.NO_ERROR);
312
313 testCases =
314 [ {target: gl.TEXTURE_2D,
315 colorBufferFormat: gl.RGB565,
316 internalFormat: 0x8054, // GL_RGB16
317 border: 0,
318 expectedError: gl.INVALID_ENUM},
319 {target: gl.TEXTURE_2D,
320 colorBufferFormat: gl.RGB565,
321 internalFormat: gl.RGBA,
322 border: 1,
323 expectedError: gl.INVALID_VALUE},
324 {target: gl.TEXTURE_2D,
325 colorBufferFormat: gl.RGB565,
326 internalFormat: gl.RGBA,
327 border: 0,
328 expectedError: gl.INVALID_OPERATION},
329 {target: gl.TEXTURE_2D,
330 colorBufferFormat: gl.RGB565,
331 internalFormat: gl.RGB,
332 border: 0,
333 expectedError: gl.NO_ERROR} ];
334
335 for (var ii = 0; ii < testCases.length; ++ii)
336 testCopyTexImage2D(testCases[ii]);
337
338 debug("");
339 debug("Checking CopyTexSubImage2D: a set of inputs that are valid in GL but inva lid in GLES2");
340
341 testCases =
342 [ {target: gl.TEXTURE_2D,
343 colorBufferFormat: gl.RGB5_A1,
344 internalFormat: gl.RGBA,
345 expectedError: gl.NO_ERROR},
346 {target: gl.TEXTURE_2D,
347 colorBufferFormat: gl.RGB565,
348 internalFormat: gl.RGBA,
349 expectedError: gl.INVALID_OPERATION} ];
350
351 for (var ii = 0; ii < testCases.length; ++ii)
352 testCopyTexSubImage2D(testCases[ii]);
353
354 debug("");
355 debug("Checking CopyTex{Sub}Image2D: copy from WebGL internal framebuffer");
356
357 testCases =
358 [ {contextAlpha: true,
359 internalFormat: gl.RGBA,
360 subImage: false,
361 expectedError: gl.NO_ERROR},
362 {contextAlpha: false,
363 internalFormat: gl.RGBA,
364 subImage: false,
365 expectedError: gl.INVALID_OPERATION},
366 {contextAlpha: true,
367 internalFormat: gl.RGBA,
368 subImage: true,
369 expectedError: gl.NO_ERROR},
370 {contextAlpha: false,
371 internalFormat: gl.RGBA,
372 subImage: true,
373 expectedError: gl.INVALID_OPERATION} ];
374
375 for (var ii = 0; ii < testCases.length; ++ii)
376 testCopyFromInternalFBO(testCases[ii]);
377
378 successfullyParsed = true;
379 </script>
380
381 <script src="../../resources/js-test-post.js"></script>
382 </body>
383 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698