From 53e0e6a56e00ed6e5b0a52f0ba2a9355842bddb7 Mon Sep 17 00:00:00 2001 From: ZhiqianXia Date: Tue, 23 Feb 2021 10:00:25 +0800 Subject: [PATCH 1/2] Replace the old version math func with C++11 to prevent some presicion issue. reference link: https://www.cplusplus.com/reference/cmath/ Signed-off-by: ZhiqianXia --- glslang/MachineIndependent/Constant.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index e21cf427..cbf500d0 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -599,17 +599,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType) newConstArray[i].setDConst(log(unionArray[i].getDConst())); break; case EOpExp2: - { - const double inv_log2_e = 0.69314718055994530941723212145818; - newConstArray[i].setDConst(exp(unionArray[i].getDConst() * inv_log2_e)); - break; - } + newConstArray[i].setDConst(exp2(unionArray[i].getDConst()); + break; case EOpLog2: - { - const double log2_e = 1.4426950408889634073599246810019; - newConstArray[i].setDConst(log2_e * log(unionArray[i].getDConst())); - break; - } + newConstArray[i].setDConst(log2(unionArray[i].getDConst())); + break; case EOpSqrt: newConstArray[i].setDConst(sqrt(unionArray[i].getDConst())); break; From 47a21828bd7538b1b4221e5747677910343b97c3 Mon Sep 17 00:00:00 2001 From: ZhiqianXia Date: Thu, 25 Feb 2021 15:37:40 +0800 Subject: [PATCH 2/2] fix a typo --- glslang/MachineIndependent/Constant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index cbf500d0..8dc04a42 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -599,7 +599,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType) newConstArray[i].setDConst(log(unionArray[i].getDConst())); break; case EOpExp2: - newConstArray[i].setDConst(exp2(unionArray[i].getDConst()); + newConstArray[i].setDConst(exp2(unionArray[i].getDConst())); break; case EOpLog2: newConstArray[i].setDConst(log2(unionArray[i].getDConst()));