Bug 1624396 - add necessary trigonometry intrinsics for conic gradients in SWGL. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Tue, 24 Mar 2020 03:41:38 +0000
changeset 520298 a6414fe1b3ecc526b2c524ae13a00467264bb07b
parent 520297 86954fd812617a5b7e5d3e4182184c44b3bb0a33
child 520299 86555508bdba0ca56663ca9b6ec92079cf06ac21
push id37246
push useropoprus@mozilla.com
push dateWed, 25 Mar 2020 03:40:33 +0000
treeherdermozilla-central@14b59d4adc95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1624396
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1624396 - add necessary trigonometry intrinsics for conic gradients in SWGL. r=jrmuizel Depends on D67960 Differential Revision: https://phabricator.services.mozilla.com/D67961
gfx/wr/glsl-to-cxx/src/hir.rs
gfx/wr/swgl/src/glsl.h
--- a/gfx/wr/glsl-to-cxx/src/hir.rs
+++ b/gfx/wr/glsl-to-cxx/src/hir.rs
@@ -3159,16 +3159,19 @@ pub fn ast_to_hir(state: &mut State, tu:
         state,
         "fwidth",
         None,
         Type::new(Vec2),
         vec![Type::new(Vec2)],
     );
     declare_function(state, "cos", None, Type::new(Float), vec![Type::new(Float)]);
     declare_function(state, "sin", None, Type::new(Float), vec![Type::new(Float)]);
+    declare_function(state, "tan", None, Type::new(Float), vec![Type::new(Float)]);
+    declare_function(state, "atan", None, Type::new(Float), vec![Type::new(Float)]);
+    declare_function(state, "atan", None, Type::new(Float), vec![Type::new(Float), Type::new(Float)]);
     declare_function(
         state,
         "clamp",
         None,
         Type::new(Vec3),
         vec![Type::new(Vec3), Type::new(Float), Type::new(Float)],
     );
     declare_function(
--- a/gfx/wr/swgl/src/glsl.h
+++ b/gfx/wr/swgl/src/glsl.h
@@ -2788,26 +2788,45 @@ float dot(vec3_scalar a, vec3_scalar b) 
 
 Float dot(vec3 a, vec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
 
 float dot(vec2_scalar a, vec2_scalar b) { return a.x * b.x + a.y * b.y; }
 
 Float dot(vec2 a, vec2 b) { return a.x * b.x + a.y * b.y; }
 
 #define sin __glsl_sin
-#define cos __glsl_cos
 
 float sin(float x) { return sinf(x); }
 
 Float sin(Float v) { return {sinf(v.x), sinf(v.y), sinf(v.z), sinf(v.w)}; }
 
+#define cos __glsl_cos
+
 float cos(float x) { return cosf(x); }
 
 Float cos(Float v) { return {cosf(v.x), cosf(v.y), cosf(v.z), cosf(v.w)}; }
 
+#define tan __glsl_tan
+
+float tan(float x) { return tanf(x); }
+
+Float tan(Float v) { return {tanf(v.x), tanf(v.y), tanf(v.z), tanf(v.w)}; }
+
+#define atan __glsl_atan
+
+float atan(float x) { return atanf(x); }
+
+Float atan(Float v) { return {atanf(v.x), atanf(v.y), atanf(v.z), atanf(v.w)}; }
+
+float atan(float a, float b) { return atan2f(a, b); }
+
+Float atan(Float a, Float b) {
+    return {atan2f(a.x, b.x), atan2f(a.y, b.y), atan2f(a.z, b.z), atan2f(a.w, b.w)};
+}
+
 bvec4 notEqual(ivec4 a, ivec4 b) {
   return bvec4(a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w);
 }
 
 bvec4_scalar notEqual(ivec4_scalar a, ivec4_scalar b) {
   return bvec4_scalar{a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w};
 }