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 <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index bb8ac60..31492bd 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 @@
                                   std::shared_ptr<SymbolTable> base,
                                   std::vector<std::unique_ptr<ProgramElement>>* outElements,
                                   std::shared_ptr<SymbolTable>* 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 = &caps;
+#endif
     fIRGenerator->start(&settings, nullptr);
     fIRGenerator->convertProgram(kind, src, length, *fTypes, outElements);
     if (this->fErrorCount) {
@@ -291,6 +305,9 @@
     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