我什么时候可以发布源 PBO?

发布于 2024-11-09 15:00:04 字数 200 浏览 0 评论 0原文

我正在使用 PBO 在 CPU 和 GPU 之间异步移动数据。

当从 GPU 移动时,我知道在 PBO 上调用 glMapBuffer 后可以删除源纹理。

然而,反过来又如何呢?我什么时候知道从 PBO 到纹理 (glTexSubImage2D(..., NULL)) 的传输已完成并且我可以安全地释放或重新使用 PBO?是我绑定纹理后立即还是其他什么?

I'm using PBOs to asynchronously move data between my cpu and gpu.

When moving from the GPU i know I can delete the source texture after I have called glMapBuffer on the PBO.

However, what about the other way around? When do I know that the transfer from the PBO to the texture (glTexSubImage2D(..., NULL)) is done and I can safely release or re-use the PBO? Is it as soon as I bind the texture or something else?

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

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

发布评论

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

评论(1

落在眉间の轻吻 2024-11-16 15:00:04

我认为在调用 glTexImage 之后,您可以安全地删除或重用缓冲区,而不会出现错误,因为驱动程序会为您处理一切,包括延迟销毁(这是缓冲区对象的优势)。但这意味着,对 glMapBuffer 的调用可能会阻塞,直到前面的 glTexImage 复制完成。如果您想重用缓冲区并覆盖其全部内容,通常的做法是在调用 glMapBuffer 之前使用 glBufferData 重新分配它。这样驱动程序就知道您不再关心以前的内容,并且可以分配一个可以立即使用的新缓冲区(当确实不再使用包含以前内容的内存时,驱动程序会释放它)。请记住,您的缓冲区对象只是内存的句柄,驱动程序可以根据需要管理和复制。

编辑:这意味着以另一种方式(GPU-CPU),您可以在 glGetTexImage 返回后删除源纹理,因为驱动程序管理幕后的所有内容。是否使用缓冲区对象的决定不应该对调用 GL 函数的顺序和时间产生任何影响。请记住,调用 glDelete... 不会立即删除对象,它只是将此命令排入 GL 命令流中,即使这样,也取决于驱动程序何时真正释放任何内存。

I think after calling glTexImage you are safe in deleting or reusing the buffer without errors, as the driver handles everything for you, including deferred destruction (that's the advantage of buffer objects). But this means, that calls to glMapBuffer may block until the preceding glTexImage copy has completed. If you want to reuse the buffer and just overwrite its whole content, it is common practice to realocate it with glBufferData before calling glMapBuffer. This way the driver knows you don't care about the previous content anymore and can allocate a new buffer that you can use immediately (the memory containing the previous content is then freed by the driver when it is really not used anymore). Just keep in mind that your buffer object is just a handle to memory, that the driver can manage and copy as it likes.

EDIT: This means in the other way (GPU-CPU) you can delete the source texture after glGetTexImage has returned, as the driver manages everything behind the scenes. The decision of using buffer objects or not should not have any implications on the order and time in which you call GL functions. Keep in mind that calling glDelete... does not immediately delete an object, it just enqueues this command into the GL command stream and even then, its up to the driver when it really frees any memory.

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