Module: Mesa Branch: staging/20.0 Commit: d6b98e432c7d4576a65ef57df85bf7376f8106a0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6b98e432c7d4576a65ef57df85bf7376f8106a0
Author: Ian Romanick <[email protected]> Date: Mon Mar 2 18:38:11 2020 -0800 soft-fp64/fsat: Correctly handle NaN fsat is defined as min(max(a, 0.0), 1.0), and IEEE defines both min and max to return the non-NaN value when one value is NaN. Based on this, fsat should definitely return 0.0 for NaN. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 841666 -> 841647 (<.01%) instructions in affected programs: 122033 -> 122014 (-0.02%) helped: 7 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 2.71 x̃: 3 helped stats (rel) min: 0.01% max: 0.02% x̄: 0.02% x̃: 0.01% 95% mean confidence interval for instructions value: -3.74 -1.69 95% mean confidence interval for instructions %-change: -0.02% -0.01% Instructions are helped. total cycles in shared programs: 6927246 -> 6926904 (<.01%) cycles in affected programs: 1038987 -> 1038645 (-0.03%) helped: 7 HURT: 0 helped stats (abs) min: 18 max: 72 x̄: 48.86 x̃: 54 helped stats (rel) min: 0.03% max: 0.05% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -67.38 -30.33 95% mean confidence interval for cycles %-change: -0.05% -0.02% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Fixes: a42163cbbc1 ("compiler: Add lowering support for 64-bit saturate operations to software") Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2585 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142> (cherry picked from commit 7673dcbd21150e67c5a36bdcc3eee419c025604b) --- .pick_status.json | 2 +- src/compiler/glsl/float64.glsl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 44168c83790..d360e68f54a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -490,7 +490,7 @@ "description": "soft-fp64/fsat: Correctly handle NaN", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "a42163cbbc1abe02b7db4ade74b569f455942d1a" }, diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 5f201c8f725..4301e67721b 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -221,10 +221,11 @@ __fge64(uint64_t a, uint64_t b) uint64_t __fsat64(uint64_t __a) { - if (__flt64(__a, 0ul)) + /* fsat(NaN) should be zero. */ + if (__is_nan(__a) || __flt64_nonnan(__a, 0ul)) return 0ul; - if (__fge64(__a, 0x3FF0000000000000ul /* 1.0 */)) + if (!__flt64_nonnan(__a, 0x3FF0000000000000ul /* 1.0 */)) return 0x3FF0000000000000ul; return __a; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
