aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-04-04 10:14:16 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 14:45:58 +0000
commitdc09213b17cfd100e1c1859387b47e3045a36010 (patch)
tree6c28b3ef6105c7755e72196a9df8a767d0c39470 /src/sksl
parentd838765478b3cebfa9822eb4eeaabfa5733dfb45 (diff)
Revert "Revert "Make SkSL GLSL generator declare sk_FragColor inout when EXT fb fetch is used.""
This reverts commit d40133092ae138b3d47a1158101faec3c53c6b1f. Bug: skia: Change-Id: I236505da047d5ad29e4952d8955eb7aa1bfb870b Reviewed-on: https://skia-review.googlesource.com/118621 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/sksl')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp6
-rw-r--r--src/sksl/SkSLMetalCodeGenerator.cpp2
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.cpp1
-rw-r--r--src/sksl/ir/SkSLProgram.h2
4 files changed, 10 insertions, 1 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 996714ec62..43c1c95327 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -1270,7 +1270,11 @@ void GLSLCodeGenerator::writeProgramElement(const ProgramElement& e) {
this->writeLine();
} else if (builtin == SK_FRAGCOLOR_BUILTIN &&
fProgram.fSettings.fCaps->mustDeclareFragmentShaderOutput()) {
- this->write("out ");
+ if (fProgram.fSettings.fFragColorIsInOut) {
+ this->write("inout ");
+ } else {
+ this->write("out ");
+ }
if (usesPrecisionModifiers()) {
this->write("mediump ");
}
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index de6b1d0854..a8301c2eb4 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -451,6 +451,8 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
}
this->writeLine(") {");
+ ASSERT(!fProgram.fSettings.fFragColorIsInOut);
+
if ("main" == f.fDeclaration.fName) {
switch (fProgram.fKind) {
case Program::kFragment_Kind:
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index dadab91753..5f312afef1 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -2545,6 +2545,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
}
if (var->fModifiers.fLayout.fBuiltin == SK_FRAGCOLOR_BUILTIN &&
kind != Program::kFragment_Kind) {
+ ASSERT(!fProgram.fSettings.fFragColorIsInOut);
continue;
}
if (!var->fReadCount && !var->fWriteCount &&
diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h
index cbb9dfe1a7..03a94fa03f 100644
--- a/src/sksl/ir/SkSLProgram.h
+++ b/src/sksl/ir/SkSLProgram.h
@@ -71,6 +71,8 @@ struct Program {
// if false, sk_FragCoord is exactly the same as gl_FragCoord. If true, the y coordinate
// must be flipped.
bool fFlipY = false;
+ // If true the destination fragment color is read sk_FragColor. It must be declared inout.
+ bool fFragColorIsInOut = false;
// if true, Setting objects (e.g. sk_Caps.fbFetchSupport) should be replaced with their
// constant equivalents during compilation
bool fReplaceSettings = true;