[Mesa-dev] [PATCH 3/6] glsl: move half<->float convertion to util

Roland Scheidegger sroland at vmware.com
Mon Oct 12 17:00:27 PDT 2015


Am 13.10.2015 um 01:01 schrieb Matt Turner:
> On Mon, Oct 12, 2015 at 3:07 PM, Roland Scheidegger <sroland at vmware.com> wrote:
>> As far as I can tell (and I could easily be wrong here...) intel hw
>> doesn't have explicit conversion instruction, you just say it's a f16
>> destination. As such I believe the conversion used would just use
>> ordinary rounding mode, which is of course usually round to nearest even
>> (and the docs don't seem to mention it, but seems likely that too large
>> floats would get converted to infinities using that mode). Rounding mode
>> is of course changeable (but would need to change it back after f32->f16
>> mov).
> 
> There's F32TO16/F16TO32 in Gen7 (IVB, HSW, VLV). The software routines
> were modified to match their behavior for constant propagation, as far
> as I know.
> 

Yes, I was looking at Broadwell, which can do the implicit conversion.
Regardless, I guess it works the same for both wrt rounding - you'd have
to change the rounding mode if you want round-to-zero as d3d10 requires
(I suspect that's exactly what the d3d driver does, since d3d11 f32tof16
instruction requires that too). Otherwise it's just
round-to-nearest-even which will round too large numbers to infinity.
(Albeit the docs don't quite seem to explicitly say default rounding
mode affects the half-float result of the f32tof16 instruction.)
But for GL any rounding is fine of course, and matching hw probably
makes sense.


More information about the mesa-dev mailing list