diff options
author | Chia-I Wu <olv@google.com> | 2018-10-03 11:10:12 -0700 |
---|---|---|
committer | Chia-I Wu <olv@google.com> | 2018-10-16 11:44:45 -0700 |
commit | 0647d4eb27d5ff8c0e90723337a0f313db45940d (patch) | |
tree | 97cb1f5c0d939ddf544e7bfdb29f5fbdd8bdd5ba | |
parent | c7e86caf44cf8eab04c891346b5c4ff194fe230d (diff) | |
download | native-0647d4eb27d5ff8c0e90723337a0f313db45940d.tar.gz |
renderengine: clamp XYZ to [0.0, 1.0] in shaders
texture2D can return strange negative values for some YUV textures.
That should be a driver bug. But with scRGB and floating-point
formats, we cannot be sure that colors will always stay non-negative
after conversion to XYZ. We need to clamp XYZ to [0.0, 1.0] such
that the following color processing behaves as expected.
Bug: 116864006
Test: manual
Change-Id: I8f432c63b800edc11ce3d86536192a5547144ca5
Merged-In: I8f432c63b800edc11ce3d86536192a5547144ca5
-rw-r--r-- | services/surfaceflinger/RenderEngine/ProgramCache.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.cpp b/services/surfaceflinger/RenderEngine/ProgramCache.cpp index 796901a2bd..cfb0ea1743 100644 --- a/services/surfaceflinger/RenderEngine/ProgramCache.cpp +++ b/services/surfaceflinger/RenderEngine/ProgramCache.cpp @@ -577,7 +577,7 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) { fs << "uniform mat4 inputTransformMatrix;"; fs << R"__SHADER__( highp vec3 InputTransform(const highp vec3 color) { - return vec3(inputTransformMatrix * vec4(color, 1.0)); + return clamp(vec3(inputTransformMatrix * vec4(color, 1.0)), 0.0, 1.0); } )__SHADER__"; } else { |