Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / functions / glsl-function-cos.html
bloba62ffc76fc370fe643d75aebd6aa84e407344672
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>GLSL cos function test</title>
12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
13 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
14 <script src="../../../js/js-test-pre.js"></script>
15 <script src="../../../js/webgl-test-utils.js"> </script>
16 <script src="../../../js/glsl-generator.js"> </script>
17 </head>
18 <body>
19 <div id="description"></div>
20 <div id="console"></div>
21 <script>
22 "use strict";
24 var piConstants = [
25 "const float kPI = 3.14159265358979323846;",
26 "const float kHalfPI = (kPI * 0.5);",
27 "const float k2PI = (kPI * 2.0);"
28 ].join("\n");
30 var kPI = Math.PI;
31 var kHalfPI = Math.PI * 0.5;
32 var k2PI = Math.PI * 2.0;
33 var cos = Math.cos; // shorthand
35 GLSLGenerator.runReferenceImageTest({
36 feature: "cos",
37 args: "$(type) value",
38 testFunc: "$(func)($(type))",
39 gridRes: 8,
40 tolerance: 3,
41 extra: piConstants,
42 tests: [
44 source: ["$(output) = vec4(",
45 " $(func)($(input).x * kHalfPI + kHalfPI),",
46 " $(func)($(input).y * kHalfPI),",
47 " 0,",
48 " 1);"].join("\n"),
49 generator: function(x, y, z, w) {
50 return [ cos(x * kHalfPI + kHalfPI),
51 cos(y * kHalfPI),
53 1 ];
57 source: ["$(output) = vec4(",
58 " $(func)($(input).xy * vec2(kPI, k2PI)) * 0.5 + vec2(0.5, 0.5),",
59 " 0, 1);"].join("\n"),
60 generator: function(x, y, z, w) {
61 return [ cos(x * kPI) * 0.5 + 0.5,
62 cos(y * k2PI) * 0.5 + 0.5,
64 1 ];
68 // FIXME: for some reason, this test requires a higher tolerance when run in a vertex shader.
69 source: ["$(output) = vec4(",
70 " $(func)($(input).xyz * vec3(kPI, k2PI, 4.0)) * ",
71 " 0.5 + vec3(0.5, 0.5, 0.5),",
72 " 1);"].join("\n"),
73 generator: function(x, y, z, w) {
74 return [ cos(x * kPI) * 0.5 + 0.5,
75 cos(y * k2PI) * 0.5 + 0.5,
76 cos(z * 4.0) * 0.5 + 0.5,
77 1 ];
79 tolerance: 7,
82 source: ["$(output) = ",
83 " $(func)($(input) * vec4(k2PI, 4.0, kHalfPI, kPI)) *",
84 " 0.5 + vec4(0.5, 0.5, 0.5, 1);",
85 ].join("\n"),
86 generator: function(x, y, z, w) {
87 return [ cos(x * k2PI) * 0.5 + 0.5,
88 cos(y * 4.0) * 0.5 + 0.5,
89 cos(z * kHalfPI) * 0.5 + 0.5,
90 cos(w * kPI) * 0.5 + 1.0 ];
94 });
95 var successfullyParsed = true;
96 </script>
97 </body>
98 </html>