aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir/SkSLType.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-18 14:10:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-18 18:32:13 +0000
commitf7b8820dc813d1eb0b6b43fe4581dded0da38caf (patch)
tree518d313a9fa571a9f9ca26af7c381664694a4706 /src/sksl/ir/SkSLType.h
parent47a540f503bc722393b61c4b822e95b17f200125 (diff)
re-land of new SkSL precisions
Bug: skia: Change-Id: Ic1deb3db2cbda6ca45f93dee99832971a36a2119 Reviewed-on: https://skia-review.googlesource.com/47841 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ir/SkSLType.h')
-rw-r--r--src/sksl/ir/SkSLType.h39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index b0474216c1..ed5e076e73 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -93,11 +93,12 @@ public:
}
// Create a scalar type.
- Type(String name, NumberKind numberKind)
+ Type(String name, NumberKind numberKind, int priority)
: INHERITED(-1, kType_Kind, StringFragment())
, fNameString(std::move(name))
, fTypeKind(kScalar_Kind)
, fNumberKind(numberKind)
+ , fPriority(priority)
, fColumns(1)
, fRows(1) {
fName.fChars = fNameString.c_str();
@@ -105,11 +106,12 @@ public:
}
// Create a scalar type which can be coerced to the listed types.
- Type(String name, NumberKind numberKind, std::vector<const Type*> coercibleTypes)
+ Type(String name, NumberKind numberKind, int priority, std::vector<const Type*> coercibleTypes)
: INHERITED(-1, kType_Kind, StringFragment())
, fNameString(std::move(name))
, fTypeKind(kScalar_Kind)
, fNumberKind(numberKind)
+ , fPriority(priority)
, fCoercibleTypes(std::move(coercibleTypes))
, fColumns(1)
, fRows(1) {
@@ -224,6 +226,14 @@ public:
}
/**
+ * Returns the "priority" of a number type, in order of double > float > half > int > short.
+ * When operating on two number types, the result is the higher-priority type.
+ */
+ int priority() const {
+ return fPriority;
+ }
+
+ /**
* Returns true if an instance of this type can be freely coerced (implicitly converted) to
* another type.
*/
@@ -315,20 +325,21 @@ public:
private:
typedef Symbol INHERITED;
- const String fNameString;
- const Kind fTypeKind;
+ String fNameString;
+ Kind fTypeKind;
// always kNonnumeric_NumberKind for non-scalar values
- const NumberKind fNumberKind;
+ NumberKind fNumberKind;
+ int fPriority = -1;
const Type* fComponentType = nullptr;
- const std::vector<const Type*> fCoercibleTypes;
- const int fColumns = -1;
- const int fRows = -1;
- const std::vector<Field> fFields;
- const SpvDim_ fDimensions = SpvDim1D;
- const bool fIsDepth = false;
- const bool fIsArrayed = false;
- const bool fIsMultisampled = false;
- const bool fIsSampled = false;
+ std::vector<const Type*> fCoercibleTypes;
+ int fColumns = -1;
+ int fRows = -1;
+ std::vector<Field> fFields;
+ SpvDim_ fDimensions = SpvDim1D;
+ bool fIsDepth = false;
+ bool fIsArrayed = false;
+ bool fIsMultisampled = false;
+ bool fIsSampled = false;
};
} // namespace