зеркало из https://github.com/AvaloniaUI/angle.git
Revert "Support constant folding of trigonometry built-ins"
Part of a chain causing compile errors on Mac. Example:
../../third_party/angle/src/compiler/translator/IntermNode.cpp:1216:89: error: no member named 'sin' in namespace 'std'; did you mean 'sinf'?
http://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Linux%20Builder/builds/33747
This reverts commit 1767e6b4f9
.
Change-Id: Ie39b1bf9a08da61aa0b16e219b34d1ba0b6f6c0f
Reviewed-on: https://chromium-review.googlesource.com/265587
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Родитель
3c772f3623
Коммит
bc7093399c
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "compiler/translator/HashNames.h"
|
||||
|
@ -20,10 +19,6 @@
|
|||
namespace
|
||||
{
|
||||
|
||||
const float kPi = 3.14159265358979323846f;
|
||||
const float kDegreesToRadiansMultiplier = kPi / 180.0f;
|
||||
const float kRadiansToDegreesMultiplier = 180.0f / kPi;
|
||||
|
||||
TPrecision GetHigherPrecision(TPrecision left, TPrecision right)
|
||||
{
|
||||
return left > right ? left : right;
|
||||
|
@ -1190,100 +1185,6 @@ TIntermTyped *TIntermConstantUnion::fold(
|
|||
}
|
||||
break;
|
||||
|
||||
case EOpRadians:
|
||||
if (getType().getBasicType() == EbtFloat)
|
||||
{
|
||||
tempConstArray[i].setFConst(kDegreesToRadiansMultiplier * unionArray[i].getFConst());
|
||||
break;
|
||||
}
|
||||
infoSink.info.message(
|
||||
EPrefixInternalError, getLine(),
|
||||
"Unary operation not folded into constant");
|
||||
return nullptr;
|
||||
|
||||
case EOpDegrees:
|
||||
if (getType().getBasicType() == EbtFloat)
|
||||
{
|
||||
tempConstArray[i].setFConst(kRadiansToDegreesMultiplier * unionArray[i].getFConst());
|
||||
break;
|
||||
}
|
||||
infoSink.info.message(
|
||||
EPrefixInternalError, getLine(),
|
||||
"Unary operation not folded into constant");
|
||||
return nullptr;
|
||||
|
||||
case EOpSin:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::sin), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpCos:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::cos), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpTan:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::tan), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAsin:
|
||||
// For asin(x), results are undefined if |x| > 1, we are choosing to set result to 0.
|
||||
if (getType().getBasicType() == EbtFloat && std::abs(unionArray[i].getFConst()) > 1.0f)
|
||||
tempConstArray[i].setFConst(0.0f);
|
||||
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::asin), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAcos:
|
||||
// For acos(x), results are undefined if |x| > 1, we are choosing to set result to 0.
|
||||
if (getType().getBasicType() == EbtFloat && std::abs(unionArray[i].getFConst()) > 1.0f)
|
||||
tempConstArray[i].setFConst(0.0f);
|
||||
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::acos), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAtan:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::atan), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpSinh:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::sinh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpCosh:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::cosh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpTanh:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::tanh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAsinh:
|
||||
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::asinh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAcosh:
|
||||
// For acosh(x), results are undefined if x < 1, we are choosing to set result to 0.
|
||||
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() < 1.0f)
|
||||
tempConstArray[i].setFConst(0.0f);
|
||||
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::acosh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
case EOpAtanh:
|
||||
// For atanh(x), results are undefined if |x| >= 1, we are choosing to set result to 0.
|
||||
if (getType().getBasicType() == EbtFloat && std::abs(unionArray[i].getFConst()) >= 1.0f)
|
||||
tempConstArray[i].setFConst(0.0f);
|
||||
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&std::atanh), infoSink, &tempConstArray[i]))
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1294,23 +1195,6 @@ TIntermTyped *TIntermConstantUnion::fold(
|
|||
}
|
||||
}
|
||||
|
||||
bool TIntermConstantUnion::foldFloatTypeUnary(const ConstantUnion ¶meter, FloatTypeUnaryFunc builtinFunc,
|
||||
TInfoSink &infoSink, ConstantUnion *result) const
|
||||
{
|
||||
ASSERT(builtinFunc);
|
||||
|
||||
if (getType().getBasicType() == EbtFloat)
|
||||
{
|
||||
result->setFConst(builtinFunc(parameter.getFConst()));
|
||||
return true;
|
||||
}
|
||||
|
||||
infoSink.info.message(
|
||||
EPrefixInternalError, getLine(),
|
||||
"Unary operation not folded into constant");
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
TString TIntermTraverser::hash(const TString &name, ShHashFunction64 hashFunction)
|
||||
{
|
||||
|
|
|
@ -292,10 +292,6 @@ class TIntermConstantUnion : public TIntermTyped
|
|||
|
||||
protected:
|
||||
ConstantUnion *mUnionArrayPointer;
|
||||
|
||||
private:
|
||||
typedef float(*FloatTypeUnaryFunc) (float);
|
||||
bool foldFloatTypeUnary(const ConstantUnion ¶meter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, ConstantUnion *result) const;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче