#ComputeTaskPool not completing by next frame

14 messages · Page 1 of 1 (latest)

versed gate
#

I'm inserting a ComputeTaskPool task (regenerating a changed mesh) as a component on an entity in PostUpdate, then polling them in PreUpdate. However, there's a visible gap before the new mesh is added despite ComputeTaskPools docs implying tasks will be completed before the next frame. Does using it in this schedule layout not work?

#

Specifically, I have a voxel game that handles inputs, which may include breaking a block - the input system adds a marker component that the mesh needs updating
The mesh should be updated by the next frame, otherwise it lags behind other entities which change (i.e. a highlight on the currently selected block)

#

Adding logging with FrameCount there's an 18 frame gap

cerulean garden
#

Unless sync evaluates to false, I would say it looks fine, although I haven't taken that good of a look yet...

versed gate
#

Seems like the problem is ComputeTaskPool doesn't automatically make sure everything's completed by next frame. par_splat_map runs tasks on the pool immediately and seems to be how this is intended to be used

solar wedge
#

I'm pretty sure there is no such guarantee. Why would you need compute pool if it finishes by the next frame. You could just use normal systems. Compute tasks are exactly a way to run some heavy computations over mutliple frames independently from the game loop.

#

Ie, they are ready when they are ready while your game can proceed as normal waiting for them to complete

sage heart
#

If you need a specific task to complete by the end of a frame (and you want other schedules to run in the meantime), I believe you can move the task into a system and block_on(task)

#

eg. if you wanted other schedules to be able to run between system A and the end of the frame, move the task from A into a resource, and then move the task out of the resource into a new task B added to Last or such with a block_on to wait on it

#

Generally speaking, game frames are pretty sensitive to timing issues that async can present, so a pool-wide flush or such would be fairly detrimental I believe

versed gate
#

Interesting, thanks

versed gate
solar wedge