Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1091)

Unified Diff: src/sksl/ir/SkSLType.h

Issue 2143323003: Revert of SkSL performance improvements (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/ir/SkSLSymbolTable.cpp ('k') | src/sksl/ir/SkSLType.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/ir/SkSLType.h
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 8a73b139baf61203ee86ab7473a4461b91eaa8a4..e17bae68db93f368b0e6bea5139795ac6beb0b29 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -24,18 +24,18 @@
class Type : public Symbol {
public:
struct Field {
- Field(Modifiers modifiers, std::string name, const Type& type)
+ Field(Modifiers modifiers, std::string name, std::shared_ptr<Type> type)
: fModifiers(modifiers)
, fName(std::move(name))
, fType(std::move(type)) {}
- const std::string description() const {
- return fType.description() + " " + fName + ";";
+ const std::string description() {
+ return fType->description() + " " + fName + ";";
}
const Modifiers fModifiers;
const std::string fName;
- const Type& fType;
+ const std::shared_ptr<Type> fType;
};
enum Kind {
@@ -56,7 +56,7 @@
, fTypeKind(kOther_Kind) {}
// Create a generic type which maps to the listed types.
- Type(std::string name, std::vector<const Type*> types)
+ Type(std::string name, std::vector<std::shared_ptr<Type>> types)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kGeneric_Kind)
, fCoercibleTypes(std::move(types)) {
@@ -78,7 +78,7 @@
, fRows(1) {}
// Create a scalar type which can be coerced to the listed types.
- Type(std::string name, bool isNumber, std::vector<const Type*> coercibleTypes)
+ Type(std::string name, bool isNumber, std::vector<std::shared_ptr<Type>> coercibleTypes)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kScalar_Kind)
, fIsNumber(isNumber)
@@ -87,23 +87,23 @@
, fRows(1) {}
// Create a vector type.
- Type(std::string name, const Type& componentType, int columns)
+ Type(std::string name, std::shared_ptr<Type> componentType, int columns)
: Type(name, kVector_Kind, componentType, columns) {}
// Create a vector or array type.
- Type(std::string name, Kind kind, const Type& componentType, int columns)
+ Type(std::string name, Kind kind, std::shared_ptr<Type> componentType, int columns)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kind)
- , fComponentType(&componentType)
+ , fComponentType(std::move(componentType))
, fColumns(columns)
, fRows(1)
, fDimensions(SpvDim1D) {}
// Create a matrix type.
- Type(std::string name, const Type& componentType, int columns, int rows)
+ Type(std::string name, std::shared_ptr<Type> componentType, int columns, int rows)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kMatrix_Kind)
- , fComponentType(&componentType)
+ , fComponentType(std::move(componentType))
, fColumns(columns)
, fRows(rows)
, fDimensions(SpvDim1D) {}
@@ -153,7 +153,7 @@
* Returns true if an instance of this type can be freely coerced (implicitly converted) to
* another type.
*/
- bool canCoerceTo(const Type& other) const {
+ bool canCoerceTo(std::shared_ptr<Type> other) const {
int cost;
return determineCoercionCost(other, &cost);
}
@@ -164,15 +164,15 @@
* costs. Returns true if a conversion is possible, false otherwise. The value of the out
* parameter is undefined if false is returned.
*/
- bool determineCoercionCost(const Type& other, int* outCost) const;
+ bool determineCoercionCost(std::shared_ptr<Type> other, int* outCost) const;
/**
* For matrices and vectors, returns the type of individual cells (e.g. mat2 has a component
* type of kFloat_Type). For all other types, causes an assertion failure.
*/
- const Type& componentType() const {
+ std::shared_ptr<Type> componentType() const {
ASSERT(fComponentType);
- return *fComponentType;
+ return fComponentType;
}
/**
@@ -195,7 +195,7 @@
return fRows;
}
- const std::vector<Field>& fields() const {
+ std::vector<Field> fields() const {
ASSERT(fTypeKind == kStruct_Kind);
return fFields;
}
@@ -204,7 +204,7 @@
* For generic types, returns the types that this generic type can substitute for. For other
* types, returns a list of other types that this type can be coerced into.
*/
- const std::vector<const Type*>& coercibleTypes() const {
+ std::vector<std::shared_ptr<Type>> coercibleTypes() const {
ASSERT(fCoercibleTypes.size() > 0);
return fCoercibleTypes;
}
@@ -257,7 +257,7 @@
case kStruct_Kind: {
size_t result = 16;
for (size_t i = 0; i < fFields.size(); i++) {
- size_t alignment = fFields[i].fType.alignment();
+ size_t alignment = fFields[i].fType->alignment();
if (alignment > result) {
result = alignment;
}
@@ -300,13 +300,13 @@
case kStruct_Kind: {
size_t total = 0;
for (size_t i = 0; i < fFields.size(); i++) {
- size_t alignment = fFields[i].fType.alignment();
+ size_t alignment = fFields[i].fType->alignment();
if (total % alignment != 0) {
total += alignment - total % alignment;
}
ASSERT(false);
ASSERT(total % alignment == 0);
- total += fFields[i].fType.size();
+ total += fFields[i].fType->size();
}
return total;
}
@@ -319,15 +319,15 @@
* Returns the corresponding vector or matrix type with the specified number of columns and
* rows.
*/
- const Type& toCompound(int columns, int rows) const;
+ std::shared_ptr<Type> toCompound(int columns, int rows);
private:
typedef Symbol INHERITED;
const Kind fTypeKind;
const bool fIsNumber = false;
- const Type* fComponentType = nullptr;
- const std::vector<const Type*> fCoercibleTypes = { };
+ const std::shared_ptr<Type> fComponentType = nullptr;
+ const std::vector<std::shared_ptr<Type>> fCoercibleTypes = { };
const int fColumns = -1;
const int fRows = -1;
const std::vector<Field> fFields = { };
@@ -338,100 +338,100 @@
const bool fIsSampled = false;
};
-extern const Type* kVoid_Type;
-
-extern const Type* kFloat_Type;
-extern const Type* kVec2_Type;
-extern const Type* kVec3_Type;
-extern const Type* kVec4_Type;
-extern const Type* kDouble_Type;
-extern const Type* kDVec2_Type;
-extern const Type* kDVec3_Type;
-extern const Type* kDVec4_Type;
-extern const Type* kInt_Type;
-extern const Type* kIVec2_Type;
-extern const Type* kIVec3_Type;
-extern const Type* kIVec4_Type;
-extern const Type* kUInt_Type;
-extern const Type* kUVec2_Type;
-extern const Type* kUVec3_Type;
-extern const Type* kUVec4_Type;
-extern const Type* kBool_Type;
-extern const Type* kBVec2_Type;
-extern const Type* kBVec3_Type;
-extern const Type* kBVec4_Type;
-
-extern const Type* kMat2x2_Type;
-extern const Type* kMat2x3_Type;
-extern const Type* kMat2x4_Type;
-extern const Type* kMat3x2_Type;
-extern const Type* kMat3x3_Type;
-extern const Type* kMat3x4_Type;
-extern const Type* kMat4x2_Type;
-extern const Type* kMat4x3_Type;
-extern const Type* kMat4x4_Type;
-
-extern const Type* kDMat2x2_Type;
-extern const Type* kDMat2x3_Type;
-extern const Type* kDMat2x4_Type;
-extern const Type* kDMat3x2_Type;
-extern const Type* kDMat3x3_Type;
-extern const Type* kDMat3x4_Type;
-extern const Type* kDMat4x2_Type;
-extern const Type* kDMat4x3_Type;
-extern const Type* kDMat4x4_Type;
-
-extern const Type* kSampler1D_Type;
-extern const Type* kSampler2D_Type;
-extern const Type* kSampler3D_Type;
-extern const Type* kSamplerCube_Type;
-extern const Type* kSampler2DRect_Type;
-extern const Type* kSampler1DArray_Type;
-extern const Type* kSampler2DArray_Type;
-extern const Type* kSamplerCubeArray_Type;
-extern const Type* kSamplerBuffer_Type;
-extern const Type* kSampler2DMS_Type;
-extern const Type* kSampler2DMSArray_Type;
-
-extern const Type* kGSampler1D_Type;
-extern const Type* kGSampler2D_Type;
-extern const Type* kGSampler3D_Type;
-extern const Type* kGSamplerCube_Type;
-extern const Type* kGSampler2DRect_Type;
-extern const Type* kGSampler1DArray_Type;
-extern const Type* kGSampler2DArray_Type;
-extern const Type* kGSamplerCubeArray_Type;
-extern const Type* kGSamplerBuffer_Type;
-extern const Type* kGSampler2DMS_Type;
-extern const Type* kGSampler2DMSArray_Type;
-
-extern const Type* kSampler1DShadow_Type;
-extern const Type* kSampler2DShadow_Type;
-extern const Type* kSamplerCubeShadow_Type;
-extern const Type* kSampler2DRectShadow_Type;
-extern const Type* kSampler1DArrayShadow_Type;
-extern const Type* kSampler2DArrayShadow_Type;
-extern const Type* kSamplerCubeArrayShadow_Type;
-extern const Type* kGSampler2DArrayShadow_Type;
-extern const Type* kGSamplerCubeArrayShadow_Type;
-
-extern const Type* kGenType_Type;
-extern const Type* kGenDType_Type;
-extern const Type* kGenIType_Type;
-extern const Type* kGenUType_Type;
-extern const Type* kGenBType_Type;
-extern const Type* kMat_Type;
-extern const Type* kVec_Type;
-extern const Type* kGVec_Type;
-extern const Type* kGVec2_Type;
-extern const Type* kGVec3_Type;
-extern const Type* kGVec4_Type;
-extern const Type* kDVec_Type;
-extern const Type* kIVec_Type;
-extern const Type* kUVec_Type;
-extern const Type* kBVec_Type;
-
-extern const Type* kInvalid_Type;
+extern const std::shared_ptr<Type> kVoid_Type;
+
+extern const std::shared_ptr<Type> kFloat_Type;
+extern const std::shared_ptr<Type> kVec2_Type;
+extern const std::shared_ptr<Type> kVec3_Type;
+extern const std::shared_ptr<Type> kVec4_Type;
+extern const std::shared_ptr<Type> kDouble_Type;
+extern const std::shared_ptr<Type> kDVec2_Type;
+extern const std::shared_ptr<Type> kDVec3_Type;
+extern const std::shared_ptr<Type> kDVec4_Type;
+extern const std::shared_ptr<Type> kInt_Type;
+extern const std::shared_ptr<Type> kIVec2_Type;
+extern const std::shared_ptr<Type> kIVec3_Type;
+extern const std::shared_ptr<Type> kIVec4_Type;
+extern const std::shared_ptr<Type> kUInt_Type;
+extern const std::shared_ptr<Type> kUVec2_Type;
+extern const std::shared_ptr<Type> kUVec3_Type;
+extern const std::shared_ptr<Type> kUVec4_Type;
+extern const std::shared_ptr<Type> kBool_Type;
+extern const std::shared_ptr<Type> kBVec2_Type;
+extern const std::shared_ptr<Type> kBVec3_Type;
+extern const std::shared_ptr<Type> kBVec4_Type;
+
+extern const std::shared_ptr<Type> kMat2x2_Type;
+extern const std::shared_ptr<Type> kMat2x3_Type;
+extern const std::shared_ptr<Type> kMat2x4_Type;
+extern const std::shared_ptr<Type> kMat3x2_Type;
+extern const std::shared_ptr<Type> kMat3x3_Type;
+extern const std::shared_ptr<Type> kMat3x4_Type;
+extern const std::shared_ptr<Type> kMat4x2_Type;
+extern const std::shared_ptr<Type> kMat4x3_Type;
+extern const std::shared_ptr<Type> kMat4x4_Type;
+
+extern const std::shared_ptr<Type> kDMat2x2_Type;
+extern const std::shared_ptr<Type> kDMat2x3_Type;
+extern const std::shared_ptr<Type> kDMat2x4_Type;
+extern const std::shared_ptr<Type> kDMat3x2_Type;
+extern const std::shared_ptr<Type> kDMat3x3_Type;
+extern const std::shared_ptr<Type> kDMat3x4_Type;
+extern const std::shared_ptr<Type> kDMat4x2_Type;
+extern const std::shared_ptr<Type> kDMat4x3_Type;
+extern const std::shared_ptr<Type> kDMat4x4_Type;
+
+extern const std::shared_ptr<Type> kSampler1D_Type;
+extern const std::shared_ptr<Type> kSampler2D_Type;
+extern const std::shared_ptr<Type> kSampler3D_Type;
+extern const std::shared_ptr<Type> kSamplerCube_Type;
+extern const std::shared_ptr<Type> kSampler2DRect_Type;
+extern const std::shared_ptr<Type> kSampler1DArray_Type;
+extern const std::shared_ptr<Type> kSampler2DArray_Type;
+extern const std::shared_ptr<Type> kSamplerCubeArray_Type;
+extern const std::shared_ptr<Type> kSamplerBuffer_Type;
+extern const std::shared_ptr<Type> kSampler2DMS_Type;
+extern const std::shared_ptr<Type> kSampler2DMSArray_Type;
+
+extern const std::shared_ptr<Type> kGSampler1D_Type;
+extern const std::shared_ptr<Type> kGSampler2D_Type;
+extern const std::shared_ptr<Type> kGSampler3D_Type;
+extern const std::shared_ptr<Type> kGSamplerCube_Type;
+extern const std::shared_ptr<Type> kGSampler2DRect_Type;
+extern const std::shared_ptr<Type> kGSampler1DArray_Type;
+extern const std::shared_ptr<Type> kGSampler2DArray_Type;
+extern const std::shared_ptr<Type> kGSamplerCubeArray_Type;
+extern const std::shared_ptr<Type> kGSamplerBuffer_Type;
+extern const std::shared_ptr<Type> kGSampler2DMS_Type;
+extern const std::shared_ptr<Type> kGSampler2DMSArray_Type;
+
+extern const std::shared_ptr<Type> kSampler1DShadow_Type;
+extern const std::shared_ptr<Type> kSampler2DShadow_Type;
+extern const std::shared_ptr<Type> kSamplerCubeShadow_Type;
+extern const std::shared_ptr<Type> kSampler2DRectShadow_Type;
+extern const std::shared_ptr<Type> kSampler1DArrayShadow_Type;
+extern const std::shared_ptr<Type> kSampler2DArrayShadow_Type;
+extern const std::shared_ptr<Type> kSamplerCubeArrayShadow_Type;
+extern const std::shared_ptr<Type> kGSampler2DArrayShadow_Type;
+extern const std::shared_ptr<Type> kGSamplerCubeArrayShadow_Type;
+
+extern const std::shared_ptr<Type> kGenType_Type;
+extern const std::shared_ptr<Type> kGenDType_Type;
+extern const std::shared_ptr<Type> kGenIType_Type;
+extern const std::shared_ptr<Type> kGenUType_Type;
+extern const std::shared_ptr<Type> kGenBType_Type;
+extern const std::shared_ptr<Type> kMat_Type;
+extern const std::shared_ptr<Type> kVec_Type;
+extern const std::shared_ptr<Type> kGVec_Type;
+extern const std::shared_ptr<Type> kGVec2_Type;
+extern const std::shared_ptr<Type> kGVec3_Type;
+extern const std::shared_ptr<Type> kGVec4_Type;
+extern const std::shared_ptr<Type> kDVec_Type;
+extern const std::shared_ptr<Type> kIVec_Type;
+extern const std::shared_ptr<Type> kUVec_Type;
+extern const std::shared_ptr<Type> kBVec_Type;
+
+extern const std::shared_ptr<Type> kInvalid_Type;
} // namespace
« no previous file with comments | « src/sksl/ir/SkSLSymbolTable.cpp ('k') | src/sksl/ir/SkSLType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698