Bug 28352 - EXA Rendering bug in geode driver
Summary: EXA Rendering bug in geode driver
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/geode (show other bugs)
Version: 7.0.99.901 (7.1RC1)
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-01 22:55 UTC by frank huang
Modified: 2010-08-23 18:15 UTC (History)
8 users (show)

See Also:
i915 platform:
i915 features:


Attachments
This is old geode driver drawing the progressbar and its result (590.01 KB, image/x-png)
2010-06-03 01:23 UTC, frank huang
no flags Details
This is new geode driver drawing the progressbar and its result (4.13 KB, image/x-png)
2010-06-03 01:24 UTC, frank huang
no flags Details
correct result on ATI graphics card as a comparison (3.37 KB, image/x-png)
2010-06-03 01:25 UTC, frank huang
no flags Details
This is new geode driver drawing the scrollbar and its result (52.76 KB, image/x-png)
2010-06-03 01:26 UTC, frank huang
no flags Details
The new patch for the rendering (9.71 KB, patch)
2010-06-03 20:55 UTC, frank huang
no flags Details | Splinter Review
Patch to solve the rendering issue on 2.11.8 version (10.79 KB, patch)
2010-06-06 23:29 UTC, frank huang
no flags Details | Splinter Review
Picture in chaos in file browser (84.15 KB, image/x-png)
2010-06-11 00:52 UTC, frank huang
no flags Details
Attach a gtk program to reproduce this issue (3.46 KB, text/plain)
2010-06-12 03:09 UTC, frank huang
no flags Details
Attach this gtk program's result with rendering error(see green part) (6.73 KB, image/x-png)
2010-06-12 03:10 UTC, frank huang
no flags Details
Wrong rendering on Firefox characters (52.61 KB, image/png)
2010-06-23 00:51 UTC, frank huang
no flags Details
Black region and discrete line in firefox (54.22 KB, image/png)
2010-06-25 01:36 UTC, frank huang
no flags Details
20x20 source picture, 40x40 rendering region with 4 colours (2.22 KB, image/png)
2010-07-15 00:02 UTC, frank huang
no flags Details
out of region, src is 22, compared with previous one (2.17 KB, image/png)
2010-07-15 00:03 UTC, frank huang
no flags Details
wrong glyph rendering using HW+SW (823.14 KB, image/png)
2010-07-21 19:51 UTC, frank huang
no flags Details

Description frank huang 2010-06-01 22:55:26 UTC
The rendering bug of geode driver has been reported on several BTS on various linux distribution. You can see the unwanted green or other color will be displayed on the gtk-applet, such as that on File Browser. At the same time, from the bug 15700, a lot of bug (progressbar and scrollbar) on rendering is reported there.
I am now checking this bug on the lx_do_composite() function in geode driver. The lastest founding is that. For the SRC and OVER operation on the rendering, the driver will wrongly handle the parameters which is given by client application. 
I have given a modification on SRC operation. Right now I am focused on OVER operation.
when our driver handles the Over operation where source image has the alpha value and mask has the alpha value, our driver does the wrong thing. It uses the mask's alpha value to do the composite operation and omit the previous alpha value. The correct formula is that the source(ARGB) should be multiplied with the mask alpha value, then use the new alpha to do the OVER operation. I have done many experiments to prove that and guys from xorg-devel mail groug gives me the hint. 

In short, our driver is short of one pass of Source*(alpha of mask) and wrongly use a*A+(1-a)*B to do the OVER operation. See datasheet of Geode on GP_RASTER_MODE for detail.

I'll correct this huge bug and let you know my result.

Thanks,
Frank
Comment 1 frank huang 2010-06-03 01:21:55 UTC
Make progress in rendering bug in OVER. See my attached pictures for progress bar on new driver.

Martin and Mart,
   give the patch on xorg-geode mail group??


Thanks,
Frank
Comment 2 frank huang 2010-06-03 01:23:07 UTC
Created attachment 36027 [details]
This is old geode driver drawing the progressbar and its result

This is old geode driver drawing the progressbar and its result
Comment 3 frank huang 2010-06-03 01:24:11 UTC
Created attachment 36028 [details]
This is new geode driver drawing the progressbar and its result

This is new geode driver drawing the progressbar and its result
Comment 4 frank huang 2010-06-03 01:25:24 UTC
Created attachment 36029 [details]
correct result on ATI graphics card as a comparison

correct result on ATI graphics card as a comparison
Comment 5 frank huang 2010-06-03 01:26:53 UTC
Created attachment 36030 [details]
This is new geode driver drawing the scrollbar and its result

This is new geode driver drawing the scrollbar and its result
Comment 6 Martin-Éric Racine 2010-06-03 01:36:37 UTC
(In reply to comment #1)
> Make progress in rendering bug in OVER. See my attached pictures for progress
> bar on new driver.
> 
> Martin and Mart,
>    give the patch on xorg-geode mail group??

Preferably attach the patch to this bug.
Comment 7 frank huang 2010-06-03 20:55:59 UTC
Created attachment 36056 [details] [review]
The new patch for the rendering

The new patch for the rendering
Comment 8 frank huang 2010-06-03 20:57:39 UTC
I have put the patch here and need Martin's help to commit.
Hope you guys give me more feedback on the patch.
Any questions are welcome. I'll go on researching.


Thanks,
Frank
Comment 9 frank huang 2010-06-06 23:29:26 UTC
Created attachment 36092 [details] [review]
Patch to solve the rendering issue on 2.11.8 version
Comment 10 frank huang 2010-06-06 23:32:22 UTC
1.Change the srcColor type from unsigned int to unsigned long for 32 bit color value use(for example. ARGB32)
2.Add the maskrepeat to record if the mask picture is repeatable
3.Correct the PictOpOver operation in lx_alpha_ops struct
4.Return FALSE in lx_check_composite() for every FALSE condition in lx_prepare_composite(), forbidding the pixmap migration as soon as possible
5.For PictOpOver operation, get the source color from the source pixmap. If that is	RGB565, convert is to ARGB32; If that is ARGB32, get the first pixel color
6.Correct the PictOpSrc and PictOpOver operation with mask value 
7.Add a fucntion lx_do_composite_maks_opover() to handle the PictOpOver condition with source ARGB32 and maks A8
8.Fix the progressbar and scrollbar bug


Thanks,
Frank
Comment 11 Mart Raudsepp 2010-06-06 23:51:31 UTC
Ideally these change would be worked on in GIT with GIT capabilites, so you can easily make it be 8 patches, instead of one big. So one patch per change. This way it would be much easier to review, get things right, and that's just the right way in open source and GIT :)

I hope the changes can be split apart into multiple commits/patches from hereon. Please contact me for any help needed with that.

I tested the patch from Friday, which seems similar or the same, and that indeed nicely fixed up my scrollbar/button borders and progressbar drawing issues, but didn't look closely on the concrete code changes yet.

Comments on things described in the changelog:

1. Why do you need to change unsigned int to unsigned long to store 32bit values? Unsigned int and unsigned long are both 32bit on x86, and conceptually unsigned int is more correct (also "unsigned long" is 64bit on x86-64, but geode is 32bit of course). Even more correct would be something like __u32 (a Xorg typedef to uint32_t), but we should use whatever other places use for storing 32bit colors, but that's just choice of which typedef.
4. If we can reliably catch inability to accelerate already in CheckComposite (all information in the checks is available to use at CheckComposite time), then we should indeed do it in there to fallback as early as possible (before pixmaps are migrated to GPU memory - memcpy overhead). But this also should mean, that we don't need to do the checks in PrepareComposite anymore, as if CheckComposite returned FALSE, we are guaranteed to not get a call to PrepareComposite with the same rendering commands. So the checks that can be done earlier should moved, not copied.


All in all, seems like awesome work, as it does fix most of my most awful rendering problems :) Now lets get this in properly in multiple commits and so on, so it would be easier to do it like that in the future too :)
Comment 12 frank huang 2010-06-11 00:52:49 UTC
Created attachment 36207 [details]
Picture in chaos in file browser
Comment 13 Bernie Innocenti 2010-06-11 05:49:53 UTC
(In reply to comment #12)
> Created an attachment (id=36207) [details]
> Picture in chaos in file browser

Did you obtain this screenshot with or without your patch applied?
Comment 14 frank huang 2010-06-11 18:29:59 UTC
This condition can be obtained without my patch.
Still I suspect it is a PictOpOver opearation bug. I am finding it now. If you have any good simple example that can reproduce the same issue, please attach your application here.

Thanks,
Frank
Comment 15 frank huang 2010-06-11 18:34:03 UTC
Answer for Mart's reply,sorry for late.
   Split it into 7 patched commited in xorg-driver-geode.
   I have acceptted your two suggestion below in my patch. 

Thanks,
Frank
Comment 16 frank huang 2010-06-12 03:09:27 UTC
Created attachment 36229 [details]
Attach a gtk program to reproduce this issue
Comment 17 frank huang 2010-06-12 03:10:15 UTC
Created attachment 36230 [details]
Attach this gtk program's result with rendering error(see green part)
Comment 18 frank huang 2010-06-12 03:11:13 UTC
Add a program attachment to reproduce the chaos picture issue.
Comment 19 Bernie Innocenti 2010-06-12 06:28:31 UTC
(In reply to comment #9)
> Created an attachment (id=36092) [details]
> Patch to solve the rendering issue on 2.11.8 version

I tested this patch on the XO-1. It fixes the black boxes in Gnome and works well across all the Sugar activities I could test.
Comment 20 Martin-Éric Racine 2010-06-12 06:32:45 UTC
Would now be a good time to push Frank's 7 patches into GIT to facilitate wider testing?
Comment 21 Bernie Innocenti 2010-06-12 06:39:51 UTC
(In reply to comment #20)
> Would now be a good time to push Frank's 7 patches into GIT to facilitate wider
> testing?

I have not done any reviewing, but I'd like to see this code land in git.

Then I'll use a git snapshot to build a package for Fedora 11, which is what currently runs on the XO-1 and XO-1.5.
Comment 22 frank huang 2010-06-12 19:10:11 UTC
Bernie, thanks for your test.
Glad to hear the news that this patch can work for 15700.
I suggest you guys after review, please commit these patches to community for users to test to give me more feedback.


Thanks
Frank
Comment 23 frank huang 2010-06-13 02:15:56 UTC
Give a new patch(the 8th) for your test to solve the chaos picture issue.
I should make sure this patch reasonable after I discussed with guys on xorg-devel.


Thanks,
Frank
Comment 24 frank huang 2010-06-23 00:51:23 UTC
Created attachment 36432 [details]
Wrong rendering on Firefox characters

Wrong rendering on Firefox characters
Comment 25 frank huang 2010-06-25 01:36:36 UTC
Created attachment 36486 [details]
Black region and discrete line in firefox

Black region and discrete line in firefox
Comment 26 frank huang 2010-06-28 02:31:05 UTC
Allocate the FB memory from 24MB to 32MB in BIOS, firefox mis-rendering issue is disappearring. Off-screen memory region is not big enough for use in 24MB condition. But the patch's modification is correct:).
Reserch more on Off-screen memory allocation under 24MB and its use.

Thanks,
Frank
Comment 27 frank huang 2010-07-02 01:51:07 UTC
Copy from mail:
>Have you narrowed down if the problem is due to your code failing to handle an offscreen memory allocation failure, or something else?

Your guess is same as me after I enlarge the off-screen memory size that result in better result. Based on my debug, the bug is right here:). Today I have fixed this bug in our driver.

Just as the previous code writes, the off-screen memory size is fixed 256KB(which is reserved long long ago), and in firefox, when you press a refresh button, a big mask region 768x268 is need to be rendered with PictOpOver. You know, for the PictOpOver, the first pass is to do src*mask, and the result is ARGB format. So the off-screen size is 768x268x4=823296 > 256KB, so it overflows! The black region and missing glyph character are due to this.

After I know this, I adjust the off-screen region to 2MB instead of 256KB. As expected, the firefox mis-rendering bug is missing. That proves my guess and the debug result. But as you know, our Framebuffer size is not big enough in Geode, especially for OPLC computer. And 2MB is not big enough. Take an example, 1280x1024x4 is nearly 5MB. So that is possible to allocate so huge memory for off-screen operation.

And Jonathan give me one-line hint, use scanline method(Jonathan usually give me the direction!). So I split the rendering into several chunk, each is 256KB, then do it. Right now, It works fine:). I am happy with this. You know that is very important for us to use a small off-screen region that can make other FB region free. So this patch is valuable. 


Thanks,
Frank
Comment 28 frank huang 2010-07-15 00:02:34 UTC
Created attachment 37062 [details]
20x20 source picture, 40x40 rendering region with 4 colours

20x20 source picture, 40x40 rendering region with 4 colours
Comment 29 frank huang 2010-07-15 00:03:17 UTC
Created attachment 37063 [details]
out of region, src is 22, compared with previous one

out of region, src is 22
Comment 30 frank huang 2010-07-21 19:51:26 UTC
Created attachment 37290 [details]
wrong glyph rendering using HW+SW

wrong glyph rendering using HW+SW
Comment 31 frank huang 2010-07-26 23:12:02 UTC
Lower the priority of this issue.
The patches for misrendering main bug has been released and in review.
Comment 32 frank huang 2010-08-05 20:38:27 UTC
Update for patch 4:
http://lists.x.org/archives/xorg-driver-geode/2010-August/000952.html

Thanks,
Frank
Comment 33 Martin-Éric Racine 2010-08-23 08:19:47 UTC
5b93fdd42d7d8af4535fd62ce0749f2c4434f9fe in Geode 2.11.9 fixes this if I'm not mistaken?
Comment 34 frank huang 2010-08-23 18:15:12 UTC
This issue can be closed now. Main rendering bugs have been solved in 2.11.9 release. The fixed ops including PictOpOver, PictOpSrc, PictOpClear, PictOpIn, PictOpInReverse, PictOpOut, PictOpOutReverse, PictOpAdd. Any new bug reported, we can reopen this issue.


Thanks,
Frank


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.