Re: Performance issues using gdk_draw_rgb_image



David J. Singer wrote:
> I'm writing an application under Linux that generates realtime audio and
uses
> GTK as the GUI.  I've been using "gdk_draw_rgb_image" to update the
interface
> components onto a backing pixmap, then copy the whole lot to a drawing
area
> at regular intervals.  The graphics stored in memory are all 24bpp, loaded

> from PNG files.
> 
> All has been well until recently I changed my X session from 16bpp to
24bpp 
> and now the whole application seems to be struggling; there are noticable 
> breakups in the audio.  
> 
> Is there a real performance issue with gdk_draw_rgb_image?  Is there a
faster
> way to do it?  And why does changing from 16bpp to 24bpp screw everything
> up so much...?

Hi, gdk_draw_rgb_image() is about as quick as you can get with X. It 
does all the obvious speed tricks (shared memory access to the server, 
etc.). Try running testrgb in the 16 and 24bpp modes ... it prints a 
pixels per second figure. You'll at least be able to see how much slower 
24bpp is.

I can think of a couple of reasons why 24bpp could be slower. First, 
your card is may not really be 24 bits: a lot are are 32-bit. 
gdk_draw_rgb_image() will therefore be building temp images twice the 
size of the old 16bpp ones, so there could be a x2 slowdown there.

Second, your X server may not have hardware accel available at higher 
bit depths, either because of the hardware on the card, or because of 
the driver. If you see more than a x2 slowdown moving to 24bpp in 
testrgb this is probably the problem. You need a new card, or a new 
driver (or maybe the next Xfree version :-)

You could try to get a speed up by going to a lower level. For example, 
if your card is 32bpp, you can unpack your PNGs to 32bpp once and do the 
GdkImage painting yourself. Alternatively, you could just do less 
painting: if you want your app to be useful on a range of machines, it's 
probably a good idea for it to have a mechanism to drop the framerate if 
there's not enough horsepower available.

> As an aside, I've noticed there are also problems when I swap down to 8bpp

> mode I have problems displaying the colours correctly.  I thought this
might 
> be a dithering issue, but I've tried GDK_RGB_DITHER_MAX and 
> GDK_RGB_DITHER_NONE and both seem to have the same effect.

Not sure here. Have you tried playing with gdk_rgb_set_min_colors()?

John



========================================================== 
Aelbert Cuyp 13 February - 12 May 2002 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/cuyp/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]