Texture change (and other state-change) costs on modern GPUs
Asked Answered
N

1

5

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.).

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).

So my questions are:

  • Should I really care about sorting my primitives by texture/color/other material parameters? Or is it less important on modern GPUs?
  • What is the expectable percentage of performance loss, if I don't?
  • Are there any other state changes, which can effect the performance?
  • Where can I find some up to date literature/best practice guide about this?

Thank you for any help or links!

Nafis answered 20/7, 2011 at 23:5 Comment(1)
Might try asking on gamedev.stackexchange.com if you don't get any responses hereThulium
N
8

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.

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

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.

Novak answered 21/7, 2011 at 2:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.