对于非常动态的数据使用顶点缓冲区对象在性能方面是一个好主意吗?

发布于 2024-09-30 15:41:47 字数 339 浏览 4 评论 0原文

我有很多粒子,它们的顶点每帧都会发生变化。当前正在使用“客户端”内存中的顶点数组绘制顶点。如果使用顶点缓冲区对象,可以获得哪些性能特征?

由于我必须使用许多 glBuffersubData 来更新粒子顶点,因此我无论如何都会将顶点传输到视频内存(就像我使用常规顶点数组一样)?在这种情况下,VBO 有什么好处吗?

这是针对 iOS 设备的。实际的绘制调用:glDrawElements(GL_POINTS,num_articles,GL_UNSIGNED_SHORT,pindices);

我应该使用GL_STREAM_DRAW还是GL_DYNAMIC_DRAW

I have many particles who's vertices change every frame. The vertices are currently being drawn using a vertex array in 'client' memory. What performance characteristics can I expect if I use a vertex buffer object?

Since I have to use a number of glBuffersubData's to update the particle vertices, I am therefore transferring the vertices to video memory every frame anyway right(like i would if i use a regular vertex array)? Is there any benefit to VBO's in this case?

This is for iOS devices. The actual draw call: glDrawElements(GL_POINTS,num_particles,GL_UNSIGNED_SHORT,pindices);

Should I use GL_STREAM_DRAW or GL_DYNAMIC_DRAW?

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

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

发布评论

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

评论(2

不爱素颜 2024-10-07 15:41:47

Apple 文档似乎推荐 VBO在所有情况下。如果您使用 ES 2.x,则 GL_STREAM_DRAW 顶点缓冲区类型明确适用于“当您的应用程序需要创建渲染少量次然后丢弃的瞬态几何体时。当您的应用程序必须动态更改顶点时,这是最有用的以无法在顶点着色器中执行的方式对每一帧进行数据处理。”然后直接提倡使用glBufferSubData。

从逻辑上讲,我猜想完全重新提供数据和将其发送到现有的 GL_STREAM_DRAW 或 GL_DYNAMIC_DRAW 缓冲区之间的唯一区别是内存映射中的空间(GPU 或 CPU,具体取决于芯片 - MBX 并不真正执行 VBO,但 Apple出于其他性能原因支持它们)可以分配一次,而不是每帧分配和释放。

使用该文档中给出的对齐和打包技巧可能比切换到 VBO 提供更好的改进,因为否则 CPU 只需要在 glDrawElements 上解包和重新打包数据。尽管您很可能已经意识到这一点,并且我很高兴这不是问题的直接一部分 - 我主要将其作为对性能优势的比较猜测。

Apple's documentation appears to recommend VBOs in all situations. If you're using ES 2.x then the GL_STREAM_DRAW vertex buffer type is explicitly for "when your application needs to create transient geometry that is rendered a small number of times and then discarded. This is most useful when your application must dynamically change vertex data every frame in a way that cannot be performed in a vertex shader." Use of glBufferSubData is then directly advocated.

Logically, I guess the only difference between supplying the data completely afresh and sending it to an existing GL_STREAM_DRAW or GL_DYNAMIC_DRAW buffer is that your space in the memory map (GPU or CPU, depending on the chip — MBXs don't really do VBOs but Apple supports them for other performance reasons) can be allocated once rather than allocated and released every frame.

Using the alignment and packing tips given in that document is likely to give a better improvement than a switch to VBOs, since otherwise the CPU just has to unpack and repack data upon glDrawElements. Though quite probably you're already aware of that and I appreciate that it isn't directly part of the question — I mainly throw it in as a comparative guess about performance benefits.

绮筵 2024-10-07 15:41:47

通过正确设置 VBO,您可以使用最佳方式将数据传输到 GPU。通过这样做,您可能会跳过一些驱动程序处理。要了解自己取得了多大的进步,唯一的方法就是进行衡量。每张卡的情况都不同。

有关 VBO 操作方法,请参阅:VBO 教程

编辑
忘记回答问题了:是的,这是个好主意。但首先要衡量。

By setting VBOs properly, you are using optimal way of transferring data to the GPU. By doing so, you might skip some driver processing. The only way to see how much you get of improvement you get is to measure. It is different from card to card.

For VBO how-to, see this : VBO tutorial

EDIT
Forgot to answer the question : yes, it is a good idea. But first measure.

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