on 02-07-2012 11:28 PM
Hey
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
Hi:
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.
Cheers,
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
Hi:
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....
Cheers
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
Hi:
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?
Cheers,
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
Hi:
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?
Cheers,
Alex
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.
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


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]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870