I'm developing a screencast program capturing screen using Direct3D9. My first approach, capturing the screen with getfrontbuffer() Direct3d function and moving screen from video to system memory, gives me around 15fps.
I'd like to reach at least to 30 fps so youtube videos could be seen fluidly. For that, I have measured the bottleneck and discovered that it is the video to system memory transfer, so I'm copying from video memory to video memory. Currently I'm trying to capture the screen using getbackbuffer() function (as it seems that getfrontbuffer() doesn't work with D3DPOOL_DEFAULT memory) and then copying the surface where the screen has been captured to the VPP's input buffer with StretchRect() D3D9 funcion.
I'm using the code from tutorial in folder simple_6_encode - d3d - vpp_preproc. Also I'm copying from my surface to the VPP's input surface directly:
hr = D3DD9->StretchRect(pRenderTarget, NULL, (IDirect3DSurface9 *)(pmfxSurfacesVPPIn[nVPPSurfIdx]->Data.MemId), NULL, D3DTEXF_NONE);
hr result is 0x8876086c
What's wrong with my approach? Is it possible to copy directly from video memory to VPP's input? If my approach is wrong, what can I do to achieve 30fps at least?