Geometric (GPU-less) picking
Redesign picking to avoid using the GPU. Previously picking involved several GPU operations per mouse movement, but now the GPU/GL isn't used at all.
By avoiding OpenGL and the graphics driver we also reduce CPU usage. Despite reimplementing the logic on the CPU, it still takes less CPU time than going through GL did.
Moving around a standard 125Hz mouse on an Intel i7-7700:
- before: 10% CPU, 1% GPU
- after: 6% CPU, 0% GPU
which is a 40% relative reduction in CPU usage according to 'top'. Although according to Google Profiler the improvement can be between 35% and 64% (typically around 50%) relative reduction in CPU usage when moving the mouse.
This new approach also dramatically reduces the number of picking paint cycles required for cursor movement since the pickability of the entire screen is calculated and cached. The cache is only invalidated when the screen contents change so for typical desktop usage where the screen is mostly idle, cursor movement doesn't incur anywhere near as many paint cycles as it used to.