diff options
author | Paul Berry <[email protected]> | 2012-07-07 08:02:48 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2012-07-20 09:35:37 -0700 |
commit | b961d37e613b8b14927c42e09d16d09d70ebcb77 (patch) | |
tree | 3fac424fdde93e42053f4da8f896f8b1ce60b3f1 /scons | |
parent | 6a27506181b29c8b7eda7bd6cf80689f849e181d (diff) |
i965/blorp: Modify manual_blend() to avoid unnecessary loss of precision.
When downsampling from an MSAA image to a single-sampled image, it is
inevitable that some loss of numerical precision will occur, since we
have to use 32-bit floating point registers to hold the intermediate
results while blending. However, it seems reasonable to expect that
when all samples corresponding to a given pixel have the exact same
color value, there will be no loss of precision.
Previously, we averaged samples as follows:
blend = (((sample[0] + sample[1]) + sample[2]) + sample[3]) / 4
This had the potential to lose numerical precision when all samples
have the same color value, since ((sample[0] + sample[1]) + sample[2])
may not be precisely representable as a 32-bit float, even if the
individual samples are.
This patch changes the formula to:
blend = ((sample[0] + sample[1]) + (sample[2] + sample[3])) / 4
This avoids any loss of precision in the event that all samples are
the same, by ensuring that each addition operation adds two equal
values.
As a side benefit, this puts the formula in the form we will need in
order to implement correct blending of integer formats.
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'scons')
0 files changed, 0 insertions, 0 deletions