Sign in to follow this  
gamedev8

Problem CPU usage

Recommended Posts

Hi, I'm new to directX programming. I am facing a problem when I'm run a program. It creates a device, can toggle between full screen / windowed. There is no error. But whenever I run this program it uses CPU of 45-50%. It's not desired. I need help how to reduce this usage of CPU . Thanks...

Share this post


Link to post
Share on other sites
You reduce CPU usage by spending less time in your program. First off make sure you are double-buffered and vsync'ed, as you don't want to be rendering any faster than the screen refresh rate - in fact, you may want to vsync to 1/2 the refresh rate (which would make it about 30 fps) to reduce usage further.

After that, offload as much work as possible to the GPU, which will again lower CPU usage.

Share this post


Link to post
Share on other sites
Use other programs.

If your processor would otherwise be idle, why wouldn't it soak up all those cycles that would be wasted doing nothing?

Alternatively, you can tell the processor you don't want to run by using a call like Sleep (windows) usleep (linux / maybe mac) etc.

Share this post


Link to post
Share on other sites
[Off topic]
Quote:
Original post by rip-off
Alternatively, you can tell the processor you don't want to run by using a call like Sleep (windows) usleep (linux / maybe mac) etc.

I wonder about Windows here, shouldn't the swap buffers call do this for you? Especially in the presence of vsync, it should be a blocking syscall/whatever that invokes the scheduler, no?
[/Off topic]

Share this post


Link to post
Share on other sites
I don't know whether it always blocks, it depends. Some driver configurations leave it up to the program, and if the program doesn't specify it might not force it. On my computer it appears to default to not blocking.

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