Increase precision in GrSRGBEffect

Allows ApplyGammaTest to pass on Bifrost, which uses fp16 for mediump.

Change-Id: Icd04001939a2cb7e1789132ab035ca498c92112a
Reviewed-on: https://skia-review.googlesource.com/118162
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2018-04-03 09:58:37 -04:00 committed by Skia Commit-Bot
parent 4db18edb95
commit 08c39fcbcb

View File

@ -47,7 +47,9 @@ public:
args.fInputColor = "half4(1)";
}
fragBuilder->codeAppendf("half4 color = %s;", args.fInputColor);
// Mali Bifrost uses fp16 for mediump. Making the intermediate color variable highp causes
// calculations to be performed with sufficient precision.
fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
fragBuilder->codeAppendf("half nonZeroAlpha = max(color.a, 0.00001);");
fragBuilder->codeAppendf("color = half4(color.rgb / nonZeroAlpha, color.a);");