aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-10-10 09:18:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-10 09:18:23 -0700
commit15341a284e78651d2b47b89753044f8d6e7eda0a (patch)
tree80e2eecf6c4d11f4aa078afcb2181af156934b6f /src/sksl/SkSLIRGenerator.cpp
parente75c19f6380dd07a19faa39edcdbd75c79c7414d (diff)
Revert of Turned on SkSL->GLSL compiler (patchset #47 id:1200001 of https://codereview.chromium.org/2288033003/ )
Reason for revert: Looks like it introduces new static initializers, and it's failing the Chrome roll. Original issue's description: > Turned on SkSL->GLSL compiler > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2288033003 > > Committed: https://skia.googlesource.com/skia/+/9b0fe3d125f237d9884732a48414fa85fc71b4e3 > Committed: https://skia.googlesource.com/skia/+/b12b3c6908c62c908b3680be01e3b5bfd30de310 > Committed: https://skia.googlesource.com/skia/+/f008b0a59f45c0d4bea3e66faf3b01805009ec89 > Committed: https://skia.googlesource.com/skia/+/08b2ccf398e2b81bc05d2c105837e5419899469b TBR=benjaminwagner@google.com,bsalomon@google.com,egdaniel@google.com,ethannicholas@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2403083002
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r--src/sksl/SkSLIRGenerator.cpp82
1 files changed, 17 insertions, 65 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index d64684e62d..c30cac17d7 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -189,11 +189,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
}
value = this->coerce(std::move(value), *type);
}
- if ("sk_FragColor" == varDecl.fName && (*fSymbolTable)[varDecl.fName]) {
- // already defined, ignore
- } else if ((*fSymbolTable)[varDecl.fName] &&
- (*fSymbolTable)[varDecl.fName]->fKind == Symbol::kVariable_Kind &&
- ((Variable*) (*fSymbolTable)[varDecl.fName])->fModifiers.fLayout.fBuiltin >= 0) {
+ if ("gl_FragCoord" == varDecl.fName && (*fSymbolTable)[varDecl.fName]) {
// already defined, just update the modifiers
Variable* old = (Variable*) (*fSymbolTable)[varDecl.fName];
old->fModifiers = var->fModifiers;
@@ -207,12 +203,6 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
std::move(variables)));
}
-std::unique_ptr<ModifiersDeclaration> IRGenerator::convertModifiersDeclaration(
- const ASTModifiersDeclaration& m) {
- Modifiers modifiers = this->convertModifiers(m.fModifiers);
- return std::unique_ptr<ModifiersDeclaration>(new ModifiersDeclaration(modifiers));
-}
-
std::unique_ptr<Statement> IRGenerator::convertIf(const ASTIfStatement& s) {
std::unique_ptr<Expression> test = this->coerce(this->convertExpression(*s.fTest),
*fContext.fBool_Type);
@@ -429,9 +419,8 @@ std::unique_ptr<FunctionDefinition> IRGenerator::convertFunction(const ASTFuncti
for (size_t i = 0; i < parameters.size(); i++) {
if (parameters[i]->fModifiers != other->fParameters[i]->fModifiers) {
fErrors.error(f.fPosition, "modifiers on parameter " +
- to_string((uint64_t) i + 1) +
- " differ between declaration and "
- "definition");
+ to_string(i + 1) + " differ between " +
+ "declaration and definition");
return nullptr;
}
}
@@ -627,9 +616,8 @@ std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr
ASSERT(ctor);
return this->call(Position(), std::move(ctor), std::move(args));
}
- std::vector<std::unique_ptr<Expression>> args;
- args.push_back(std::move(expr));
- return std::unique_ptr<Expression>(new Constructor(Position(), type, std::move(args)));
+ ABORT("cannot coerce %s to %s", expr->fType.description().c_str(),
+ type.description().c_str());
}
static bool is_matrix_multiply(const Type& left, const Type& right) {
@@ -844,12 +832,12 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
std::vector<std::unique_ptr<Expression>> arguments) {
if (function.fParameters.size() != arguments.size()) {
std::string msg = "call to '" + function.fName + "' expected " +
- to_string((uint64_t) function.fParameters.size()) +
+ to_string(function.fParameters.size()) +
" argument";
if (function.fParameters.size() != 1) {
msg += "s";
}
- msg += ", but found " + to_string((uint64_t) arguments.size());
+ msg += ", but found " + to_string(arguments.size());
fErrors.error(position, msg);
return nullptr;
}
@@ -933,8 +921,7 @@ std::unique_ptr<Expression> IRGenerator::convertConstructor(
std::vector<std::unique_ptr<Expression>> args) {
// FIXME: add support for structs and arrays
Type::Kind kind = type.kind();
- if (!type.isNumber() && kind != Type::kVector_Kind && kind != Type::kMatrix_Kind &&
- kind != Type::kArray_Kind) {
+ if (!type.isNumber() && kind != Type::kVector_Kind && kind != Type::kMatrix_Kind) {
fErrors.error(position, "cannot construct '" + type.description() + "'");
return nullptr;
}
@@ -951,7 +938,7 @@ std::unique_ptr<Expression> IRGenerator::convertConstructor(
if (args.size() != 1) {
fErrors.error(position, "invalid arguments to '" + type.description() +
"' constructor, (expected exactly 1 argument, but found " +
- to_string((uint64_t) args.size()) + ")");
+ to_string(args.size()) + ")");
}
if (args[0]->fType == *fContext.fBool_Type) {
std::unique_ptr<IntLiteral> zero(new IntLiteral(fContext, position, 0));
@@ -966,18 +953,6 @@ std::unique_ptr<Expression> IRGenerator::convertConstructor(
"' constructor (expected a number or bool, but found '" +
args[0]->fType.description() + "')");
}
- if (args[0]->fKind == Expression::kIntLiteral_Kind && (type == *fContext.fInt_Type ||
- type == *fContext.fUInt_Type)) {
- return std::unique_ptr<Expression>(new IntLiteral(fContext,
- position,
- ((IntLiteral&) *args[0]).fValue,
- &type));
- }
- } else if (kind == Type::kArray_Kind) {
- const Type& base = type.componentType();
- for (size_t i = 0; i < args.size(); i++) {
- args[i] = this->coerce(std::move(args[i]), base);
- }
} else {
ASSERT(kind == Type::kVector_Kind || kind == Type::kMatrix_Kind);
int actual = 0;
@@ -1062,7 +1037,7 @@ std::unique_ptr<Expression> IRGenerator::convertPrefixExpression(
}
this->markWrittenTo(*base);
break;
- case Token::LOGICALNOT:
+ case Token::NOT:
if (base->fType != *fContext.fBool_Type) {
fErrors.error(expression.fPosition,
"'" + Token::OperatorName(expression.fOperator) +
@@ -1070,14 +1045,6 @@ std::unique_ptr<Expression> IRGenerator::convertPrefixExpression(
return nullptr;
}
break;
- case Token::BITWISENOT:
- if (base->fType != *fContext.fInt_Type) {
- fErrors.error(expression.fPosition,
- "'" + Token::OperatorName(expression.fOperator) +
- "' cannot operate on '" + base->fType.description() + "'");
- return nullptr;
- }
- break;
default:
ABORT("unsupported prefix operator\n");
}
@@ -1087,8 +1054,7 @@ std::unique_ptr<Expression> IRGenerator::convertPrefixExpression(
std::unique_ptr<Expression> IRGenerator::convertIndex(std::unique_ptr<Expression> base,
const ASTExpression& index) {
- if (base->fType.kind() != Type::kArray_Kind && base->fType.kind() != Type::kMatrix_Kind &&
- base->fType.kind() != Type::kVector_Kind) {
+ if (base->fType.kind() != Type::kArray_Kind && base->fType.kind() != Type::kMatrix_Kind) {
fErrors.error(base->fPosition, "expected array, but found '" + base->fType.description() +
"'");
return nullptr;
@@ -1097,11 +1063,9 @@ std::unique_ptr<Expression> IRGenerator::convertIndex(std::unique_ptr<Expression
if (!converted) {
return nullptr;
}
- if (converted->fType != *fContext.fUInt_Type) {
- converted = this->coerce(std::move(converted), *fContext.fInt_Type);
- if (!converted) {
- return nullptr;
- }
+ converted = this->coerce(std::move(converted), *fContext.fInt_Type);
+ if (!converted) {
+ return nullptr;
}
return std::unique_ptr<Expression>(new IndexExpression(fContext, std::move(base),
std::move(converted)));
@@ -1179,21 +1143,9 @@ std::unique_ptr<Expression> IRGenerator::convertSuffixExpression(
return nullptr;
}
switch (expression.fSuffix->fKind) {
- case ASTSuffix::kIndex_Kind: {
- const ASTExpression* expr = ((ASTIndexSuffix&) *expression.fSuffix).fExpression.get();
- if (expr) {
- return this->convertIndex(std::move(base), *expr);
- } else if (base->fKind == Expression::kTypeReference_Kind) {
- const Type& oldType = ((TypeReference&) *base).fValue;
- Type* newType = new Type(oldType.name() + "[]", Type::kArray_Kind, oldType,
- -1);
- fSymbolTable->takeOwnership(newType);
- return std::unique_ptr<Expression>(new TypeReference(fContext, base->fPosition,
- *newType));
- } else {
- fErrors.error(expression.fPosition, "'[]' must follow a type name");
- }
- }
+ case ASTSuffix::kIndex_Kind:
+ return this->convertIndex(std::move(base),
+ *((ASTIndexSuffix&) *expression.fSuffix).fExpression);
case ASTSuffix::kCall_Kind: {
auto rawArguments = &((ASTCallSuffix&) *expression.fSuffix).fArguments;
std::vector<std::unique_ptr<Expression>> arguments;