您的位置:首页 > 其它

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐