diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-06-21 11:25:18 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-21 15:55:06 +0000 |
commit | 7da6dfabc44891c51dedcb4754477b662d8c8a0a (patch) | |
tree | f64e1e88cbeb67319490ae138eb5afdb6175e627 /src/sksl/SkSLCompiler.cpp | |
parent | ce57552e11776c8f93798c3a2244fa378604b4af (diff) |
implemented mustImplementGSInvocationsWithLoop workaround in sksl
Third time's the charm
This reverts commit 84cda40bd7e98f4e19574c6e946395e244901408.
Bug: skia:
Change-Id: I2c0f4425122a94beb7b4053ee6e891faa8a5f290
Reviewed-on: https://skia-review.googlesource.com/20441
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLCompiler.cpp')
-rw-r--r-- | src/sksl/SkSLCompiler.cpp | 82 |
1 files changed, 12 insertions, 70 deletions
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index dd20b5c257..2d541a3b53 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -7,11 +7,9 @@ #include "SkSLCompiler.h" -#include "ast/SkSLASTPrecision.h" #include "SkSLCFGGenerator.h" #include "SkSLGLSLCodeGenerator.h" #include "SkSLIRGenerator.h" -#include "SkSLParser.h" #include "SkSLSPIRVCodeGenerator.h" #include "ir/SkSLExpression.h" #include "ir/SkSLExpressionStatement.h" @@ -156,7 +154,7 @@ Compiler::Compiler() Modifiers::Flag ignored1; std::vector<std::unique_ptr<ProgramElement>> ignored2; - this->internalConvertProgram(String(SKSL_INCLUDE), &ignored1, &ignored2); + fIRGenerator->convertProgram(String(SKSL_INCLUDE), *fTypes, &ignored1, &ignored2); fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); ASSERT(!fErrorCount); } @@ -1059,69 +1057,6 @@ void Compiler::scanCFG(FunctionDefinition& f) { } } -void Compiler::internalConvertProgram(String text, - Modifiers::Flag* defaultPrecision, - std::vector<std::unique_ptr<ProgramElement>>* result) { - Parser parser(text, *fTypes, *this); - std::vector<std::unique_ptr<ASTDeclaration>> parsed = parser.file(); - if (fErrorCount) { - return; - } - *defaultPrecision = Modifiers::kHighp_Flag; - for (size_t i = 0; i < parsed.size(); i++) { - ASTDeclaration& decl = *parsed[i]; - switch (decl.fKind) { - case ASTDeclaration::kVar_Kind: { - std::unique_ptr<VarDeclarations> s = fIRGenerator->convertVarDeclarations( - (ASTVarDeclarations&) decl, - Variable::kGlobal_Storage); - if (s) { - result->push_back(std::move(s)); - } - break; - } - case ASTDeclaration::kFunction_Kind: { - std::unique_ptr<FunctionDefinition> f = fIRGenerator->convertFunction( - (ASTFunction&) decl); - if (!fErrorCount && f) { - this->scanCFG(*f); - result->push_back(std::move(f)); - } - break; - } - case ASTDeclaration::kModifiers_Kind: { - std::unique_ptr<ModifiersDeclaration> f = fIRGenerator->convertModifiersDeclaration( - (ASTModifiersDeclaration&) decl); - if (f) { - result->push_back(std::move(f)); - } - break; - } - case ASTDeclaration::kInterfaceBlock_Kind: { - std::unique_ptr<InterfaceBlock> i = fIRGenerator->convertInterfaceBlock( - (ASTInterfaceBlock&) decl); - if (i) { - result->push_back(std::move(i)); - } - break; - } - case ASTDeclaration::kExtension_Kind: { - std::unique_ptr<Extension> e = fIRGenerator->convertExtension((ASTExtension&) decl); - if (e) { - result->push_back(std::move(e)); - } - break; - } - case ASTDeclaration::kPrecision_Kind: { - *defaultPrecision = ((ASTPrecision&) decl).fPrecision; - break; - } - default: - ABORT("unsupported declaration: %s\n", decl.description().c_str()); - } - } -} - std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String text, const Program::Settings& settings) { fErrorText = ""; @@ -1131,18 +1066,25 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String tex Modifiers::Flag ignored; switch (kind) { case Program::kVertex_Kind: - this->internalConvertProgram(String(SKSL_VERT_INCLUDE), &ignored, &elements); + fIRGenerator->convertProgram(String(SKSL_VERT_INCLUDE), *fTypes, &ignored, &elements); break; case Program::kFragment_Kind: - this->internalConvertProgram(String(SKSL_FRAG_INCLUDE), &ignored, &elements); + fIRGenerator->convertProgram(String(SKSL_FRAG_INCLUDE), *fTypes, &ignored, &elements); break; case Program::kGeometry_Kind: - this->internalConvertProgram(String(SKSL_GEOM_INCLUDE), &ignored, &elements); + fIRGenerator->convertProgram(String(SKSL_GEOM_INCLUDE), *fTypes, &ignored, &elements); break; } fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); Modifiers::Flag defaultPrecision; - this->internalConvertProgram(text, &defaultPrecision, &elements); + fIRGenerator->convertProgram(text, *fTypes, &defaultPrecision, &elements); + if (!fErrorCount) { + for (auto& element : elements) { + if (element->fKind == ProgramElement::kFunction_Kind) { + this->scanCFG((FunctionDefinition&) *element); + } + } + } auto result = std::unique_ptr<Program>(new Program(kind, settings, defaultPrecision, &fContext, std::move(elements), fIRGenerator->fSymbolTable, |