OGRE Using the new threading scheme
2013-01-15 16:34
435 查看
by JeDi » Wed Nov 19, 2008 4:56 pm
Hi,
I upgraded to Ogre 1.6, and want to make use of the new threading scheme (OGRE_THREAD_SUPPORT = 2). We have a fairly complex resource system on top of Ogre (because we use our "engine" on a lot of systems, some not using Ogre, some not even graphical), so we
have our own background thread doing paging and resource loading.
I just used to call SceneManager::createEntity in our background thread, because I had full threading enabled in our previous version. But I want to do it properly now. The resources are downloaded from a server on the fly. I want to process the meshes, materials
and textures in the background thread. What would be the proper way to do this?
I can't find a lot of information/documentation about this subject, but my idea for now is to create the resources in our background thread, and also call Resource::prepare there. Then queue the entity with a mutex around the queue, and process it in a frame
listener (so in the main thread). Does this sound OK, or am I thinking in a very wrong direction?
Any help appreciated.
Greetz,
JeDi
JeDi
Gnome Posts: 351 Kudos:
3 Joined: 21 Oct 2004 Location: Diepenbeek, Belgium
Website
Top
by
sinbad » Wed Nov 19, 2008 7:51 pm
In OGRE_THREAD_SUPPORT = 2 mode, only the 'preparation' of resource data should be in a thread other than the graphics thread. That means cacheing data from the filesystem or from some other slow medium, or calculating the data if it's
procedural. It's important that nothing in that separate thread can create any GPU resources - that is the essence of OGRE_THREAD_SUPPORT = 2, in that the graphics API (D3D, GL) can continue to run in single-threaded mode with no locks, which is considerably
faster than the situation with OGRE_THREAD_SUPPORT = 1, which let you create GPU structures if you wanted but therefore required the graphics API to be fully threadsafe, which has an overhead.
The original discussion about this is here: http://www.ogre3d.org/phpBB2/viewtopic. ... ght=thread
Blog |
Twitter
sinbad
OGRE Founder (Retired)
Posts: 25862 Kudos:
61 Joined: 06 Oct 2002 Location: Guernsey, Channel Islands
Website
Top
by
JeDi » Wed Nov 19, 2008 9:19 pm
Thanks, that confirms that my thoughts were on the right track.
I'm still getting used to this. I parse the material and prepare the mesh in the background thread and then queue the entity so that it is created in the graphics thread. Will it work that way? Or do I have to explicitly load the mesh first? I guess I have
to queue destroying the entities (when they're paged out) too?
Edit I implemented it this way, and it works perfectly. A lot smoother than with full threading! Thanks a lot for these improvements!
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=45943
Hi,
I upgraded to Ogre 1.6, and want to make use of the new threading scheme (OGRE_THREAD_SUPPORT = 2). We have a fairly complex resource system on top of Ogre (because we use our "engine" on a lot of systems, some not using Ogre, some not even graphical), so we
have our own background thread doing paging and resource loading.
I just used to call SceneManager::createEntity in our background thread, because I had full threading enabled in our previous version. But I want to do it properly now. The resources are downloaded from a server on the fly. I want to process the meshes, materials
and textures in the background thread. What would be the proper way to do this?
I can't find a lot of information/documentation about this subject, but my idea for now is to create the resources in our background thread, and also call Resource::prepare there. Then queue the entity with a mutex around the queue, and process it in a frame
listener (so in the main thread). Does this sound OK, or am I thinking in a very wrong direction?
Any help appreciated.
Greetz,
JeDi
JeDi
Gnome Posts: 351 Kudos:
3 Joined: 21 Oct 2004 Location: Diepenbeek, Belgium
Website
Top
by
sinbad » Wed Nov 19, 2008 7:51 pm
In OGRE_THREAD_SUPPORT = 2 mode, only the 'preparation' of resource data should be in a thread other than the graphics thread. That means cacheing data from the filesystem or from some other slow medium, or calculating the data if it's
procedural. It's important that nothing in that separate thread can create any GPU resources - that is the essence of OGRE_THREAD_SUPPORT = 2, in that the graphics API (D3D, GL) can continue to run in single-threaded mode with no locks, which is considerably
faster than the situation with OGRE_THREAD_SUPPORT = 1, which let you create GPU structures if you wanted but therefore required the graphics API to be fully threadsafe, which has an overhead.
The original discussion about this is here: http://www.ogre3d.org/phpBB2/viewtopic. ... ght=thread
Blog |
sinbad
OGRE Founder (Retired)
Posts: 25862 Kudos:
61 Joined: 06 Oct 2002 Location: Guernsey, Channel Islands
Website
Top
by
JeDi » Wed Nov 19, 2008 9:19 pm
Thanks, that confirms that my thoughts were on the right track.
I'm still getting used to this. I parse the material and prepare the mesh in the background thread and then queue the entity so that it is created in the graphics thread. Will it work that way? Or do I have to explicitly load the mesh first? I guess I have
to queue destroying the entities (when they're paged out) too?
Edit I implemented it this way, and it works perfectly. A lot smoother than with full threading! Thanks a lot for these improvements!
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=45943
相关文章推荐
- Using IIS with VS 2005 and the new Web Project system
- paper:synthesizable finite state machine design techniques using the new systemverilog 3.0 enhancements 之 FSM Coding Goals
- Fw:Managing View State in ASP.NET 4 Using the New ViewStateMode Property
- How can I add a new user as sudoer using the command line?
- MS Bigdata HDInsight -Process, analyze, and gain new insights from big data using the power of Apache Hadoop
- [Chapter 3 Process]Practice 3.5 When a process creates a new process using the fork() operation
- How do I import a new Java CA cert without using the keytool command line utility?
- Using XSLT files with the new XMLDataSource control(转)
- paper:synthesizable finite state machine design techniques using the new systemverilog 3.0 enhancements 之 standard verilog FSM conding styles(二段式)
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之enhanced coding styles
- Using Claims in your Web App is Easier with the new OWIN Security Components
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之output encoded style with registered outputs(Good style)
- 评率控论文“A New Rate Control Scheme Using Quadratic Rate Distortion Model”
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之全0/1/z/x的SV写法
- Linux - How to remove the new line at the end of file when using vim
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之onehot coding styles(index-parameter style with registered outputs)
- Using the New MySQL Query Profiler
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之onehot coding styles(encoded-parameter style with registered outputs不推荐但是经常有人写这样的代码)
- Using the New MySQL Query Profiler
- Your boot partition is on a disk using the GPT partitioning Scheme but this machines cannot boot