XNA/DirectX:您应该始终使用索引吗?

发布于 2024-07-21 04:43:16 字数 334 浏览 5 评论 0原文

我正在为植被实现广告牌,其中广告牌当然是由两个三角形组成的单个四边形。 顶点数据存储在顶点缓冲区中,但我应该担心索引吗? 我知道,当您使用索引时,就发送到显卡的顶点而言,地形等方面的节省可能是巨大的,但在广告牌上使用索引意味着每个四边形将有 4 个顶点,而不是 6 个,因为每个四边形完全是与其他人分开。

由于存在额外的间接级别,索引的使用实际上是否有可能降低性能? 或者说这根本没有任何意义?

我问这个问题是因为使用索引会让事情稍微复杂化,我很好奇我是否没有做额外的工作,只会让事情变慢(无论是在理论上还是在实践中实际上很明显)。

这是使用 XNA,但应该适用于 DirectX。

I'm implementing billboards for vegetation where a billboard is of course a single quad consisting of two triangles. The vertex data is stored in a vertex buffer, but should I bother with indices? I understand that the savings on things like terrain can be huge in terms of vertices sent to the graphics card when you use indices, but using indices on billboards means that I'll have 4 vertices per quad rather than 6, since each quad is completely separate from the others.

And is it possible that the use of indices actually reduces performance because there is an extra level of indirection? Or isn't that of any significance at all?

I'm asking this because using indices would slightly complicate matters and I'm curious to know if I'm not doing extra work that just makes things slower (whether just in theory or actually noticeable in practice).

This is using XNA, but should apply to DirectX.

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

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

发布评论

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

评论(2

恬淡成诗 2024-07-28 04:43:16

使用索引不仅可以通过向卡发送更少的数据来节省带宽,而且还可以减少顶点着色器必须完成的工作量。 如果有索引用作键,则可以缓存顶点着色器的结果。

如果您渲染大量广告牌植被并且不更改索引缓冲区,我认为您应该会看到一个小的增益。

Using indices not only saves on bandwidth, by sending less data to the card, but also reduces the amount of work the vertex shader has to do. The results of the vertex shader can be cached if there is an index to use as a key.

If you render lots of this billboarded vegetation and don't change your index buffer, I think you should see a small gain.

流星番茄 2024-07-28 04:43:16

当涉及到非常原始的几何时,使用索引可能没有任何意义,在这种情况下我什至不会关心性能,即使是适度的硬件也会每秒渲染数百万个三角形。

现在,从技术上讲,您不知道硬件如何在内部处理数据,它可能会将它们转换为索引,因为这是最流行的几何表示形式。

When it comes to very primitive gemotery then it might won't make any sense to use indices, I won't even bother with performance in that case, even the modest HW will render millions of triangles a seconds.

Now, technically, you don't know how the HW will handle the data internally, it might convert them to indices anyway because that's the most popular form of geometry presentation.

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