aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-12-09 17:22:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-12 16:42:34 +0000
commitce33f10677630e34187b661a02161378d8304d68 (patch)
tree570afa6dc9fc971ab1b886563a04b48cfd41156b /src/sksl/SkSLGLSLCodeGenerator.h
parentf44703a87f532b3f593d91605d66d52c6bbc45c9 (diff)
added sk_FragCoord support to skslc
BUG=skia: Change-Id: If78a4d08121699f87659f0d2e35f3edbf1867401 Reviewed-on: https://skia-review.googlesource.com/5408 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.h')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index ffc5a4d473..bb7d8b1080 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,22 @@ 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 fSetupFragPosition = false;
+
+ typedef CodeGenerator INHERITED;
};
}