Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Moleculo

DX9: huge file eating, eating up resources

This topic is 5397 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

Hi all, the following: I was fooling around a bit with the DX tutorials on http://www.drunkenhyena.com. I cut and paste the code for creating a window, compiled and it creates an exe. Very nice and all, but I have 2 problems with this. First: The file is rather large around 580kb (compiled on VC7 with DX9). Is this normal for an exe that does so little. Secondly: when running it after 10 seconds or so, it''ll be consuming 100% of my processor power (my cpu fan is running overtime): is this normal or is it because of my system; laptop amd1800, 256mb with no specifiec video card (takes its memory from the RAM I believe?

Share this post


Link to post
Share on other sites
Advertisement
Answer to the first: Was it a debug, cuz they usually are pretty big. Also, just link the files required (libraries).
Answer to the second: I don't know, what program were you expirimenting with?

[edited by - bcome on November 6, 2003 2:57:05 PM]

[edited by - bcome on November 6, 2003 3:02:40 PM]

Share this post


Link to post
Share on other sites
First: I am running DX SDK debug, so your suggestion makes sense; I''ll try that.

Second: It is just a program that does nothing more and nothing less than creating a window and changing some background colors in the window a bit (nothing special: so it should consume hardly any cpu cycles!)
But this is the simplest of program: I noticed pretty much every (DX) program I pluck of the web and compile eats up 100% of my cpu within 10 secs (including the example code from the DX SDK and also the precompiled code!)...
So my guess is, since I am running all of this on a laptop, that the laptops videocard isnt up for it (eventhough its supposed to be 32MB). But then again I am able to run games such as Half-Life and CS perfectly well..

Share this post


Link to post
Share on other sites
''It is just a program that does nothing more and nothing less than creating a window and changing some background colors in the window a bit (nothing special: so it should consume hardly any cpu cycles!)''

It''s not how much your program outputs per frame, it''s how many frames it puts out per second.

If you want your application to be less CPU intensive, you''ll have to restructure the main message loop to use GetMessage (as opposed to PeekMessage -- which I''m fairly sure it''s using now), and hook your rendering code to only occur when a WM_PAINT message is received. While this is more ''friendly'' to the CPU, it''s not suited to doing games (but may be fine if you just want to hack around with simple concepts on your laptop).

As a side note, any application can be made to eat up 100% of the CPU while doing seemingly nothing (it''s not a problem with DirectX 9). All you need to do is use a ''while(1)'' loop for the main part of your program, compile, run, and watch the CPU useage skyrocket.

Share this post


Link to post
Share on other sites
quote:

First: The file is rather large around 580kb (compiled on VC7 with DX9). Is this normal for an exe that does so little.


It depends on whether it has debugging information in it, etc. But for a program that does nothing it shouldn''t really matter, should it (I doubt your going to distribute it ) The percentage of the exe that is library code will quicky diminish once your app grows in size.
quote:

Secondly: when running it after 10 seconds or so, it''ll be consuming 100% of my processor power (my cpu fan is running overtime): is this normal or is it because of my system; laptop amd1800, 256mb with no specifiec video card (takes its memory from the RAM I believe?


As already stated, anything that goes into an infinite loop (using peekmessage instead of getmessage) will use up the cpu (even if it does nothing). But that''s normal for games because they need 100% of the cpu.

Share this post


Link to post
Share on other sites
(looks like I replied when Sysop was replying as well)

First: okay, thanx for the info I guess that''s clear to me now

Second: you say games are supposed to take up 100% cpu ???
I dont think so... I think there are very little programs that are supposed to (or are you pulling my leg here?)

Could this also change when I run this on a decent video card, since the videocard will take some of the load?

Sidenote: it''s indeed using PeekMessage.

Share this post


Link to post
Share on other sites
quote:
Second: you say games are supposed to take up 100% cpu ???

Sure. Every game takes up 100% CPU, because you want to get the highest FPS possible

Share this post


Link to post
Share on other sites
To add to what noVum said, there are other things most games do such as AI calculations, state updates, and retrieving user input which can take far more time than simply rendering a frames worth of graphics. The more time the game has to process and update such things, the better the experience can potentially become.

It is possible to write games that don't take up 100% of the CPU time, but they tend to be fairly simple, or don't need spectacular FPS to look good, or uber responsive controls to win (such as solitaire, minesweeper, checkers, etc).

Edit: 'Newer' video cards do help take some of the workload off of the CPU, but the time that is saved on the graphics processing can then be used for the other non-graphical aspects, which in my opinion is a 'good thing'.

[edited by - SysOp_1101 on November 6, 2003 7:52:20 PM]

Share this post


Link to post
Share on other sites
mmmm that''s very interesting....

Anyway this is what I plucked of the site also (maybe I should have read that before posting here (shame)):

The sample applications use 100% of my CPU, why don''t you use a timer?

The timers available through the Win32 API (WM_TIMER, etc) are low resolution and unreliable. You will not be able to reliably maintain a presentation rate of 60 frames per second using those timers.

Realistically, any running task that doesn''t sleep will use all the available CPU time. That''s the way it should work. All idle cycles are given to running tasks. Granted it may be hard to use your word processor while running my applications, but why would you want to do that anyway?

If you feel strongly about throttling your apps back, feel free to experiment with timers and add calls to Sleep().

Share this post


Link to post
Share on other sites
Games and demos that use a loop and peekmessage typically run at 100% CPU. I found that even a sleep(1) executed once in the loop can really lower the CPU usage (measures with task manager), without impacting frame rates.
Apparently present() also uses a busy wait loop so even a demo fixed at 60 fps uses 100%.

Share this post


Link to post
Share on other sites

  • 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!