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

  • \$\begingroup\$ Isn't the lag caused by the PresentationInterval not being immediate? \$\endgroup\$ – Appleshell Aug 24 '13 at 2:31
  • \$\begingroup\$ 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? \$\endgroup\$ – M4rkus Aug 24 '13 at 2:48
  • \$\begingroup\$ What happens if you do Windowed = false and PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE? \$\endgroup\$ – Nathan Reed Aug 24 '13 at 2:52
  • \$\begingroup\$ Then it also needs the vsync code, which tears unless it's tweaked correctly for the graphics card. \$\endgroup\$ – M4rkus Aug 24 '13 at 3:28
  • \$\begingroup\$ How are you building all your other presentation parameters? \$\endgroup\$ – Panda Pajama Aug 24 '13 at 15:27

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.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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