I am hoping someone from Nvidia will take a few moments to read this and maybe shed some light on this issue for me and others.
I am writing a desktop application in OpenGL. One of the main priorities in a mutlitasking desktop application is to co-operate with the other applications running on the system.
I feel the Linux/FreeBSD drivers have a broken implementation
that means desktop applications cannot be successfully developed for this card.
Under the Windows
drivers, I can turn on vertical syncing and this allows me to only render the frames I need to. Whilst the application is "waiting" for the next vertical sync to occur, the SwapBuffers() call blocks the application/thread so no CPU time is used unnecessarily. Basically, this means that the application uses < 3% CPU time overall, as most of its life is spent "waiting" in the SwapBuffers() call.
Under the Linux/FreeBSD
drivers, if I turn on vertical syncing, the SwapBuffers() call uses a busy-loop whilst waiting for the next vertical sync to occur. This results in 100% of the CPU time being used unnecessarily. This means the application uses 100% CPU time, even when doing very little, thanks to the inefficiency of the SwapBuffers() call. An application that always uses 100% of the CPU is awful for a desktop environment and degrades performance of the whole system.
Now, this was not always the case so I have been told! Apparently, once upon a time, one could sucessfully block the application/thread (so no CPU time is used) while waiting for the vertical sync by issuing a poll() on "/dev/nvidia0". Basically this would do the job:
pollVerticalSync.fd = verticalSyncFD;
pollVerticalSync.events = 0xffff;
pollVerticalSync.revents = 0xffff;
verticalSyncFD = open("/dev/nvidia0", O_RDONLY);
poll(&pollVerticalSync, 1, -1);
Unfortunately, this does not work, and has not for a long time. The poll() returns instantly, instead of blocking until the next vertical sync.
So, please Nvidia, how are we supposed to write desktop applications, that sync to the vertical refresh of the monitor (important for some video work etc.) without any efficient way of handling the vertical sync? The Windows implementation works fine, this is a major setback for Linux/FreeBSD workstation
Dynamic Expression Ltd., UK.