Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have written two small test games using DirectX 9. One uses

presentParams.Windowed = false;

presentParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

and the other one uses

presentParams.Windowed = false; // same results with true

presentParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

Both use exactly the same window position, size and style. Both are written to cover the screen completely, even when using "Windowed = true".

In the latter game, to vsync and avoid tearing, my code waits until a certain scan line is passed. My tests showed: On different PCs it has to wait for different scan lines to avoid tearing completely. This is a drawback, since it has to be tweaked individually by the user. Is this technique used in any games?

And, compared to this technique, why does DirectX produce a display lag when "Windowed = false" is used with D3DPRESENT_INTERVAL_ONE?


To clarify where the lag occurs:

Windowed = false + INTERVAL_ONE => LAG

Windowed = false + ...IMMEDIATE => no lag


Not mentioned in the question but tested:

Windowed = true; + INTERVAL_ONE => no lag, tearing

Windowed = true; + ...IMMEDIATE => no lag

share|improve this question
    
Isn't the lag caused by the PresentationInterval not being immediate? –  Adam S Aug 24 '13 at 2:31
    
Yes, I think so too. But why isn't INTERVAL_ONE not implemented with less lag, if this seems possible? Is knowing a "scan line to wait for" faster then the drivers own code? Is it a common technique or is it problematic? –  M4rkus Aug 24 '13 at 2:48
    
What happens if you do Windowed = false and PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE? –  Nathan Reed Aug 24 '13 at 2:52
    
Then it also needs the vsync code, which tears unless it's tweaked correctly for the graphics card. –  M4rkus Aug 24 '13 at 3:28
    
How are you building all your other presentation parameters? –  Panda Pajama Aug 24 '13 at 15:27

1 Answer 1

up vote 0 down vote accepted

With vsync on, and the CPU running faster than the GPU D3D will buffer up to three frames worth of GPU commands.

You can prevent it from doing that by forcing a CPU<->GPU sync which you can do with by issuing and waiting for queries or by adjusting video card settings ("Maximum pre-rendered frames" on Nvidia cards).

Having one frame buffered up allows the GPU to work on a different frame to the CPU, without that they can't run in parallel so performance will suffer.

Having multiple frames buffered up is what allows SLI systems to improve performance by giving one frame to each card, so you need to be careful when limiting how many can be buffered.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.