Skip to main content
gamedev.net
🔒 Locked

Problem CPU usage

Started by gamedev8 3 replies 650+ views
Original Post
gamedev8
gamedev8
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...
swiftcoder
swiftcoder
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.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
rip-off
rip-off
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.
swiftcoder
swiftcoder
[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]
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
rip-off
rip-off
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.