diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2016-12-12 15:33:30 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-13 14:28:53 +0000 |
commit | 941e7e2c9567ab1d8a3b2d1b0e3db71ee5eb75c9 (patch) | |
tree | 7f0ad6c5b2c3772d2c83be545fe04c53044746bd /src/sksl/SkSLGLSLCodeGenerator.h | |
parent | 3dc73f3596d93a89f71b0c7e96d5d63dafeaf378 (diff) |
re-land of added sk_FragCoord support to skslc
BUG=skia:
Change-Id: Ifac1aa39839058787ad1794200c3dbb93c147a69
Reviewed-on: https://skia-review.googlesource.com/5850
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.h')
-rw-r--r-- | src/sksl/SkSLGLSLCodeGenerator.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h index ffc5a4d473..0ae2c5c585 100644 --- a/src/sksl/SkSLGLSLCodeGenerator.h +++ b/src/sksl/SkSLGLSLCodeGenerator.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_GLSLCODEGENERATOR #define SKSL_GLSLCODEGENERATOR @@ -12,7 +12,6 @@ #include <tuple> #include <unordered_map> -#include "GrShaderCaps.h" #include "SkStream.h" #include "SkSLCodeGenerator.h" #include "ir/SkSLBinaryExpression.h" @@ -72,11 +71,12 @@ public: kTopLevel_Precedence = 18 }; - GLSLCodeGenerator(const Context* context, const GrShaderCaps* caps) - : fContext(*context) - , fCaps(*caps) {} + GLSLCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors, + SkWStream* out) + : INHERITED(program, errors, out) + , fContext(*context) {} - void generateCode(const Program& program, ErrorReporter& errors, SkWStream& out) override; + virtual bool generateCode() override; private: void write(const char* s); @@ -104,15 +104,17 @@ private: void writeLayout(const Layout& layout); void writeModifiers(const Modifiers& modifiers, bool globalContext); - + void writeGlobalVars(const VarDeclaration& vs); void writeVarDeclarations(const VarDeclarations& decl, bool global); + void writeFragCoord(); + void writeVariableReference(const VariableReference& ref); void writeExpression(const Expression& expr, Precedence parentPrecedence); - + void writeIntrinsicCall(const FunctionCall& c); void writeMinAbsHack(Expression& absExpr, Expression& otherExpr); @@ -156,21 +158,23 @@ private: void writeReturnStatement(const ReturnStatement& r); const Context& fContext; - const GrShaderCaps& fCaps; - SkWStream* fOut = nullptr; SkDynamicMemoryWStream fHeader; SkString fFunctionHeader; Program::Kind fProgramKind; int fVarCount = 0; int fIndentation = 0; bool fAtLineStart = false; - // Keeps track of which struct types we have written. Given that we are unlikely to ever write - // more than one or two structs per shader, a simple linear search will be faster than anything + // Keeps track of which struct types we have written. Given that we are unlikely to ever write + // more than one or two structs per shader, a simple linear search will be faster than anything // fancier. std::vector<const Type*> fWrittenStructs; // true if we have run into usages of dFdx / dFdy bool fFoundDerivatives = false; bool fFoundImageDecl = false; + bool fSetupFragPositionGlobal = false; + bool fSetupFragPositionLocal = false; + + typedef CodeGenerator INHERITED; }; } |