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?
#ComputeTaskPool not completing by next frame
14 messages · Page 1 of 1 (latest)
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
Unless sync evaluates to false, I would say it looks fine, although I haven't taken that good of a look yet...
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
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
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
Interesting, thanks
ComputeTaskPool is for 'CPU-intensive work that must be completed to deliver the next frame'
A newtype for a task pool for CPU-intensive work that must be completed to deliver the next frame
Nice, I didn't thought we have Async one separately as there seems to not be that much of need for non-async one to me. If it doesn't work as expected please open a gitlab issue and in the meantime perhaps try using something like rayon lib(consider also that queries have parallel iterators if that would make sense in your scenario).