Ogre 1.9.1 (D3D9) crashes when Qt OpenGL is used

Problems building or running the engine, queries about how to use features etc.
Post Reply
Job
Gnoblar
Posts: 3
Joined: Thu Sep 29, 2011 8:23 am

Ogre 1.9.1 (D3D9) crashes when Qt OpenGL is used

Post by Job »

I have an application that uses Qt for the main application and Qt's OpenGL widgets for drawing 2d graphs etc, while Ogre is used for a 3D viewport with meshes, shadows etc.
Recently we had to update Qt to 5.7 for some required features that were not in 5.6, which also required a rebuild of Ogre in Visual Studio 2015. So I have the latest (1.9 branch) Ogre, updated from 1.9 RC1.
In the past, Ogre (1.9 RC1) worked fine next to Qt (5.6) in this setup, however it does not anymore. Very often when opening an Open GL widget, I get a crash in Ogre with essentially this callstack:

RenderSystem_Direct3D9_d.dll!Ogre::D3D9HardwareIndexBuffer::updateBufferResources(const char * systemMemoryBuffer, Ogre::D3D9HardwareIndexBuffer::BufferResources * bufferResources) Line 380 C++
> RenderSystem_Direct3D9_d.dll!Ogre::D3D9HardwareIndexBuffer::unlockImpl() Line 161 C++
OgreMain_d.dll!Ogre::HardwareBuffer::unlock() Line 251 C++
OgreMain_d.dll!Ogre::ShadowCaster::generateShadowVolume(Ogre::EdgeData * edgeData, const Ogre::HardwareIndexBufferSharedPtr & indexBuffer, unsigned __int64 & indexBufferUsedSize, const Ogre::Light * light, std::vector<Ogre::ShadowRenderable *,Ogre::STLAllocator<Ogre::ShadowRenderable *,Ogre::CategorisedAllocPolicy<0> > > & shadowRenderables, unsigned long flags) Line 383 C++
OgreMain_d.dll!Ogre::Entity::getShadowVolumeRenderableIterator(Ogre::ShadowTechnique shadowTechnique, const Ogre::Light * light, Ogre::HardwareIndexBufferSharedPtr * indexBuffer, unsigned __int64 * indexBufferUsedSize, bool extrude, float extrusionDistance, unsigned long flags) Line 2009 C++
OgreMain_d.dll!Ogre::Entity::getShadowVolumeRenderableIterator(Ogre::ShadowTechnique shadowTechnique, const Ogre::Light * light, Ogre::HardwareIndexBufferSharedPtr * indexBuffer, unsigned __int64 * indexBufferUsedSize, bool extrude, float extrusionDistance, unsigned long flags) Line 1869 C++
OgreMain_d.dll!Ogre::SceneManager::renderShadowVolumesToStencil(const Ogre::Light * light, const Ogre::Camera * camera, bool calcScissor) Line 5669 C++
OgreMain_d.dll!Ogre::SceneManager::renderModulativeStencilShadowedQueueGroupObjects(Ogre::RenderQueueGroup * pGroup, Ogre::QueuedRenderableCollection::OrganisationMode om) Line 2510 C++
OgreMain_d.dll!Ogre::SceneManager::_renderQueueGroupObjects(Ogre::RenderQueueGroup * pGroup, Ogre::QueuedRenderableCollection::OrganisationMode om) Line 3035 C++
OgreMain_d.dll!Ogre::SceneManager::renderVisibleObjectsDefaultSequence() Line 2351 C++
OgreMain_d.dll!Ogre::SceneManager::_renderVisibleObjects() Line 2266 C++
OgreMain_d.dll!Ogre::SceneManager::_renderScene(Ogre::Camera * camera, Ogre::Viewport * vp, bool includeOverlays) Line 1565 C++
OgreMain_d.dll!Ogre::Camera::_renderScene(Ogre::Viewport * vp, bool includeOverlays) Line 430 C++
OgreMain_d.dll!Ogre::Viewport::update() Line 226 C++
OgreMain_d.dll!Ogre::RenderTarget::_updateViewport(Ogre::Viewport * viewport, bool updateStatistics) Line 201 C++
RenderSystem_Direct3D9_d.dll!Ogre::D3D9RenderWindow::_updateViewport(Ogre::Viewport * viewport, bool updateStatistics) Line 843 C++
OgreMain_d.dll!Ogre::RenderTarget::_updateAutoUpdatedViewports(bool updateStatistics) Line 180 C++
OgreMain_d.dll!Ogre::RenderTarget::updateImpl() Line 156 C++
OgreMain_d.dll!Ogre::RenderTarget::update(bool swap) Line 616 C++
OgreMain_d.dll!Ogre::RenderSystem::_updateAllRenderTargets(bool swapBuffers) Line 127 C++
OgreMain_d.dll!Ogre::Root::_updateAllRenderTargets() Line 1412 C++
OgreMain_d.dll!Ogre::Root::renderOneFrame() Line 983 C++

And this exception:
Exception thrown at 0x00007FFB070ED6D6 (RenderSystem_Direct3D9_d.dll) in application.exe: 0xC0000005: Access violation reading location 0x00000009B2223000.

I did find it strange that there is a _lockBuffer happening inside a HardwareBuffer::unlock() call, but this may be correct, I don't know the ins and outs of the hardware access.

The same code used to work perfectly fine in older Qt, which may hev been less aggressive in its access to the graphics hardware.
The error also does not happen when I switch off the shadows, obviously, but this is not an option in my application.

If anyone can help me solve this, I would greatly appreciate it :)

I've avoided the problem for now by using Ogre 1.9RC1 instead of the latest 1.9 branch version.
Post Reply