glsl: Fix software 64-bit integer to 32-bit float conversions.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 27 Dec 2019 22:10:31 +0000 (14:10 -0800)
committerFrancisco Jerez <currojerez@riseup.net>
Fri, 10 Jan 2020 18:51:58 +0000 (10:51 -0800)
commita30bb25a7a495db7b7cb3be50431029f48019fc3
tree4923a1c68ab80d427b1b8e3037b84a982ced18b0
parent8b7a42d6d0b15508940e095642136c53d0c7dcee
glsl: Fix software 64-bit integer to 32-bit float conversions.

The current implementation was broken for any integers between 2^24
and 2^30 (it would return zero for me on ICL).  The reason is that for
such integers we wouldn't take the 'if (0 <= shiftCount)' early return
path, however 'shiftCount + 7' would be positive, leading to a
negative 'count' argument passed to __shift64RightJamming(), which
would give undefined results.

This reworks the affected conversion functions to use either
__shortShift64Left() or __shift64RightJamming() based on the sign of
the final shift count, which should avoid the problem.  In addition
this should qualify as a clean-up/optimization -- This implementation
of the conversion functions translates to 7 instructions less than the
original on Intel hardware.

This fixes the 'KHR-GL46.shader_ballot_tests.ShaderBallotFunctionBallot'
conformance tests on soft fp64 hardware with large enough subgroup
size (>16).

Fixes: d5cf6e92b4f7 "glsl: Add built-in functions to do uint64_to_fp32(uint64_t)"
Fixes: c9d333a6b76e "glsl: Add built-in functions to do int64_to_fp32(int64_t)"
Cc: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
src/compiler/glsl/float64.glsl