作为帧缓冲区存储的纹理缓冲区对象

发布于 2024-12-05 15:16:42 字数 570 浏览 0 评论 0原文

有什么方法可以将纹理缓冲区对象(ARB_texture_buffer_object)附加到帧缓冲区(EXT_framebuffer_object),以便我可以直接渲染到纹理缓冲区对象中?

我需要它来制作多重采样帧缓冲区(颜色缓冲区、深度缓冲区和模板缓冲区)的精确按位副本,并将此副本驻留在主内存而不是 VRAM 中。

更新: 问题是我无法直接在多采样帧缓冲区上调用 glReadPixels 来复制其内容。相反,我必须将多采样帧缓冲区传输到中间帧缓冲区,然后对其调用 glReadPixels。在此过程中,多个样本被平均并写入中间缓冲区。当然,如果我用 glWritePixels 恢复此缓冲区,现在精度会有所损失。

我意识到我可以使用多样本纹理作为帧缓冲区对象的后备存储,但该纹理将驻留在 VRAM 中,并且似乎无法将其复制到主内存而不造成同样的精度损失。具体来说,我担心与多采样深度缓冲区附件相关的精度损失,而不是与颜色缓冲区相关的精度损失。

是否有另一种方法可以在 OpenGL 中制作多采样帧缓冲区的精确副本(并恢复此副本)?

TL;DR:如何将多样本帧缓冲区(特别是深度缓冲区)的确切内容复制到主内存并稍后恢复这些内容,而不损失精度。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半步萧音过轻尘 2024-12-12 15:16:42

OpenGL 不允许您将缓冲区纹理绑定为渲染目标。但是,我不明白是什么阻止您制作“多重采样帧缓冲区的精确按位副本”。您遇到了哪些您认为缓冲区纹理可以解决的问题?


如何将多样本帧缓冲区(特别是深度缓冲区)的确切内容复制到主内存并稍后恢复这些内容,而不会损失精度。

不需要。

您不需要将图像的内容复制到主内存中以便稍后保存和恢复。如果您需要保留多重采样图像的内容,只需将其传输到另一个多重采样图像即可。您可以将其位块传输回来以恢复它。或者更好的是,渲染为多重采样纹理,直到完成后才将其擦除。这样,就不需要任何复制。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文