Jump to content
  • Advertisement

Archived

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

mdias

Why does CPU usage is 100%

This topic is 5853 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, I''m making a 3D engine and when I''m running my program CPU usage goes up to 100%. I''ve seen my code and if I disable the line: Mesh->DrawSubset() CPU usage goes down to 1% or 2%.... I''ve made smaller engines before the big one I''m doing now and CPU usage was not bigger that 10%. Does anyone know what kind of coding can make this happen ??? Help would be appreciated Kamikaze

Share this post


Link to post
Share on other sites
Advertisement
I think I found the reason, it''s because of the p_D3Dpresentparams.EnableAutoDepthStencil
being set to TRUE.
I''ve set it to FALSE and things now are MUCH (I mean MUCH) faster
than before, and CPU usage is now 0% or 1% when moving the camera.

But I got a new problem!!
now the pixels that are empty (Not rendered with polygons) are
flicking from Green to Red every frame, and ZBuffer works no more.
How can I fix this ???

Kamikaze

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The green/purple is a feature in the debug runtime to spot holes in your geometry. Select the retail driver and it''s gone. You can also draw a background poly to cover it if it disturbes you.
Z-buffer should work though, do you clear it every frame?

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Select the retail driver and it''s gone.

no. you clear screen with Clear() and then it goes away. don''t ever work around your bugs, they will come back and bite you when you least expect it.

device->Clear() is the way to go.

Share this post


Link to post
Share on other sites
quote:
Original post by Kamikaze15
now the pixels that are empty (Not rendered with polygons) are
flicking from Green to Red every frame


you''re probably clearing ZBUFFER|RENDERTARGET and since there''s no zbuffer anymore, entire call fails. check your output window, you should have warning messages from dx runtime.
quote:
and ZBuffer works no more.


you didn''t create one, so you don''t have one.
quote:

How can I fix this ???


set autodepthstencil back to true.

Share this post


Link to post
Share on other sites
quote:
Original post by Kamikaze15
I'm making a 3D engine and when I'm running my
program CPU usage goes up to 100%.


this will always be the case if you're using standard game loop:

while (peekmessage()) processmessage();
else rungame();

"business" apps call getmessage() or waitmessage() that stop process when there are no pending messages, resulting in low cpu utilization, but a game always runs something, and occupies close to 100% cpu.


[edited by - niyaw on December 3, 2002 2:23:00 PM]

Share this post


Link to post
Share on other sites
I''ve had the problem of PeekMessage once, but I have
already solved it, and now ythe CPU utilization is
fine (0% or 1%)

I''m enabling the ZBuffer by doing:
p_D3Ddevice->SetRenderState( D3DRS_ZENABLE, true );

And when I''m clearing the screen I use the flags
D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER

If I set autodepthstencil back to true the number of
F/ps goes down to about 15 or 20 frames, I don''t know
very well ''cause I''m not testing it. However if the
autodepthstencil is FALSE the F/ps really increases to
about 50 or 70 F/ps, so I want it set to false

My problem is that when autodepthstencil is set to FALSE
to have an average rendering I have to render the objects
front-to-back. If ZBuffer works well I don''t have to render
objects front-to-back.

So my objects are all messed up, the one that should be at
the back of the other is in front etc.

Kamikaze

Share this post


Link to post
Share on other sites
My computer is drivin'' me crazy !!!!
now I can set p_D3Dpresentparams.EnableAutoDepthStencil
to TRUE withou Frame Rate loss....
I''ve done nothing !!!!!!!
Thanx for your help guys, I really appreciated it

Kamikaze

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!