intrinsics: Add degrees() and radians()

Fixed: tint:1329
Change-Id: I5fb927268fc9cb8047a2b365d26e813a8546605a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75423
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-01-05 20:11:00 +00:00
committed by Tint LUCI CQ
parent 4beeaea9da
commit 5c99ed046a
77 changed files with 5932 additions and 3149 deletions

View File

@@ -145,6 +145,12 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
const bool is_deprecated_;
};
/// Constant value used by the degrees() intrinsic
static constexpr double kRadToDeg = 57.295779513082322865;
/// Constant value used by the radians() intrinsic
static constexpr double kDegToRad = 0.017453292519943295474;
} // namespace sem
} // namespace tint

View File

@@ -72,6 +72,9 @@ IntrinsicType ParseIntrinsicType(const std::string& name) {
if (name == "cross") {
return IntrinsicType::kCross;
}
if (name == "degrees") {
return IntrinsicType::kDegrees;
}
if (name == "determinant") {
return IntrinsicType::kDeterminant;
}
@@ -192,6 +195,9 @@ IntrinsicType ParseIntrinsicType(const std::string& name) {
if (name == "pow") {
return IntrinsicType::kPow;
}
if (name == "radians") {
return IntrinsicType::kRadians;
}
if (name == "reflect") {
return IntrinsicType::kReflect;
}
@@ -368,6 +374,8 @@ const char* str(IntrinsicType i) {
return "countOneBits";
case IntrinsicType::kCross:
return "cross";
case IntrinsicType::kDegrees:
return "degrees";
case IntrinsicType::kDeterminant:
return "determinant";
case IntrinsicType::kDistance:
@@ -448,6 +456,8 @@ const char* str(IntrinsicType i) {
return "pack4x8unorm";
case IntrinsicType::kPow:
return "pow";
case IntrinsicType::kRadians:
return "radians";
case IntrinsicType::kReflect:
return "reflect";
case IntrinsicType::kRefract:

View File

@@ -48,6 +48,7 @@ enum class IntrinsicType {
kCosh,
kCountOneBits,
kCross,
kDegrees,
kDeterminant,
kDistance,
kDot,
@@ -88,6 +89,7 @@ enum class IntrinsicType {
kPack4x8snorm,
kPack4x8unorm,
kPow,
kRadians,
kReflect,
kRefract,
kReverseBits,