I'm trying to port my application from Ogre 1.8 to 1.9 but I experience a crash when using multi-pass techniques with vertex shaders and meshes converted from manual objects.
The problem arise on Ubuntu 14.04 with NVIDIA drivers.
Here is the stack trace:
Code: Select all
Program received signal SIGSEGV, Segmentation fault.
0x00007fffef2c3390 in ?? () from /usr/lib/nvidia-304/libnvidia-glcore.so.304.117
(gdb) bt
#0 0x00007fffef2c3390 in ?? () from /usr/lib/nvidia-304/libnvidia-glcore.so.304.117
#1 0x00007fffef489f30 in ?? () from /usr/lib/nvidia-304/libnvidia-glcore.so.304.117
#2 0x00007fffef48bb5d in ?? () from /usr/lib/nvidia-304/libnvidia-glcore.so.304.117
#3 0x00007fffef0d0924 in ?? () from /usr/lib/nvidia-304/libnvidia-glcore.so.304.117
#4 0x00007fffb674bd97 in Ogre::GLRenderSystem::_render(Ogre::RenderOperation const&) () from lib/RenderSystem_GL.so.1.9.0
#5 0x00007ffff5897994 in Ogre::SceneManager::renderSingleObject(Ogre::Renderable*, Ogre::Pass const*, bool, bool, Ogre::HashedVector<Ogre::Light*> const*) ()
from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#6 0x00007ffff5895cbb in Ogre::SceneManager::BRAND NAME::visit(Ogre::Renderable*) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#7 0x00007ffff5830b0b in Ogre::QueuedRenderableCollection::acceptVisitorGrouped(Ogre::BRAND NAME*) const () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#8 0x00007ffff5830903 in Ogre::QueuedRenderableCollection::acceptVisitor(Ogre::BRAND NAME*, Ogre::QueuedRenderableCollection::OrganisationMode) const ()
from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#9 0x00007ffff5896157 in Ogre::SceneManager::renderObjects(Ogre::QueuedRenderableCollection const&, Ogre::QueuedRenderableCollection::OrganisationMode, bool, bool, Ogre::HashedVector<Ogre::Light*> const*) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#10 0x00007ffff5896468 in Ogre::SceneManager::renderBasicQueueGroupObjects(Ogre::RenderQueueGroup*, Ogre::QueuedRenderableCollection::OrganisationMode) ()
from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#11 0x00007ffff58963d4 in Ogre::SceneManager::_renderQueueGroupObjects(Ogre::RenderQueueGroup*, Ogre::QueuedRenderableCollection::OrganisationMode) ()
from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#12 0x00007ffff5893a8c in Ogre::SceneManager::renderVisibleObjectsDefaultSequence() () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#13 0x00007ffff58937e8 in Ogre::SceneManager::_renderVisibleObjects() () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#14 0x00007ffff588f2c6 in Ogre::SceneManager::_renderScene(Ogre::Camera*, Ogre::Viewport*, bool) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#15 0x00007ffff5978526 in Ogre::Camera::_renderScene(Ogre::Viewport*, bool) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#16 0x00007ffff5824207 in Ogre::Viewport::update() () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#17 0x00007ffff5720f97 in Ogre::RenderTarget::_updateViewport(Ogre::Viewport*, bool) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#18 0x00007ffff5720eb0 in Ogre::RenderTarget::_updateAutoUpdatedViewports(bool) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#19 0x00007ffff5720de3 in Ogre::RenderTarget::updateImpl() () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
#20 0x00007ffff5722aba in Ogre::RenderTarget::update(bool) () from /home/steficy/develop/webots/lib/libOgreMain_d.so.1.9.0
Code: Select all
// load default and persistent material from script
Ogre::MaterialManager &mgr = Ogre::MaterialManager::getSingleton();
Ogre::ResourceManager::ResourceCreateOrRetrieveResult result = mgr.createOrRetrieve("RegularDefault", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mDefaultMaterial = static_cast<Ogre::Material *>(result.first.getPointer());
//create camera and viewport
mCamera = mSceneMgr->createCamera("camera");
mViewport = mRenderWindow->addViewport(mCamera);
// create box
double x = 1.0; double y = 1.0; double z = 1.0;
Ogre::ManualObject *o = mSceneMgr->createManualObject("box_mesh_1");
o->estimateVertexCount(24);
o->estimateIndexCount(36);
o->begin("RegularDefault", Ogre::RenderOperation::OT_TRIANGLE_LIST);
// back
o->position(-x,y,-z); o->textureCoord(1,0);
o->normal(0,0,-1);
o->position(x,y,-z); o->textureCoord(0,0);
o->position(x,-y,-z); o->textureCoord(0,1);
o->position(-x,-y,-z); o->textureCoord(1,1);
o->quad(0,1,2,3);
// left
o->position(-x,y,-z); o->textureCoord(0,0);
o->normal(-1,0,0);
o->position(-x,-y,-z); o->textureCoord(0,1);
o->position(-x,-y,z); o->textureCoord(1,1);
o->position(-x,y,z); o->textureCoord(1,0);
o->quad(4,5,6,7);
// bottom
o->position(x,-y,z); o->textureCoord(1,0);
o->normal(0,-1,0);
o->position(-x,-y,z); o->textureCoord(0,0);
o->position(-x,-y,-z); o->textureCoord(0,1);
o->position(x,-y,-z); o->textureCoord(1,1);
o->quad(8,9,10,11);
// front
o->position(x,y,z); o->textureCoord(1,0);
o->normal(0,0,1);
o->position(-x,y,z); o->textureCoord(0,0);
o->position(-x,-y,z); o->textureCoord(0,1);
o->position(x,-y,z); o->textureCoord(1,1);
o->quad(12,13,14,15);
// right
o->position(x,-y,-z); o->textureCoord(1,1);
o->normal(1,0,0);
o->position(x,y,-z); o->textureCoord(1,0);
o->position(x,y,z); o->textureCoord(0,0);
o->position(x,-y,z); o->textureCoord(0,1);
o->quad(16,17,18,19);
// top
o->position(x,y,z); o->textureCoord(1,1);
o->normal(0,1,0);
o->position(x,y,-z); o->textureCoord(1,0);
o->position(-x,y,-z); o->textureCoord(0,0);
o->position(-x,y,z); o->textureCoord(0,1);
o->quad(20,21,22,23);
o->end();
o->convertToMesh("box_mesh_1");
mSceneMgr->destroyManualObject(o);
mGeomEntity = mSceneMgr->createEntity("box_mesh_1", "box_mesh_1");
mGeomEntity->setCastShadows(true);
mGeomNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("box_node");
mGeomNode->attachObject(mGeomEntity);
// create material
Ogre::Material *mat = static_cast<Ogre::Material *>(Ogre::MaterialManager::getSingleton().create("box_1", "General").get());
// remove techniques
Ogre::Material::TechniqueIterator tIt = mat->getTechniqueIterator();
while (tIt.hasMoreElements()) {
Ogre::Technique *t = tIt.getNext();
Ogre::Technique::PassIterator pIt = t->getPassIterator();
while (pIt.hasMoreElements()) {
Ogre::Pass *p = pIt.getNext();
p->removeAllTextureUnitStates();
}
t->removeAllPasses();
}
mat->removeAllTechniques();
Ogre::Technique *t;
Ogre::Pass *p;
t = mat->createTechnique();
t->setName("Approx");
p = t->createPass();
p->setName("Ambient");
p->setLightingEnabled(false);
p = t->createPass();
p->setName("PointLights");
p->setVertexProgram("ApproxPointLightVert");
t = mat->createTechnique();
t->setName("Precise");
p = t->createPass();
p->setName("Ambient");
p->setLightingEnabled(false);
p = t->createPass();
p->setName("PointLights");
p->setVertexProgram("PrecisePointLightVert");
mGeomEntity->setMaterialName("box_1");
// create light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
mLight = mSceneMgr->createLight("pointlight_2");
mLight->setVisible(true);
mLight->setCastShadows(true);
mLight->setType(Ogre::Light::LT_POINT);
mLight->setPosition(2.0f, 5.0f, 8.0f);
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
I get the crash during the first rendering after the recreation.
Code: Select all
mRenderWindow->removeViewport(mViewport->getZOrder());
mSceneMgr->destroyCamera(mCamera);
mSceneMgr->destroyLight(mLight);
mLight = NULL;
Ogre::String meshName = mGeomEntity->getMesh()->getName();
mGeomNode->detachObject(mGeomEntity);
mSceneMgr->destroyEntity(mGeomEntity);
mSceneMgr->destroySceneNode(mGeomNode);
Ogre::MeshManager::getSingletonPtr()->remove(meshName);
Ogre::MaterialManager::getSingleton().remove("box_1");
mGeomNode = NULL;
mGeomEntity = NULL;
But it is independent from the code defined in the vertex program and it is working with Ogre 1.8.
I also noticed that if I use a static mesh loaded from file or if I remove the vertex shaders, then the application doesn't crash.
Does anyone have some suggestions about what could be the problem?
