From f008b0a59f45c0d4bea3e66faf3b01805009ec89 Mon Sep 17 00:00:00 2001 From: ethannicholas Date: Fri, 30 Sep 2016 06:23:24 -0700 Subject: 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 Review-Url: https://codereview.chromium.org/2288033003 --- src/sksl/SkSLCompiler.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/sksl/SkSLCompiler.cpp') diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index d2ad81223e..8cc30c4bb7 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -10,11 +10,13 @@ #include #include +#include "ast/SkSLASTPrecision.h" #include "SkSLIRGenerator.h" #include "SkSLParser.h" #include "SkSLSPIRVCodeGenerator.h" #include "ir/SkSLExpression.h" #include "ir/SkSLIntLiteral.h" +#include "ir/SkSLModifiersDeclaration.h" #include "ir/SkSLSymbolTable.h" #include "ir/SkSLVarDeclaration.h" #include "SkMutex.h" @@ -97,6 +99,7 @@ Compiler::Compiler() ADD_TYPE(Sampler1D); ADD_TYPE(Sampler2D); ADD_TYPE(Sampler3D); + ADD_TYPE(SamplerExternalOES); ADD_TYPE(SamplerCube); ADD_TYPE(Sampler2DRect); ADD_TYPE(Sampler1DArray); @@ -128,8 +131,10 @@ Compiler::Compiler() ADD_TYPE(GSampler2DArrayShadow); ADD_TYPE(GSamplerCubeArrayShadow); - std::vector> ignored; - this->internalConvertProgram(SKSL_INCLUDE, &ignored); + Modifiers::Flag ignored1; + std::vector> ignored2; + this->internalConvertProgram(SKSL_INCLUDE, &ignored1, &ignored2); + printf("%s", errorText().c_str()); ASSERT(!fErrorCount); } @@ -138,12 +143,14 @@ Compiler::~Compiler() { } void Compiler::internalConvertProgram(std::string text, + Modifiers::Flag* defaultPrecision, std::vector>* result) { Parser parser(text, *fTypes, *this); std::vector> 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) { @@ -164,6 +171,14 @@ void Compiler::internalConvertProgram(std::string text, } break; } + case ASTDeclaration::kModifiers_Kind: { + std::unique_ptr f = fIRGenerator->convertModifiersDeclaration( + (ASTModifiersDeclaration&) decl); + if (f) { + result->push_back(std::move(f)); + } + break; + } case ASTDeclaration::kInterfaceBlock_Kind: { std::unique_ptr i = fIRGenerator->convertInterfaceBlock( (ASTInterfaceBlock&) decl); @@ -179,6 +194,10 @@ void Compiler::internalConvertProgram(std::string text, } break; } + case ASTDeclaration::kPrecision_Kind: { + *defaultPrecision = ((ASTPrecision&) decl).fPrecision; + break; + } default: ABORT("unsupported declaration: %s\n", decl.description().c_str()); } @@ -190,16 +209,18 @@ std::unique_ptr Compiler::convertProgram(Program::Kind kind, std::strin fErrorCount = 0; fIRGenerator->pushSymbolTable(); std::vector> elements; + Modifiers::Flag ignored; switch (kind) { case Program::kVertex_Kind: - this->internalConvertProgram(SKSL_VERT_INCLUDE, &elements); + this->internalConvertProgram(SKSL_VERT_INCLUDE, &ignored, &elements); break; case Program::kFragment_Kind: - this->internalConvertProgram(SKSL_FRAG_INCLUDE, &elements); + this->internalConvertProgram(SKSL_FRAG_INCLUDE, &ignored, &elements); break; } - this->internalConvertProgram(text, &elements); - auto result = std::unique_ptr(new Program(kind, std::move(elements), + Modifiers::Flag defaultPrecision; + this->internalConvertProgram(text, &defaultPrecision, &elements); + auto result = std::unique_ptr(new Program(kind, defaultPrecision, std::move(elements), fIRGenerator->fSymbolTable));; fIRGenerator->popSymbolTable(); this->writeErrorCount(); -- cgit v1.2.3