[Mesa-dev] [PATCH] r600g: Add support for ROUND

Henri Verbeet hverbeet at gmail.com
Sun Aug 7 22:12:28 PDT 2011

On 8 August 2011 03:58, Jose Fonseca <jfonseca at vmware.com> wrote:
> It's subjective. It depends on the expected input distribution, which is effectively impossible to characterize in general. One can easily find datasets where one method gives biased results and the other not, and vice versa. And if one takes all possible numbers, they are equally good.
This is probably largely irrelevant to the patch in question, but just
for arguments sake, I don't think that's true. The function floor(x +
.5) will introduce positive bias regardless of input distribution,
while for rndne this depends on the ratio of even and uneven inputs.
Taking the real numbers as input, always rounding up will produce
positive bias, while rndne will have 0 bias. Similarly, I don't think
there's any set of inputs for which rounding to nearest even (or
pretty much any other scheme) produces larger (absolute) bias than
always rounding up.

> The only thing that could define what's wrong/right here in the OpenGL GLSL / Direct3D HLSL specs, but I don't think they go this level of detail. At least I couldn't find any mention last time I checked.
AFAIK HLSL round() only specifies rounding to the nearest integer.
GLSL (1.30) round() is similar, but GLSL also has an explicit
roundEven() function.

More information about the mesa-dev mailing list