mdsteele / azimuth

A metroidvania with vector graphics
https://mdsteele.games/azimuth/
GNU General Public License v3.0
51 stars 15 forks source link

glFinish causes CPU saturation #10

Closed ghost closed 5 years ago

ghost commented 5 years ago

Azimuth has 100% CPU usage on my machine. (Annoying because my PC has always had a problem where it gets super noisy and then dies under prolonged excessive load (underpowered PSU maybe, I don't know). Azimuth manages to kill it in about 10 minutes :) ). The problem goes away if I comment out the glFinish call.

I don't believe glFlush and glFinish are needed in modern times, when you have vsync and SDL_GL_SwapBuffers. I think glFinish blocks until all draw commands are completed, which is not something you need, and it seems to do this in a very wasteful way.

Couple random links:

My machine: Ubuntu 18 and GeForce GTX 750 Ti. No idea if my drivers are up to date.

mdsteele commented 5 years ago

Thanks for tracking this down and for the writeup! Testing this on my Mac, removing the glFlush() and glFinish() calls seems to provide a significant reduction in CPU usage (from about 12% to about 9% with a release build of Azimuth), and doesn't seem to have any effect on the rendering. So yeah, seems like they should be removed.