Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

tbb and 3d engine

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

im using intel thread building blocks for my 3d engine and im havin some problems with coming up with a good design... right now ive got several different sub systems which each create a "task" and then create as many sub task as they can... soo when i run my main loop i create a task for each subsystem and then wait for them to finish and synchronize the shared data... main_loop renderTask = renderer->CreateTask(); simulationtask = simulation->CreateTask(); spawn_and_wait_for_all({renderTask , simulationtask }); synhronize_shared_data(); this works very well and im getting full utilization of all my cpu cores... the problem however arises when i want to run the different subsystems with different frequencies... id like to simply bind each subsystem to a timer that creates the task on the predefined frequencies... but im unsure how i couldo do this in a task based system like intel thread building blocks... any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
How about have the update loops inside the tasks?
e.g.
[source lang = "cpp"]
mutex renderDataMutex;
struct RenderData
{
// ...
};

RenderData globalRenderData;

void update_render_data( RenderData& data )
{
RenderData localCopy;

{
scoped_lock copyLock(renderDataMutex);
localCopy = globalRenderData;
}

while(!done)
{
localCopy.update(); // or update(localCopy) or whatever

{
scoped_lock updateLock(renderDataMutex);
globalRenderData = localCopy;
}
}
}

void perform_render()
{
RenderData localCopy;

while(!done)
{
{
scoped_lock updateLock(renderDataMutex);
localCopy = globalRenderData;
}
render(localCopy); // or localCopy.render() or whatever
}

}




That would be pretty much the most simple way to do it. Another, more tricky, way to do it would be to increase the lock granularity and have no thread local copies of the entire data set, just lock around operations that absolutely must be atomic.
BTW in case you hadn't noticed I don't know the TBB API.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!