用于读取和写入的 OpenGL 缓冲区用法

OpenGL Buffer Usage for both reading and writing

虽然众所周知 OpenGL 的 glBufferData 函数中的用法标志只是一个提示而非真正的限制,但文档说 "DRAW" 用于 "User writes to it and then uses it to pass as an argument to other OpenGL functions." 和 "READ" 是 "This buffer will be filled with data from the GL and the user wants to read from it." 但是如果我想要,只是作为一个假设的用途,使用 GPU 作为外部存储,然后简单地写入并稍后从同一个缓冲区读取(可能在 GL 对其进行更改之后)?

这些常量的位值并不意味着我可以组合它们(如 GL_DYNAMIC_READ | GL_DYNAMIC_DRAW)。

是否有任何 "best" 用法标志可以用来提示 GL "I want to use that buffer as storage to read and write from"?

what if I want, just as a hypothetical useage, use the GPU as external storage and simply write and later read from the same buffer (maybe after the GL has made changes to it)?

那么要么你不再关心使用提示,要么你不使用 OpenGL。 OpenGL 的缓冲区对象的存在是为了 OpenGL 的使用目的。它们不会让您访问新的内存池来玩弄。

特别是,因为“内存池*很可能是同一个内存池malloc等人分配的内存。而且你无能为力OpenGL 确保缓冲区对象的存储来自 GPU 内存(或者甚至检查 GPU 是否有专用内存)。

简而言之,这不是 OpenGL 支持的使用模式,因此它不能很好地支持它。