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

查看:20
本文介绍了为什么 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.

出于这个原因,硬件不太可能支持这一点.但它也不太可能支持它,因为你可以自己做.是否通过缓冲纹理图像加载/存储SSBO,您现在可以随心所欲地获取顶点数据.既然可以,那么硬件制造商真的没有理由开发特殊硬件来帮助您.

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天全站免登陆