Fixed for crashes on exit associaciated with VAO usage and vairous niche usage cases

This commit is contained in:
Robert Osfield
2019-01-08 19:32:50 +00:00
parent 1c65815f4e
commit f6b64afdfc
13 changed files with 161 additions and 7 deletions

View File

@@ -340,9 +340,14 @@ void Camera::resizeGLObjectBuffers(unsigned int maxSize)
void Camera::releaseGLObjects(osg::State* state) const
{
if (_renderer.valid())
{
_renderer->releaseGLObjects(state);
}
if (_renderingCache.valid())
{
const_cast<Camera*>(this)->_renderingCache->releaseGLObjects(state);
_renderingCache->releaseGLObjects(state);
}
Transform::releaseGLObjects(state);

View File

@@ -438,7 +438,7 @@ bool GraphicsContext::realize()
void GraphicsContext::close(bool callCloseImplementation)
{
OSG_INFO<<"close("<<callCloseImplementation<<")"<<this<<std::endl;
OSG_INFO<<"GraphicsContext::close("<<callCloseImplementation<<")"<<this<<std::endl;
// switch off the graphics thread...
setGraphicsThread(0);

View File

@@ -222,3 +222,26 @@ unsigned int View::findSlaveIndexForCamera(osg::Camera* camera) const
return _slaves.size();
}
void View::resizeGLObjectBuffers(unsigned int maxSize)
{
if (_camera) _camera->resizeGLObjectBuffers(maxSize);
for(Slaves::iterator itr = _slaves.begin();
itr != _slaves.end();
++itr)
{
if (itr->_camera.valid()) itr->_camera->resizeGLObjectBuffers(maxSize);
}
}
void View::releaseGLObjects(osg::State* state) const
{
if (_camera) _camera->releaseGLObjects(state);
for(Slaves::const_iterator itr = _slaves.begin();
itr != _slaves.end();
++itr)
{
if (itr->_camera.valid()) itr->_camera->releaseGLObjects(state);
}
}

View File

@@ -56,7 +56,6 @@ LightPointDrawable::LightPointDrawable(const LightPointDrawable& lpd,const osg::
LightPointDrawable::~LightPointDrawable()
{
OSG_NOTICE<<"LightPointDrawable::~LightPointDrawable()"<<std::endl;
}
void LightPointDrawable::reset()

View File

@@ -927,6 +927,58 @@ void SceneView::releaseAllGLObjects()
_camera->releaseGLObjects(_renderInfo.getState());
}
void SceneView::resizeGLObjectBuffers(unsigned int maxSize)
{
struct Resize
{
unsigned int maxSize = 1;
Resize(unsigned int ms) : maxSize(ms) {}
void operator() (osg::Referenced* object)
{
if (object) object->resizeGLObjectBuffers(maxSize);
}
} operation(maxSize);
operation(_localStateSet.get());
operation(_updateVisitor.get());
operation(_cullVisitor.get());
operation(_stateGraph.get());
operation(_renderStage.get());
operation(_cullVisitorRight.get());
operation(_stateGraphRight.get());
operation(_renderStageRight.get());
operation(_globalStateSet.get());
operation(_secondaryStateSet.get());
operation(_cameraWithOwnership.get());
}
void SceneView::releaseGLObjects(osg::State* state) const
{
if (state && state!=_renderInfo.getState()) return;
struct Release
{
void operator() (const osg::Referenced* object)
{
if (object) object->releaseGLObjects();
}
} operation;
operation(_localStateSet.get());
operation(_updateVisitor.get());
operation(_cullVisitor.get());
operation(_stateGraph.get());
operation(_renderStage.get());
operation(_cullVisitorRight.get());
operation(_stateGraphRight.get());
operation(_renderStageRight.get());
operation(_globalStateSet.get());
operation(_secondaryStateSet.get());
operation(_cameraWithOwnership.get());
}
void SceneView::flushAllDeletedGLObjects()
{
_requiresFlush = false;

View File

@@ -930,6 +930,18 @@ void Renderer::operator () (osg::GraphicsContext* /*context*/)
}
}
void Renderer::resizeGLObjectBuffers(unsigned int maxSize)
{
if (_sceneView[0].valid()) _sceneView[0]->resizeGLObjectBuffers(maxSize);
if (_sceneView[1].valid()) _sceneView[1]->resizeGLObjectBuffers(maxSize);
}
void Renderer::releaseGLObjects(osg::State* state) const
{
if (_sceneView[0].valid()) _sceneView[0]->releaseGLObjects(state);
if (_sceneView[1].valid()) _sceneView[1]->releaseGLObjects(state);
}
void Renderer::release()
{
OSG_INFO<<"Renderer::release()"<<std::endl;