Bug 45086

Summary: Jitter when downsampling [SNA]
Product: xorg Reporter: Clemens Eisserer <linuxhippy>
Component: Driver/intelAssignee: Chris Wilson <chris>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: low    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
screenshot
none
screenshot none

Description Clemens Eisserer 2012-01-22 07:03:36 UTC
The page http://www.haustechnikdialog.de/Forum/p/1651034 has an embedded image, which - when embedded into the original page, is partially rendered black (seems to be some kind of offset error).
The image itself is located at: http://www.dw255.de/_foren/Grabenkonstruktion_V1.jpg

I can reproduce this behaviour on my i945GM with official Firefox builds, as well as the binaries shipped by Fedora. With UXA everything is rendered correctly.
Comment 1 Clemens Eisserer 2012-01-22 07:07:15 UTC
Created attachment 55962 [details]
screenshot
Comment 2 Chris Wilson 2012-01-22 07:44:17 UTC
Looking at the full image demonstrates I broke the code to tile oversized sources for the render pipeline, that at least seems trivial to fix...
Comment 3 Chris Wilson 2012-01-22 08:10:29 UTC
I'm not sure that I've seen exactly the same scenario as yourself, but I did find a couple of bugs in relation to that image:

commit 5aa494305e90eed5df211427741a75380add8e96
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sun Jan 22 16:10:39 2012 +0000

    sna: Correct the offsets for performing partial downsampling on the GPU
    
    Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
    References: https://bugs.freedesktop.org/show_bug.cgi?id=45086
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

commit a7b24bb4342eefb2b23fa40d7c7216c38f2edc09
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sun Jan 22 15:50:47 2012 +0000

    sna: Correct image buffer size when uploading a downsampled image
    
    Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
    References: https://bugs.freedesktop.org/show_bug.cgi?id=45086
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 4 Clemens Eisserer 2012-01-23 02:29:52 UTC
Thanks, this fixes the main issue.

A little glitch is left - the image seems to be blitted slightly different sometimes - probably an interpolation issue. I'll try to create screenshots.
Comment 5 Chris Wilson 2012-01-23 02:32:02 UTC
I suspect it's whether the origin is an odd pixel or not...
Comment 6 Clemens Eisserer 2012-01-23 02:37:01 UTC
Created attachment 56020 [details]
screenshot
Comment 7 Clemens Eisserer 2012-01-23 02:38:26 UTC
ok this is really nit-picking. When the image is partially visible it seems its interpolated differently.

When scrolling down in firefox, after a small delay the image suddenly looks slightly different. Shouldn't do any harm imho ;)
Comment 8 Chris Wilson 2012-01-23 03:00:16 UTC
Right, that looks consistent with my misaligning the sampling of the partial image by a pixel between the two frames. Should be fixable.
Comment 9 Chris Wilson 2012-01-23 03:40:18 UTC
Can you please test

commit c67e6a05ff729c0ddb26775e1c8533be1144d85a
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jan 23 11:40:13 2012 +0000

    sna: Align the origin of downsampling subregion to an even pixel
    
    In order for us to produce stable downsampled images across multiple
    frames, we need to sample the same pairs of pixels every time. This
    requires us to align the origin of the sample region to an even pixel.
    
    Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
    References: https://bugs.freedesktop.org/show_bug.cgi?id=45086
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

and see if that passes your eagle eyes. :)
Comment 10 Clemens Eisserer 2012-01-24 09:29:05 UTC
Unfourtunatly I still see the sampling difference - both with the official FF build as well as FF9 shipped with Fedora.

Taking the risk of beeing declared a nit-picker, I recorded a video (sorry about the low bandwith): http://93.83.133.214/P1000773.MOV

The sampling difference can be seen best near the end of the video, in the area covered by the fine grid. The different appearance is not caused by sampling of the camera but is visible in "real vision" too.

As mentioned earlier, this sampling difference doesn't bother me at all ;)
Comment 11 Chris Wilson 2012-01-24 11:50:37 UTC
I think the error is now due to the fudging of the transformation matrix after downsampling and tweaking the sample origin. Or lack of correct fudging.

I've now observed something similar on my pnv system, afaict the sampling looks consistent, just the whole image jumps by a pixel of two. Which is good enough for the time being...
Comment 12 Chris Wilson 2012-01-25 19:56:26 UTC
Having just about completed rewriting that path to eliminate the misalignment of the sample coordinates, I am convinced the remaining interpolation artifact is due to poor filtration of the hardware.
Comment 13 Chris Wilson 2012-01-26 05:00:21 UTC
commit e2b8b1c145932e2254a705905c60f18c200cf2e8
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Jan 26 12:42:12 2012 +0000

    sna: Apply any previous transformation when downsampling
    
    In order to handle rotations and fractional offsets produced by the act
    of downsampling, we need to compute the full affine transformation and
    apply it to the vertices rather than attempt to fudge it with an integer
    offset.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=45086
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

It looks like it was mostly instability introduced by the interpolation whilst downsampling. As well as fixing the transformation bug, I set the downsampling to use Nearest rather than Bilinear interpolation, it fixes the jitter and I'm optimistic nobody will notice the reduce image quality. ;-)
Comment 14 Chris Wilson 2012-01-26 05:10:15 UTC
Oh well, the interpolation on the downsampling image is still unstable. It's as good as its going to get, for a while at least.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.