diff options
author | Greg Daniel <egdaniel@google.com> | 2017-12-01 16:19:43 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-02 00:00:59 +0000 |
commit | 10ed243e2ee7d733f73c9e5947ab5189fd6d46e3 (patch) | |
tree | 5cce27e7a9212b26532780c1a92796ca712da1bb /src/shaders/gradients/SkGradientShader.cpp | |
parent | 0d05ca3e2fc36a8397b4cec4c23284beaf87642c (diff) |
Add cap on intel to avoid calling abs and floor on the same line in a
shader.
This fixes a bug on some intel devices where we are failing
in the ProcessorOptimizationTest.
I've tried other "no op" type things between the floor call and abs which
also fixed the issue, as well as adding explicit checks to see if we are
less than -1 or greater than 1 where the clamp is. Thus the clamp itself
should be a no op and shouldn't secretly be fixing the problem outside
of forcing the floor and abs lines to be separate.
Bug: skia:
Change-Id: I85bf82e0e02607b78470b7a5f8f918e9f53f0154
Reviewed-on: https://skia-review.googlesource.com/76820
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/shaders/gradients/SkGradientShader.cpp')
-rw-r--r-- | src/shaders/gradients/SkGradientShader.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index c448b4038a..1ff42e7a2f 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -1052,7 +1052,14 @@ void GrGradientEffect::GLSLProcessor::emitAnalyticalColor(GrGLSLFPFragmentBuilde break; case GrSamplerState::WrapMode::kMirrorRepeat: fragBuilder->codeAppendf("half t_1 = %s - 1.0;", t); - fragBuilder->codeAppendf("half tiled_t = abs(t_1 - 2.0 * floor(t_1 * 0.5) - 1.0);"); + fragBuilder->codeAppendf("half tiled_t = t_1 - 2.0 * floor(t_1 * 0.5) - 1.0;"); + if (shaderCaps->mustDoOpBetweenFloorAndAbs()) { + // At this point the expected value of tiled_t should between -1 and 1, so this + // clamp has no effect other than to break up the floor and abs calls and make sure + // the compiler doesn't merge them back together. + fragBuilder->codeAppendf("tiled_t = clamp(tiled_t, -1.0, 1.0);"); + } + fragBuilder->codeAppendf("tiled_t = abs(tiled_t);"); break; } |