AFAIK you'd have to implement that yourself to get portability. It won't be rocket science, there's just 2 APIs to wrap: POSIX and WIN32. I'm sure if you crack open boost's implementation it will be a single compilation unit/header, and you will see that's exactly what they've done. Just steal theirs
I wanted to try out, if i get the threading work with standard librarys.
Got some weird crashes in the stl thread files, where i dont want to dig deeper for now and gave up.
I'm using boost for threading now (ogre 2.1). But it seems the rendering still freezes if a new item enters the camera view...
The shader compilation seems to freeze the renderer.
What's the best practice?
Should that not be made in the background loading process?
Or should the shader compilation for all needed materials be done before loading a scene?
Can we precompile the shaders and load them at runtime?
Thyrion wrote:Or should the shader compilation for all needed materials be done before loading a scene?
Can we precompile the shaders and load them at runtime?
Note that on D3D11 the cache is system-agnostic but in GL the cache only works for that particular system until the drivers are updated.
The advice I give is to render a few frames with all/most possible material combinations you'll have on the real scene in order to warm up our caches. You could even run a scene after installation, fill all caches, and save it to disk to avoid delays during the actual game.
If the game later discovers the cache is no longer valid (i.e. GL drivers have been updated) then rebuild the cache again, just once (and inform the player in a clever way, e.g. "System changes detected. Optimizing performance cache. Please wait...").
Replacing boost/TBB threading with C++11 is not an option, because C++11 is not available in all compilers! There are a lot of people which are still using VS2010, VS2012 or VS2013 and not VS2015.
As c6burns has noted, a wrapper for POSIX and WIN32 is required. An additional option could be C++11 threads in this module.
Forums are great for communicating with people, but unfortunately they suck at making something visible for everyone, so I'm going to write this again:
STL's threading has no place in a high performance graphics library.
In particular, Visual Studio's STL implementation of threads sucks.
If it were by me, the current background resource loading mechanism could die in a fire. It's only been kept there because there is no replacement at the moment and some users have successfully been able to use it. But I don't particularly recommend it. But if you can make it work for you, and you're happy, I won't stand in your way.
I've used background resource loading system before, and it sucks in my opinion, i have to do nasty multithreaded coding in order to avoid race conditions and deadlocks (probably i misused it) in my own code, now i'm using a very different approach without relying exclusively from the OGRE's resource system, using the Helium's Project Asset System, it's a bit more complex than OGRE's but the background loading is pretty good for me.
I felt so well since dark_sylinc told us OGRE 2.1 multithreading doesn't need Boost/TBB/Poco because those libraries are a PITA to build (specially TBB and Boost), i prefer the old background loading system die, and if i can decouple OGRE and the ResourceManager system to access data.