Jump to content
  • Advertisement
Sign in to follow this  
kimryo

Why simple D3D app consume 100% CPU?

This topic is 4506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Main loop code as following: if(xGetMainWnd()->IsActive() || !(xGetApp()->GetAppstyles() & xApp::APPS_PAUSEONLOST)) bRet=(PeekMessage(&msg,NULL,0U,0U,PM_REMOVE)!=0); else bRet=(GetMessage(&msg,NULL,0U,0U)!=0); if(bRet){ TranslateMessage(&msg); DispatchMessage(&msg); xGetApp()->RenderProcedure(); } The Render proceudre only clear back buffer to black color and draws nothing. How to reduce it?Any indication is appreciate,thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Well, it's just running as fast as possible, it's not actually a CPU-intensive program or anything, if that's what you're worried about.

Try putting Sleep( 17 ); in there at the bottom if to bothers you enough.

Share this post


Link to post
Share on other sites
If you are the only person on a bus, the bus is devoting 100% of its resources to transport you to where you want to go.

Share this post


Link to post
Share on other sites
I don't understand why so many people worry about this; it's not like you're stealing time from other applications. If an application needs a resource, it's the OS responsibility to provide it. You can use Sleep() if you want to be extra nice to other apps, but then again who expects a 3D graphics program, of all applications, to be "nice"?

Share this post


Link to post
Share on other sites
Quote:
Original post by mikeman
I don't understand why so many people worry about this; it's not like you're stealing time from other applications. If an application needs a resource, it's the OS responsibility to provide it. You can use Sleep() if you want to be extra nice to other apps, but then again who expects a 3D graphics program, of all applications, to be "nice"?


Well, its pretty annoying when a 2D game (even a basic 3D game) is chewing through my laptop battery and burning a hole through my pants... Of course, no one expects Doom 3 to give of "extra" resources, since it needs them, but 3D pong doesn't need that much cpu time.

Share this post


Link to post
Share on other sites
Thanks everybody.
My current solution is to limit the 1000+ FPS to 60 to give time back to OS.
Now I use (1000/CurFPS)*(CurFPS-60) to calculate the time should "relax" during one frame in ms,as

RenderEverything();
Sleep( (1000/CurFPS)*(CurFPS-60) );

But it seems not so accurate,is there any good ways to achieve this?

Thanks again.

Share this post


Link to post
Share on other sites
The other way is to force VSYNC, so there is a pause after you've done all your logic and rendering while you wait for the monitor to refresh.

Does VSYNC work on laptops and LCDs?

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
The other way is to force VSYNC, so there is a pause after you've done all your logic and rendering while you wait for the monitor to refresh.

Does VSYNC work on laptops and LCDs?


Yep. And it definitely cuts down on the medical bills for burned thighs.

Share this post


Link to post
Share on other sites
The problem with vsync is that the refresh rate may be different on different video cards. My LCD is synced to 60 Hz, but my CRT can run over 100 on lower resolutions. Keep that in mind if you plan to base all the frame timing assuming 60 FPS.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!