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

Side by Side Diff: extra/out-of-vram.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « extra/out-of-resources.html ('k') | extra/simulated-attrib-0-bug-test.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:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL Out Of VRAM Test</title>
11 <link rel="stylesheet" href="../resources/js-test-style.css"/>
12 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri pt>
13 <script src="../resources/js-test-pre.js"></script>
14 <script src="../conformance/resources/webgl-test.js"></script>
15 <script src="../conformance/resources/webgl-test-utils.js"></script>
16 </head>
17 <body>
18 <div id="description"></div>
19 <div id="console"></div>
20 <canvas id="canvas" width="2" height="2"> </canvas>
21 <script>
22 debug("This tests WebGL running out of vram.");
23
24 debug("");
25 debug("Canvas.getContext");
26
27 var wtu = WebGLTestUtils;
28 var canvas = document.getElementById("canvas");
29 try {
30 var gl = create3DContext(canvas);
31 } catch(e) {
32 }
33 if (!gl) {
34 testFailed("could not create context");
35 } else {
36 testPassed("context exists");
37
38 var args = wtu.getUrlArguments();
39
40 canvas.addEventListener('webglcontextlost', contextLost, false);
41
42 function contextLost(e) {
43 e.preventDefault();
44 debug("***context lost***");
45 }
46
47 function contextRestored(e) {
48 debug("***context restored***");
49 }
50
51 debug("");
52 debug("Allocating textures.");
53
54 var intervalId;
55 var count = 0;
56 var textureMem = 0;
57 var textures = [];
58 var size = 2048;
59 var limit = (args.limit ? args.limit : 8192) * 1024 * 1024;
60
61 debug("limit: " + InMB(limit))
62
63 function InMB(v) {
64 return "" + Math.floor(v / 1024 / 1024) + "MB";
65 }
66
67 function makeTexture() {
68 if (gl.isContextLost()) {
69 stop("out of memory");
70 return;
71 }
72 ++count;
73 textureMem += size * size * 4;
74 if (textureMem > limit) {
75 stop("reached limit");
76 return;
77 }
78 debug ("creating texture #" + count + " mem = " + InMB(textureMem));
79 var texture = gl.createTexture();
80 textures.push(texture);
81 gl.bindTexture(gl.TEXTURE_2D, texture);
82 gl.texImage2D(gl.TEXTURE_2D,
83 0, // level
84 gl.RGBA, // internalFormat
85 size, // width
86 size, // height
87 0, // border
88 gl.RGBA, // format
89 gl.UNSIGNED_BYTE, // type
90 null); // data
91 var err = gl.getError();
92 if (err != gl.NO_ERROR) {
93 stop("out of memory");
94 return;
95 }
96 }
97
98 intervalId = window.setInterval(makeTexture, 1000 / 15);
99
100 }
101
102 function stop(msg) {
103 window.clearInterval(intervalId);
104 testPassed(msg);
105 finish();
106 }
107
108 function finish() {
109 debug("");
110 successfullyParsed = true;
111 }
112
113 </script>
114 </body>
115 </html>
OLDNEW
« no previous file with comments | « extra/out-of-resources.html ('k') | extra/simulated-attrib-0-bug-test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698