Texture buffer object as framebuffer storage
Is there any way to attach a texture buffer object (ARB_texture_buffer_object) to a framebuffer (EXT_framebuffer_object), so that I can directly render into the texture buffer object?
I need this to make an exact, bit-wise copy of a multisample framebuffer (color buffer, depth buffer and stencil buffer), and have this copy reside in main memory rather than VRAM.
UPDATE: The problem is that I cannot directly call glReadPixels on a multi sampled frame buffer, to copy its contents. Instead, I have to blit the multi sampled frame buffer to an intermediate frame buffer and then call glReadPixels on that. During this process, multiple samples are averaged and written to the intermediate buffer. There is now, of course, a loss in precision if I restore this buffer with glWritePixels.
I realize that I can use a multi sample texture as the backing storage for a frame buffer object, but this texture will reside in VRAM and there appears to be no way of c开发者_如何学Copying it to main memory without the same loss of precision. Specifically, I am worried about a loss of precision pertinent to the multi sampled depth buffer attachment, rather than the color buffer.
Is there another way to make an exact copy (and restore this copy) of a multi sampled frame buffer in OpenGL?
TL;DR: How to copy the exact contents of a multi sample frame buffer (specifically, depth buffer) to main memory and restore those contents later, without a loss of precision.
OpenGL does not allow you to bind a buffer texture as a render target. However, I don't see what is stopping you from making "an exact, bit-wise copy of a multisample framebuffer". What problem are you encountering that you believe buffer textures can solve?
How to copy the exact contents of a multi sample frame buffer (specifically, depth buffer) to main memory and restore those contents later, without a loss of precision.
No.
And you don't need to copy the contents of an image to main memory to be able to save and restore it later. If you need to preserve the contents of a multisample image, simply blit it to another multisample image. You can blit it back to restore it. Or better yet, render to a multisample texture that you don't erase until you're done with it. That way, there's no need for any copying.
精彩评论