Sign in to follow this  
JoshG

Copy contents of Front Buffer to a device memory surface

Recommended Posts

JoshG    127
Hi All,

I am currently attempting to create an application that duplicates the contents of one window and displays it in another window at a smaller resolution.

What I currently have is the following: (in pseudo code)


[code]
captureSwapChain = WindowToCaptureSwapChain
captureSurface = SystemMemory_Surface
displayTexture = DeviceMemory_Texture

captureSwapChain.GetFrontBufferData(captureSurface);
LoadSurfaceFromSurface(displayTexture.GetSurfaceLevel(0), captureSurface);

RenderSprite(displayTexture, size);
[/code]

Now, the above technique works, and does what I need. But it requires a Device Memory -> System memory -> Device Memory copy.
Ideally, I would like to optimise the technique into just a DeviceMemory -> DeviceMemory technique but I can't seem to find the correct API to get this to happen.

NOTE: I do not have any control over the applications that I am duplicating. I just want to duplicate their visuals.

Does anyone have any other ideas?

Cheers

Josh

Share this post


Link to post
Share on other sites
DanielDoyle    102
Hi
I'm not all to sure a device to device pass like that is possible, but i suppose you could try setting the destination devices render target to the surface you would normally pass to it, such as:

device2->setrendertarget(surface);

device1->getrendertarget(surface);

i dont want to say that would work, im not sure on how the devices keep track of their surface pointers, but i do know from a brief bit of work on shadow mapping you had to reset the render targets etc, so i should imagine that may work if the surface pointer was not initially null

Share this post


Link to post
Share on other sites
JoshG    127
Hmm, thats an interesting thought, though I don't think the front buffer has a surface associated with it... so what value of 'surface' would I use?

Share this post


Link to post
Share on other sites
DanielDoyle    102
the front buffer and back buffer are the exact same, they just get swaped during drawing
draw to back buffer, flip this to front buffer and present while drawing to the other buffer (now the current back buffer)

so after you present the back buffer i suppose you could do what i said by grabbing the front buffer (which it would then be)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this