Celios

Hi.

First of all, Happy New Year to all of you :)

I am using Direct3D 9 to write a part of my company's software to output uncompressed
HD contents by drawing 2 triangles and putting the image frames of the HD clip to a texture, and put the texture on the triangles ( well known strategy for showing 2D graphics on Direct3D, I think all of you know this ).

The clip I used for testing is 1080i 30fps. Because the monitor refresh rate is 60 and D3DPRESENT_INTERVAL_DEFAULT gives 60 fps, I used D3DPRESENT_INTERVAL_TWO, which should give 30 fps.

Graphics card I used is nVidia Quadro FX 3000 and Direct3D9.
Using my company's modified timing function, I found out that for the first 5 frames, the time between frames are not 33.33 ms as expected. The first one took only 0 ms ( I wonder if it even waited for vertical blank ). The second, third and fourth frame took around 9 - 10 ms, the fifth frame took around 25 ms (these for sure did not wait for vertical blank). The rest constantly waited for around 33 ms which is expected. The timing function has been used in my company for a long time, so I think it is trustworthy.


Anybody knows why this happened or had this kind of problem and know how to solve it
Please help.

Thank you.


Re: Game Technologies: DirectX 101 Direct3D 9 -> Strange problem with vertical blank

Robert Dunlop

This is because Present returns as soon as the persent operation can be queued up, not when the vertical refresh actually occurs. The frames are queued up in the swap chain, and don't actually hit the screen until the vertical blanking period. DirectX will buffer up to three frames in advance, which helps to keep a stable frame rate despite variations of rendering time per frame, even allowing the occasional frame to take in excess of one refresh period without missing a frame.

You numbers are indictive of this behavior. It took the first five frames 52-55 ms to render, during which time two vertical refreshes could have occured. After that your frame rate was locked by the refresh, as no more frames could be buffered.





Re: Game Technologies: DirectX 101 Direct3D 9 -> Strange problem with vertical blank

Celios

Robert, Thanks very much for your reply.

Just want to make sure if I understand you correctly ( because I'm a beginner in DirectX ),
did you mean that before the first 5 frames are all buffered, there are no output shown on screen

Or did you mean that I do not have to worry about all these, as what I have been timing is the time to buffer all the images, but in reality frames are shown on the output in order, once every 2 vertical blanks ( because it's D3DPRESENT_INTERVAL_TWO )

Celios




Re: Game Technologies: DirectX 101 Direct3D 9 -> Strange problem with vertical blank

Robert Dunlop

The latter is what I meant. The first rendered frame will be presented at the next vertical synch, the second rendered frame will occur two vertical sync periods after that, etc. DirectX will allow you to continue rendering even when the GPU has not finished with a frame, allowing up to two frames to be queued up for rendering. Add to this double buffering (one frame rendered and waiting to be presented at the vertical sync), this means that what is actually on the screen can be up to three frames behind what you have rendered. In your case, with a presentation interval of two at a 60hz refresh rate, that means that you can render video up to 100ms in advance of the actual display.

The only time this might become a concern is if that much delay causes an obvious lag between user interaction and actual response. This percieved latency may be even greater, as what the user is seeing was actually rendered 100ms earlier, and once the user responds it will take 100ms for changes to reach the screen.





Re: Game Technologies: DirectX 101 Direct3D 9 -> Strange problem with vertical blank

Celios

Thanks very much, Robert !!!
You really helped.