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

Side by Side Diff: conformance/limits/gl-max-texture-dimensions.html

Issue 41503006: Add ToT WebGL conformance tests : part 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « conformance/limits/00_test_list.txt ('k') | conformance/limits/gl-min-attribs.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
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 the max advertized texture size is supported.</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/js-test-pre.js"></script>
35 <script src="../resources/webgl-test.js"> </script>
36 <script src="../resources/webgl-test-utils.js"> </script>
37 </head>
38 <body>
39 <canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></c anvas>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vshader" type="x-shader/x-vertex">
43 attribute vec4 vPosition;
44 attribute vec2 texCoord0;
45 varying vec2 texCoord;
46 void main()
47 {
48 gl_Position = vPosition;
49 texCoord = texCoord0;
50 }
51 </script>
52
53 <script id="fshader" type="x-shader/x-fragment">
54 precision mediump float;
55 uniform samplerCube tex;
56 varying vec2 texCoord;
57 void main()
58 {
59 gl_FragColor = textureCube(tex, normalize(vec3(texCoord, 1)));
60 }
61 </script>
62 <script>
63 "use strict";
64 description(document.title);
65 var wtu = WebGLTestUtils;
66 var gl = wtu.create3DContext("example");
67 var program = wtu.setupTexturedQuad(gl);
68
69 function shouldBePowerOfTwo(n, name) {
70 var power = Math.round(Math.log(n) / Math.log(2));
71 if (Math.pow(2, power) == n) {
72 testPassed(name + ' is a power of two.');
73 } else {
74 testFailed(name + ' should be a power of two, but was ' + n);
75 }
76 }
77
78 // Note: It seems like a reasonable assuption that a 1xN texture size should
79 // work. Even 1 by 128k is only 512k
80 var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
81 debug("advertised max size: " + maxSize);
82 debug("verifying max size is power-of-two (implied by GLES 2.0 section 3.7.1)");
83 shouldBePowerOfTwo(maxSize, 'Max size');
84 var testSize = Math.min(maxSize, 128 * 1024);
85 var pixels = new Uint8Array(testSize * 4);
86 for (var ii = 0; ii < testSize; ++ii) {
87 var off = ii * 4;
88 pixels[off + 0] = 0;
89 pixels[off + 1] = 255;
90 pixels[off + 2] = 128;
91 pixels[off + 3] = 255;
92 }
93 var tex = gl.createTexture();
94 gl.bindTexture(gl.TEXTURE_2D, tex);
95
96 debug("test " + testSize + "x1");
97 gl.texImage2D(
98 gl.TEXTURE_2D, 0, gl.RGBA, testSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
99 pixels);
100 gl.generateMipmap(gl.TEXTURE_2D);
101
102 wtu.clearAndDrawUnitQuad(gl);
103 wtu.checkCanvas(gl, [0, 255, 128, 255],
104 "Should be 0, 255, 128, 255");
105 debug("test 1x" + testSize);
106 gl.texImage2D(
107 gl.TEXTURE_2D, 0, gl.RGBA, 1, testSize, 0, gl.RGBA, gl.UNSIGNED_BYTE,
108 pixels);
109 gl.generateMipmap(gl.TEXTURE_2D);
110
111 wtu.clearAndDrawUnitQuad(gl);
112 wtu.checkCanvas(gl, [0, 255, 128, 255],
113 "Should be 0, 255, 128, 255");
114
115 var program = wtu.setupProgram(
116 gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
117
118 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
119
120 // NOTE: We can't easily test cube maps because they require width == height
121 // and we might not have enough memory for maxSize by maxSize texture.
122
123 var successfullyParsed = true;
124
125 </script>
126 <script src="../../resources/js-test-post.js"></script>
127
128 </body>
129 </html>
130
131
OLDNEW
« no previous file with comments | « conformance/limits/00_test_list.txt ('k') | conformance/limits/gl-min-attribs.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698