[Mesa-dev] [PATCH] Add an accelerated version of F_TO_I for x86_64

Roland Scheidegger sroland at vmware.com
Mon Jul 28 15:05:15 PDT 2014


Am 29.07.2014 00:01, schrieb Kenneth Graunke:
> On Monday, July 28, 2014 05:34:59 PM Roland Scheidegger wrote:
>> Looking all good, though it got me thinking about these numerous 
>> float-to-int rounding functions in mesa in various places a bit
>> more. There is, for instance, a _mesa_round_to_even() function,
>> which claims that the c99 lrintf() and friends functions can't be
>> used because the environment might use a different rounding mode.
>> This is of course true though I wonder why it would matter there
>> and not here for instance, since of course cvtss2si is affected by
>> that as well.
> 
> _mesa_round_to_even() is currently only used by the GLSL compiler.
> 
> The GLSL compiler implements round() as round-to-even on the GPU, so
> we want to make sure that CPU-side constant expression evaluation
> rounds the same way.
If you truly want it to match gpus round-to-even, it won't work for
numbers between [-]2^23 to [1]2^24, just like ordinary IROUND.

Roland


> I don't think other code needs to be as paranoid.
> 
> --Ken
> 



More information about the mesa-dev mailing list