[Development] QtSC: Scene Graph discussion
Gunnar.Sletta at digia.com
Wed Jul 31 10:33:16 CEST 2013
We went through a couple of topics and I try to summarise and make tasks for most of it.
Render thread animations: https://bugreports.qt-project.org/browse/QTBUG-32703
Integration with native rendering, aka raw OpenGL for instance as a result of QQuickWindow::beforeRendering(). Document which state scenegraph exists in and make a function to reset the GL state afterwards. https://bugreports.qt-project.org/browse/QTBUG-32700
A request was made for running the scene graph in "slave mode", aka let for instance Ogre3D be the one owning the GL context and driving the render loop and let the QML scene be drawn on demand. -> This is doable already by implementing a custom renderloop using the private scene graph backend API (customcontext in
ssh://codereview.qt-project.org:29418/playground/scenegraph.git). No public API planned at this time.
Antialiasing: The Qt Quick items are currently antialiased by adding vertices along the edges and fading the opacity to 0. This gives nice results and always works, but OpenGL can do multisample based antialiasing which is a lot faster and which still gives decent results. Multisampling typically comes at a higher memory cost, several popular embedded chips (iPhone's SGX, for instance) can do 4x multisampling with minimal performance impact and no memory overhead. Using multisampling also has the added benefit that rectangles and opaque images are treated as opaque when they are rendered which enables better batching and reordering of the GL commands, further improving performance. Conclusion was to make this configurable: https://bugreports.qt-project.org/browse/QTBUG-32699
The scene graph renderer needs to start using Vertex Array Objects when mixed with raw GL using the OpenGL 3+ core profiles. Sean has promised a patch: https://bugreports.qt-project.org/browse/QTBUG-32050
The question was asked about how to add custom OpenGL into the scene graph scene. Though this is possible using private API, it is highly discouraged and will NEVER be public API. I plan on removing that feature all together at some point. It breaks batching and reordering can cost quite a bit in terms of buffer clearing and state restoration in the middle of rendering. The solution is to render UNDER the scene graph, OVER the scene graph or into a FramebufferObject if you want to be inside the scene graph.
I've been experimenting with a new renderer which takes the batching ideas from the overlaprenderer, front-to-back rendering of the default renderer and caching in VBOs between frames when possible. For ideal usecases, we're looking at 10-1000x improvement, CPU-side. It's looking good and might be a good place to include the Vertex Array Objects as it should also benefit from them. https://bugreports.qt-project.org/browse/QTBUG-32695 and https://bugreports.qt-project.org/browse/QTBUG-32697
Stand alone module. Though the scene graph is public API inside Qt Quick, the question has been raised in the past if it makes sense to make it possible to build it into a separate module. Not an officially supported module, but just possible. We concluded that it doesn't really make sense.
More information about the Development