by kiririn · 3y ago · 0 comments
sad to see another linux api design failure
Telling a graphics card "here's a bitmap, please render it at these coordinates, over the framebuffer content" is so much easier and more efficient than, in the earlier days, rendering a cursor into the framebuffer (and then undoing that for the next frame), at the rate where this needs to happen (pretty much every frame) to boot.
I don't know if in modern times, this could be reasonably achieved through compositing, but I suspect "here's the bitmap, render it here" is still easier, conceptually at least.
> of an idea so clearly implemented in software.
As an aside, many hardware things are ideas that could be clearly implemented in software.
Evidently it can, as Wayland does it, but the result is pretty mediocre.
2: Hardware cursors of old were akin to sprite hardware on consoles, here the hardware did compositing (or pre-compositing) operations on a per-line basis just before sending the frame contents to the display.
On platforms like the C64 you only had 8 sprites in hardware but if you tuned your code to race the display processor you could have more by updating the sprite positions to lines below (so still limited to 8 per line but non-overlapped it was possible to have more).
3: Looking at WDDM there seems to be 2 ways cursors could be handled, either Windows uses overlays under the hood for the cursor (if overlays support operations like alpha-blending automatically) or the compositor pre-empts the GPU when it's time for an display update, modern GPU's are fast enough that compositing operations should be able to finish quickly enough to meet frame-times but if done off-screen for safety it could be producing an extra frame of latency. Regardless the GPUs should be fast enough today to make it happen whenever needed even if not using the classic ways.
You can sort of solve it by ensuring the frame is generated (or at least the cursor added to it) just in time for vsync (ie as late as possible) but it won’t be as good as a traditional hardware cursor
If you ever had the “fortune” to get a kernel that is brokenly busy, you might have seen a completely irresponsive static image, but the cursor might still move. This is also due to this.