Trouble with very slow rendering with nvidia under Linux

Started by
11 comments, last by floatingwoods 11 years, 2 months ago

Hello,

I have a cross-platform openGl application that works fine with most graphic cards. However, there are rare cases when rendering is very slow under following conditions:

- Linux (Ubuntu)

- Nvidia card (e.g. Nvidia NVS 5200 M)

The application runs a single thread (the main thread), and turns vsync off at the beginning (following is the Linux code to turn Vsync off):


typedef int (APIENTRY * AAAAGLSWAPINTERVALEXTPROC)(int);
AAAAGLSWAPINTERVALEXTPROC wglSwapIntervalEXT=(AAAAGLSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI");
if (wglSwapIntervalEXT)
{
    wglSwapIntervalEXT(0);
}

Rendering gets very slow because following functions seems to be blocking for several ms even with an almost empty scene content:


openglWidget->swapBuffers(); // Qt command

or/and

openglWidget->doneCurrent(); // Qt command

It seems that VSync could not be turned off! More strange is that following command:


export __GL_SYNC_TO_VBLANK=1

improves the rendering speed (but still takes around 40-50 ms for each frame).

what is going on here? Other platforms or other graphic cards do not have any problem at all. It is critical to be able to render as quickly as possible (disable vsync) for various reasons (e.g. rendering for generation of movie files).

Thanks for any insight!!

Advertisement

I'm not a linux expert, but under windows you often have the option to set the driver settings to overwrite application settings, including the vsync. Therefor check if your driver settings first.

Which drivers are you using? The default open source drivers have poor 3D performance, so make sure you have the nvidia's closed drivers installed.

You should get information with glGetString and also, make sure you have the drivers from nvidia installed and not MESA3D or some other software junk.

Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
This is a known bug in nVidia's binary blob drivers.

nVidia has been working with Valve to fix a number of performance issues. A newer (experimental) version 310 of the driver is available in the Ubuntu archives for testing with: it may solve this particular problem. On quantal this is the nvidia-experimental-310 package and on raring it's just nvidia-310. Try that and see if it solves your problem: you can always return to the default nvidia-current package if there are other problems.

Stephen M. Webb
Professional Free Software Developer

As others have said, my guess is the driver. Check this out https://help.ubuntu.com/community/BinaryDriverHowto/Nvidia

Driver 313.09 is out already.

http://www.phoronix.com/scan.php?page=news_item&px=MTI1MDA

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Driver 313.09 is out already.

I strongly do not recommend installing nVidia drivers directly from nVidia into Ubuntu.

(1) The nVidia drivers directly from Ubuntu are not packaged correctly: they follow the methodology of stomping all over your system without respect to the Ubuntu packaging, and it's difficult or impossible to back them out without reinstalling your system.

(2) Ubuntu tests the drivers before packaging them, and does not distribute drivers with known breakage (instead, they work with nVidia to remedy the situation in another driver release -- Canonical actually has full-time people working with nVidia to help with this).

Of course, it's your system. If you break it, you get to keep both halves.

Stephen M. Webb
Professional Free Software Developer

Of course, it's your system. If you break it, you get to keep both halves.

That's why I have /home on a separate partition :D

I did broke the graphical desktop environment a few times on Debian, just delete the nVidia script that blacklists nouveau and it works again. It wasn't because the drivers though, I had driver packages from Debian that conflicted with the ones I downloaded from nVidia.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

I did broke the graphical desktop environment a few times on Debian, just delete the nVidia script that blacklists nouveau and it works again. It wasn't because the drivers though, I had driver packages from Debian that conflicted with the ones I downloaded from nVidia.

The "package conflict" is because Debian installs various libraries using DEB packaging and the dpkg-alternatives system, symlinking driver-specific OpenGL shared objects so they get picked up at run time. The nVidia installer does not use packaging and simply clobbers the links with real libraries. You can tweak in the kernel modules all you want, you're effectively blixened once the packaging has been clobbered unless you carefully manually remove and re-symlink all the libraries as well. Don't miss one. Also, don't forget to remove the several-versions-out-of-date xorg.conf that nVidia installs.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement