Stuttering in windowed DX9

Started by
2 comments, last by gabe83 15 years, 5 months ago
I am writing a small Direct3D 9 (unmanaged) demo in which i have an height field with different levels of detail. When in windowed mode, switching to the higher levels of detail causes the frame rate to begin stuttering every 2 seconds or so. At first i thought it could be the driver having to thrash video memory because of the big vertex buffer i was using, but after some time spent testing i noticed that the problem did not appear in fullscreen mode at all. Instead of a choppy 40fps frame rate, using the same meshes and all, in fullscreen mode i have a constant 30fps frame rate with no stuttering. I tried changing D3DPRESENT_PARAMETERS::PresentationInterval to D3DPRESENT_INTERVAL_DEFAULT and D3DPRESENT_INTERVAL_ONE, thinking that it could be that IDirect3DDevice9::Present was called too often for the gpu to handle it, but nothing changed. If i try to limit the frequency of calls to my render function (e.g. by checking if at least 1 / 30 seconds have passed since the last one) i manage to eliminate the stuttering but, of course, the frame rate never goes above 30. Just to make sure that it's not a problem of video memory thrashing i switched back to the low level of detail mesh and introduced a different shader that does nothing but consume more cycles than the previous one. As i thought the increased draw time makes the stuttering appear again, and again only in windowed mode. Does anyone have an idea what could be happening? Even a clue could help, so, please, any answer is greatly appreciated.
Advertisement
Are you running any other applications when in Windows mode? Are you sure the environments are comparable - in fullscreen mode most applications will take a back seat whereas in windowed mode you have to share just like everyone else.

Media players can be buggers for switching the timer resolution (timeSetPeriod() I think - related to timeGetTime()), but that usually just results in slower rather than stuttering code.

Another key check is to run up a few SDK samples (or other 3rd party graphics demos) and see if they exhibit a similar behaviour. This will give you crucial information as to whether this is just a characteristic of your system or whether your code is somehow different (and 'broken') compared to other D3D code.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

What does your window message pump look like? Are you processing all window messages before rendering a frame? Processing one message then rendering is going to cause a backlog of window messages and could cause this sort of problem I suspect.
Failing that, all I can suggest is adding some timing functions to your code to see what's causing the stutter.
I found a NVIDIA SDK 9 demo that had the same behaviour, so i started terminating processes and comes out that it was all "NVIDIA Instrumentation Tray" fault.

It's quite strange since the process itself shouldn't do anything unless instrumentation is enabled (and it wasn't), and that i already tried hiding the application bar and nothing changed.

I feel stupid for having spent two days after something like that.

Thank you both, you have been really helpful!

BTW: both PIX and the timing functions i had in my code, indicated that the stall was in some vertex buffer Unlock function, everytime a different one, so i guess NVIDIA instrumentation has something to do with that.

This topic is closed to new replies.

Advertisement