0

Say there are many different meshes with transformations that changes more or less each frame, what would in general be the faster of these drawing methods:

  1. For each frame fill a big vertex buffer with the transformed vertices of the mesh (transformation is done on CPU and vertices copied to the buffer each frame).
  2. For each object creation insert the non-transformed vertices of the mesh, then when drawing send the transformation of each mesh as a uniform parameter (transformation done on GPU, vertices are copied at mesh creation).

We can assume that all meshes are drawn each frame so not copying vertices for case 1) would not matter.

Jens Åkerblom
  • 898
  • 8
  • 19

1 Answers1

0

Option #2 will almost always be faster. If you have N vertices and M transformations, it's the difference between doing ~N arithmetic ops on a CPU followed by a ~N bus transfer, versus doing a ~M bus transfer (faster) followed by ~N arithmetic ops on a GPU (also faster).

The only times this would be a lose is if your CPU were way faster than your GPU in terms of total throughput for vertex manipulation (very unlikely), or if M is the same order of magnitude as N.

MooseBoys
  • 6,641
  • 1
  • 19
  • 43
  • How about the cost of setting the transform as a uniforms / constants shader parameter for each frame and each mesh as is required in #2 but not #1? Is that overhead negligible? – Jens Åkerblom Nov 05 '14 at 07:02
  • That is the "~M bus transfer" cost referenced in my answer. The overhead isn't negligible in an application that only uses approach #2, but it's orders of magnitude smaller than the cost of pre-transforming the entire mesh and then doing another ~N cost bus transfer. This is because most of the time, N is many orders of magnitude larger than M, and also GPUs are much more efficient at doing the per-vertex transformation than CPUs are. – MooseBoys Nov 05 '14 at 18:13