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>
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index ffc5a4d..0ae2c5c 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 @@
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 @@
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 @@
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;
};
}