aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.cpp
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/SkSLIRGenerator.cpp
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/SkSLIRGenerator.cpp')
-rw-r--r--src/sksl/SkSLIRGenerator.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 023f1916c8..06988173aa 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -9,6 +9,7 @@
#include "limits.h"
+#include "SkSLCompiler.h"
#include "ast/SkSLASTBoolLiteral.h"
#include "ast/SkSLASTFieldSuffix.h"
#include "ast/SkSLASTFloatLiteral.h"
@@ -84,7 +85,6 @@ IRGenerator::IRGenerator(const Context* context, std::shared_ptr<SymbolTable> sy
ErrorReporter& errorReporter)
: fContext(*context)
, fCurrentFunction(nullptr)
-, fCapsMap(nullptr)
, fSymbolTable(std::move(symbolTable))
, fLoopLevel(0)
, fErrors(errorReporter) {}
@@ -97,14 +97,40 @@ void IRGenerator::popSymbolTable() {
fSymbolTable = fSymbolTable->fParent;
}
-void IRGenerator::start(std::unordered_map<SkString, CapValue>* caps) {
- this->fCapsMap = caps;
+static void fill_caps(const GrShaderCaps& caps, std::unordered_map<SkString, CapValue>* capsMap) {
+#define CAP(name) capsMap->insert(std::make_pair(SkString(#name), CapValue(caps.name())));
+ CAP(fbFetchSupport);
+ CAP(fbFetchNeedsCustomOutput);
+ CAP(bindlessTextureSupport);
+ CAP(dropsTileOnZeroDivide);
+ CAP(flatInterpolationSupport);
+ CAP(noperspectiveInterpolationSupport);
+ CAP(multisampleInterpolationSupport);
+ CAP(sampleVariablesSupport);
+ CAP(sampleMaskOverrideCoverageSupport);
+ CAP(externalTextureSupport);
+ CAP(texelFetchSupport);
+ CAP(imageLoadStoreSupport);
+ CAP(mustEnableAdvBlendEqs);
+ CAP(mustEnableSpecificAdvBlendEqs);
+ CAP(mustDeclareFragmentShaderOutput);
+ CAP(canUseAnyFunctionInShader);
+#undef CAP
+}
+
+void IRGenerator::start(const Program::Settings* settings) {
+ fSettings = settings;
+ fCapsMap.clear();
+ if (settings->fCaps) {
+ fill_caps(*settings->fCaps, &fCapsMap);
+ }
this->pushSymbolTable();
+ fInputs.reset();
}
void IRGenerator::finish() {
this->popSymbolTable();
- this->fCapsMap = nullptr;
+ fSettings = nullptr;
}
std::unique_ptr<Extension> IRGenerator::convertExtension(const ASTExtension& extension) {
@@ -600,6 +626,11 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTIdentifier&
case Symbol::kVariable_Kind: {
const Variable* var = (const Variable*) result;
this->markReadFrom(*var);
+ if (var->fModifiers.fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN &&
+ fSettings->fFlipY &&
+ (!fSettings->fCaps || !fSettings->fCaps->fragCoordConventionsExtensionString())) {
+ fInputs.fRTHeight = true;
+ }
return std::unique_ptr<VariableReference>(new VariableReference(identifier.fPosition,
*var));
}
@@ -1336,9 +1367,8 @@ std::unique_ptr<Expression> IRGenerator::convertSwizzle(std::unique_ptr<Expressi
}
std::unique_ptr<Expression> IRGenerator::getCap(Position position, SkString name) {
- ASSERT(fCapsMap);
- auto found = fCapsMap->find(name);
- if (found == fCapsMap->end()) {
+ auto found = fCapsMap.find(name);
+ if (found == fCapsMap.end()) {
fErrors.error(position, "unknown capability flag '" + name + "'");
return nullptr;
}