If the only texture you ever wanted to render was a font, sure...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?
About freeorion's performance
Moderator: Committer
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
Re: About freeorion's performance
Oops. Sorry, I mixed up 'binding' with 'creation', in my head, for some reason... that basically invalidates my line of thought.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
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.
Re: About freeorion's performance
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.
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.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
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...)raptor wrote:...it looks like freeorion calls [glBindTexture()] on every glyph render.
Edit: commenting out line 855 of Font.cpp,
Code: Select all
//glBindTexture(GL_TEXTURE_2D, m_texture->OpenGLId());
Re: About freeorion's performance
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().
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
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: 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!
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: 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!
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
If a few others could test it out, that would be helpful... I'm a bit hesitant to merge without a few other reports.
Re: About freeorion's performance
I'm still on vacation, will try to get around to it next week.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.
Re: About freeorion's performance
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.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
Re: About freeorion's performance
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.
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.
Re: About freeorion's performance
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.
Edit: on the main map window, it's not just a perception, massive improvement in mouse responsiveness and general control over screen and game.
Last edited by MatGB on Thu Jul 02, 2015 10:05 pm, edited 1 time in total.
Mat Bowles
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: About freeorion's performance
Have you turned off background starfields and galaxy gas, and tried enabling or disabling optimizing system rendering?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.
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.raptor wrote:The new largest offender is PartlyRoundedRect() at 14% of the whole, with most of that (10%) in CircleArc(), from CUIDrawUtil.cpp.