1

Is there a way to directly copy the backbuffer data into the video memory? I mean without using system memory. All the methods that I found so far (like this or this) copy the backbuffer content into system memory which takes significant amount of time.

My task is to create a surface or a texture in the video memory and tell the graphics adapter to directly copy the backbuffer to there, without using the bus. Thanks

Community
  • 1
  • 1
Isso
  • 1,285
  • 11
  • 23
  • And render to texture directly using fbo? Than you may copy to backbuffer with a simple draw call using a textured quad... – j-p Dec 13 '14 at 16:24
  • Another alternative, but one that introduces latency because you have to wait for the rendering to catch up before reading, is to use a Pixel Buffer Object. _Can you explain in a little bit more detail what you intend to ***do*** with the backbuffer?_ If you're trying to capture video like FRAPS does, then a Pixel Buffer Object is actually a more appropriate choice -- it'll introduce a couple frame latency but that's acceptable in that sort of situation. _Also, why is this tagged both OpenGL and DirectX?_ – Andon M. Coleman Dec 13 '14 at 17:31
  • Thank you for your answers. I'm trying to capture the display content, then process it on the GPU using shaders. So I'm not rendering anything, just grabbing the screen and processing it, then reading a small amount of resulting data from the GPU. – Isso Dec 13 '14 at 17:58
  • For OpenGL and DirectX - any of them would do provided they can accomplish this task. – Isso Dec 13 '14 at 18:00
  • @Isso: That's a little trickier actually... are you trying to get the entire screen's contents, or just the contents of a single window? – Andon M. Coleman Dec 13 '14 at 18:28
  • Entire screen contents. If you check the links in my question they use Direct3D for that task, however I don't need to copy the display content to the system memory, I need to quickly "flip" it to another video memory area. Hope this makes sense – Isso Dec 13 '14 at 19:16

1 Answers1

1

The back buffer is already in video memory, by the way -- just not necessarily complete when you want it. Your performance issues might actually be due to forcing a pipeline stall while you wait for rendering to finish; it is hard to say from your description.

If you draw into an FBO image attachment you can do this without causing a stall, but you will be drawing into a separate buffer rather than the window system's swap chain (back buffer). Thus, the result will not appear on screen when you swap buffers and you will either have to manually call glBlitFramebuffer (...) or draw a textured quad using the image you attached to your FBO as a texture.

Andon M. Coleman
  • 42,359
  • 2
  • 81
  • 106
  • Andon, thank you for your answer. I'm not rendering anything, I just need to capture the display contents, then process it on the GPU using shaders, and finally read the processing results (which is a small amount of data) to the system memory. – Isso Dec 13 '14 at 18:01