Board index FlightGear Development Canvas

Canvas::View element: performance/optimizations

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Canvas::View element: performance/optimizations

Postby Hooray » Sat Sep 02, 2017 1:08 pm

Moving this private discussion over to the Canvas sub-forum:
Icecode GL wrote:RTT is expensive no matter the context. Right now FPS gets effectively cut in half, since the scene needs to be rendered twice. And by the way, I don't think canvas::Image uses osg::Image, or at least I didn't see it anywhere. It only creates a quad with the size of the image and textures it with the image. The osg::Image is then freed and not used again till the path/image is changed.



For the View element itself, we could maintain a std::map<> for each configured view, so that we only ever set up one texture per view - so no matter the number of views created, there would only be one RTT - we would mainly need to introduce some sort of "ViewProvider" that maintains a cache of requested view textures, and at that point we could check if the previously computed viewMatrix is identical or not, and only re-compute/rebuild the texture if it's different - that should pay off for complex cockpits with lots of screens showing possibly identical views/tailcams.

Obviously, things would become complicated the very instant we start supporting draw-masks per view or custom shaders ...

Anyway, the view element is certainly one of those Canvas elements that would clearly benefit from having support for OSG stats, so that these views do show up in the osg stats.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas::View element: performance/optimizations

Postby icecode » Sat Sep 02, 2017 1:15 pm

In my opinion the three changes that would result in the best improvement would be:
  1. Draw masks, mainly for PFDs and similar stuff where we don't need to render the whole scene.
  2. Customizable shaders. Rendering the scene twice in ALS doesn't come cheap, so external camera views and mirrors could use lower ALS quality settings. In the of PFDs, it would allow to have that synthetic terrain appearance that Hooray was talking about.
  3. Configurable refresh rate per view. 15 fps might be enough for a external camera, we don't need to draw at max rate.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: Canvas::View element: performance/optimizations

Postby Hooray » Sat Sep 02, 2017 1:22 pm

Yeah, those sound like good ideas to me - I think psadro_gm once mentioned in the "synthetic terrain" discussion a few ideas on reusing the terrain mesh for such purposes, we may need to get in touch with him and Stuart to learn how to best hook up draw-masks to each element, I suppose we need to provide our own element-specific updateVisitor to accomplish that ?

Apart from that, views would seem to benefit from aggressive culling - i.e. if a view is not visible or partially obscured, there is no need for the Canvas to update the whole view.

Then again, I do think that a simple helper class with a STL std::map<> could be good to make sure that there are never more RTT/FBOs set up than we have views. After all, down-sampling can be done dynamically be the Canvas. Obviously, this would ideally be "lazy", i.e. only actually set up view textures if we have an element showing the view.

However, in the end this may also prove useful to help optimize the view manager itself, because it's infamous for its initial stuttering when switching between views not previously shown.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU


Return to Canvas

Who is online

Users browsing this forum: No registered users and 5 guests