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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/extra/slow-shader-example.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 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
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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 "http://www.w3.org/TR/html4/loose.dtd">
8 <html>
9 <head>
10 <title>WebGL Slow Shader example.</title>
11 <link rel="stylesheet" href="../resources/js-test-style.css"/>
12 <script src="../resources/js-test-pre.js"></script>
13 <script src="../conformance/resources/webgl-test-utils.js"> </script>
14 </head>
15 <body>
16 <canvas id="example" width="1024" height="1024" style="width: 40px; height: 40px ;">
17 </canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="slow" type="text/something-not-javascript">
21 #if defined(GL_ES)
22 precision mediump float;
23 #endif
24 uniform sampler2D tex;
25 varying vec2 texCoord;
26 void main() {
27 gl_FragColor = texture2D(tex, texture2D(tex, texture2D(tex, texCoord).xy).xy);
28 }
29 </script>
30 <script>
31 window.onload = main;
32
33 debug("Tests drawing a very slow shader.");
34 var wtu = WebGLTestUtils;
35 var canvas = document.getElementById("example");
36 var gl = wtu.create3DContext(canvas);
37 var texSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
38 debug("Max Texture size: " + texSize);
39 var shaderSource =
40 document.getElementById("slow").text.replace(/\$size/g, texSize + ".0");
41 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after getting a context");
42 var vs = wtu.setupSimpleTextureVertexShader(gl);
43 var fs = wtu.loadShader(
44 gl,
45 shaderSource,
46 gl.FRAGMENT_SHADER)
47 var program = wtu.setupProgram(
48 gl,
49 [vs, fs],
50 ['vPosition', 'texCoord0'],
51 [0, 1]);
52 wtu.setupUnitQuad(gl, 0, 1);
53 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after program setup");
54 var tex = gl.createTexture();
55 gl.enable(gl.BLEND);
56 gl.disable(gl.DEPTH_TEST);
57
58 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after creating texture");
59 debug("preparing...");
60 var numBytes = texSize * texSize * 4;
61 var pixelBuf = new ArrayBuffer(numBytes);
62 var pixels = new Uint8Array(pixelBuf);
63 for (var ii = 0; ii < numBytes; ++ii) {
64 pixels[ii] = Math.random() * 255;
65 }
66 gl.bindTexture(gl.TEXTURE_2D, tex);
67 gl.texImage2D(
68 gl.TEXTURE_2D, 0, gl.RGBA, texSize, texSize, 0,
69 gl.RGBA, gl.UNSIGNED_BYTE, pixels);
70 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture setup");
71
72 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
73 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
74 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
75 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
76 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture param setting");
77
78 var loc = gl.getUniformLocation(program, "tex");
79 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after getting tex location");
80 gl.uniform1i(loc, 0);
81 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting tex uniform");
82
83 var numQuads = 1000;
84 var indexBuf = new ArrayBuffer(numQuads * 6);
85 var indices = new Uint8Array(indexBuf);
86 for (var ii = 0; ii < numQuads; ++ii) {
87 var offset = ii * 6;
88 indices[offset + 0] = 0;
89 indices[offset + 1] = 1;
90 indices[offset + 2] = 2;
91 indices[offset + 3] = 3;
92 indices[offset + 4] = 4;
93 indices[offset + 5] = 5;
94 }
95 var indexBuffer = gl.createBuffer();
96 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
97 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
98 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
99
100 function main () {
101 if (confirm(
102 "after clicking ok your machine may be come unresponsive or crash")) {
103 gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0);
104 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
105 } else {
106 debug("cancelled");
107 }
108 }
109
110 successfullyParsed = true;
111 </script>
112 </body>
113 </html>
114
115
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698