Skip to content

Commit

Permalink
Bug 1624396 - add necessary trigonometry intrinsics for conic gradien…
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman authored and github-sync committed Mar 25, 2020
1 parent d32f52f commit d64bf04
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions glsl-to-cxx/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3164,6 +3164,9 @@ pub fn ast_to_hir(state: &mut State, tu: &syntax::TranslationUnit) -> Translatio
);
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",
Expand Down
21 changes: 20 additions & 1 deletion swgl/src/glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2793,16 +2793,35 @@ 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);
}
Expand Down

0 comments on commit d64bf04

Please sign in to comment.