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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/draw-elements-out-of-bounds.html

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

Powered by Google App Engine
This is Rietveld 408576698