Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe556cd7 authored by Brandon Chen's avatar Brandon Chen
Browse files

Use highp to avoid float overflow in expression



float D = C * (A / B) could be relaxed to
float D =  (C * A) * (1 / B).

This is qualified in GLES Spec at chapter Evaluation of Expressions.

Note that "C * A" could exceed the maximal value of FP16.
Use highp float to keep the correct value.

Bug: 237997490
Test: Launch gallery and check thumbnail of video

Signed-off-by: default avatarBrandon Chen <brandon.chen@imgtec.com>
Change-Id: Icfa355ecb2501267b00a9615b36fb70606864b94
parent 47f12cdd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -374,7 +374,11 @@ void ProgramCache::generateToneMappingProcess(Formatter& fs, const Key& needs) {
                                    return color * slope;
                                } else if (nits < x1) {
                                    // scale [x0, x1] to [y0, y1] linearly
                                    float slope = (y1 - y0) / (x1 - x0);
                                    // Use highp since some compilers may do this
                                    // operation as reciprocal multiplication with
                                    // re-association that could exceed the range
                                    // of mediump float.
                                    highp float slope = (y1 - y0) / (x1 - x0);
                                    nits = y0 + (nits - x0) * slope;
                                } else if (nits < x2) {
                                    // scale [x1, x2] to [y1, y2] using Hermite interp