FreeOrion

Forums for the FreeOrion project
It is currently Mon Dec 18, 2017 12:50 pm

All times are UTC




Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Mon Jun 29, 2015 6:24 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
raptor wrote:
Could a texture cache be bound only once at application start-up, then just modify the quad coordinates of the glyph when rendering?
If the only texture you ever wanted to render was a font, sure...


Top
 Profile  
 
PostPosted: Mon Jun 29, 2015 7:24 pm 
Offline
Space Squid

Joined: Sat Jun 02, 2012 11:29 pm
Posts: 74
Oops. Sorry, I mixed up 'binding' with 'creation', in my head, for some reason... that basically invalidates my line of thought.


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 11:49 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
Testing requsted: https://github.com/freeorion/freeorion/pull/159


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 4:11 pm 
Offline
Space Squid

Joined: Sat Jun 02, 2012 11:29 pm
Posts: 74
Performance with the new code is almost identical. With a similar test performed like before, the node cost of GG::Font::RenderCachedText is about 19% of the whole. I looked into getting the debug symbols for my drivers but so far, no luck. I'm looking into other ways to figure out which GL calls are the most expensive; any ideas would be appreciated.


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 4:30 pm 
Offline
Space Squid

Joined: Sat Jun 02, 2012 11:29 pm
Posts: 74
I did some more digging and found other methods that call the same symbol. It looks like the issues is indeed glBindTexture().

Looking at other font caching methods (like this one: https://github.com/akrinke/Font-Stash/b ... ash.c#L414), it looks like that glBindTexture() is only ever called when a new glyph needs to be added to the texture cache or when a new texture is created; however, it looks like freeorion calls it on every glyph render.


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 6:50 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
raptor wrote:
...it looks like freeorion calls [glBindTexture()] on every glyph render.
Why do you say that? RenderCachedText renders (I think) a whole Control's text (many Glyphs), but only binds and unbinds once. PreRenderText similarly binds once (though I'm not sure why that's necessary...)

Edit: commenting out line 855 of Font.cpp,
Code:
    //glBindTexture(GL_TEXTURE_2D, m_texture->OpenGLId());
seems to have no ill-effects for me. Does it still work for you, possibly with an minor speed improvement?


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 7:28 pm 
Offline
Space Squid

Joined: Sat Jun 02, 2012 11:29 pm
Posts: 74
Commenting out that line in PreRenderText() doesn't change the performance; however, commenting out the two calls in RenderCachedText() does give a slight performance boost (with unacceptable visual artifacts), but not much. Maybe I'm mistaken in thinking it was glBindTexture().


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 10:05 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
Try this: https://github.com/freeorion/freeorion/pull/164


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 3:27 pm 
Offline
Space Squid

Joined: Sat Jun 02, 2012 11:29 pm
Posts: 74
This was really good!

FPS increased to about 45-50 FPS (from about 30 before) when viewing the tech-tree the same as with previous tests. I did another callgrind analysis and came up with about a 3.7x performance increase of GG:Font::RenderCachedText() as rough guess. See my numbers:
Attachment:
snapshot2.png
snapshot2.png [ 69.31 KiB | Viewed 1337 times ]

Note that there is a huge reduction in number of calls per Render() fram of the TechPanel.

The new largest offender is PartlyRoundedRect() at 14% of the whole, with most of that (10%) in CircleArc(), from CUIDrawUtil.cpp.

Great change!


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 6:22 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
If a few others could test it out, that would be helpful... I'm a bit hesitant to merge without a few other reports.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 7:52 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4309
Location: Sol III
Geoff the Medio wrote:
If a few others could test it out, that would be helpful... I'm a bit hesitant to merge without a few other reports.
I'm still on vacation, will try to get around to it next week.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 8:37 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3295
I'm having problems getting Git to recognise the branch you've put the code in, I'm sure I'll figure it out.

_________________
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 9:20 pm 
Offline
Content Scripter
User avatar

Joined: Sat Mar 17, 2007 12:28 am
Posts: 685
I've pulled the PR, compiled and ran a test. The performance is certainly not worse, but i can't really tell whether it's better.

For me the easiest way to crash my framerate is to build the super testers takeover. With a big galaxy (250+) fully visible it even becomes hard to click on a system, because the mouse cursor reacts so badly.

_________________
All released under the GNU GPL 2.0 and Creative Commons Attribution-ShareAlike 3.0 licences.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 10:01 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3295
Builds and runs fine, I perceive an improvement in the tech screen but can't quantify it, then I never noticed a reduction in FPS in that window anyway, I've always had low FPS, even on the new machine.

Edit: on the main map window, it's not just a perception, massive improvement in mouse responsiveness and general control over screen and game.

_________________
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Last edited by MatGB on Thu Jul 02, 2015 10:05 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Jul 02, 2015 10:02 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
Sloth wrote:
For me the easiest way to crash my framerate is to build the super testers takeover. With a big galaxy (250+) fully visible it even becomes hard to click on a system, because the mouse cursor reacts so badly.
Have you turned off background starfields and galaxy gas, and tried enabling or disabling optimizing system rendering?
raptor wrote:
The new largest offender is PartlyRoundedRect() at 14% of the whole, with most of that (10%) in CircleArc(), from CUIDrawUtil.cpp.
Those functions have a substantial number of immediate glVertex calls, so that's not surprising. This in particular, and most of the UI Wnd-derived classes, would be better re-implementing using buffer objects for rendering instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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