[Glamor] [Patch 00/01] Move realloc out of diagonal line drawing loop.

Conn Clark conn.o.clark at gmail.com
Thu Mar 27 11:58:44 PDT 2014


On Wed, Mar 26, 2014 at 3:14 AM, Grigori Goronzy <greg at chown.ath.cx> wrote:
> On 25.03.2014 22:02, Conn Clark wrote:
>>
>> The number of line segments in drawing the diagonal line can be
>> calculated. This means we can move two operations out of the loop, the
>> realloc and the adjustment to the final count.
>>
>> This shaves 3 to 5 seconds off of gtkperf line benchmark that takes 388
>> seconds on my machine (About a 1% improvement ) .  I have more
>> optimizations but that can shave a total of 20 but they are ugly at the
>> moment and I'll submit them later.
>>
>
> AFAICT the real bottleneck with line drawing is the lack of batching - each
> line, and in case of diagonal lines each line segment, is rendered with a
> single draw call each. That has a huge overhead. I haven't tested this, but
> I can imagine you'll easily see multiple orders of magnitude speed ups with
> proper batching.
>
> No idea if this has been improved in the xserver-based glamor yet.
>
> Best regards
> Grigori

Hi Grigori,

As I'm following the code through each chained function call there are
several inefficiencies. There are numerous duplicate variable
assignments and checks made at each step. Each of these checks and
variable assignments could be done once before the loop that processes
through the rectangles. I'm trying to find the biggest bottle necks by
making one huge function and eliminating the lower function calls one
at a time. I haven't had time to work on it lately though.

I still think the best way to do diagonal lines is with a Bresenham's
line shader program and use a geometry shader to do any clipping. We
can't use GL Lines because they aren't guaranteed to Bresenham's lines
and you can't be sure that drawing another line in the back ground
color will erase a previous line (some CAD programs using GL lines
will leave artifacts on some systems).

 Best Regards,

Conn

-- 

Conn O. Clark

Observation: In formal computer science advances are made
by standing on the shoulders of giants. Linux has proved
that if there are enough of you, you can advance just as
far by stepping on each others toes.


More information about the Glamor mailing list