Repository navigation
Conversation
|
Provides a new pull model task API. The current API is a push model. The pull model is more flexible and non-blocking. Push model: b2WorldDef def = b2DefaultWorldDef();
def.workerCount = 4; // [1, B2_MAX_WORKERS]
def.enqueueTask = MyEnqueueFunction;
def.finishTask = MyFinishTaskFunction;
def.userTaskContext = &MyTaskSystem;
myWorldId = b2CreateWorld(&def);
// later ...
while (running)
{
// ...
b2World_Step(myWorldId , timeStep, subStepCount);
// ...
};Pull model: b2WorldDef def = b2DefaultWorldDef();
def.workerCount = 4; // [1, B2_MAX_WORKERS]
myWorldId = b2CreateWorld(&def);
// later ...
// Somewhere on any thread.
b2TaskBatch batch = b2World_BeginStep(myWorldId, timeStep, subStepCount);
MyDispatch(batch);
// ...
// Later once the batch is done. Any thread. Keep calling this until done.
b2TaskBatch nextBatch = b2World_ContinueStep( myWorldId );
if (nextBatch.count > 0)
{
MyDispatch(nextBatch);
}
else
{
stepDone = true;
}Sometimes a batch has a deferred task that doesn't need to be joined until a later batch asks for it. Currently only one of these exist (the tree rebuild). |
| s_context.showControls = s_context.newUser; | ||
|
|
||
| s_context.workerCount = b2MinInt( 8, GetNumberOfCores() / 2 ); | ||
| s_context.workerCount = 1; |
There was a problem hiding this comment.
Intended or leftover from testing? Sample will always run with a single thread.
| .deferred = false, | ||
| }; | ||
|
|
||
| stepContext->batchCount += 1; |
There was a problem hiding this comment.
I'm unsure of the intentions around batch and task counts but this seems out of place? Not sure why batch and task would both be increased here unconditionally.
All8Up
left a comment
There was a problem hiding this comment.
Overall, a pass over this only noted the two items which looked questionable on the surface and I believe were only leading to informational reporting issues if they were actual errors. There were possibly a few documentation changes that don't match comments in code but that is always a bit difficult to verify in a diff view so might want to make a pass over them after the merge to be sure.
From what I can see, I should be able to get the concurrent execution model working and remove the hack I put in to spin on the physics completion. I'll give it a try as soon as possible and put it in my graphics perf testbed, figure if it can handle the 50k boids and allow overlapping concurrent work, that would be a pretty solid test.
No description provided.