Trillian's picture

SwapBuffers abnormally slow, on my laptop only

Hello,

I've been working on a game on my laptop for more than a year. Recently enough, the game started to go really slow. This only occurs on my laptop and not on other systems, even if they have older graphics cards. On all other machines, the game still runs as smoothly as it always had.

I thought it might be a driver problem but I've tried reverting to configurations which had worked without results. I've profiled the game and 94% of the time is in the OpenTK.Platform.Windwos.WinGLContext.SwapBuffers() method, which again seems points to a driver problem. I've had a few weird unexplainable problems on this laptop but I hope there's an explanation and a solution to this one because it makes testing a pain.

The weird thing is that I can play other games without problem. I've even tried the OpenTK example "texture matrix wormhole" and it runs smoothly, wereas my game is horribly slow even when drawing only a few textured quads. I've also tried changing VSync, but it makes no difference.

I'd be surprised if this was a problem with OpenTK or my usage of it, but I hoped someone here had encountered this problem and has a solution.

Thanks for any help.

My system:
- Dell Inspiron 1520
- Core 2 Duo
- nVidia 8600m GT, driver 260.99 (the latest from nVidia's official website)
- Windows 7 Pro x86
- .NET 4 installed, but game uses 3.5
- Game compiled for x86 rather than AnyCPU
- OpenTK 1.0.278.44921
- Using the OpenTK GameWindow

Inline Images
Profile

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vmelkon's picture

What is the GL_VERSION and GL_RENDERER?

Trillian's picture

Your question lead me to the solution :)

Version "2.1.2"
Vendor "NVIDIA Corporation"
Renderer "GeForce 8600M GT/PCI/SSE2"

Nothing here seems to indicate the use of a software renderer. I went to my GameWindow initialization code to check the requested GL version and saw that I use a 8-8-8-8 bits ColorFormat (I use the alpha component for some cheap fixed-function texture splatting hack). I tried removing the alpha component and tada! Performance is back to normal, or even faster than it has ever been, and I most likely have discovered an important performance bottleneck. I'll just have to think of a less hackish way to do fixed function texture splatting until I implement shaders.

Thanks a lot. Testing is going to be a much more pleasant experience from now on. :)

the Fiddler's picture

Never heard of the alpha component causing problems before! Live and learn.

vmelkon's picture

GPU's prefer 8888 format rather than 888. 888 is converted to 888X where X is just a padding. Must be something weird in the nVidia driver. Also, I have the same GPU as you in my laptop and my GL version is 3.3 (although I use GL 2.0 in some projects and GL 1.1 in others).

Trillian's picture

Yeah it's quite weird. I recall the game working fine with this GPU in 8888 pixel format some time ago. As for the GL version, I'm requirering version 2.0 in the GameWindow setup code. Are you saying that when requirering that version (2.0), you still get a GL_VERSION of 3.3 for the same GPU?

c2woody's picture

Use the OpenGL extension viewer and GPU-Z to check if the drivers are working fine and provide correct OpenGL support.

Trillian's picture

The problem just came back, and is maybe worse than ever. I get about 0.5 fps and my profiler tells me all this time (90%+) is spent in SwapBuffers. Adding or removing the backbuffer alpha component doesn't change a thing. It seems like it was just a coincidence. I've had other such performance peaks, although none of them as flagrant.

So... I'm back to my original problem :/

c2woody wrote:

Use the OpenGL extension viewer and GPU-Z to check if the drivers are working fine and provide correct OpenGL support.

I have done so and haven't noticed anything unexpected (GL seems fully supported up to v3.3) except that GPU-Z indicates a GPU load of 0% when the game is running, but I don't know what I should be seeing here.

vmelkon's picture
Trillian wrote:

Yeah it's quite weird. I recall the game working fine with this GPU in 8888 pixel format some time ago. As for the GL version, I'm requirering version 2.0 in the GameWindow setup code. Are you saying that when requirering that version (2.0), you still get a GL_VERSION of 3.3 for the same GPU?

I make a context with the old fashion way because I don't need GL 3.0 or 3.3 forward context. I really do want to support older GPUs as well.
However, the driver reports 3.3 which is normal.

In your case, your drivers are old. Get your laptop drivers from nvidia.