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

Unified Diff: src/sksl/SkSLIRGenerator.cpp

Issue 2185393003: added initial GLSL support to skslc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added initial GLSL support to skslc 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
Index: src/sksl/SkSLIRGenerator.cpp
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index f250c4bb0cc0d59c44c2a72244c78ce0203f6985..0bbd0b2b37e99a53bece98b8d1d2a33ffe47c8fa 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -182,7 +182,6 @@ std::unique_ptr<VarDeclaration> IRGenerator::convertVarDeclaration(const ASTVarD
currentVarSizes.push_back(nullptr);
}
}
- sizes.push_back(std::move(currentVarSizes));
auto var = std::unique_ptr<Variable>(new Variable(decl.fPosition, modifiers, decl.fNames[i],
*type, storage));
std::unique_ptr<Expression> value;
@@ -193,9 +192,16 @@ std::unique_ptr<VarDeclaration> IRGenerator::convertVarDeclaration(const ASTVarD
}
value = this->coerce(std::move(value), *type);
}
- variables.push_back(var.get());
- fSymbolTable->add(decl.fNames[i], std::move(var));
- values.push_back(std::move(value));
+ if ("gl_FragCoord" == decl.fNames[i] && (*fSymbolTable)[decl.fNames[i]]) {
+ // already defined, just update the modifiers
+ Variable* old = (Variable*) (*fSymbolTable)[decl.fNames[i]];
+ old->fModifiers = var->fModifiers;
+ } else {
+ variables.push_back(var.get());
+ fSymbolTable->add(decl.fNames[i], std::move(var));
+ values.push_back(std::move(value));
+ sizes.push_back(std::move(currentVarSizes));
+ }
}
return std::unique_ptr<VarDeclaration>(new VarDeclaration(decl.fPosition, std::move(variables),
std::move(sizes), std::move(values)));
@@ -574,7 +580,8 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTIdentifier&
const Field* field = (const Field*) result;
VariableReference* base = new VariableReference(identifier.fPosition, field->fOwner);
return std::unique_ptr<Expression>(new FieldAccess(std::unique_ptr<Expression>(base),
- field->fFieldIndex));
+ field->fFieldIndex,
+ true));
dogben 2016/07/31 23:20:20 nit: use enum, or "/*inAnonymousInterfaceBlock*/ t
ethannicholas 2016/08/02 16:13:18 Done.
}
case Symbol::kType_Kind: {
const Type* t = (const Type*) result;
@@ -651,18 +658,31 @@ static bool determine_binary_type(const Context& context,
right.canCoerceTo(*context.fBool_Type);
case Token::STAR: // fall through
case Token::STAREQ:
- // FIXME need to handle non-square matrices
if (left.kind() == Type::kMatrix_Kind && right.kind() == Type::kVector_Kind) {
- *outLeftType = &left;
- *outRightType = &right;
- *outResultType = &right;
- return left.rows() == right.columns();
+ // determine final component type
+ if (determine_binary_type(context, Token::STAR, left.componentType(),
+ right.componentType(), outLeftType, outRightType,
+ outResultType, false)) {
+ *outLeftType = &left;
dogben 2016/07/31 23:20:21 Seems like you need *outLeftType = &(*outResultTyp
ethannicholas 2016/08/02 16:13:18 Completely reworked this.
+ *outRightType = &right;
+ *outResultType = &(*outResultType)->toCompound(context, left.rows(), 1);
+ return left.rows() == right.columns();
dogben 2016/07/31 23:20:20 Should be left.columns() == right.columns() becaus
+ } else {
+ return false;
+ }
}
if (left.kind() == Type::kVector_Kind && right.kind() == Type::kMatrix_Kind) {
- *outLeftType = &left;
- *outRightType = &right;
- *outResultType = &left;
- return left.columns() == right.columns();
+ // determine final component type
+ if (determine_binary_type(context, Token::STAR, left.componentType(),
+ right.componentType(), outLeftType, outRightType,
+ outResultType, false)) {
+ *outLeftType = &left;
+ *outRightType = &right;
+ *outResultType = &(*outResultType)->toCompound(context, right.columns(), 1);
+ return left.columns() == right.rows();
+ } else {
+ return false;
+ }
}
// fall through
default:
@@ -1043,7 +1063,7 @@ std::unique_ptr<Expression> IRGenerator::convertField(std::unique_ptr<Expression
auto fields = base->fType.fields();
for (size_t i = 0; i < fields.size(); i++) {
if (fields[i].fName == field) {
- return std::unique_ptr<Expression>(new FieldAccess(std::move(base), (int) i));
+ return std::unique_ptr<Expression>(new FieldAccess(std::move(base), (int) i, false));
}
}
fErrors.error(base->fPosition, "type '" + base->fType.description() + "' does not have a "

Powered by Google App Engine
This is Rietveld 408576698