From ebf0825ec4cd51c03e15e869843dccabeac7fb20 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 24 Jun 2013 22:40:19 +0000 Subject: [PATCH] Add the 6 hyperbolic trig functions. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22149 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/300.frag | 5 ++++ glslang/Include/intermediate.h | 6 ++++ glslang/MachineIndependent/Constant.cpp | 7 +++++ glslang/MachineIndependent/Initialize.cpp | 36 +++++++++++++++++++++++ glslang/MachineIndependent/intermOut.cpp | 6 ++++ 5 files changed, 60 insertions(+) diff --git a/Test/300.frag b/Test/300.frag index 1e16a1459..8a185ba48 100644 --- a/Test/300.frag +++ b/Test/300.frag @@ -90,6 +90,11 @@ void main() sc = s2.c; sf = s2.f; + + sinh(c1D) + + cosh(c1D) * tanh(c2D); + asinh(c4D) + acosh(c4D); + atanh(c3D); } float imageBuffer; // ERROR, reserved diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index ec11f6171..725de03d6 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -149,6 +149,12 @@ enum TOperator { EOpAsin, EOpAcos, EOpAtan, + EOpSinh, + EOpCosh, + EOpTanh, + EOpAsinh, + EOpAcosh, + EOpAtanh, EOpPow, EOpExp, diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index fdb3c6a84..f40a693e3 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -541,6 +541,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, // TODO: Functionality: constant folding: the rest of the ops have to be fleshed out + case EOpSinh: + case EOpCosh: + case EOpTanh: + case EOpAsinh: + case EOpAcosh: + case EOpAtanh: + case EOpIsNan: case EOpIsInf: diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 8b7e3fc00..8364a26ad 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -140,6 +140,36 @@ void TBuiltIns::initialize(int version, EProfile profile) s.append(TString("vec3 atan(vec3 y_over_x);")); s.append(TString("vec4 atan(vec4 y_over_x);")); + s.append(TString("float sinh(float angle);")); + s.append(TString("vec2 sinh(vec2 angle);")); + s.append(TString("vec3 sinh(vec3 angle);")); + s.append(TString("vec4 sinh(vec4 angle);")); + + s.append(TString("float cosh(float angle);")); + s.append(TString("vec2 cosh(vec2 angle);")); + s.append(TString("vec3 cosh(vec3 angle);")); + s.append(TString("vec4 cosh(vec4 angle);")); + + s.append(TString("float tanh(float angle);")); + s.append(TString("vec2 tanh(vec2 angle);")); + s.append(TString("vec3 tanh(vec3 angle);")); + s.append(TString("vec4 tanh(vec4 angle);")); + + s.append(TString("float asinh(float x);")); + s.append(TString("vec2 asinh(vec2 x);")); + s.append(TString("vec3 asinh(vec3 x);")); + s.append(TString("vec4 asinh(vec4 x);")); + + s.append(TString("float acosh(float x);")); + s.append(TString("vec2 acosh(vec2 x);")); + s.append(TString("vec3 acosh(vec3 x);")); + s.append(TString("vec4 acosh(vec4 x);")); + + s.append(TString("float atanh(float y_over_x);")); + s.append(TString("vec2 atanh(vec2 y_over_x);")); + s.append(TString("vec3 atanh(vec3 y_over_x);")); + s.append(TString("vec4 atanh(vec4 y_over_x);")); + // // Exponential Functions. // @@ -1507,6 +1537,12 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb symbolTable.relateToOperator("asin", EOpAsin); symbolTable.relateToOperator("acos", EOpAcos); symbolTable.relateToOperator("atan", EOpAtan); + symbolTable.relateToOperator("sinh", EOpSinh); + symbolTable.relateToOperator("cosh", EOpCosh); + symbolTable.relateToOperator("tanh", EOpTanh); + symbolTable.relateToOperator("asinh", EOpAsinh); + symbolTable.relateToOperator("acosh", EOpAcosh); + symbolTable.relateToOperator("atanh", EOpAtanh); symbolTable.relateToOperator("pow", EOpPow); symbolTable.relateToOperator("exp2", EOpExp2); diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index fe0f233d8..bbab55b65 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -207,6 +207,12 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it) case EOpAsin: out.debug << "arc sine"; break; case EOpAcos: out.debug << "arc cosine"; break; case EOpAtan: out.debug << "arc tangent"; break; + case EOpSinh: out.debug << "hyp. sine"; break; + case EOpCosh: out.debug << "hyp. cosine"; break; + case EOpTanh: out.debug << "hyp. tangent"; break; + case EOpAsinh: out.debug << "arc hyp. sine"; break; + case EOpAcosh: out.debug << "arc hyp. cosine"; break; + case EOpAtanh: out.debug << "arc hyp. tangent"; break; case EOpExp: out.debug << "exp"; break; case EOpLog: out.debug << "log"; break;