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

Side by Side Diff: third_party/webgl/sdk/tests/extra/out-of-vram.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 Out Of VRAM Test</title>
33 <link rel="stylesheet" href="../resources/js-test-style.css"/>
34 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri pt>
35 <script src="../resources/js-test-pre.js"></script>
36 <script src="../conformance/resources/webgl-test.js"></script>
37 <script src="../conformance/resources/webgl-test-utils.js"></script>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <canvas id="canvas" width="2" height="2"> </canvas>
43 <script>
44 debug("This tests WebGL running out of vram.");
45
46 debug("");
47 debug("Canvas.getContext");
48
49 var wtu = WebGLTestUtils;
50 var canvas = document.getElementById("canvas");
51 try {
52 var gl = create3DContext(canvas);
53 } catch(e) {
54 }
55 if (!gl) {
56 testFailed("could not create context");
57 } else {
58 testPassed("context exists");
59
60 var args = wtu.getUrlArguments();
61
62 canvas.addEventListener('webglcontextlost', contextLost, false);
63
64 function contextLost(e) {
65 e.preventDefault();
66 debug("***context lost***");
67 }
68
69 function contextRestored(e) {
70 debug("***context restored***");
71 }
72
73 debug("");
74 debug("Allocating textures.");
75
76 var intervalId;
77 var count = 0;
78 var textureMem = 0;
79 var textures = [];
80 var size = 2048;
81 var limit = (args.limit ? args.limit : 8192) * 1024 * 1024;
82
83 debug("limit: " + InMB(limit))
84
85 function InMB(v) {
86 return "" + Math.floor(v / 1024 / 1024) + "MB";
87 }
88
89 function makeTexture() {
90 if (gl.isContextLost()) {
91 stop("out of memory");
92 return;
93 }
94 ++count;
95 textureMem += size * size * 4;
96 if (textureMem > limit) {
97 stop("reached limit");
98 return;
99 }
100 debug ("creating texture #" + count + " mem = " + InMB(textureMem));
101 var texture = gl.createTexture();
102 textures.push(texture);
103 gl.bindTexture(gl.TEXTURE_2D, texture);
104 gl.texImage2D(gl.TEXTURE_2D,
105 0, // level
106 gl.RGBA, // internalFormat
107 size, // width
108 size, // height
109 0, // border
110 gl.RGBA, // format
111 gl.UNSIGNED_BYTE, // type
112 null); // data
113 var err = gl.getError();
114 if (err != gl.NO_ERROR) {
115 stop("out of memory");
116 return;
117 }
118 }
119
120 intervalId = window.setInterval(makeTexture, 1000 / 15);
121
122 }
123
124 function stop(msg) {
125 window.clearInterval(intervalId);
126 testPassed(msg);
127 finish();
128 }
129
130 function finish() {
131 debug("");
132 successfullyParsed = true;
133 }
134
135 </script>
136 </body>
137 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698