Skip to content

Geometric (OpenGL-less) picking

Daniel van Vugt requested to merge vanvugt/mutter:geometric-picking into master

Redesign picking to avoid using OpenGL. Previously picking involved several GL 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.

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.

Even regular repaints are now noticeably faster because the GL pipeline isn't getting stalled by a call to glReadPixels.

CPU usage on an Intel i7-7700, tested with two different GPUs/drivers:

Intel Nvidia
Moving the mouse:
Before 10% 10%
After 6% 6%
Moving a window:
Before 23% 81%
After 19% 40%

Closes: #154 (closed) Closes: #691 (closed)

Helps significantly with: #283 (closed), #590 (closed), #700 (closed)

Edited by Daniel van Vugt

Merge request reports