on 02-07-2012 11:28 PM
Im trying to load assets in the background via a separate thread but the graphics framework isn't thread safe and crashes when i try to load a texture or using anything in the graphics framework. How do i go about making this so?
on 03-07-2012 02:27 PM
Did you try using mutex( c# lock(<variable name>) ) between the graphics calls? I know this could be slow but could work, and of course doing only when all other subsystem are running not when rendering.
on 05-07-2012 02:15 PM
Multi-threading on the graphics framework is currently not supported. For this reason, all your graphics calls have to be on the same thread.
on 05-07-2012 03:00 PM
Correct me if I'm wrong, but if he use locking and make a call from other thread and that thread use exclusive calls(mutex lock-unlock) on texture creation that will work. Is not at the same time but is loading data when doing other stuff like game update (physics/game logics/ etc etc). Ex:
Thread1 : running game logic update(nothing related with graphics);
Thread2: calling texture creation(only on this thread);
of course is possible that this hung too but...I need to review this again....
on 05-07-2012 03:59 PM
Is there an alternative for background loading?
All my assets load in around 2 seconds anyways but there are other games im due to port which utilize background loading heavily.
on 05-07-2012 05:00 PM
Since you can create textures using byte arrays, load them as streams(not png) and then in the main thread create the textures, but I'm sure that the other idea could work. Did you try it?
on 05-07-2012 09:15 PM
I tried it in a basic project and it still crashed. Its the Texture2D constructor where it crashes which doesnt need the context. I tried updating in a separate thread and leaving rendering on the main thread but its still the same issue with loading being on a separate thread.
on 06-07-2012 02:07 AM
Strange because I made a quick test today and works. I still sugest you to use a mutex on both resource manager and rendering,, did you us a kind of threadpool manager?
on 06-07-2012 09:47 AM
Ill give it another go. Haven't had much chance to play with it as the porting of the game is the higher priority as opposed to a 2 second load hang on the splash screen.
on 06-07-2012 03:22 PM
Please let us know the outcome of your test . In theory, you should be able to load all your Texture2D images on a seperate thread and pass them to your main thread when you need it.
If you still have the same problem, please feel free to post or pm me some code and we can investigate it further.
Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]