Jump to content
  • Advertisement
Sign in to follow this  
chris2001net

Render list + render thread

This topic is 2701 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

I'm finding little information on organising render data and wondering what others do for this situation:

My game has a seperate render thread which renders a prepared visible list of world entities, each list item contains transformation & animation info for the entity.

It crashes when the game thread updates the object render list as the render thread is trying to use it.

To solve this I'm thinking of having two lists where one list is drawn while the other is updated on the other thread. Then flip and repeat.

Is this generally how others have solved this problem? Thanks

Share this post


Link to post
Share on other sites
Advertisement
You could do it with two nice and easy, but that'll probably take up more memory etc. You could make the render call wait until the render queue is ready to be rendered and then fill up the render queue a frame before it gets used? So just after you've finished copying your queue to the graphics memory, you can set a flag to say that it is ready to be rendered and also set another to say that you can start filling up the queue again.

Share this post


Link to post
Share on other sites

To solve this I'm thinking of having two lists where one list is drawn while the other is updated on the other thread. Then flip and repeat. Is this generally how others have solved this problem?
Yes this is one common solution - known as double-buffered data.
When you perform the flip, you need to ensure that the update thread has finished writing to it's buffer, and that the render thread has finished reading from it's buffer. You'll likely use one critical section for each buffer, so that each thread can lock one of them at a time. In order to perform the flip, one thread will have to lock both of them.

[color="#1C2837"]Check out Multicore Programming Two Years Later for some examples of double-buffered data, and other solutions.

Share this post


Link to post
Share on other sites
Thanks Hodgman just what I needed! I like the idea of maintaining a smaller mirrored data set for the render thread ( just updating changes instead of preparing a whole list )

Good to confirm I'm on the right track.


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!