c++windowswinapidirectx-9

Execution time: GetFrontBufferData, GetBackBuffer, GetRenderTargetData


I'm trying several methods to capture screen with DirectX and I've come up with 3 methods so far:

Average times have been computed by taking 50 screenshots and by measuring time with clock().

All the methods above work, however, as you can see, execution times vary a lot from one method to another for the same results (apparently).

So I have a few questions:

I have an hypothesis about my first question, correct me if I'm wrong:

Thank you.

EDIT: I'm still looking for an answer.


Solution

  • The process you are referring to is called 'readback' which involves copying the data back from the GPU video RAM. With the exception of a few specific unified memory architectures (such as Xbox 360), readback is a slow process.

    Depending on your OS and other settings, it's likely that the front buffer and the back buffer are both just 'offscreen' textures in VRAM. There are also various locks and GPU pipeline stalls involved when you halt rendering to capture a screen shot.

    You may find this (now rather old) article useful.

    Note that Direct3D 10/11 offer many features to overcome the inherent slowness of 'readback' from the GPU mostly by allowing algorithms to keep the data on the GPU.