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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html

Issue 1601093008: Remove duplicated WebGL layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9
10 <script>
11 description("Test of drawElements with out-of-bounds parameters");
12
13 if (window.internals)
14 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
15
16 var context = create3DContext();
17 var program = loadStandardProgram(context);
18
19 context.useProgram(program);
20 var vertexObject = context.createBuffer();
21 context.enableVertexAttribArray(0);
22 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
23 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0 , 0.5,-0.5,0 ]), context.STATIC_DRAW);
24 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
25
26 var indexObject = context.createBuffer();
27
28 debug("Test empty index buffer")
29 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
30 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ ]), context.S TATIC_DRAW);
31 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
32 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
33 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
34 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
35 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 1, context.UNSIGNED_BYTE, 0)");
36 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
37 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
38 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
39 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
40
41 debug("")
42 debug("Test buffer with 3 byte indexes")
43 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
44 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2 ]), co ntext.STATIC_DRAW);
45 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
46 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 3, context.UNSIGNED_INT, 0)");
47 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(0x000 9, 3, context.UNSIGNED_BYTE, 0)"); // GL_POLYGON
48 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 2)");
49 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000, context.UNSIGNED_BYTE, 0)");
50 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 10000000000000, context.UNSIGNED_BYTE, 0)");
51 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 0)");
52 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0, context.UNSIGNED_BYTE, -1)");
53 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, -1, context.UNSIGNED_BYTE, 1)");
54 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 1, context.UNSIGNED_BYTE, -1)");
55 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 4)");
56 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_BYTE, 0)");
57 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0)");
58 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_BYTE, 0x7fffffff)");
59
60 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ELE MENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1), context.STATIC_ DRAW)");
61 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
62 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))");
63 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_BYTE, 0)");
64 shouldGenerateGLError(context, context.NO_ERROR, "context.bufferSubData(context. ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1))");
65 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 3, context.UNSIGNED_BYTE, 0)");
66 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_BYTE, 0)");
67
68 debug("")
69 debug("Test buffer with interleaved (3+2) float vectors")
70
71 var program2 = createProgram(context,
72 "attribute vec3 aOne;" +
73 "attribute vec2 aTwo;" +
74 "void main() { gl_Position = vec4(aOne, 1.0) + vec4 (aTwo, 0.0, 1.0); }",
75 "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1 .0); }",
76 [ "aOne", "aTwo" ]);
77 if (!program2) {
78 testFailed("failed to create test program");
79 }
80
81 context.useProgram(program2);
82
83 var vbo = context.createBuffer();
84 context.bindBuffer(context.ARRAY_BUFFER, vbo);
85 // enough for 9 vertices, so 3 triangles
86 context.bufferData(context.ARRAY_BUFFER, new Float32Array(9*5), context.STATIC_D RAW);
87
88 // bind first 3 elements, with a stride of 5 float elements
89 context.vertexAttribPointer(0, 3, context.FLOAT, false, 5*4, 0);
90 // bind 2 elements, starting after the first 3; same stride of 5 float elements
91 context.vertexAttribPointer(1, 2, context.FLOAT, false, 5*4, 3*4);
92
93 context.enableVertexAttribArray(0);
94 context.enableVertexAttribArray(1);
95
96 var ebo = context.createBuffer();
97 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
98 context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 0, 1, 2,
99 1, 2, 0,
100 2, 0, 1,
101 200, 200, 200 ,
102 0x7fff, 0x7ff f, 0x7fff,
103 0xffff, 0xfff f, 0xffff ]),
104 context.STATIC_DRAW);
105
106 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 9, context.UNSIGNED_SHORT, 0)");
107
108 // invalid type arguments
109 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.FLOAT, 0)");
110 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.SHORT, 0)");
111 shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(conte xt.TRIANGLES, 9, context.UNSIGNED_INT, 0)");
112
113 // invalid operation with indices that would be valid with correct bindings
114 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 9, context.UNSIGNED_SHORT, 1000)");
115 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 12, context.UNSIGNED_SHORT, 0)");
116 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 15, context.UNSIGNED_SHORT, 0)");
117 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 18, context.UNSIGNED_SHORT, 0)");
118 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 3, context.UNSIGNED_SHORT, 2*15)");
119
120 shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawElements(cont ext.TRIANGLES, 0xffffffff, context.UNSIGNED_SHORT, 0)");
121 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 0x7fffffff, context.UNSIGNED_SHORT, 0)");
122
123 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 0, context.UNSIGNED_SHORT, 0)");
124
125 // invalid operation with offset that's not a multiple of the type size
126 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 0)");
127 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 1)");
128 shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.T RIANGLES, 6, context.UNSIGNED_SHORT, 2)");
129
130 // invalid operation if no buffer is bound to ELEMENT_ARRAY_BUFFER
131 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
132 shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements( context.TRIANGLES, 6, context.UNSIGNED_SHORT, 0)");
133
134 debug("")
135 </script>
136
137 </body>
138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698