From 66ad44a3f1df2547981b97c51d24f6881ba328e0 Mon Sep 17 00:00:00 2001 From: dvonbeck Date: Fri, 8 Jul 2016 08:59:47 -0700 Subject: [PATCH] Fixed error when normal.z = 1 in GPUs with binary16 floats Check failed in GPUs with low-precision floats since 0.9999 was too small a difference from 1 to be detected by a 16-bit float comparison. Changed it to 0.999 which fixed the issue and results in indistinguishable correct behavior. BUG=skia:5499 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2124183004 Review-Url: https://codereview.chromium.org/2124183004 --- src/core/SkNormalSource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/SkNormalSource.cpp b/src/core/SkNormalSource.cpp index 52bb4ad..03c1a3a 100644 --- a/src/core/SkNormalSource.cpp +++ b/src/core/SkNormalSource.cpp @@ -109,7 +109,7 @@ public: // transforming all the normals here! // If there's no x & y components, return (0, 0, +/- 1) instead to avoid division by 0 - fragBuilder->codeAppend( "if (abs(normal.z) > 0.9999) {"); + fragBuilder->codeAppend( "if (abs(normal.z) > 0.999) {"); fragBuilder->codeAppendf(" %s = normalize(vec4(0.0, 0.0, normal.z, 0.0));", args.fOutputColor); // Else, Normalizing the transformed X and Y, while keeping constant both Z and the -- 2.7.4