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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/textures/texture-formats-test.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 <title>WebGL Texture Format Conformance Tests</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s cript>
35 <script src="../../resources/js-test-pre.js"></script>
36 <script src="../resources/webgl-test.js"></script>
37 <script src="../resources/webgl-test-utils.js"></script>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <canvas id="canvas2d" width="2" height="2" style="width: 50px; height: 50px; bor der: 1px solid black;"></canvas>
43 <canvas id="canvas" width="2" height="2" style="width: 100px; height:100px; bord er: 1px solid black;"> </canvas>
44 <script>
45 description("This test ensures WebGL implementations allow the OpenGL ES 2.0 tex ture formats and do not allow DesktopGL texture formats.");
46
47 debug("");
48 debug("Canvas.getContext");
49
50 var wtu = WebGLTestUtils;
51 var gl = wtu.create3DContext(document.getElementById("canvas"));
52 if (!gl) {
53 testFailed("context does not exist");
54 } else {
55 testPassed("context exists");
56
57 debug("");
58 debug("Checking texture formats.");
59
60 function createTexture(internalFormat, format, opt_border) {
61 var border = (opt_border === undefined) ? 0 : opt_border;
62 var tex = gl.createTexture();
63 gl.bindTexture(gl.TEXTURE_2D, tex);
64 gl.texImage2D(gl.TEXTURE_2D,
65 0, // level
66 internalFormat, // internalFormat
67 16, // width
68 16, // height
69 border, // border
70 format, // format
71 gl.UNSIGNED_BYTE, // type
72 null); // data
73 }
74
75 function testValidFormat(internalFormat, formatName) {
76 createTexture(internalFormat, internalFormat);
77 glErrorShouldBe(gl, gl.NO_ERROR,
78 "was able to create texture of " + formatName);
79 }
80
81 function testInvalidFormat(internalFormat, formatName) {
82 createTexture(internalFormat, internalFormat);
83 var err = gl.getError();
84 if (err == gl.NO_ERROR) {
85 testFailed("should NOT be able to create texture of type " + formatNam e);
86 } else if (err == gl.INVALID_OPERATION) {
87 testFailed("should return gl.INVALID_ENUM for type " + formatName);
88 } else if (err == gl.INVALID_ENUM) {
89 testPassed("not able to create invalid format: " + formatName);
90 }
91 }
92
93 var invalidEnums = [
94 '1',
95 '2',
96 '3',
97 '4',
98 'RGB4',
99 'RGB5',
100 'RGB8',
101 'RGB10',
102 'RGB12',
103 'RGB16',
104 'RGBA2',
105 'RGBA4',
106 'RGB5_A1',
107 'RGBA8',
108 'RGB10_A2',
109 'RGBA12',
110 'RGBA16',
111 'BGR',
112 'BGRA',
113 'ALPHA4_EXT',
114 'ALPHA8_EXT',
115 'ALPHA12_EXT',
116 'ALPHA16_EXT',
117 'COMPRESSED_ALPHA',
118 'COMPRESSED_LUMINANCE',
119 'COMPRESSED_LUMINANCE_ALPHA',
120 'COMPRESSED_INTENSITY',
121 'COMPRESSED_RGB',
122 'COMPRESSED_RGBA',
123 'DEPTH_COMPONENT16',
124 'DEPTH_COMPONENT24',
125 'DEPTH_COMPONENT32',
126 'LUMINANCE4_EXT',
127 'LUMINANCE8_EXT',
128 'LUMINANCE12_EXT',
129 'LUMINANCE16_EXT',
130 'LUMINANCE4_ALPHA4_EXT',
131 'LUMINANCE6_ALPHA2_EXT',
132 'LUMINANCE8_ALPHA8_EXT',
133 'LUMINANCE12_ALPHA4_EXT',
134 'LUMINANCE12_ALPHA12_EXT',
135 'LUMINANCE16_ALPHA16_EXT',
136 'INTENSITY_EXT',
137 'INTENSITY4_EXT',
138 'INTENSITY8_EXT',
139 'INTENSITY12_EXT',
140 'INTENSITY16_EXT',
141 'RGB4_EXT',
142 'RGB5_EXT',
143 'RGB8_EXT',
144 'RGB10_EXT',
145 'RGB12_EXT',
146 'RGB16_EXT',
147 'RGBA2_EXT',
148 'RGBA4_EXT',
149 'RGB5_A1_EXT',
150 'RGBA8_EXT',
151 'RGB10_A2_EXT',
152 'RGBA12_EXT',
153 'RGBA16_EXT',
154 'SLUMINANCE_EXT',
155 'SLUMINANCE8_EXT',
156 'SLUMINANCE_ALPHA_EXT',
157 'SLUMINANCE8_ALPHA8_EXT',
158 'SRGB_EXT',
159 'SRGB8_EXT',
160 'SRGB_ALPHA_EXT',
161 'SRGB8_ALPHA8'
162 ];
163
164 for (var ii = 0; ii < invalidEnums.length; ++ii) {
165 var formatName = invalidEnums[ii]
166 if (desktopGL[formatName] === undefined) {
167 debug("bad format" + formatName)
168 } else {
169 testInvalidFormat(desktopGL[formatName], "GL_" + formatName);
170 }
171 }
172
173 var validEnums = [
174 'ALPHA',
175 'RGB',
176 'RGBA',
177 'LUMINANCE',
178 'LUMINANCE_ALPHA'
179 ];
180
181 for (var ii = 0; ii < validEnums.length; ++ii) {
182 var formatName = validEnums[ii]
183 testValidFormat(gl[formatName], "gl." + formatName);
184 }
185
186 debug("");
187 debug("checking non 0 border parameter to gl.TexImage2D");
188 createTexture(gl['RGBA'], gl['RGBA'], 1);
189 glErrorShouldBe(gl, gl.INVALID_VALUE,
190 "non 0 border to gl.TexImage2D should return INVALID_VALUE");
191
192
193 function checkTypes() {
194 var tex = gl.createTexture();
195 gl.bindTexture(gl.TEXTURE_2D, tex);
196 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
197 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
198 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
199
200 var loc = gl.getUniformLocation(program, "tex");
201 gl.uniform1i(loc, 0);
202
203 function checkType(r, g, b, a, type, format, buf) {
204 var typeName = wtu.glEnumToString(gl, type);
205 var formatName = wtu.glEnumToString(gl, format);
206 var desc = "format: " + formatName + ", type: " + typeName;
207 debug("");
208 debug("checking gl.texImage2D with " + desc);
209 gl.texImage2D(gl.TEXTURE_2D,
210 0, // level
211 format, // internalFormat
212 2, // width
213 2, // height
214 0, // border
215 format, // format
216 type, // type
217 buf); // data
218
219 glErrorShouldBe(gl, gl.NO_ERROR,
220 "gl.texImage2D with " + desc + " should generate NO_ERROR");
221
222 wtu.drawQuad(gl, [255, 0, 0, 255]);
223 wtu.checkCanvas(gl, [r,g,b,a],
224 "texture " + desc + " should draw with " +
225 r + ", " + g + ", " + b + ", " + a);
226
227 }
228 checkType(
229 0, 255, 0, 255, gl.UNSIGNED_BYTE, gl.RGBA,
230 new Uint8Array(
231 [ 0, 255, 0, 255,
232 0, 255, 0, 255,
233 0, 255, 0, 255,
234 0, 255, 0, 255]));
235 checkType(
236 0, 0, 255, 255, gl.UNSIGNED_SHORT_4_4_4_4, gl.RGBA,
237 new Uint16Array(
238 [ 255, 255,
239 255, 255,
240 255, 255,
241 255, 255]));
242 checkType(
243 0, 255, 0, 255, gl.UNSIGNED_SHORT_5_6_5, gl.RGB,
244 new Uint16Array(
245 [ 2016, 2016,
246 2016, 2016,
247 2016, 2016,
248 2016, 2016]));
249 checkType(
250 0, 0, 255, 255, gl.UNSIGNED_SHORT_5_5_5_1, gl.RGBA,
251 new Uint16Array(
252 [ 63, 63,
253 63, 63,
254 63, 63,
255 63, 63]));
256 checkType(
257 255, 255, 255, 255, gl.UNSIGNED_BYTE, gl.LUMINANCE,
258 new Uint8Array([
259 255,
260 255,
261 255,
262 255]));
263 checkType(
264 0, 0, 0, 128, gl.UNSIGNED_BYTE, gl.ALPHA,
265 new Uint8Array([
266 128,
267 128,
268 128,
269 128]));
270 checkType(
271 128, 128, 128, 192, gl.UNSIGNED_BYTE, gl.LUMINANCE_ALPHA,
272 new Uint8Array([
273 128, 192,
274 128, 192,
275 128, 192,
276 128, 192]));
277 }
278 var program = wtu.setupTexturedQuad(gl);
279 gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
280 checkTypes();
281 }
282
283 debug("");
284 successfullyParsed = true;
285
286 </script>
287 <script src="../../resources/js-test-post.js"></script>
288
289 </body>
290 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698