Skip to content

gallium/util: Add back (and rename) util_float_to_half implementation

Roland Scheidegger requested to merge sroland/mesa:format_floattohalf_rtz into master

This implementation was removed by 8b8af6d3 ("gallium/util: Switch util_float_to_half to _mesa_float_to_half()'s impl.") It was not actually broken, but _mesa_float_to_half() implements round-to-nearest-even, whereas util_float_to_half() implemented round-to-zero. So rename it appropriately. GL actually never cares about rounding (except a broken piglit test), however d3d10 very much does and requires RTZ for float to half conversion. Moreover, apparently at least radeon gpus actually always do RTZ when doing RT writes (and I'd suspect for shader image writes as well). Hence it seems appropriate to hook up this rtz function to the format instead. This will cause llvmpipe and softpipe to use rtz rounding for clears with half float formats, and softpipe would use rtz behavior for rt writes as well (llvmpipe has that hardcoded), not sure if "real" hw drivers hit this function for much. (For shader opcodes would still need to figure out what rounding to use appropriately, but this is a question for another day.)

Edited by Roland Scheidegger

Merge request reports