顶点缓冲区对象的最大大小 (OpenGL ES 2.0)

发布于 2024-12-04 04:04:33 字数 660 浏览 1 评论 0原文

绑定到 GL_ARRAY_BUFFER 或 GL_ELEMENT_ARRAY_BUFFER 的顶点缓冲区对象是否有最大大小???

最初,我正在绘制一个由 16 个子网格组成的网格。对于每个子网格,我创建了一个顶点缓冲区,并在渲染阶段调用了 glDrawElements。 这在 iOS 模拟器上运行良好,但当我尝试渲染到我的设备时,屏幕不断闪烁并且不显示网格。

然后我做了一些阅读,发现在渲染阶段不应该多次调用 glDrawElements 。 我尝试将所有子网格合并到一个顶点缓冲区中。 绑定到 GL_ARRAY_BUFFER 的缓冲区包含 3969 个顶点,其中每个顶点包含 20 个浮点数。所以这个缓冲区的大小是317520字节。 绑定到 GL_ELEMENT_ARRAY_BUFFER 的索引是 16425 个空头。因此,该缓冲区的大小为 32850 字节。

在 OpenGL wiki 上,对于顶点缓冲区对象,“根据一份 nVidia 文档,1MB 到 4MB 是一个不错的大小”。

绑定每个缓冲区对象并调用 glDrawElements 后,我打印出了 glGetError 的结果,并且没有看到任何错误。 但是,我的网格没有正确显示。似乎只有第一个网格被正确绘制。我的实现方式有什么可疑之处吗?我不想让这个问题太长,所以如果您需要回答这个问题有任何额外的信息,请告诉我。如果理论上没有什么问题,也许我只是在实现它时犯了一个错误。

Is there a max size for vertex buffer objects binded to GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER???

Originally, I was drawing a mesh composed of 16 submeshes. For each submesh, I created a vertex buffer and during the rendering phase, I called glDrawElements.
This worked fine on the iOS simulator, but when I tried to render to my device, the screen flashes constantly and the meshes aren't displayed.

I then did some reading and found that you shouldn't call glDrawElements too many times during a render phase.
I tried to combine all of my submeshes into one vertex buffer.
The buffer bound to GL_ARRAY_BUFFER contains 3969 vertices, where each vertex contains 20 floats. So the size of this buffer is 317520 bytes.
The indices bound to GL_ELEMENT_ARRAY_BUFFER are 16425 shorts. The size of this buffer is therefore 32850 bytes.

On the OpenGL wiki, it says that "1MB to 4MB is a nice size according to one nVidia document" for a Vertex Buffer Object.

I printed out the result of glGetError after binding each buffer object, and calling glDrawElements, and I don't see any errors.
However, my meshes aren't correctly displayed. It seems as though only the first mesh gets correctly drawn. Is there anything fishy in the way I've implemented this? I didn't want to make this question too long so if there's any extra information you need to answer this question let me know. If there's nothing in theory that seems wrong, perhaps I've just made a mistake in implementing it.

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

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

发布评论

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

评论(3

陌上芳菲 2024-12-11 04:04:33

存在最大大小,从某种意义上说,GPU 始终会发出 GL_OUT_OF_MEMORY 错误。但除此之外,没有。

There is a maximum size, in the sense that the GPU can always issue a GL_OUT_OF_MEMORY error. But other than that, no.

夜深人未静 2024-12-11 04:04:33

请参阅:

http://www.sunsetlakesoftware.com/2008/ 08/05/lessons-molecules-opengl-es

使用较小的数据类型有一些自然限制,例如使用 Shorts 作为明显的〜65000索引。

但更重要的是,链接中有一些额外的帮助,这是一个非常好的教程,并且包括一些达不到自然功能极限工作的轶事证据。

See this:

http://www.sunsetlakesoftware.com/2008/08/05/lessons-molecules-opengl-es

There are some natural limits using smaller data types, like obviously ~65000 for using shorts as indexes.

But more importantly there is some additional help in the link, which is a very good tutorial, and includes some anecdotal evidence that shorts up to the natural functional limit work.

隔岸观火 2024-12-11 04:04:33

我知道现在回答这个问题已经太晚了。但是,我希望答案对某人有所帮助!

基于 OpenG 图形系统规范(4.5 版(核心配置文件)- 2015 年 5 月 28 日),其中规定:
“除了顶点数组的大小之外,可以指定的顶点数量没有限制。”请参阅第 322 页。

抱歉,也正如尼可波拉斯在这里提到的:
https://stackoverflow.com/a/7369392/4228827

干杯,
纳伊夫

I know it is too late to answer this question. However, I wish the answer helps someone!

Based on The Specification of OpenG Graphics System (Version 4.5 (Core Profile) - May 28, 2015), it states:
"There is no limit to the number of vertices that may be specified, other than the size of the vertex arrays." please see page 322.

Sorry, also as Nicol Bolas mention here:
https://stackoverflow.com/a/7369392/4228827

Cheers,
Naif

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