为什么OpenGL不支持多索引缓冲? [英] Why does OpenGL not support multiple index buffering?

查看:104
本文介绍了为什么OpenGL不支持多索引缓冲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么OpenGL不支持顶点属性的多个索引缓冲区呢?

Why does OpenGL not support multiple index buffers for vertex attributes (yet)?

在我看来,这很有用,因为您可以重用属性,并且可以对几何图形的呈现进行更多的控制.

To me it seems very useful, since you could reuse attributes and you would have a lot more control over the rendering of your geometry.

是否存在所有属性数组都必须具有相同索引的原因,或者在不久的将来可以使用此功能?

Is there a reason why all attribute arrays have to take the same index or could this feature be available in the near future?

推荐答案

OpenGL(以及D3D,Metal,Mantle和Vulkan)不支持此功能,因为硬件不支持此功能.硬件不支持此功能,因为对于网格数据的绝大多数,这将无济于事.这主要用于主要是不光滑的网格(顶点共享位置,但不共享法线等).而且大多数网格都是光滑的.

OpenGL (and D3D. And Metal. And Mantle. And Vulkan) doesn't support this because hardware doesn't support this. Hardware doesn't support this because, for the vast majority of mesh data, this would not help. This is primarily useful for meshes that are predominantly not smooth (vertices sharing positions but not normals and so forth). And most meshes are smooth.

此外,这通常是内存与性能之间的权衡.访问您的顶点数据可能会更慢.与单次交错获取相比,GPU必须从内存中的两个不同位置进行获取.尽管缓存有帮助,但与单索引访问相比,多索引访问的缓存一致性很难控制.

Furthermore, it will frequently be a memory-vs-performance tradeoff. Accessing your vertex data will likely be slower. The GPU has to fetch from two distinct locations in memory, compared to the case of a single interleaved fetch. And while caching helps, the cache coherency of multi-indexed accesses is much harder to control than for single-indexed accesses.

因此,硬件不太可能支持此功能.但是它也不大可能支持它,因为您可以自己完成.是否通过缓冲纹理

Hardware is unlikely to support this for that reason. But it also is unlikely to support it because you can do it yourself. Whether through buffer textures, image load/store or SSBOs, you can get your vertex data however you want nowadays. And since you can, there's really no reason for hardware makers to develop special hardware to help you.

另外,还有一个问题是您是否真的要使顶点数据变小.在多索引渲染中,每个顶点由一组索引定义.好吧,每个索引都占用空间.如果模型中的属性超过64K(在许多情况下几乎没有不合理的数目),则每个索引将需要4个字节.

Also, there are questions as to whether you'd really be making your vertex data smaller at all. In multi-indexed rendering, each vertex is defined by a set of indices. Well, each index takes up space. If you have more than 64K of attributes in a model (hardly an unreasonable number in many cases), then you'll need 4 bytes per index.

可以使用GL_INT_2_10_10_10_REV和规范化以4个字节提供一个法线. 2D纹理坐标也可以作为一对短裤存储在4个字节中.颜色可以存储在4个字节中.因此,除非多个属性共享相同的索引(法线和纹理坐标的边发生在同一位置,就像在多维数据集上发生的那样),否则在许多情况下,您实际上将通过这样做使数据更大.

A normal can be provided in 4 bytes, using GL_INT_2_10_10_10_REV and normalization. A 2D texture coordinate can be stored in 4 bytes too, as a pair of shorts. Colors can be stored in 4 bytes. So unless multiple attributes share the same index (normals and texture coordinate edges happen at the same place, as might happen on a cube), you will actually make your data bigger by doing this in many cases.

这篇关于为什么OpenGL不支持多索引缓冲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆