[managed DX9-DX10] Irregular framerate

Started by
5 comments, last by CuboDeAgua 13 years, 3 months ago
Hi there.

I'll explain my problem a little bit:

First of all i have to say that i have experienced it with early XNA (i don't use it anymore), with managed directx (which i know is deprecated now) and with SlimDX (with directx9 and directx10 versions).

I thought the problem was due to a too young XNA or a deprecated library but i'm experiencing the same thing with any managed directx api so it must be something i miss.

The problem is that even if my application framerate per second is very uniform, i get small jumps in some frames quite often and the problem gets worse with the complexity of the scene. I've also experienced this behaviour with any computer i've used.

I've tried the "render" task to be executed in other thread different than the target windows forms one and i've also tried to execute the render subscribing it to the "Iddle" event of the application. I've tried with all others taks being executed in one thread or in many other threads but i still get the same jumps. I've also tried to assign priority to the forms thread in case the form couldn't refresh itself often enought but nothing worked (don't even know it this has any sense).

I know that nothing irregular is being added to the render process (just same things all frames) and i've measured the milliseconds per one frame and the values are pretty constant.

The problem seem to come from the forms image refresh rate more than from the directx backbuffer generation rate.

Can anyone give me some great advice about this please? ;)

Thanks in advance.

PD. This question can also be resumed to: Can anyone affirm that with a managed directx9 api a constant framerate can be achieved with complex scenes even if it's slower than the one that we would get with a native directx api?
Advertisement
Do u know PIX? With PIX u can record what DirectX is doing in a frame.
It records every drawcal, setrenderstate etc etc and also it records timing/fps over time. So run ur app with PIX and then analyze a "slow" frame and maybe compare it to normal ones. This way u should find ur problem, if its DirectX and not ur gameloop for example.

Good Luck
I used pix time ago and couldn't find the issue. Everything was pretty normal and very constant on the directx side (that's what i remember at least). By that time i was screwing up myself because i thought the problem was something in my threads, but i really think the problem is somewhere between the directx and the windows forms "communication".

Did any of you heard about a general behaviour like this with managed directx before?
The only extra issue you have with the managed API's is garbage collection. If you have too many live objects and you're allocating a lot of new ones each frame, then you may small pauses and hitches during collections. Shawn Hargreaves has a few good articles on this blog that you can read through.

Aside from that you have the regular issues: too many API calls will have a lot of CPU overhead, and can slow you down. Overloading the GPU will cause the CPU to stall on Present and wait for the GPU to catch. Usually the first step in diagnosing performance problems is to figure out whether you're GPU-bound or CPU-bound. There are old-school ways to do it, but if you can run your app in PIX (or better yet a performance analysis tool like AMD GPU PerfStudi) you can find out very quickly.
Well... that's the curious thing about this problem.

My CPU work is very low (my engine is designed to do that) and my framerate when rendering in other thread different than the forms one is about 400 frames per second so the GPU it's also very relaxed with each frame, but i still get the jumps. Thats why i think its a basic windows form or directX configuration issue rather than other "performance" thing.

Beleive it or not i've been more than 4 years with this issue and i haven't solved it yet hoping i would find the clue some day but... sigh

(i never had such a problem with directx in native code)
I have encountered a similar issue when running in window mode.
I never really bothered to check what was causing this though, since those applications were designed to run in fullscreen only.
Finally i've got a quite stable framerate.

I've done so many changes that i don't even remember them exactly, but the main ones have been setting "presentParams.PresentationInterval = PresentInterval.One;" (Immediate didn't stabilize the framerate in windowed mode not in fullscreen mode) and placing the render task in another thread (pool or pure didn't matter). No other combination worked for me.

Anyway, if the computer is fast and the scene is not very heavy, the framerate looks pretty stable.

This topic is closed to new replies.

Advertisement