Sign in to follow this  
floatingwoods

OpenGL Trouble with very slow rendering with nvidia under Linux

Recommended Posts

floatingwoods    364

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!!

 

 

 

 

Share this post


Link to post
Share on other sites
Ashaman73    13715

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.

Share this post


Link to post
Share on other sites
V-man    813

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.

Share this post


Link to post
Share on other sites
Bregma    9199
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.

Share this post


Link to post
Share on other sites
Bregma    9199

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.

Share this post


Link to post
Share on other sites
TheChubu    9446

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.

Share this post


Link to post
Share on other sites
Bregma    9199

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.

Share this post


Link to post
Share on other sites
TheChubu    9446

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

Yep, I know. Had to delete a few soft links here and there (pretty much the standard approach to installing newer GCC versions too) Re installing the Debian packages should remake all the links if you want to go back. Dunno why is a big issue.

 

Anyway, whatever suits your boat. Its fun to me to install new drivers and see what's new. Somebody may want to wait until everything just works, its fine by me.

Share this post


Link to post
Share on other sites
Bregma    9199

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

Yep, I know. Had to delete a few soft links here and there (pretty much the standard approach to installing newer GCC versions too) Re installing the Debian packages should remake all the links if you want to go back. Dunno why is a big issue.
 
Anyway, whatever suits your boat. Its fun to me to install new drivers and see what's new. Somebody may want to wait until everything just works, its fine by me.

Installing the Debian package will not restore the symlinks. That was my point. It will simply fail.

 

I don't have a problem if you like to install third-party software and tweak your system, or if you like to customize the kernel and build your own gcc -- I do it all the time.  Where the problem happens is when I have to spend time addressing complaints from someone because "someone on a forum somewhere on the web told me to do it this way and it broke my system, and now it's broken, it's your fault and Ubuntu sucks, tell me how to fix it right now."

 

So, anyone can go ahead and munge their system.  I still strongly recommend against doing so unless you already know how to recover, in which case you probably wouldn't be asking here for advice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

    • By altay
      Hi folks,
      Imagine we have 8 different light sources in our scene and want dynamic shadow map for each of them. The question is how do we generate shadow maps? Do we render the scene for each to get the depth data? If so, how about performance? Do we deal with the performance issues just by applying general methods (e.g. frustum culling)?
      Thanks,
       
  • Popular Now