diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2018-01-23 16:39:42 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-23 22:23:30 +0000 |
commit | 29b3434e48ca41672266ac40f5b9e8f8a0405cb5 (patch) | |
tree | 2524748fc90c30ae887e6a086e6bb76ffaa05e81 /src/sksl/SkSLIRGenerator.cpp | |
parent | 8524c30a971cd22fe1e3e0fd3db5988fe23272b6 (diff) |
Revert "converted vertex shaders to device coords"
This reverts commit e7e81c15c144b8133f696d0744ed9f7e8d06e936.
Reason for revert: Chrome perf regressions
Bug: skia:
Change-Id: I17fadc97c4b8e80bfdccbf123554614a00c58473
Reviewed-on: https://skia-review.googlesource.com/99040
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r-- | src/sksl/SkSLIRGenerator.cpp | 89 |
1 files changed, 4 insertions, 85 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index 3388a4758d..019aee8eaa 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -154,9 +154,6 @@ void IRGenerator::start(const Program::Settings* settings) { this->pushSymbolTable(); fInvocations = -1; fInputs.reset(); - fSkPerVertex = nullptr; - fRTAdjust = nullptr; - fRTAdjustInterfaceBlock = nullptr; } void IRGenerator::finish() { @@ -174,26 +171,8 @@ std::unique_ptr<Statement> IRGenerator::convertStatement(const ASTStatement& sta return this->convertBlock((ASTBlock&) statement); case ASTStatement::kVarDeclaration_Kind: return this->convertVarDeclarationStatement((ASTVarDeclarationStatement&) statement); - case ASTStatement::kExpression_Kind: { - std::unique_ptr<Statement> result = - this->convertExpressionStatement((ASTExpressionStatement&) statement); - if (fRTAdjust && Program::kGeometry_Kind == fKind) { - ASSERT(result->fKind == Statement::kExpression_Kind); - Expression& expr = *((ExpressionStatement&) *result).fExpression; - if (expr.fKind == Expression::kFunctionCall_Kind) { - FunctionCall& fc = (FunctionCall&) expr; - if (fc.fFunction.fBuiltin && fc.fFunction.fName == "EmitVertex") { - std::vector<std::unique_ptr<Statement>> statements; - statements.push_back(getNormalizeSkPositionCode()); - statements.push_back(std::move(result)); - return std::unique_ptr<Block>(new Block(statement.fOffset, - std::move(statements), - fSymbolTable)); - } - } - } - return result; - } + case ASTStatement::kExpression_Kind: + return this->convertExpressionStatement((ASTExpressionStatement&) statement); case ASTStatement::kIf_Kind: return this->convertIf((ASTIfStatement&) statement); case ASTStatement::kFor_Kind: @@ -278,11 +257,6 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa } auto var = std::unique_ptr<Variable>(new Variable(decl.fOffset, decl.fModifiers, varDecl.fName, *type, storage)); - if (var->fName == Compiler::RTADJUST_NAME) { - ASSERT(!fRTAdjust); - ASSERT(var->fType == *fContext.fFloat4_Type); - fRTAdjust = var.get(); - } std::unique_ptr<Expression> value; if (varDecl.fValue) { value = this->convertExpression(*varDecl.fValue); @@ -498,10 +472,6 @@ std::unique_ptr<Statement> IRGenerator::convertExpressionStatement( std::unique_ptr<Statement> IRGenerator::convertReturn(const ASTReturnStatement& r) { ASSERT(fCurrentFunction); - // early returns from a vertex main function will bypass the sk_Position normalization, so - // assert that we aren't doing that. It is of course possible to fix this by adding a - // normalization before each return, but it will probably never actually be necessary. - ASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->fName); if (r.fExpression) { std::unique_ptr<Expression> result = this->convertExpression(*r.fExpression); if (!result) { @@ -605,40 +575,6 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr< return std::unique_ptr<Block>(new Block(-1, std::move(children))); } -std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() { - // sk_Position = float4(sk_Position.x * rtAdjust.x + sk_Position.w * rtAdjust.y, - // sk_Position.y * rtAdjust.z + sk_Position.w * rtAdjust.w, - // 0, - // sk_Position.w); - ASSERT(fSkPerVertex && fRTAdjust); - #define REF(var) std::unique_ptr<Expression>(\ - new VariableReference(-1, *var, VariableReference::kRead_RefKind)) - #define FIELD(var, idx) std::unique_ptr<Expression>(\ - new FieldAccess(REF(var), idx, FieldAccess::kAnonymousInterfaceBlock_OwnerKind)) - #define POS std::unique_ptr<Expression>(new FieldAccess(REF(fSkPerVertex), 0, \ - FieldAccess::kAnonymousInterfaceBlock_OwnerKind)) - #define ADJUST (fRTAdjustInterfaceBlock ? \ - FIELD(fRTAdjustInterfaceBlock, fRTAdjustFieldIndex) : \ - REF(fRTAdjust)) - #define SWIZZLE(expr, field) std::unique_ptr<Expression>(new Swizzle(fContext, expr, { field })) - #define OP(left, op, right) std::unique_ptr<Expression>(\ - new BinaryExpression(-1, left, op, right, *fContext.fFloat_Type)) - std::vector<std::unique_ptr<Expression>> children; - children.push_back(OP(OP(SWIZZLE(POS, 0), Token::STAR, SWIZZLE(ADJUST, 0)), - Token::PLUS, - OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 1)))); - children.push_back(OP(OP(SWIZZLE(POS, 1), Token::STAR, SWIZZLE(ADJUST, 2)), - Token::PLUS, - OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 3)))); - children.push_back(std::unique_ptr<Expression>(new FloatLiteral(fContext, -1, 0.0))); - children.push_back(SWIZZLE(POS, 3)); - std::unique_ptr<Expression> result = OP(POS, Token::EQ, - std::unique_ptr<Expression>(new Constructor(-1, - *fContext.fFloat4_Type, - std::move(children)))); - return std::unique_ptr<Statement>(new ExpressionStatement(std::move(result))); -} - void IRGenerator::convertFunction(const ASTFunction& f) { const Type* returnType = this->convertType(*f.fReturnType); if (!returnType) { @@ -755,9 +691,7 @@ void IRGenerator::convertFunction(const ASTFunction& f) { } // conservatively assume all user-defined functions have side effects ((Modifiers&) decl->fModifiers).fFlags |= Modifiers::kHasSideEffects_Flag; - if (Program::kVertex_Kind == fKind && f.fName == "main" && fRTAdjust) { - body->fStatements.insert(body->fStatements.end(), this->getNormalizeSkPositionCode()); - } + fProgramElements->push_back(std::unique_ptr<FunctionDefinition>( new FunctionDefinition(f.fOffset, *decl, std::move(body)))); } @@ -768,7 +702,6 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte AutoSymbolTable table(this); std::vector<Type::Field> fields; bool haveRuntimeArray = false; - bool foundRTAdjust = false; for (size_t i = 0; i < intf.fDeclarations.size(); i++) { std::unique_ptr<VarDeclarations> decl = this->convertVarDeclarations( *intf.fDeclarations[i], @@ -783,11 +716,6 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte "only the last entry in an interface block may be a runtime-sized " "array"); } - if (vd.fVar == fRTAdjust) { - foundRTAdjust = true; - ASSERT(vd.fVar->fType == *fContext.fFloat4_Type); - fRTAdjustFieldIndex = fields.size(); - } fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->fName, &vd.fVar->fType)); if (vd.fValue) { @@ -841,9 +769,6 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte Variable* var = new Variable(intf.fOffset, intf.fModifiers, intf.fInstanceName.fLength ? intf.fInstanceName : intf.fTypeName, *type, Variable::kGlobal_Storage); - if (foundRTAdjust) { - fRTAdjustInterfaceBlock = var; - } old->takeOwnership(var); if (intf.fInstanceName.fLength) { old->addWithoutOwnership(intf.fInstanceName, var); @@ -853,10 +778,6 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte (int) i))); } } - if (var->fName == Compiler::PERVERTEX_NAME) { - ASSERT(!fSkPerVertex); - fSkPerVertex = var; - } return std::unique_ptr<InterfaceBlock>(new InterfaceBlock(intf.fOffset, var, intf.fTypeName, @@ -2106,12 +2027,10 @@ void IRGenerator::markWrittenTo(const Expression& expr, bool readWrite) { } } -void IRGenerator::convertProgram(Program::Kind kind, - const char* text, +void IRGenerator::convertProgram(const char* text, size_t length, SymbolTable& types, std::vector<std::unique_ptr<ProgramElement>>* out) { - fKind = kind; fProgramElements = out; Parser parser(text, length, types, fErrors); std::vector<std::unique_ptr<ASTDeclaration>> parsed = parser.file(); |