Drakemor's picture

[SOLVED] Big CPU usage on GeForce 8800 GT

Why so big CPU usage? I have 40-50% all the time (code is below)?
When I add some VBOs it goes up to 90%.

I believe to have decent machine, but even on slower PC's blank screen shouldn't eat so much CPU power.


WinXP 32bit, and NVIDIA GeForce 8800 GT, 4GB RAM.

I read other posts suggesting to enable VSync and added Thread.sleep, but that didn't change a thing.

Code below.

using System;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
 
using OpenTK.Platform;
 
namespace ngine
{
    public class Game : GameWindow
    {
        public Game() : base(800, 600){}
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            VSync = VSyncMode.On;
            Mouse.Move += new EventHandler<MouseMoveEventArgs>(Mouse_Move);
        }
 
        void Mouse_Move(object sender, MouseMoveEventArgs e)
        {
            if (!Mouse[MouseButton.Right]) return;
            Title = "X: "+Mouse.X + " Y: " + Mouse.Y;
        }
 
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            CursorVisible = !Mouse[MouseButton.Right];
            System.Threading.Thread.Sleep(1);
        }
 
        protected override void OnRenderFrame(FrameEventArgs fea)
        {
            base.OnRenderFrame(fea);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            SwapBuffers();
            System.Threading.Thread.Sleep(1);
        }
 
        [STAThread]
        public static void Main()
        {
            using (Game example = new Game())
            {
                example.Run(60);
            }
        }
    }
}

Comments

Comment viewing options

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

Try running in release mode outside visual studio. Also setting the Title is rather costly - what happens if you remove that line?

Drakemor's picture

As you may overlooked - I'm setting title only if RMB is pressed. I removed that line, and nothing changed.

Running in Release Mode from .exe didn't change anything.

JTalton's picture

I believe I am seeing the same issue. The interesting thing is, I see it on one machine, I do not see it on the other. Both are running Win7 64-bit. I'll profile it tonight on the system that is showing the issue.

Drakemor's picture

Yeah. I've send this code to some people - and they don't complain about CPU usage.

JTalton's picture

With your code I am not seeing any different between my two test machines. Very low CPU usage.
My project on the other hand, uses 2% on one machine and 50% on the other, which is a lot like what you are seeing. But I can't reproduce your issue.

JTalton's picture

Testing, I would randomly get either 800FPS, 150 FPS, or 46FPS, consistently for that run. Profiling the 46 FPS, it seems like the issue is the call to SwapBuffers taking up 95.6% of the time. It is interesting that I also have a NVidia 8800 GT. My machine with the ATI card does not see this issue at all. Updating drivers to the latest (1/18/2011) seems to have fixed the issue.

Drakemor's picture

Updating drivers to the latest (18.01.2011) fixed the issue.

Thanks for the tip!!! I buy you a beer when you'll be around Łódz@Poland