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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/misc/glsl-function-nodes.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>GLSL function nodes Test</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
35 <script src="../../../resources/js-test-pre.js"></script>
36 <script src="../../resources/webgl-test.js"> </script>
37 <script src="../../resources/webgl-test-utils.js"> </script>
38
39 <script id="vshaderFunction", type="x-shader/x-vertex">
40 attribute vec4 aPosition;
41 varying vec4 vColor;
42
43 float sign_emu(float value) {
44 if (value == 0.0) return 0.0;
45 return value > 0.0 ? 1.0 : -1.0;
46 }
47
48 void main()
49 {
50 gl_Position = aPosition;
51 vec2 texcoord = vec2(aPosition.xy * 0.5 + vec2(0.5, 0.5));
52 vec4 color = vec4(
53 texcoord,
54 texcoord.x * texcoord.y,
55 (1.0 - texcoord.x) * texcoord.y * 0.5 + 0.5);
56 vColor = vec4(
57 sign_emu(color.x * 2.0 - 1.0) * 0.5 + 0.5,
58 sign_emu(color.y * 2.0 - 1.0) * 0.5 + 0.5,
59 0,
60 1);
61 }
62 </script>
63
64 <script id="vshaderMacro", type="x-shader/x-vertex">
65 attribute vec4 aPosition;
66 varying vec4 vColor;
67
68 #define sign_emu(value) ((value) == 0.0 ? 0.0 : ((value) > 0.0 ? 1.0 : -1.0))
69
70 void main()
71 {
72 gl_Position = aPosition;
73 vec2 texcoord = vec2(aPosition.xy * 0.5 + vec2(0.5, 0.5));
74 vec4 color = vec4(
75 texcoord,
76 texcoord.x * texcoord.y,
77 (1.0 - texcoord.x) * texcoord.y * 0.5 + 0.5);
78 vColor = vec4(
79 sign_emu(color.x * 2.0 - 1.0) * 0.5 + 0.5,
80 sign_emu(color.y * 2.0 - 1.0) * 0.5 + 0.5,
81 0,
82 1);
83 }
84 </script>
85
86 <script id="fshader", type="x-shader/x-fragment">
87 #if defined(GL_ES)
88 precision mediump float;
89 #endif
90 varying vec4 vColor;
91 void main()
92 {
93 gl_FragColor = vColor;
94 }
95 </script>
96 </head>
97 <body>
98 <canvas id="canvasFunction" width="50" height="50"></canvas>
99 <canvas id="canvasMacro" width="50" height="50"></canvas>
100 <div id="description">This tests against a Mac driver bug related to function ca lls.</div>
101 <div id="console"></div>
102 <script>
103 var width = 50;
104 var height = 50;
105
106 function drawAndRead(canvasID, vshaderID, buffer)
107 {
108 var gl = initWebGL(canvasID);
109 var program = setupProgram(gl, vshaderID, "fshader", ["aPosition"]);
110 var vertexObject = gl.createBuffer();
111 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
112 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5, -0.5,0 ]), gl.STATIC_DRAW);
113 gl.enableVertexAttribArray(0);
114 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
115
116 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
117 gl.drawArrays(gl.TRIANGLES, 0, 3);
118 gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
119 if (gl.getError() != gl.NO_ERROR)
120 return false;
121 return true;
122 }
123
124 function compareRendering(buffer1, buffer2, tol)
125 {
126 for (var i = 0; i < width * height * 4; ++i) {
127 if (Math.abs(buffer1[i] - buffer2[i]) > tol)
128 return false;
129 }
130 return true;
131 }
132
133 function init()
134 {
135 if (window.initNonKhronosFramework) {
136 window.initNonKhronosFramework(false);
137 }
138
139 description("tests function nodes");
140
141 var bufFunction = new Uint8Array(width * height * 4);
142 var bufMacro = new Uint8Array(width * height * 4);
143
144 if (drawAndRead("canvasFunction", "vshaderFunction", bufFunction) == false | |
145 drawAndRead("canvasMacro", "vshaderMacro", bufMacro) == false) {
146 testFailed("Setup failed");
147 } else {
148 if (compareRendering(bufFunction, bufMacro, 4) == false)
149 testFailed("Rendering results are different");
150 else
151 testPassed("Rendering results are the same");
152 }
153 }
154
155 init();
156 successfullyParsed = true;
157 </script>
158 <script src="../../../resources/js-test-post.js"></script>
159 </body>
160 </html>
161
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698