Dplug icon indicating copy to clipboard operation
Dplug copied to clipboard

Drop onAnimate frames when dt is too small

Open p0nce opened this issue 3 years ago • 2 comments

Making a limit of accumulated 20ms before calling onAnimate can save CPU at little visual cost. Could be a counter inside UIElement that is checked before calling onAnimate (eg: 20ms).

  • [x] Do we want that UI-wide, or for each single UI Element? => I don't think it makes sense UI-wide
  • [x] What's the use case? It can be "no short animation steps" or "fixed animation step" => no short animation steps is kinda more needed
  • [x] At the same time, a global time measure on animation CPU cost can be helpful too. => much less so that (say) a flame graph that show widget display cost

Use case 1: Note: high feedback plugins may want to synchronize feedback in the same sync queue, in order to minimize scheduler lock (exiting a tryLock is a heavy operation anyway). And then it is helpful to have onAnimate for children called just after main gui.d onAnimate. Such a UI might need both "do not animate for low dt" and "animated with fixed dt" at the same time, and will batch setDirty calls likewise.

p0nce avatar May 10 '22 15:05 p0nce

Could be useful both UI-wide, and per element (use the greater of the two?). I would still want the ability to attempt 60fps (<16.6ms) for small elements though, so maybe the limit could be optional?

PolyVector avatar May 11 '22 23:05 PolyVector

Could be a UIElement field (another one) that says "don't animate me unless for at least N ms", and then they accumulate an animation "debt". Fixed timestep can be left out I think.

  • [ ] Implement that, 0 is default (no minimum)

Note: accumulating double dt means when the debt is paid back, the dt don't add up correctly though.

p0nce avatar Oct 13 '22 18:10 p0nce