Loading textures in thread

In my app, I need to load lots of textures in an asynchronous manner (To be able to display a planet and zoom on it at any level, I have virtual textures, split into a huge tree of textures patches that are loaded on demand).

To avoid any lagging or stuttering, I’m loading these textures in a separate thread from the main thread and I’m using a callback mechanism to be notified across threads that the textures are ready.

“In the past”, it was working fine, but “recently” I noticed that the loading was no longer smooth but rather behaved as if the texture were loaded synchronously. I put quotes because I can’t really remember when that happened as I was busy switching to 1.11 and converting my code to use the new async feature.

Using PStats, and creating the thread into a new taskchain, I discovered that the texture read is done inside the main task although the call to Texture.read() is clearly inside the specific thread. So I assume there is something either due to the switch to async or due to changes in Texture.read()

As they say, don’t debug late at night, you might miss the obvious :slight_smile:

in this case a synchronization point added for debugging that I forgot to remove… Without it, the texture loading in a separate thread is working smoothly and lightning fast !