diff --git a/docs/foundation.md b/docs/foundation.md index 00865cb..ab6457b 100644 --- a/docs/foundation.md +++ b/docs/foundation.md @@ -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; } diff --git a/src/parallel_for.c b/src/parallel_for.c index c4d7840..d444fa6 100644 --- a/src/parallel_for.c +++ b/src/parallel_for.c @@ -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, diff --git a/src/physics_world.c b/src/physics_world.c index af5a50e..2cea1d0 100644 --- a/src/physics_world.c +++ b/src/physics_world.c @@ -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; diff --git a/src/solver.h b/src/solver.h index 7c66a78..f7ae1ab 100644 --- a/src/solver.h +++ b/src/solver.h @@ -86,7 +86,6 @@ typedef struct b3StepTask b3TaskCallback* fcn; void* context; b3StepContext* stepContext; - bool deferred; } b3StepTask; typedef struct b3WorkerContext