Jump to content
  • Advertisement
Sign in to follow this  
Phantom5800

Resources being loaded in separate thread from renderer

This topic is 2342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, I have a threaded Resource Manager that queues up resources on the main thread, and then loads them on the resource thread. My question is, how do I handle creation of graphics resources? Obviously I can't create a gl resource (VBO, Texture, etc) on the resource thread. What is everyones opinion?

Do I force graphics resources to be loaded on the main thread? Or do I have some kind of check before using a graphics resource that says "If I haven't been initialized, do it now"? Or is there some other solution I haven't thought of that other people use?

Share this post


Link to post
Share on other sites
Advertisement
I use a lock-free queue, the loader thread will push elements and the graphics job(s) pull from it every frame. While GL's total lack of thread support (reason #456987 why Direct3D is better and you should use it, etc.) means you can't have more than one thread dequeuing items, you can probably use something very similar. The COFU idea is a bad one, IMHO, for a few reasons-- it's less predictable (queuing means all creates can happen in one, easily-trackable place and it's something of a data-parallel problem anyway) and it adds overhead to using a resource even after you've loaded it (branching once per resource per draw call is small but likely not entirely negligible, and that's without considering synchronization problems/ordering)

Share this post


Link to post
Share on other sites
Thanks for the advice. Unfortunately DirectX isn't really an option for me right now (cross platform engine without time to work on two renderers). After dealing with a race condition it all works nicely.

Share this post


Link to post
Share on other sites
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=234543

I don't know much about OpenGL, but I did find this thread which seemed to confirm that you can load on other threads. What operating systems are you using and what version of OpenGL?

P.S. In my opinion your resource loader system sounds perfectly reasonable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!