aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-08-01 19:29:48 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-01 19:30:04 +0000
commit0e9605542444a7653359f4fc610f7620df9f6313 (patch)
treec9edebc09b883c9500b0da4565fab0e2d08570af /src/sksl/ir
parentd310879427018ee3727d61c3a0780f0a17c93935 (diff)
Revert "support for 'half' types in sksl, plus general numeric type improvements"
This reverts commit 93061b53442ce303e9d3ef74c7eeddc034802c4f. Reason for revert: bot failures Original change's description: > support for 'half' types in sksl, plus general numeric type improvements > > Bug: skia: > Change-Id: Id285262fda8291847f11343d499b5df62ddb4b09 > Reviewed-on: https://skia-review.googlesource.com/28980 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> TBR=bsalomon@google.com,ethannicholas@google.com Change-Id: Ie8672271d35b9fcdf567f8bc3674084748be66ad No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/29600 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ir')
-rw-r--r--src/sksl/ir/SkSLExpression.h4
-rw-r--r--src/sksl/ir/SkSLIntLiteral.h7
-rw-r--r--src/sksl/ir/SkSLType.cpp30
-rw-r--r--src/sksl/ir/SkSLType.h66
4 files changed, 25 insertions, 82 deletions
diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h
index 286610f078..89a1a1e84a 100644
--- a/src/sksl/ir/SkSLExpression.h
+++ b/src/sksl/ir/SkSLExpression.h
@@ -85,10 +85,6 @@ struct Expression : public IRNode {
return nullptr;
}
- virtual int coercionCost(const Type& target) const {
- return fType.coercionCost(target);
- }
-
const Kind fKind;
const Type& fType;
diff --git a/src/sksl/ir/SkSLIntLiteral.h b/src/sksl/ir/SkSLIntLiteral.h
index 6199f96610..d8eba5573a 100644
--- a/src/sksl/ir/SkSLIntLiteral.h
+++ b/src/sksl/ir/SkSLIntLiteral.h
@@ -40,13 +40,6 @@ struct IntLiteral : public Expression {
return fValue == i.fValue;
}
- int coercionCost(const Type& target) const override {
- if (target.isUnsigned()) {
- return 0;
- }
- return INHERITED::coercionCost(target);
- }
-
const int64_t fValue;
typedef Expression INHERITED;
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index 1fdc9bb68a..60d40cd867 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -10,37 +10,31 @@
namespace SkSL {
-int Type::coercionCost(const Type& other) const {
+bool Type::determineCoercionCost(const Type& other, int* outCost) const {
if (*this == other) {
- return 0;
+ *outCost = 0;
+ return true;
}
if (this->kind() == kVector_Kind && other.kind() == kVector_Kind) {
if (this->columns() == other.columns()) {
- return this->componentType().coercionCost(other.componentType());
+ return this->componentType().determineCoercionCost(other.componentType(), outCost);
}
- return INT_MAX;
+ return false;
}
if (this->kind() == kMatrix_Kind) {
- if (this->columns() == other.columns() && this->rows() == other.rows()) {
- return this->componentType().coercionCost(other.componentType());
+ if (this->columns() == other.columns() &&
+ this->rows() == other.rows()) {
+ return this->componentType().determineCoercionCost(other.componentType(), outCost);
}
- return INT_MAX;
- }
- if (this->isNumber() && other.isFloat()) {
- return 1;
- }
- if (this->isSigned() && other.isSigned()) {
- return 1;
- }
- if (this->isUnsigned() && other.isUnsigned()) {
- return 1;
+ return false;
}
for (size_t i = 0; i < fCoercibleTypes.size(); i++) {
if (*fCoercibleTypes[i] == other) {
- return (int) i + 1;
+ *outCost = (int) i + 1;
+ return true;
}
}
- return INT_MAX;
+ return false;
}
const Type& Type::toCompound(const Context& context, int columns, int rows) const {
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 6ea4c5694c..ec91a1c52b 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -52,47 +52,37 @@ public:
kOther_Kind
};
- enum NumberKind {
- kFloat_NumberKind,
- kSigned_NumberKind,
- kUnsigned_NumberKind,
- kNonnumeric_NumberKind
- };
-
// Create an "other" (special) type with the given name. These types cannot be directly
// referenced from user code.
Type(String name)
: INHERITED(Position(), kType_Kind, std::move(name))
- , fTypeKind(kOther_Kind)
- , fNumberKind(kNonnumeric_NumberKind) {}
+ , fTypeKind(kOther_Kind) {}
// Create a generic type which maps to the listed types.
Type(String name, std::vector<const Type*> types)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kGeneric_Kind)
- , fNumberKind(kNonnumeric_NumberKind)
, fCoercibleTypes(std::move(types)) {}
// Create a struct type with the given fields.
Type(Position position, String name, std::vector<Field> fields)
: INHERITED(position, kType_Kind, std::move(name))
, fTypeKind(kStruct_Kind)
- , fNumberKind(kNonnumeric_NumberKind)
, fFields(std::move(fields)) {}
// Create a scalar type.
- Type(String name, NumberKind numberKind)
+ Type(String name, bool isNumber)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kScalar_Kind)
- , fNumberKind(numberKind)
+ , fIsNumber(isNumber)
, fColumns(1)
, fRows(1) {}
// 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, bool isNumber, std::vector<const Type*> coercibleTypes)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kScalar_Kind)
- , fNumberKind(numberKind)
+ , fIsNumber(isNumber)
, fCoercibleTypes(std::move(coercibleTypes))
, fColumns(1)
, fRows(1) {}
@@ -105,7 +95,6 @@ public:
Type(String name, Kind kind, const Type& componentType, int columns)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kind)
- , fNumberKind(kNonnumeric_NumberKind)
, fComponentType(&componentType)
, fColumns(columns)
, fRows(1)
@@ -115,7 +104,6 @@ public:
Type(String name, const Type& componentType, int columns, int rows)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kMatrix_Kind)
- , fNumberKind(kNonnumeric_NumberKind)
, fComponentType(&componentType)
, fColumns(columns)
, fRows(rows)
@@ -126,14 +114,13 @@ public:
bool isSampled)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kSampler_Kind)
- , fNumberKind(kNonnumeric_NumberKind)
, fDimensions(dimensions)
, fIsDepth(isDepth)
, fIsArrayed(isArrayed)
, fIsMultisampled(isMultisampled)
, fIsSampled(isSampled) {}
- const String& name() const {
+ String name() const {
return fName;
}
@@ -160,35 +147,7 @@ public:
* Returns true if this is a numeric scalar type.
*/
bool isNumber() const {
- return fNumberKind != kNonnumeric_NumberKind;
- }
-
- /**
- * Returns true if this is a floating-point scalar type (float, half, or double).
- */
- bool isFloat() const {
- return fNumberKind == kFloat_NumberKind;
- }
-
- /**
- * Returns true if this is a signed scalar type (int or short).
- */
- bool isSigned() const {
- return fNumberKind == kSigned_NumberKind;
- }
-
- /**
- * Returns true if this is an unsigned scalar type (uint or ushort).
- */
- bool isUnsigned() const {
- return fNumberKind == kUnsigned_NumberKind;
- }
-
- /**
- * Returns true if this is a signed or unsigned integer.
- */
- bool isInteger() const {
- return isSigned() || isUnsigned();
+ return fIsNumber;
}
/**
@@ -196,15 +155,17 @@ public:
* another type.
*/
bool canCoerceTo(const Type& other) const {
- return coercionCost(other) != INT_MAX;
+ int cost;
+ return determineCoercionCost(other, &cost);
}
/**
* Determines the "cost" of coercing (implicitly converting) this type to another type. The cost
* is a number with no particular meaning other than that lower costs are preferable to higher
- * costs. Returns INT_MAX if the coercion is not possible.
+ * costs. Returns true if a conversion is possible, false otherwise. The value of the out
+ * parameter is undefined if false is returned.
*/
- int coercionCost(const Type& other) const;
+ bool determineCoercionCost(const Type& other, int* outCost) const;
/**
* For matrices and vectors, returns the type of individual cells (e.g. mat2 has a component
@@ -284,8 +245,7 @@ private:
typedef Symbol INHERITED;
const Kind fTypeKind;
- // always kNonnumeric_NumberKind for non-scalar values
- const NumberKind fNumberKind;
+ const bool fIsNumber = false;
const Type* fComponentType = nullptr;
const std::vector<const Type*> fCoercibleTypes;
const int fColumns = -1;