Hi everyone!
In my game I load things dynamically (Static meshes, skinmeshes, terrains, images etc.)
and of course the game freezez up when the loading occurs
so I'm looking into ways to remove those freezes using a loading-thread.
I've done some searches and if I understood correctly:
You can't mess with the scenegraph in another thread.
You can't load up textures or meshes to another scenemanager in another thread as different scenemanagers share caches.
So the question is, can you load up things in memory and let main thread add it to the scenegraph when it is done?
or can you have an invisible node (so that the draw calls won't be affected by it or by its childs) and load up things to it
(say a mesh+texture) in the loading-thread and when it is done, main thread can move the newly loaded data to the correct place?
Or maybe there is another way to do it?
Thanks!
Multi threaded Loading
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
There are two critical things in this process. One is the handling of the scene graph. You don't need two scene managers, because loading just the mesh (without adding a scene node) does not touch the scene graph. And AFAIK, the mesh cache is not that fragile.
Loading textures (which also happens in the mesh loading phase) does not work from different threads, though. Simply because the texture creation involves the GPU/hw driver as well. And there's no easy way around.
Loading textures (which also happens in the mesh loading phase) does not work from different threads, though. Simply because the texture creation involves the GPU/hw driver as well. And there's no easy way around.
Thanks for the answer hybrid!
I guess the most of the 'freeze' time concerning texture creation (but I can be wrong for sure)
goes to disk access and much less to the AGP/PCI-Express bus data transfer and other driver related things.
If that's so, is there a way to preload the texture into memory and then in
the main thread create the new texture from memory instead of from disk?
I guess the most of the 'freeze' time concerning texture creation (but I can be wrong for sure)
goes to disk access and much less to the AGP/PCI-Express bus data transfer and other driver related things.
If that's so, is there a way to preload the texture into memory and then in
the main thread create the new texture from memory instead of from disk?
Yes, load an IImage instead of a texture. This will take them from disk but not put them into graphics memory, you can create the textures manually in the graphics thread.
Models (VBOs) are added and removed into GPU memory on the fly, so no need to worry about them. You may need to hack the mesh loaders to make sure they don't create textures though.
Models (VBOs) are added and removed into GPU memory on the fly, so no need to worry about them. You may need to hack the mesh loaders to make sure they don't create textures though.
It will be interesting to see if we could, at the end of this, add in a loader that will allow things to be rendered while a mesh is being loaded, removing the usual stall related to loading a mesh.
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
"I'll find out if what I deleted was vital here shortly..." -d3jake
Hi,
I very interest in this topic too, if we could implement this feature in irrlicht core as generic task based system multicore hardware could be detected and equivalent thread number created, it could be used in Filesystem, Scene paging, loading mesh, etc...
We could talk in Open development thread and design something.
What you think?
I very interest in this topic too, if we could implement this feature in irrlicht core as generic task based system multicore hardware could be detected and equivalent thread number created, it could be used in Filesystem, Scene paging, loading mesh, etc...
We could talk in Open development thread and design something.
What you think?