Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 <!--
2 Copyright (c) 2011 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>GLSL function nodes Test</title>
11 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
12 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
13 <script src="../../../resources/js-test-pre.js"></script>
14 <script src="../../resources/webgl-test.js"> </script>
15 <script src="../../resources/webgl-test-utils.js"> </script>
17 <script id="vshaderNoBranch", type="x-shader/x-vertex">
18 attribute vec3 aPosition;
19 uniform float redIntensity;
21 varying vec4 vColor;
23 float MADBug(float paramValue) {
24 float localVar = 1.0;
25 return 0.25 * ceil(localVar) + paramValue;
26 }
28 void main(void) {
29 gl_Position = vec4(aPosition, 1.0);
30 vColor = vec4(MADBug(redIntensity), 0., 0., 1.);
31 }
32 </script>
34 <script id="vshaderBranch", type="x-shader/x-vertex">
35 attribute vec3 aPosition;
36 uniform float redIntensity;
38 varying vec4 vColor;
40 float MADBug(float paramValue) {
41 float localVar = 1.0;
42 return 0.25 * ceil(localVar) + paramValue;
43 }
45 void main(void) {
46 float condition = 42.;
47 if (condition == 0.) {}
48 gl_Position = vec4(aPosition, 1.0);
49 vColor = vec4(MADBug(redIntensity), 0., 0., 1.);
50 }
51 </script>
53 <script id="fshader", type="x-shader/x-fragment">
54 #if defined(GL_ES)
55 precision mediump float;
56 #endif
57 varying vec4 vColor;
58 void main()
59 {
60 gl_FragColor = vColor;
61 }
62 </script>
63 </head>
64 <body>
65 <canvas id="canvasNoBranch" width="50" height="50"></canvas>
66 <canvas id="canvasBranch" width="50" height="50"></canvas>
67 <div id="description">This tests against a Mac driver bug related to branches
68 inside of Vertex Shaders.</div>
69 <div id="console"></div>
70 <script>
71 var width = 50;
72 var height = 50;
74 function drawAndRead(canvasID, vshaderID, buffer)
75 {
76 var gl = initWebGL(canvasID, vshaderID, "fshader", ["aPosition"], [0, 0, 0, 1], 1);
77 var vertexObject = gl.createBuffer();
78 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
79 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -1,-1,0, 1,-1,0 ]), gl.STATIC_DRAW);
80 gl.enableVertexAttribArray(0);
81 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
83 var loc = gl.getUniformLocation(gl.program, "redIntensity");
84 gl.uniform1f(loc, 0.75);
85 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
86 gl.drawArrays(gl.TRIANGLES, 0, 3);
87 gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
88 if (gl.getError() != gl.NO_ERROR)
89 return false;
90 return true;
91 }
93 function compareRendering(buffer1, buffer2, tol)
94 {
95 for (var i = 0; i < width * height * 4; ++i) {
96 if (Math.abs(buffer1[i] - buffer2[i]) > tol)
97 return false;
98 }
99 return true;
100 }
102 function init()
103 {
104 if (window.initNonKhronosFramework) {
105 window.initNonKhronosFramework(false);
106 }
108 description("tests vertex shader with branch");
110 var bufBranch = new Uint8Array(width * height * 4);
111 var bufNoBranch = new Uint8Array(width * height * 4);
113 if (drawAndRead("canvasBranch", "vshaderBranch", bufBranch) == false ||
114 drawAndRead("canvasNoBranch", "vshaderNoBranch", bufNoBranch) == false) {
115 testFailed("Setup failed");
116 } else {
117 if (compareRendering(bufBranch, bufNoBranch, 4) == false)
118 testFailed("Rendering results are different");
119 else
120 testPassed("Rendering results are the same");
121 }
122 }
124 init();
125 successfullyParsed = true;
126 </script>
127 <script>finishTest();</script>
128 </body>
129 </html>