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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/rendering/draw-elements-out-of-bounds.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 </head>
36 <body>
37 <div id="description"></div>
38 <div id="console"></div>
39
40 <script>
41 description("Test of drawElements with out-of-bounds parameters");
42
43 var context = create3DContext();
44 var program = loadStandardProgram(context);
45
46 context.useProgram(program);
47 var vertexObject = context.createBuffer();
48 context.enableVertexAttribArray(0);
49 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
50 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0 , 0.5,-0.5,0 ]), context.STATIC_DRAW);
51 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
52
53 var indexObject = context.createBuffer();
54
55 debug("Test empty index buffer")
56 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
57 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ ]), context.S TATIC_DRAW);
58 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
59 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
60 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
61 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
62 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 1, context.UNSIGNED_BYTE, 0)");
63 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
64 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
65 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
66 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
67
68 debug("")
69 debug("Test buffer with 3 byte indexes")
70 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
71 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2 ]), co ntext.STATIC_DRAW);
72 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
73 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 3, context.UNSIGNED_INT, 0)");
74 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(0x000 9, 3, context.UNSIGNED_BYTE, 0)"); // GL_POLYGON
75 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 2)");
76 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
77 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
78 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
79 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
80 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
81 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
82 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 4)");
83 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_BYTE, 0)");
84 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0)");
85 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0x7fffffff)");
86
87 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ELE MENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1), context.STATIC_ DRAW)");
88 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
89 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))");
90 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
91 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1))");
92 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
93 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
94
95 debug("")
96 debug("Test buffer with interleaved (3+2) float vectors")
97
98 var program2 = createProgram(context,
99 "attribute vec3 aOne;" +
100 "attribute vec2 aTwo;" +
101 "void main() { gl_Position = vec4(aOne, 1.0) + vec4 (aTwo, 0.0, 1.0); }",
102 "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1 .0); }",
103 [ "aOne", "aTwo" ]);
104 if (!program2) {
105 testFailed("failed to create test program");
106 }
107
108 context.useProgram(program2);
109
110 var vbo = context.createBuffer();
111 context.bindBuffer(context.ARRAY_BUFFER, vbo);
112 // enough for 9 vertices, so 3 triangles
113 context.bufferData(context.ARRAY_BUFFER, new Float32Array(9*5), context.STATIC_D RAW);
114
115 // bind first 3 elements, with a stride of 5 float elements
116 context.vertexAttribPointer(0, 3, context.FLOAT, false, 5*4, 0);
117 // bind 2 elements, starting after the first 3; same stride of 5 float elements
118 context.vertexAttribPointer(1, 2, context.FLOAT, false, 5*4, 3*4);
119
120 context.enableVertexAttribArray(0);
121 context.enableVertexAttribArray(1);
122
123 var ebo = context.createBuffer();
124 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
125 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array(
126 [ 0, 1, 2,
127 1, 2, 0,
128 2, 0, 1,
129 200, 200, 200,
130 0x7fff, 0x7fff, 0x7fff,
131 0xffff, 0xffff, 0xffff ]),
132 context.STATIC_DRAW);
133
134 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 9, context.UNSIGNED_SHORT, 0)");
135
136 // invalid type arguments
137 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.FLOAT, 0)");
138 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.SHORT, 0)");
139 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.UNSIGNED_INT, 0)");
140
141 // invalid operation with indices that would be valid with correct bindings
142 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 9, context.UNSIGNED_SHORT, 1000)");
143 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 12, context.UNSIGNED_SHORT, 0)");
144 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 15, context.UNSIGNED_SHORT, 0)");
145 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 18, context.UNSIGNED_SHORT, 0)");
146 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_SHORT, 2*15)");
147
148 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_SHORT, 0)");
149 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_SHORT, 0)");
150
151 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_SHORT, 0)");
152
153 // invalid operation with offset that's not a multiple of the type size
154 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 0)");
155 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 1)");
156 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 2)");
157
158 // invalid operation if no buffer is bound to ELEMENT_ARRAY_BUFFER
159 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
160 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 0)");
161 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
162
163 debug("")
164 debug("Test buffer setting attrib 0 to a buffer too small and disable it.");
165 var smallVBO = context.createBuffer();
166 shouldBeNonNull('smallVBO');
167 context.bindBuffer(context.ARRAY_BUFFER, smallVBO);
168 context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW);
169 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0x10);
170 context.disableVertexAttribArray(0);
171 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 2)");
172 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
173 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 2)");
174 debug("")
175 successfullyParsed = true;
176 </script>
177
178 <script src="../../resources/js-test-post.js"></script>
179 </body>
180 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698