From a11035bf774978b610c2e36e49157104ad8bf6d5 Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Tue, 26 Nov 2019 16:27:47 -0500 Subject: [PATCH] SkSL now handles sk_Caps in include files This also fixes error reporting in broken include files. Change-Id: I39b74ced4fe56f7bf654aef4c8c402713bdb15b6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256778 Auto-Submit: Ethan Nicholas Reviewed-by: Brian Salomon Commit-Queue: Brian Salomon --- src/sksl/SkSLCompiler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index bb8ac60e14..31492bd493 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -28,6 +28,11 @@ #include "src/sksl/ir/SkSLUnresolvedFunction.h" #include "src/sksl/ir/SkSLVarDeclarations.h" +#if !defined(SKSL_STANDALONE) & SK_SUPPORT_GPU +#include "include/gpu/GrContextOptions.h" +#include "src/gpu/GrShaderCaps.h" +#endif + #ifdef SK_ENABLE_SPIRV_VALIDATION #include "spirv-tools/libspirv.hpp" #endif @@ -281,8 +286,17 @@ void Compiler::processIncludeFile(Program::Kind kind, const char* src, size_t le std::shared_ptr base, std::vector>* outElements, std::shared_ptr* outSymbolTable) { +#ifdef SK_DEBUG + String source(src, length); + fSource = &source; +#endif fIRGenerator->fSymbolTable = std::move(base); Program::Settings settings; +#if !defined(SKSL_STANDALONE) & SK_SUPPORT_GPU + GrContextOptions opts; + GrShaderCaps caps(opts); + settings.fCaps = ∩︀ +#endif fIRGenerator->start(&settings, nullptr); fIRGenerator->convertProgram(kind, src, length, *fTypes, outElements); if (this->fErrorCount) { @@ -291,6 +305,9 @@ void Compiler::processIncludeFile(Program::Kind kind, const char* src, size_t le SkASSERT(!fErrorCount); fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); *outSymbolTable = fIRGenerator->fSymbolTable; +#ifdef SK_DEBUG + fSource = nullptr; +#endif } // add the definition created by assigning to the lvalue to the definition set