fixes and simplification
This commit is contained in:
parent
878b5521fb
commit
69b2ad35e3
4 changed files with 12 additions and 11 deletions
|
|
@ -159,12 +159,12 @@ You can optionally connect your own task scheduler if you want more control. Mu
|
|||
```c
|
||||
// Implement b3EnqueueTaskCallback
|
||||
void* MyEnqueueTask(b3TaskCallback* task, void* taskContext,
|
||||
void* userContext, const char* taskName)
|
||||
void* userContext, b3TaskType taskType)
|
||||
{
|
||||
MyTask* t = AllocTask();
|
||||
t->task = task;
|
||||
t->taskContext = taskContext;
|
||||
Scheduler* myScheduler = (Scheduler*)userContact;
|
||||
Scheduler* myScheduler = (Scheduler*)userContext;
|
||||
SubmitToThreadPool(myScheduler, t);
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ static void b3RunStepTask( void* taskContext )
|
|||
|
||||
task->fcn( task->context );
|
||||
|
||||
if ( task->deferred )
|
||||
int index = (int)( task - stepContext->stepTasks );
|
||||
if ( stepContext->tasks[index].deferred )
|
||||
{
|
||||
if ( b3AtomicFetchAddInt( &stepContext->treePending, -1 ) == 1 && stepContext->signalSemaphores )
|
||||
{
|
||||
|
|
@ -52,7 +53,6 @@ void b3AddTask( b3StepContext* stepContext, b3TaskType type, b3TaskCallback* fcn
|
|||
stepTask->fcn = fcn;
|
||||
stepTask->context = context;
|
||||
stepTask->stepContext = stepContext;
|
||||
stepTask->deferred = false;
|
||||
|
||||
stepContext->tasks[index] = (b3Task){
|
||||
.fcn = b3RunStepTask,
|
||||
|
|
@ -73,7 +73,6 @@ void b3StageDeferredTask( b3StepContext* stepContext, b3TaskType type, b3TaskCal
|
|||
stepTask->fcn = fcn;
|
||||
stepTask->context = context;
|
||||
stepTask->stepContext = stepContext;
|
||||
stepTask->deferred = true;
|
||||
|
||||
stepContext->tasks[0] = (b3Task){
|
||||
.fcn = b3RunStepTask,
|
||||
|
|
|
|||
|
|
@ -1115,7 +1115,6 @@ static void b3LaunchTreeTask( b3StepContext* context, bool deferred )
|
|||
if ( deferred == false )
|
||||
{
|
||||
context->tasks[0].deferred = false;
|
||||
context->stepTasks[0].deferred = false;
|
||||
b3AtomicStoreInt( &context->treePending, 0 );
|
||||
}
|
||||
}
|
||||
|
|
@ -1460,8 +1459,6 @@ void b3World_Step( b3WorldId worldId, float timeStep, int subStepCount )
|
|||
return;
|
||||
}
|
||||
|
||||
B3_ASSERT( 0 < subStepCount );
|
||||
|
||||
b3TracyCZoneNC( world_step, "Step", b3_colorBox2DGreen, true );
|
||||
|
||||
if ( world->useScheduler )
|
||||
|
|
@ -1552,8 +1549,6 @@ void b3World_Step( b3WorldId worldId, float timeStep, int subStepCount )
|
|||
|
||||
b3TaskBatch b3World_BeginStep( b3WorldId worldId, float timeStep, int subStepCount )
|
||||
{
|
||||
B3_ASSERT( 0 < subStepCount );
|
||||
|
||||
b3World* world = b3GetWorldFromId( worldId );
|
||||
B3_ASSERT( world->locked == false );
|
||||
if ( world->locked )
|
||||
|
|
@ -2842,6 +2837,14 @@ static uint64_t b3GetWorldByteCount( b3World* world, bool log )
|
|||
b3Log( "pairSet: %d (%d, %d)", pairSetBytes, pairSet->count, pairSet->capacity );
|
||||
}
|
||||
|
||||
int stepContextBytes = (int)sizeof( b3StepContext );
|
||||
total += (uint64_t)stepContextBytes;
|
||||
|
||||
if ( log )
|
||||
{
|
||||
b3Log( "step context: %d", stepContextBytes );
|
||||
}
|
||||
|
||||
// Manifold block allocators, one per manifold point count
|
||||
int manifoldArrayBytes = b3Array_ByteCount( world->manifoldAllocators );
|
||||
int manifoldBlockBytes = 0;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ typedef struct b3StepTask
|
|||
b3TaskCallback* fcn;
|
||||
void* context;
|
||||
b3StepContext* stepContext;
|
||||
bool deferred;
|
||||
} b3StepTask;
|
||||
|
||||
typedef struct b3WorkerContext
|
||||
|
|
|
|||
Loading…
Reference in a new issue