I'm attempting to write a small screen capture utility that writes captured video to disk.
First, I get the front buffer surface. I've written a shader that takes this surface and through render to texture, converts it to a YUY2 format frame. The format change is required so that I can pass the frames off to an encoder.
I'm using DirectX 9 to acquire the frontbuffer. There are a couple of ways I know of to get at the front buffer:
The MSDN page on both of these API calls state that the data is copied from device memory to system memory. I'd like to copy the front buffer surface directly to another graphics memory surface, as I have other manipulations to perform on the acquired surface before returning it to system memory.
I'm creating a D3DUSAGE_DYNAMIC texture (gfx mem texture) and calling GetFrontBufferData() to write the front buffer to my textures surface0. Is this valid? Will the operation remain in gfx memory, or will it need to move to system memory and then back to graphics memory? If this is the case, is what I'm trying to achieve possible?
EDIT I've been acquiring the front buffer as below, simply because its a convenient way to get a surface populated:
hr = Dx9Mgr::Ref().D3DDev()->GetFrontBufferData( 0, m_spCaptureSurface );
OTOH, GetBackBuffer() allocates a new surface (I want to reuse one over and over), so I just went with GetFrontBufferData().
GetRenderTargetData() requires that the destination surface be created in system memory rather than in gfx memory (e.g. uses D3DPOOL_SYSTEMMEM ), so I ruled this out. Maybe I should reconsider?