现代 GPU 上的纹理更改(和其他状态更改)成本 [英] Texture change (and other state-change) costs on modern GPUs

查看:28
本文介绍了现代 GPU 上的纹理更改(和其他状态更改)成本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个基于场景图的图形引擎用于建模.我正在使用 XNA 4.在我读过的很多地方,在渲染过程中应该最小化纹理变化(和其他状态变化)(所以我必须按材质等对我的图元进行排序).

I'm writing a scene-graph based graphics engine for modeling purposes. I'm using XNA 4. On many places I have been reading, that texture changes (and other state changes) should be minimized during rendering (so I have to order my primitives by materials, etc.).

我在 XNA 4 中创建了一个小型测试应用程序,它使用单个纹理渲染数百个 stanford bunny 模型,然后切换 2 个不同的纹理.渲染时间没有区别(但是我使用了大约 100x100 的小纹理).

I created a small test application in XNA 4, which was rendering hundreds of stanford bunny models with a single texture, then doing the same toggling 2 different textures. There was no difference in rendering time (however I used small ~100x100 textures).

所以我的问题是:

  • 我真的应该关心按纹理/颜色/其他材料参数对我的图元进行排序吗?还是它在现代 GPU 上不那么重要?
  • 如果我不这样做,预期的性能损失百分比是多少?
  • 是否有任何其他状态更改会影响性能?
  • 在哪里可以找到有关此问题的最新文献/最佳实践指南?

感谢您提供任何帮助或链接!

Thank you for any help or links!

推荐答案

很长时间 状态更改的成本并不高.批次很昂贵.(并且状态更改需要新批次).批处理基本上是对 Draw*Primitives 函数的调用.

State changes haven't really been expensive for a long time. Batches are expensive. (And a state change necessitates a new batch). A batch is basically a call to a Draw*Primitives function.

这个来自 nVidia 的 PDF 详细解释了它.它还提供了减少批次数量的想法.

This PDF from nVidia explains it in detail. It also gives ideas for reducing your batch count.

批次是基于 CPU 的限制(而非 GPU).该 PDF 将< 130 tris/batch"列为提交批次支配性能并且GPU闲置等待更多批次的点(详细信息).它还表示,每 1GHz 的 CPU 功率专用于提交批次,每帧大约 400 个批次,60 FPS.(虽然 PDF 有点旧,所以这些数字有点过时了.)

Batches are a CPU-based limit (not GPU). That PDF lists "< 130 tris/batch" as the point where submitting batches dominates performance and the GPU sits idle waiting for more batches (details). It also says you get about 400 batches per frame, at 60 FPS, per 1GHz of CPU power dedicated to submitting batches. (Although the PDF is a bit old, so those figures are a bit out of date.)

我在游戏开发网站上的回答类似的问题应该提供更多细节.这个也是.

My answer on the gamedev site to a similar question should provide some more details. This one too.

这篇关于现代 GPU 上的纹理更改(和其他状态更改)成本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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