<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span style="font-family: Menlo-Regular; font-size: 11px;">In doing some testing we’ve noticed that trying to draw pixel aligned textures does not work very well with linear filtering in llvmpipe.</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">Here’s an example of the problem.</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">Imagine wanting to paint a 100x100 texture. After being scaled by 100 the texture coordinates will end up as:</span><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">0.5, 1.5, 2.5, 3.5, 4.5..</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">These are then multiplied by 256 and converted to integers giving us:</span><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">128, 384, 640, 896, 1152..</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">We subtract the 128:</span><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">0, 256, 512, 768, 1024..</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">Then mask to get the fractional component and shift to get the integer component:</span><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">0,0, 1,0, 2,0, 3,0, 4,0...</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">However, if for example 3.5 ends up as 3.4999999 we get:</span><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">895.9999744 -> 895 -> 767 -> 2,255 instead of 3,0</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">When we lerp using this value we end up including some of the pixel value at 2 instead of just at 3.</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">If we add 0.5 before converting to an integer this problem goes away.</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">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.</span><br style="font-family: Menlo-Regular; font-size: 11px;"><br style="font-family: Menlo-Regular; font-size: 11px;"><span style="font-family: Menlo-Regular; font-size: 11px;">-Jeff</span></body></html>