Running irrlicht's beginScene with differen threads?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
L o
Posts: 44
Joined: Sun Mar 29, 2009 2:53 pm

Running irrlicht's beginScene with differen threads?

Post by L o »

Hello,

is it possible to run beginScene() with thread 1, and then with another thread, named thread 2? Also, is it possible to do the initial setup, like createDevice(), with a different thread as I run beginScene() with?

Here's a valgrind output:

Code: Select all

 
==11811== Thread 2:
==11811== Invalid read of size 4
==11811==    at 0x41637E6: ??? (in /usr/X11R6/lib/libGL.so.295.71)
==11811==    by 0x81096B9: irr::video::COpenGLDriver::beginScene(bool, bool, irr::video::SColor, irr::video::SExposedVideoData const&, irr::core::rect<int>*) (COpenGLDriver.cpp:840)
==11811==    by 0x8065661: IrrlichtBase::update_graphics() (irrlicht_base.cpp:67)
==11811==    by 0x8064E20: CoreModule::do_work_on_timeout(boost::posix_time::ptime const&) (core_module.h:38)
==11811==    by 0x40993B2: Task::do_exec(ThreadPool*, boost::posix_time::ptime const&, bool) (task.h:92)
==11811==    by 0x409944C: Task::exec(ThreadPool*, boost::posix_time::ptime, bool) (task.h:116)
==11811==    by 0x4099BB4: ThreadPool::do_work(int) (thread_pool.h:462)
==11811==    by 0x4097C88: ThreadBase::run() (thread_worker.cpp:66)
==11811==    by 0x44BFBC7: thread_proxy (in /usr/lib/libboost_thread.so.1.46.1)
==11811==    by 0x4400D5D: clone (in /lib/libc-2.11.3.so)
==11811==  Address 0x27c is not stack'd, malloc'd or (recently) free'd
==11811== 
==11811== 
==11811== Process terminating with default action of signal 11 (SIGSEGV)
==11811==  Access not within mapped region at address 0x27C
==11811==    at 0x41637E6: ??? (in /usr/X11R6/lib/libGL.so.295.71)
==11811==    by 0x81096B9: irr::video::COpenGLDriver::beginScene(bool, bool, irr::video::SColor, irr::video::SExposedVideoData const&, irr::core::rect<int>*) (COpenGLDriver.cpp:840)
==11811==    by 0x8065661: IrrlichtBase::update_graphics() (irrlicht_base.cpp:67)
==11811==    by 0x8064E20: CoreModule::do_work_on_timeout(boost::posix_time::ptime const&) (core_module.h:38)
==11811==    by 0x40993B2: Task::do_exec(ThreadPool*, boost::posix_time::ptime const&, bool) (task.h:92)
==11811==    by 0x409944C: Task::exec(ThreadPool*, boost::posix_time::ptime, bool) (task.h:116)
==11811==    by 0x4099BB4: ThreadPool::do_work(int) (thread_pool.h:462)
==11811==    by 0x4097C88: ThreadBase::run() (thread_worker.cpp:66)
==11811==    by 0x44BFBC7: thread_proxy (in /usr/lib/libboost_thread.so.1.46.1)
==11811==    by 0x4400D5D: clone (in /lib/libc-2.11.3.so)
Thanks for your help.

Greetings,
Johannes
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Running irrlicht's beginScene with differen threads?

Post by mongoose7 »

No. Only one thread can do the rendering. See elsewhere for how you can employ the other CPUs, but this is nontrivial.
L o
Posts: 44
Joined: Sun Mar 29, 2009 2:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by L o »

Thanks! I believe you, but only for interest: Why isn't it possible? I have seen such issues with Qt and SDL aswell, but never found out what the reason was...
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by hendu »

OpenGL is not thread-safe.
L o
Posts: 44
Joined: Sun Mar 29, 2009 2:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by L o »

If I use the NULL device on my application's server (which means no OpenGL), is it still then possible to handle beginScene() in different threads? After what has been said, it looks so, but can please someone guarantee?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by hendu »

beginScene with a NULL device does not make any sense...
L o
Posts: 44
Joined: Sun Mar 29, 2009 2:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by L o »

hendu wrote:beginScene with a NULL device does not make any sense...
We are using irrBullet for the server, and thus we thought we needed to use irrlicht, too. However, since it a server, we give irrlicht a null device. Does that make no sense?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Running irrlicht's beginScene with differen threads?

Post by hendu »

Certainly it's going through several unnecessary layers :P

I have no knowledge whether irrbullet depends on beginscene. Signing out of this thread.
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Re: Running irrlicht's beginScene with differen threads?

Post by d3jake »

I think for irrBullet, you only need to step the simulation, you shouldn't need to do any beginScene()\endScene() calls, or renderAll(), for that matter. the NULL device means you don't have to or can't do any rendering, so you shouldn't have to do anything render-related.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
Post Reply