OGRE Using the new threading scheme
来源:互联网 发布:java小技术分享 编辑:程序博客网 时间:2024/06/05 10:34
by JeDi » Wed Nov 19, 2008 4:56 pm
Blog | Twitter
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
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
Top
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
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
Top
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!
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
- OGRE Using the new threading scheme
- Using MIT-Scheme in MacOS X on the Command Line
- Using the New MySQL Query Profiler
- Future of threading in Ogre
- Is it possible to simulate a new addressing scheme for MANETs using GNS3 ?
- 评率控论文“A New Rate Control Scheme Using Quadratic Rate Distortion Model”
- C# Threading Safety using Lock
- This page needs work The Complete Blanks Guide To Using The OGRE SDK AppWizard
- CentOS Setup the new Java binary as default using alternatives:
- PowerShell入门 - 2 (Using the New-Item Cmdlet)
- The BM25 Weighting Scheme
- The Wavelet Lifting Scheme
- Your boot partition is on a disk using the GPT partitioning Scheme but this machines cannot boot
- Linux - How to remove the new line at the end of file when using vim
- After clone Redhat machine by using vSphere, can't reach the new machine
- Using Claims in your Web App is Easier with the new OWIN Security Components
- How do I import a new Java CA cert without using the keytool command line utility?
- OGRE基础教程六 The Ogre Startup Sequence
- Oracle使用触发器禁止远程DDL操作
- native-activity 工程完全注解
- 深入剖析Linux中断机制之四 --中断API
- ant build.xml 配置
- spring配置datasource三种方式 数据库连接池
- OGRE Using the new threading scheme
- ubuntu 下编译库(so文件),解决库文件找不到错误
- Linux 下MongoDB的安装以及使用
- LVS/NAT 操作笔记
- CONTROL_FILE_RECORD_KEEP_TIME
- GEF入门
- Android api error
- data get
- 通过js调用java与.net 开发的webservices