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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/gl-object-get-calls.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 get calls against GL objects like getBufferParameter, etc." );
37
38 function sizeInBytes(type) {
39 switch (type) {
40 case gl.BYTE:
41 case gl.UNSIGNED_BYTE:
42 return 1;
43 case gl.SHORT:
44 case gl.UNSIGNED_SHORT:
45 return 2;
46 case gl.INT:
47 case gl.UNSIGNED_INT:
48 case gl.FLOAT:
49 return 4;
50 default:
51 throw "unknown type";
52 }
53 }
54
55 var gl = create3DContext();
56
57 var standardVert = loadStandardVertexShader(gl);
58 var standardFrag = loadStandardFragmentShader(gl);
59 var standardProgram = gl.createProgram();
60 gl.attachShader(standardProgram, standardVert);
61 gl.attachShader(standardProgram, standardFrag);
62 gl.linkProgram(standardProgram);
63 var shaders = gl.getAttachedShaders(standardProgram);
64 shouldBe('shaders.length', '2');
65 shouldBeTrue('shaders[0] == standardVert && shaders[1] == standardFrag || shader s[1] == standardVert && shaders[0] == standardFrag');
66 glErrorShouldBe(gl, gl.NO_ERROR);
67 shouldBeNull('gl.getAttachedShaders(null)');
68 glErrorShouldBe(gl, gl.INVALID_VALUE);
69 shouldThrow('gl.getAttachedShaders(standardVert)');
70 glErrorShouldBe(gl, gl.NO_ERROR);
71
72 // Test getBufferParameter
73 var buffer = gl.createBuffer();
74 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
75 gl.bufferData(gl.ARRAY_BUFFER, 16, gl.DYNAMIC_DRAW);
76 shouldBe('gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE)', '16');
77 shouldBe('gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE)', 'gl.DYNAMIC_ DRAW');
78
79 // Test getFramebufferAttachmentParameter
80 var texture = gl.createTexture();
81 gl.bindTexture(gl.TEXTURE_2D, texture);
82 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE,
83 new Uint8Array([
84 0, 0, 0, 255,
85 255, 255, 255, 255,
86 255, 255, 255, 255,
87 0, 0, 0, 255]));
88 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
89 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
90 gl.bindTexture(gl.TEXTURE_2D, null);
91 var framebuffer = gl.createFramebuffer();
92 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
93 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex ture, 0);
94 var renderbuffer = gl.createRenderbuffer();
95 glErrorShouldBe(gl, gl.NO_ERROR);
96 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
97 glErrorShouldBe(gl, gl.NO_ERROR);
98 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 2, 2);
99 glErrorShouldBe(gl, gl.NO_ERROR);
100 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
101 // FIXME: on some machines (in particular the WebKit commit bots) the
102 // framebuffer status is FRAMEBUFFER_UNSUPPORTED; more investigation
103 // is needed why this is the case, because the FBO allocated
104 // internally by the WebKit implementation has almost identical
105 // parameters to this one. See https://bugs.webkit.org/show_bug.cgi?id=31843.
106 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE') ;
107 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME NT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)', 'gl.TEXTURE');
108 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME NT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)', 'texture');
109 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME NT0, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL)', '0');
110 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME NT0, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE)', '0');
111
112 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_ATTACHME NT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)', 'gl.RENDERBUFFER');
113 shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_ATTACHME NT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)', 'renderbuffer');
114
115 // Test getProgramParameter
116 shouldBe('gl.getProgramParameter(standardProgram, gl.DELETE_STATUS)', 'false');
117 shouldBe('gl.getProgramParameter(standardProgram, gl.LINK_STATUS)', 'true');
118 shouldBe('typeof gl.getProgramParameter(standardProgram, gl.VALIDATE_STATUS)', ' "boolean"');
119 shouldBe('gl.getProgramParameter(standardProgram, gl.ATTACHED_SHADERS)', '2');
120 shouldBe('gl.getProgramParameter(standardProgram, gl.ACTIVE_ATTRIBUTES)', '2');
121 shouldBe('gl.getProgramParameter(standardProgram, gl.ACTIVE_UNIFORMS)', '1');
122
123 // Test getRenderbufferParameter
124 shouldBe('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH)', '2');
125 shouldBe('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT)', '2');
126 // Note: we can't test the actual value of the internal format since
127 // the implementation is allowed to change it.
128 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_IN TERNAL_FORMAT)');
129 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_DE PTH_SIZE)');
130 var colorbuffer = gl.createRenderbuffer();
131 glErrorShouldBe(gl, gl.NO_ERROR);
132 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
133 glErrorShouldBe(gl, gl.NO_ERROR);
134 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 2, 2);
135 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RE D_SIZE)');
136 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GR EEN_SIZE)');
137 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BL UE_SIZE)');
138 shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_AL PHA_SIZE)');
139
140 // Test getShaderParameter
141 shouldBe('gl.getShaderParameter(standardVert, gl.SHADER_TYPE)', 'gl.VERTEX_SHADE R');
142 shouldBe('gl.getShaderParameter(standardVert, gl.DELETE_STATUS)', 'false');
143 shouldBe('gl.getShaderParameter(standardVert, gl.COMPILE_STATUS)', 'true');
144
145 // Test getTexParameter
146 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
147 gl.bindTexture(gl.TEXTURE_2D, texture);
148 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
149 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
150 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
151 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
152 shouldBe('gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER)', 'gl.NEAREST ');
153 shouldBe('gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER)', 'gl.NEAREST ');
154 shouldBe('gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S)', 'gl.CLAMP_TO_ED GE');
155 shouldBe('gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T)', 'gl.CLAMP_TO_ED GE');
156
157 // Test getUniform with all variants of data types
158 // Boolean uniform variables
159 var boolProgram = loadProgram(gl, "resources/boolUniformShader.vert", "resources /noopUniformShader.frag");
160 shouldBe('gl.getProgramParameter(boolProgram, gl.LINK_STATUS)', 'true');
161 var bvalLoc = gl.getUniformLocation(boolProgram, "bval");
162 var bval2Loc = gl.getUniformLocation(boolProgram, "bval2");
163 var bval3Loc = gl.getUniformLocation(boolProgram, "bval3");
164 var bval4Loc = gl.getUniformLocation(boolProgram, "bval4");
165 gl.useProgram(boolProgram);
166 gl.uniform1i(bvalLoc, 1);
167 gl.uniform2i(bval2Loc, 1, 0);
168 gl.uniform3i(bval3Loc, 1, 0, 1);
169 gl.uniform4i(bval4Loc, 1, 0, 1, 0);
170 glErrorShouldBe(gl, gl.NO_ERROR);
171 shouldBe('gl.getUniform(boolProgram, bvalLoc)', 'true');
172 shouldBe('gl.getUniform(boolProgram, bval2Loc)', '[true, false]');
173 shouldBe('gl.getUniform(boolProgram, bval3Loc)', '[true, false, true]');
174 shouldBe('gl.getUniform(boolProgram, bval4Loc)', '[true, false, true, false]');
175 // Integer uniform variables
176 var intProgram = loadProgram(gl, "resources/intUniformShader.vert", "resources/n oopUniformShader.frag");
177 shouldBe('gl.getProgramParameter(intProgram, gl.LINK_STATUS)', 'true');
178 var ivalLoc = gl.getUniformLocation(intProgram, "ival");
179 var ival2Loc = gl.getUniformLocation(intProgram, "ival2");
180 var ival3Loc = gl.getUniformLocation(intProgram, "ival3");
181 var ival4Loc = gl.getUniformLocation(intProgram, "ival4");
182 gl.useProgram(intProgram);
183 gl.uniform1i(ivalLoc, 1);
184 gl.uniform2i(ival2Loc, 2, 3);
185 gl.uniform3i(ival3Loc, 4, 5, 6);
186 gl.uniform4i(ival4Loc, 7, 8, 9, 10);
187 glErrorShouldBe(gl, gl.NO_ERROR);
188 shouldBe('gl.getUniform(intProgram, ivalLoc)', '1');
189 shouldBe('gl.getUniform(intProgram, ival2Loc)', '[2, 3]');
190 shouldBe('gl.getUniform(intProgram, ival3Loc)', '[4, 5, 6]');
191 shouldBe('gl.getUniform(intProgram, ival4Loc)', '[7, 8, 9, 10]');
192 // Float uniform variables
193 var floatProgram = loadProgram(gl, "resources/floatUniformShader.vert", "resourc es/noopUniformShader.frag");
194 shouldBe('gl.getProgramParameter(floatProgram, gl.LINK_STATUS)', 'true');
195 var fvalLoc = gl.getUniformLocation(floatProgram, "fval");
196 var fval2Loc = gl.getUniformLocation(floatProgram, "fval2");
197 var fval3Loc = gl.getUniformLocation(floatProgram, "fval3");
198 var fval4Loc = gl.getUniformLocation(floatProgram, "fval4");
199 gl.useProgram(floatProgram);
200 gl.uniform1f(fvalLoc, 11);
201 gl.uniform2f(fval2Loc, 12, 13);
202 gl.uniform3f(fval3Loc, 14, 15, 16);
203 gl.uniform4f(fval4Loc, 17, 18, 19, 20);
204 glErrorShouldBe(gl, gl.NO_ERROR);
205 shouldBe('gl.getUniform(floatProgram, fvalLoc)', '11');
206 shouldBe('gl.getUniform(floatProgram, fval2Loc)', '[12, 13]');
207 shouldBe('gl.getUniform(floatProgram, fval3Loc)', '[14, 15, 16]');
208 shouldBe('gl.getUniform(floatProgram, fval4Loc)', '[17, 18, 19, 20]');
209 // Sampler uniform variables
210 var samplerProgram = loadProgram(gl, "resources/noopUniformShader.vert", "resour ces/samplerUniformShader.frag");
211 shouldBe('gl.getProgramParameter(samplerProgram, gl.LINK_STATUS)', 'true');
212 var s2DValLoc = gl.getUniformLocation(samplerProgram, "s2D");
213 var sCubeValLoc = gl.getUniformLocation(samplerProgram, "sCube");
214 gl.useProgram(samplerProgram);
215 gl.uniform1i(s2DValLoc, 0);
216 gl.uniform1i(sCubeValLoc, 1);
217 glErrorShouldBe(gl, gl.NO_ERROR);
218 shouldBe('gl.getUniform(samplerProgram, s2DValLoc)', '0');
219 shouldBe('gl.getUniform(samplerProgram, sCubeValLoc)', '1');
220 // Matrix uniform variables
221 var matProgram = loadProgram(gl, "resources/matUniformShader.vert", "resources/n oopUniformShader.frag");
222 shouldBe('gl.getProgramParameter(matProgram, gl.LINK_STATUS)', 'true');
223 var mval2Loc = gl.getUniformLocation(matProgram, "mval2");
224 var mval3Loc = gl.getUniformLocation(matProgram, "mval3");
225 var mval4Loc = gl.getUniformLocation(matProgram, "mval4");
226 gl.useProgram(matProgram);
227 gl.uniformMatrix2fv(mval2Loc, false, [1, 2, 3, 4]);
228 gl.uniformMatrix3fv(mval3Loc, false, [5, 6, 7, 8, 9, 10, 11, 12, 13]);
229 gl.uniformMatrix4fv(mval4Loc, false, [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 , 25, 26, 27, 28, 29]);
230 glErrorShouldBe(gl, gl.NO_ERROR);
231 shouldBe('gl.getUniform(matProgram, mval2Loc)', '[1, 2, 3, 4]');
232 shouldBe('gl.getUniform(matProgram, mval3Loc)', '[5, 6, 7, 8, 9, 10, 11, 12, 13] ');
233 shouldBe('gl.getUniform(matProgram, mval4Loc)', '[14, 15, 16, 17, 18, 19, 20, 21 , 22, 23, 24, 25, 26, 27, 28, 29]');
234
235 // Test getVertexAttrib
236 var array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
237 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
238 gl.bufferData(gl.ARRAY_BUFFER, array, gl.DYNAMIC_DRAW);
239 // Vertex attribute 0 is special in that it has no current state, so
240 // fetching GL_CURRENT_VERTEX_ATTRIB generates an error. Use attribute
241 // 1 for these tests instead.
242 gl.enableVertexAttribArray(1);
243 gl.vertexAttribPointer(1, 4, gl.FLOAT, false, 0, 0);
244 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)', 'buffer ');
245 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_ENABLED)', 'true');
246 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_SIZE)', '4');
247 // Stride MUST be the value the user put in.
248 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_STRIDE)', '0');
249 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_TYPE)', 'gl.FLOAT');
250 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED)', 'false');
251 gl.vertexAttribPointer(1, 4, gl.FLOAT, false, 36, 12);
252 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_STRIDE)', '36');
253 shouldBe('gl.getVertexAttribOffset(1, gl.VERTEX_ATTRIB_ARRAY_POINTER)', '12');
254 gl.disableVertexAttribArray(1);
255 shouldBe('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_ENABLED)', 'false');
256 gl.vertexAttrib4f(1, 5, 6, 7, 8);
257 shouldBe('gl.getVertexAttrib(1, gl.CURRENT_VERTEX_ATTRIB)', '[5, 6, 7, 8]');
258 glErrorShouldBe(gl, gl.NO_ERROR);
259
260 // Test cases where name == 0
261 gl.deleteTexture(texture);
262 shouldBeNull('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTA CHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)');
263 gl.deleteRenderbuffer(renderbuffer);
264 shouldBeNull('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_ATTA CHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)');
265 gl.deleteBuffer(buffer);
266 shouldBeNull('gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)');
267 glErrorShouldBe(gl, gl.NO_ERROR);
268
269 successfullyParsed = true;
270 </script>
271
272 <script src="../resources/js-test-post.js"></script>
273 </body>
274 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698