[Qt-interest] Comments on: 220548 - X11: Use PictStandardA8 instead of PictStandardA1 in X11 paint engine

Trond Kjernaasen trond at trolltech.com
Tue Feb 3 15:29:05 CET 2009


Hi Clemens,

Clemens Eisserer wrote:
> Hi Trond,
> 
>> but for me the aliased version is
>> about 2 times faster than the antialiased one when running GEARSFANCY.
>> Also note that the code path that uses the A1 mask is only used when you
>> draw a polygon or path with a texture brush that has an alpha channel.
> Are you using EXA or XAA. XAA was basically software-only, and most
> mature drivers now use EXA by default.
> Practically all recent distributions default to it and when used
> carefully (trying to hit no fallbacks), there are some great
> performance improvements.
> 
> Sun also had problems with it, reverting to software rendering only,
> until my XRender backend is completed:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6708580
> 
> 
>> We can change the A1 mask picture, but I don't see any huge differences
>> on my local box. I'm not sure what part of that demo you are looking at
>> (GEARSFANCY, GEARS, COMPO or TEXT),
> I was reffering to GEARS.
> Oh, I misread the code, sorry.
> In the non-antialiased case no mask is used at all right?

Right.

> Using no mask at all is basically the worst thing you can do:
> The X-Server iterates through the list of trapezoids, and doing a
> "XRenderCompositeTrapezoid" for each trapezoid.
> Every time allocating a temporary mask image, uploading it to vram,
> compoite and free it.
> 
> I wrote a benchmark (attached) drawing a 100x100 circle consisting of
> ~180 trapezoids:
> 20ms, fmtA8
> 120ms, fmtA1
> 270ms, no mask format
> This was on Xorg-1.5.3 / Ubuntu-8.10 / Intel-i945GM

Ouch! We were not aware of that actually. Thanks for that tip.

> So better use a A1 mask in the mean time, using a mask you also get
> rid of the individual texture offset problem.
> This way you give at least Xorg a chance to do the right things.
 >
> However, I was wrong about simply replacing A1 with A8, because this
> still results in antialiased rendering, even if
> XRenderPictureAttributes.polyEdge == PolyEdgeSharp.
> The right thing would probably to use A8 internally in Xorg when A1 is
> requested and switch to aliased rendering.
> I will have a look and discuss it on Xorg.

Yes, I see the same here.

>> Needless to say, this is suboptimal - however there is a reason for it.
>> The texture offsets are reset for every trapezoid that is rendered (at
>> least it is in every RENDER implementation I've tested). We need to
>> adjust the offset for each individual trapezoid to get the correct output.
> Wow I also was not aware of this. However using a mask seems to solve it :)
> 
>>> 3.) qt_XRenderCompositeTrapezoids:
>>> This seems to be a work-arround, however it breaks antialiasing :-/
>> Why does it break antialiasing?
> Because Trapezoids are in the antialiased case added with PictOpAdd,
> so two overlapping edged with 0.5 will give 1.0.
> However, when compositing you have your own operator, so at the edges
> between the traps in the first go and the traps of the second go you
> won't have PictOpAdd that makes it look seamless,
> but instead the value resulting of your chosen operator. (e.g. for
> PictOpOver 0.5+0.5 ~ 0.75)
> However this is a very uncommon problem, not very likely to occur.

Ah, yes - you're right. However, in the workaround we have in place 
you'll need to draw more than 50000 trapezoids to hit this, which I'd 
say is not the common case. The workaround is there mainly to stop 
certain X servers from borking out when drawing *extremely* complex 
polygons.

> Thanks for listening, Clemens

Thanks for your input Clemens, I've attached a patch which simplifies 
our polygon/path drawing code a bit. I've tried it on different X 
servers, both an EXA one running on an Intel 965 chipset and one running 
with the latest NVidia proprietary drivers on a GS 7600 card. Both of 
them shows a doubling in speed when rendering aliased trapezoids that 
uses this code path, which is caused by using the A1 mask format instead 
of not using a mask at all. For the EXA case I also see a speedup of 
around 25% in the antialiased case, but that remains unchanged when 
running with the Nvidia driver. The patch will most likely be included 
in 4.5.0.


Regards,
--
Trond K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 4296 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090203/0fd582d5/attachment.bin 


More information about the Qt-interest-old mailing list