[Mesa-dev] [PATCH 0/7] glsl: Fix float->uint conversion (gallium review requested).
Paul Berry
stereotype441 at gmail.com
Wed Jun 13 17:14:12 PDT 2012
This patch series fixes a rather insidious bug in conversion from
floats to uints on i965 (and possibly other platforms).
Previously, we implemented conversion from float to uint by a two step
process: first convert to int, then convert to uint. This doesn't
work if the float value is greater than 0x7fffffff, because it is
undefined how float-to-int conversion handles out-of-range values. On
i965, out-of-range values are clamped during float-to-int conversion,
so if we convert a float greater than 0x7fffffff to an int first, and
then to a uint, we get the wrong result.
To fix this bug I had to add a new ir operation, ir_unop_f2u, so that
i965 could be instructed to do the conversion directly, without going
through an intermediate int type. That meant I had to add support for
this operation to all the back-ends, including Gallium. I would
especially appreciate some review of my Gallium patches (patches 5 and
6) to make sure I didn't make a stupid mistake, since I'm not terribly
familiar with the Gallium part of the codebase.
I've posted a patch to the Piglit mailing list (glsl-1.30: Verify
proper conversion of large floats to uints) that demonstrates the bug
this patch series is meant to fix.
[PATCH 1/7] glsl: Add unary operation ir_unop_f2u.
[PATCH 2/7] glsl: Add support for ir_unop_f2u to constant folding.
[PATCH 3/7] i965: Add support for ir_unop_f2u to i965 backend.
[PATCH 4/7] ir_to_mesa: Add support for ir_unop_f2u to ir_to_mesa backend.
[PATCH 5/7] gallium: Add support for ir_unop_f2u to tgsi backend.
[PATCH 6/7] gallium: Add TGSI_OPCODE_F2U to gallivm backend.
[PATCH 7/7] glsl: Use ir_unop_f2u to convert floats to uints.
More information about the mesa-dev
mailing list