[Mesa-dev] [RFC] llvmpipe texture coordinate rounding
Jeff Muizelaar
jmuizelaar at mozilla.com
Fri Feb 14 09:07:43 PST 2014
In doing some testing we’ve noticed that trying to draw pixel aligned textures does not work very well with linear filtering in llvmpipe.
Here’s an example of the problem.
Imagine wanting to paint a 100x100 texture. After being scaled by 100 the texture coordinates will end up as:
0.5, 1.5, 2.5, 3.5, 4.5..
These are then multiplied by 256 and converted to integers giving us:
128, 384, 640, 896, 1152..
We subtract the 128:
0, 256, 512, 768, 1024..
Then mask to get the fractional component and shift to get the integer component:
0,0, 1,0, 2,0, 3,0, 4,0...
However, if for example 3.5 ends up as 3.4999999 we get:
895.9999744 -> 895 -> 767 -> 2,255 instead of 3,0
When we lerp using this value we end up including some of the pixel value at 2 instead of just at 3.
If we add 0.5 before converting to an integer this problem goes away.
The attached patch does this. It also changes the REPEAT mode code to use similar integer conversion code as the non-REPEAT path. The new generated code should be more efficient than the old code.
-Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140214/e1d1feac/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-0.5-before-converting-to-integer.patch
Type: application/octet-stream
Size: 9046 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140214/e1d1feac/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140214/e1d1feac/attachment-0001.html>
More information about the mesa-dev
mailing list