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

Side by Side Diff: third_party/webgl/sdk/tests/extra/out-of-resources.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 Resources 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="../../debug/webgl-debug.js"></script>
36 <script src="../resources/js-test-pre.js"></script>
37 <script src="../conformance/resources/webgl-test.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 <canvas id="canvas2" width="2" height="2"> </canvas>
44 <script>
45 window.onload = init;
46 debug("Tests a WebGL program that tries to use all of vram.");
47
48 function init() {
49 if (confirm(
50 "after clicking ok your machine may be come unresponsive or crash")) {
51 main();
52 } else {
53 debug("cancelled");
54 }
55 }
56
57 function main() {
58 debug("");
59 debug("Canvas.getContext");
60
61 var gl = create3DContext(document.getElementById("canvas"));
62 if (!gl) {
63 testFailed("context does not exist");
64 } else {
65 testPassed("context exists");
66
67 debug("");
68 debug("Checking for out of memory handling.");
69
70 var size = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);
71 debug("max render buffer size: " + size);
72
73 var allocateFramebuffers = true;
74 var itervalId;
75 var count = 0;
76
77 gl = WebGLDebugUtils.makeDebugContext(gl, function(err, functionName, args) {
78 window.clearInterval(intervalId);
79 assertMsg(err == gl.OUT_OF_MEMORY,
80 "correctly returns gl.OUT_OF_MEMORY when out of memory");
81 finish();
82 });
83
84 intervalId = window.setInterval(function() {
85 ++count;
86 var mem = count * size * size * 4;
87 debug("#" + count + " : memory allocated so far " + (mem / 1024 / 1024) + "MB");
88 var tex = gl.createTexture();
89 gl.bindTexture(gl.TEXTURE_2D, tex);
90 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
91 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
92 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
93 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
94 gl.texImage2D(gl.TEXTURE_2D,
95 0, // level
96 gl.RGBA, // internalFormat
97 size, // width
98 size, // height
99 0, // border
100 gl.RGBA, // format
101 gl.UNSIGNED_BYTE, // type
102 null); // data
103 if (allocateFrameBuffers) {
104 var fb = gl.createFramebuffer();
105 gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
106 gl.framebufferTexture2D(
107 gl.FRAMEBUFFER,
108 gl.COLOR_ATTACHMENT0,
109 gl.TEXTURE_2D,
110 tex,
111 0);
112 var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
113 if (status != gl.FRAMEBUFFER_COMPLETE) {
114 testFailed("gl.checkFramebufferStatus() returned " + WebGLDebugUtils.g lEnumToString(status) +
115 " should have gotten gl.OUT_OF_MEMORY before getting this." );
116 window.clearInterval(intervalId);
117 finish();
118 }
119 }
120 }, 1000/10);
121 }
122
123 function finish() {
124 debug("");
125 successfullyParsed = true;
126 }
127 }
128 </script>
129 </body>
130 </html>
OLDNEW
« no previous file with comments | « third_party/webgl/sdk/tests/extra/out-of-memory.html ('k') | third_party/webgl/sdk/tests/extra/out-of-vram.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698