Strategy for background loading

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
Ethon
Posts: 21
Joined: Wed Nov 30, 2011 10:01 am

Strategy for background loading

Post by Ethon »

Hi,
I searched for some time and I didn't find much information about this.

Two things:
1. I know that Irrlicht ist not threadsafe.
2. But I still want background loading.

Texture Loading:
The image loaders should be threadsafe, as they do no chaching. So I could load an IImage in a second thread and only do the conversion to an ITexture in the main thread.
Any better way to do this?

Mesh Loading:
If I am not wrong, the IMeshLoader implementations also don't use the cache, only ISceneManager does that. So it should also be threadsafe.
It should also be possible to use ISceneManager::getMesh if only one thread does the mesh loading, also if its another thread.

Are my considerations correct? I'd really like to avoid strange threading errors. ;)

Thanks,
Ethon
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Strategy for background loading

Post by greenya »

Ethon wrote:Texture Loading:
The image loaders should be threadsafe, as they do no chaching. So I could load an IImage in a second thread and only do the conversion to an ITexture in the main thread.
This is true.
Even more: you can call driver->addTexture() and removeTexture() from different threads, BUT this calls must be called between beginScene() and endScene() AND must be synchronized between each other, so one call at single time. MORE: this will work with DirectX driver, but not with OpenGL, since it requires switching context - and you must call actually addTexture() and removeTexture() from the thread where you have created the device.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Strategy for background loading

Post by hendu »

I went the other way, ie make it as fast as possible and spin a loading screen in between.

Faster caches + libjpeg-turbo + readahead to ram.
Post Reply