Rendering with QGeometryData - optimisations
I have a couple of questions regarding the method I'm thinking of using to render 3D objects. I'm utilising the Qt3D library and have created an interface with which renderable objects "export" their geometry to a QGeometryData object, which is then used by the render system:
@virtual QGeometryData toGeomData() const = 0;@
I have some thoughts about this that I'd like to get clarified if possible: firstly, is a function returning a QGeometryData object a good idea? If the object creates its QGD on the stack, fills it and then returns it, copying the object as the function returns I feel might add up to a lot of overhead if lots of objects are being rendered.
Secondly, if a new QGD object is returned from the function each time the object is rendered, would this interfere with the optimisations on QGD::upload()? If a new QGD is created each time to replace the previous object from the last frame, I'm assuming that would negate the functionality where in the documentation it is stated that the data is not re-uploaded to the GPU if it hasn't changed. Would it be advantageous instead to ensure that the renderable object itself does not replace its QGD unless its rendering parameters have changed?
Lastly, if I've understood the documentation correctly, each QGD object has its own VBO/other buffers on the graphics card. Does it make sense to use one QGD for each renderable object (of which there could be thousands), or should they be grouped differently?