OpenSceneGraph
OpenSceneGraph copied to clipboard
Fix issue with VertexArrayState current VBO/EBO pointers being set after it is no longer current
My understanding is that osg::VertexArrayState keeps _currentVBO/_currentEBO to avoid re-binding buffers unnecessarily.
However when osg::Drawable finishes drawing, it keeps those pointers set.
So the following can happen:
- During
draw()Drawable A binds VBO1 and sets its_currentVBOto point to VBO1. - During
draw()Drawable B binds VBO2 and sets its_currentVBOto point to VBO2. - Next time Drawable A decides to bind VBO1 it will see that
_currentVBOto points to VBO1, so it will do nothing. - Drawable A will now dispatch an attribute stored in VBO1, but since it didn't bind VBO1, its VAO will be now bound with VBO2.
I have noticed this issue with multiple osg::Geometry objects that share some attributes and use a shared VBO for those, and have some individual attributes in their individual VBOs.
This PR will reset _currentVBO/_currentEBO pointers when drawing is complete.
Have you tried PR #1079 with https://github.com/openscenegraph/OpenSceneGraph/pull/1079/commits/84a36eb9c26067868806b43db4bb1acd36f17bd7 ? Can it fix your issues?
I am not sure, but I think it is not a good idea to reset buffers like that, OSG uses "lazy mechanism".
Apologies for the late response, was swamped with work. I have tried PR #1079 and it seems to fix the problem for me as well. However I suspect only part of the PR is necessary to fix the issue and it doesn't look like it will be accepted any time soon. I was hoping that a PR smaller in scope could be easier to accept