'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:
GetFrontBufferData()- Average execution times:GetFrontBufferData(): 0.83598 sD3DXSaveSurfaceToFile(): 0.0036 s- Total: 0.83958 s
GetBackBuffer()- Average execution times:GetBackBuffer(): 0 s <-- INTERESTING - WHY?D3DXSaveSurfaceToFile(): 0.2918 s- Total: 0.2918 s
GetRenderTargetData()- Average execution times:GetRenderTargetData(): 0.00928 sD3DXSaveSurfaceToFile(): 0.00354 s- Total: 0.01282 s
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:
- Why the execution time differs so much from one method to another?
- Why is
GetBackBuffer()very fast but thenD3DXSaveSurfaceToFile()is very slow?
I have an hypothesis about my first question, correct me if I'm wrong:
GetFrontBufferData()is very slow because the front buffer is in the VRAM and it's locked/protected because that's what's currently displayed to the screen.GetBackBuffer()(andD3DXSaveSurfaceToFile()) is faster because the back buffer is in the VRAM but it's not currently displayed to the screen, so it's easier to retrieve.- Finally,
GetRenderTargetData()is fast because the render target is in the system ram (not in the VRAM) so we can retrieve it very fast.
Thank you.
EDIT: I'm still looking for an answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
