Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 5:50 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Drawing Text seems slow
PostPosted: Sat Jul 21, 2012 10:41 pm 
Offline

Joined: Sat Jul 21, 2012 10:11 pm
Posts: 3
I've been toying around a bit with the TWL demos, and I noticed that they use a lot of CPU on my little subnotebook. Particularly the TextAreaDemo uses around 40% of my 1.3 ghz core 2 duo, and that for just one smallish text display area.

I did a bit of profiling with the (probably not so accurate) jvisualvm, and the results were that a lot of that time is spent in the actual openGL calls to render the text. Here's part of the snapshot from the sampler.

Image

So I'm not entirely sure, but I believe there is room for optimization there. I had the idea of something like the option of caching text as textures or images, which seem to render significantly faster. But I haven't really looked into the code much yet, so I can't say.

In either case, it'd be really nice if drawing large amounts of text could be sped up to the point where an extensive GUI can actually run on a low-end PC, and with some pointers I'm fine making the necessary modifications myself, if viable at all.


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 9:00 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
You can write another Renderer implementation which uses different approaches / GL calls to render text.

I don't think that caching whole text as texture is a good idea - as you this might creates lots of textures.

In your case it looks more likely that using display lists is causing the issue for you - you can test that by disabling the current caching in de.matthiasmann.twl.renderer.lwjg.LWJGLFont.cacheText() by always returning null.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 11:07 am 
Offline

Joined: Sat Jul 21, 2012 10:11 pm
Posts: 3
Thanks for the quick response! ^^

I tried your suggestion, but it only made rendering slightly slower. (from 40% / 25% on my two cores to 50% / 40%). Something I don't quite understand is that the calls to glClear() also seem to get more expensive, the more expensive the other gl calls get(glClear always takes around 50% in the profiler).

Image


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 3:25 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
This sounds like your GPU runs into a fill rate limit - as nearly everything in TWL (using the provided default renderer) is alpha blended.
So it's unlikely that you can make it much faster. You could try to disable blending (use alpha testing) for rendering text and use a font without AA.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Tue Jul 31, 2012 3:55 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Ditching immediate mode might also help reduce some CPU load (on my machine, fill-rate bottlenecks lead to high self-time in nSwapBuffers, not glVertex and glTexCoord).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group