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

Side by Side Diff: conformance/rendering/draw-elements-out-of-bounds.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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 Copyright (C) 2011 Apple Computer, Inc. All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 1. Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 -->
25 <!DOCTYPE html>
26 <html>
27 <head>
28 <meta charset="utf-8">
29 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
30 <script src="../../resources/js-test-pre.js"></script>
31 <script src="../resources/webgl-test.js"></script>
32 </head>
33 <body>
34 <div id="description"></div>
35 <div id="console"></div>
36
37 <script>
38 description("Test of drawElements with out-of-bounds parameters");
39
40 var context = create3DContext();
41 var program = loadStandardProgram(context);
42
43 context.useProgram(program);
44 var vertexObject = context.createBuffer();
45 context.enableVertexAttribArray(0);
46 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
47 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0 , 0.5,-0.5,0 ]), context.STATIC_DRAW);
48 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
49
50 var indexObject = context.createBuffer();
51
52 debug("Test empty index buffer")
53 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
54 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ ]), context.S TATIC_DRAW);
55 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
56 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
57 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
58 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
59 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 1, context.UNSIGNED_BYTE, 0)");
60 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
61 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
62 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
63 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
64
65 debug("")
66 debug("Test buffer with 3 byte indexes")
67 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
68 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2 ]), co ntext.STATIC_DRAW);
69 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
70 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 3, context.UNSIGNED_INT, 0)");
71 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(0x000 9, 3, context.UNSIGNED_BYTE, 0)"); // GL_POLYGON
72 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 2)");
73 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
74 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
75 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
76 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
77 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
78 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
79 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 4)");
80 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_BYTE, 0)");
81 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0)");
82 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0x7fffffff)");
83
84 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ELE MENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1), context.STATIC_ DRAW)");
85 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
86 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))");
87 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
88 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1))");
89 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
90 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
91
92 debug("")
93 debug("Test buffer with interleaved (3+2) float vectors")
94
95 var program2 = createProgram(context,
96 "attribute vec3 aOne;" +
97 "attribute vec2 aTwo;" +
98 "void main() { gl_Position = vec4(aOne, 1.0) + vec4 (aTwo, 0.0, 1.0); }",
99 "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1 .0); }",
100 [ "aOne", "aTwo" ]);
101 if (!program2) {
102 testFailed("failed to create test program");
103 }
104
105 context.useProgram(program2);
106
107 var vbo = context.createBuffer();
108 context.bindBuffer(context.ARRAY_BUFFER, vbo);
109 // enough for 9 vertices, so 3 triangles
110 context.bufferData(context.ARRAY_BUFFER, new Float32Array(9*5), context.STATIC_D RAW);
111
112 // bind first 3 elements, with a stride of 5 float elements
113 context.vertexAttribPointer(0, 3, context.FLOAT, false, 5*4, 0);
114 // bind 2 elements, starting after the first 3; same stride of 5 float elements
115 context.vertexAttribPointer(1, 2, context.FLOAT, false, 5*4, 3*4);
116
117 context.enableVertexAttribArray(0);
118 context.enableVertexAttribArray(1);
119
120 var ebo = context.createBuffer();
121 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
122 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array(
123 [ 0, 1, 2,
124 1, 2, 0,
125 2, 0, 1,
126 200, 200, 200,
127 0x7fff, 0x7fff, 0x7fff,
128 0xffff, 0xffff, 0xffff ]),
129 context.STATIC_DRAW);
130
131 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 9, context.UNSIGNED_SHORT, 0)");
132
133 // invalid type arguments
134 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.FLOAT, 0)");
135 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.SHORT, 0)");
136 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.UNSIGNED_INT, 0)");
137
138 // invalid operation with indices that would be valid with correct bindings
139 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 9, context.UNSIGNED_SHORT, 1000)");
140 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 12, context.UNSIGNED_SHORT, 0)");
141 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 15, context.UNSIGNED_SHORT, 0)");
142 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 18, context.UNSIGNED_SHORT, 0)");
143 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_SHORT, 2*15)");
144
145 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_SHORT, 0)");
146 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_SHORT, 0)");
147
148 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_SHORT, 0)");
149
150 // invalid operation with offset that's not a multiple of the type size
151 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 0)");
152 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 1)");
153 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 2)");
154
155 // invalid operation if no buffer is bound to ELEMENT_ARRAY_BUFFER
156 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
157 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 0)");
158 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
159
160 debug("")
161 debug("Test buffer setting attrib 0 to a buffer too small and disable it.");
162 var smallVBO = context.createBuffer();
163 shouldBeNonNull('smallVBO');
164 context.bindBuffer(context.ARRAY_BUFFER, smallVBO);
165 context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW);
166 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0x10);
167 context.disableVertexAttribArray(0);
168 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 2)");
169 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
170 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 2)");
171 debug("")
172 successfullyParsed = true;
173 </script>
174
175 <script src="../../resources/js-test-post.js"></script>
176 </body>
177 </html>
OLDNEW
« no previous file with comments | « conformance/rendering/draw-arrays-out-of-bounds.html ('k') | conformance/rendering/gl-clear.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698