• Advertisement
Sign in to follow this  

Render Time laggs every +- 1 sec

This topic is 2772 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,

This one baffels me completely.

When I render, about every second one frame would take plus minus X + 100ms to render, where the rest of the frames would render at Xms.

If im not clear enough. On average the frames would render at say, 40ms and then every 25th frame would take 140+ms to render. And all the time all the frames gets render the same way, as far as I can see.

Im using D3D9.

Share this post


Link to post
Share on other sites
Advertisement
First you should try to figure out where the additional time is burned. The simplest check here is to measure the time it spends inside the Present call.

What you might although check is if you allocate any resources inside your render loop. This can although cause stalls when the heap needs to be cleaned up.

Share this post


Link to post
Share on other sites
Quote:
Original post by Demirug
First you should try to figure out where the additional time is burned. The simplest check here is to measure the time it spends inside the Present call.

What you might although check is if you allocate any resources inside your render loop. This can although cause stalls when the heap needs to be cleaned up.


Cool, I'll have a look at this.

Share this post


Link to post
Share on other sites
this is the output of the delta time it took to "Present" with m_d3dDevice->Present( 0, 0, 0, 0 ), and it looks very inconsistent.

Note that there is nothing happening in my scene when I took these delta times, no animations or camera moving or things being drawn different or anything like that, I stood at a constant place in my scene when I took these delta times.

The time is in seconds

0.0462922
0.06112453
0.01720945
0.03615823
0.07129984
0.02106329
0.03527515
0.07011282
0.00008604
0.00009554
0.005107353
0.01618977
0.03664935
0.04424417
0.04020232
0.06294459
0.03231053
0.06017301
0.02805943
0.03923906
0.03404008
0.00009414
0.0001056
0.00009163
0.03019462
0.03490583
0.04021573
0.03801684
0.05405296
0.04409052
0.02509816
0.06810139
0.00009358
0.0678089
0.02816196
0.00009274
0.00009470
0.00009163
0.02619411
0.03536706
0.04041575
0.04232968
0.03396465
0.06560359
0.01413113
0.06929596
0.00009135
0.05595935
0.00008911



[Edited by - G-Man9566 on July 21, 2010 4:30:10 AM]

Share this post


Link to post
Share on other sites
Hmm, it's hard to tell.

It could be a bug in your timer implementation which is showing up as frame drops.

Maybe download and run fraps and see if that matches up with your frame-rate counter. At least that way you have cut out one of the potential problems...

Share this post


Link to post
Share on other sites
Quote:
Original post by Westie007
It could be a bug in your timer implementation which is showing up as frame drops.


thanks, but I have tested my timer before and it works very well, so its not that. when I do navigate through my scene, it actually feels like something is holding you back every +-1 second, when that frame takes longer to render than the rest.

Share this post


Link to post
Share on other sites
this is an example of my frame times in ms that I got from Fraps' benchmark utility.

214
25
26
44
50
71
71
90
47
68
95
67
42
61
215
27
27
30
56
74
75
61
70
71
67
66
72
67
217
25
26
25
67
49
68
80
84
43
61
84
87
42
61
215

Share this post


Link to post
Share on other sites
What function are you using as a timer? GetTickCount() (Very bad), timeGetTime() (Probably ok), or QueryPerformanceCounter() (Fine so long as you know it can give gibberish results sometimes)?

EDIT: Never mind if FRAPS is giving the same results.


You really need to run your code through a profiler and see what takes all the time on a "long" frame.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
You really need to run your code through a profiler and see what takes all the time on a "long" frame.


Ill do that. its just weird that if I startup my pc and run my engine directly after startup, then most of the time it does not do that one long frame every couple of frames.

I tested it once by starting up my machine and running the engine, no long frame, I then started skype and there goes the long frame, closed skype and the long frame stops. but after some time of operating on my pc it does not matter if I start or stop skype, it still renders on frame very long. Once, on another machine I ran GameBooster and then it stopped with the one long frame.

Could it be that I am handling my rendering sequence in Application::Idle. Im registering to the System::Application::Idle event and do Engine->Run in the function that is registered to that event.

Share this post


Link to post
Share on other sites
Since the lag occurs once a second, it may be that there's a background task on your system that's scheduled for 1 second intervals. If something has to be swapped out in memory between that background task and your app, that may cause delays in swapping memory. Admittedly, ~200 milliseconds is quite a delay!

Share this post


Link to post
Share on other sites
I think I found the problem.

I use D3DXCreateTextureFromFileEx() to create my textures. I also used D3DPOOL_DEFAULT as the mem pool, which looked like it uses much less (almost 3 x less) system mem than D3DPOOL_MANAGED. So I changed it back to D3DPOOL_MANAGED after I started to think that it might be a mem swapping out issue like this guy is having.

After I changed it to D3DPOOL_MANAGED, it stopped lagging every few frames, the frame time was much more consistent and my frame rate increased by 3x.

I would like to know why this is, but for now I just glad that my frame rate/time is back to normal.

Share this post


Link to post
Share on other sites
Quote:
Original post by G-Man9566
After I changed it to D3DPOOL_MANAGED, it stopped lagging every few frames, the frame time was much more consistent and my frame rate increased by 3x.

I would like to know why this is, but for now I just glad that my frame rate/time is back to normal.
What graphics card do you have? And are you creating any textures per-frame?
The default pool is driver managed, which essentially means the resource is in video memory. It should always be higher performance than D3DPOOL_MANAGED (Although D3DPOOL_MANAGED copes when you exceed VRAM capacity, which is the major benefit)

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
What graphics card do you have? And are you creating any textures per-frame?


I have a GeForce 9800M GTS and no im not creating any textures per-frame.

But, although I am now rendering much faster, I am running out of system memory (it looks like it) since I start to reach 1.6GB on a 32-bit XP machine when using managed pool.

Share this post


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

  • Advertisement