aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Osman <brianosman@google.com>2019-04-19 15:45:55 -0400
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-04-22 13:04:12 +0000
commit135e7813d23e728358f7db55f88d17cc808db6b9 (patch)
tree7900a7c953f9c0ebe9551aa9d5b504d9660f4908
parentf1275c6fa4c9165f9c31a0532b49186bebc5926c (diff)
downloadskia-135e7813d23e728358f7db55f88d17cc808db6b9.tar.gz
Ganesh: Clamp blend inputs when using F16_Clamped pixel config
This ensures that we stay in [0,1], except for plus mode, which requires a larger and more invasive change. First of two F16 clamping fix cherry-picks to android/next-release. Bugs: b/130753257 No-Tree-Checks: true No-Try: true No-Presubmit: true Change-Id: I97f6bcea8b10e70e55ba24bcff759ddbb1761794 Reviewed-On: https://skia-review.googlesource.com/c/skia/+/201460 Reviewed-By: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209404 Reviewed-by: Derek Sollenberger <djsollen@google.com>
-rw-r--r--include/private/GrTypesPriv.h4
-rw-r--r--src/gpu/GrProgramDesc.cpp1
-rw-r--r--src/gpu/GrProgramDesc.h3
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp13
4 files changed, 19 insertions, 2 deletions
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 06c708085c..05433e5a3f 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -1039,6 +1039,10 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
return false;
}
+static inline bool GrPixelConfigNeedsClamp(GrPixelConfig config) {
+ return kRGBA_half_Clamped_GrPixelConfig == config;
+}
+
/**
* Returns true if the pixel config is a GPU-specific compressed format
* representation.
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 26b06f96d5..5401d4d368 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -253,5 +253,6 @@ bool GrProgramDesc::Build(
SkASSERT(header->processorFeatures() == processorFeatures); // Ensure enough bits.
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
header->fHasPointSize = hasPointSize ? 1 : 0;
+ header->fClampBlendInput = GrPixelConfigNeedsClamp(renderTarget->config()) ? 1 : 0;
return true;
}
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index e2fe270275..af5ce8031f 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -103,7 +103,8 @@ public:
uint8_t fProcessorFeatures : 1;
bool fSnapVerticesToPixelCenters : 1;
bool fHasPointSize : 1;
- uint8_t fPad : 3;
+ bool fClampBlendInput : 1;
+ uint8_t fPad : 2;
};
GR_STATIC_ASSERT(sizeof(KeyHeader) == 6);
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 09e238852b..ff9ad863bc 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -253,11 +253,22 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
SkASSERT(dstTexture->texturePriv().textureType() != GrTextureType::kExternal);
}
+ SkString finalInColor;
+ if (colorIn.size()) {
+ if (this->desc()->header().fClampBlendInput) {
+ finalInColor.printf("saturate(%s)", colorIn.c_str());
+ } else {
+ finalInColor = colorIn;
+ }
+ } else {
+ finalInColor = "float4(1)";
+ }
+
GrGLSLXferProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
this->shaderCaps(),
xp,
- colorIn.size() ? colorIn.c_str() : "float4(1)",
+ finalInColor.c_str(),
coverageIn.size() ? coverageIn.c_str() : "float4(1)",
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),