1
\$\begingroup\$

I am currently using ModelMesh.Draw() to draw the each mesh of the model and thus the whole model. Note that my models are very heavy -- around 30MB of data, I think if there is any other way to draw the models which is more efficient then performance of my application will better.

\$\endgroup\$
1
  • \$\begingroup\$ Are the models big enough that they aren't always visible? Culling? \$\endgroup\$ Nov 9, 2011 at 20:54

1 Answer 1

5
\$\begingroup\$

I think if there is any other way to draw the models which is more efficient then performance of my application will better

Don't guess -- profile. Determine where your bottleneck is (provably) before you go jumping at random ideas about what might be slow. You may not be bound by the performance of the GPU at all, there may in fact be some other bit of code that runs on the CPU in your game that's killing your performance.

Your best bet is going to be actually sitting down and analyzing the performance of your program with various tools to determine if you are CPU or GPU bound, and then looking into profiling that. If you end end CPU bound, look for regular C# code profilers to examine your application. If you are GPU bound, consider something like this.

That said, a typical technique for improving render performance is to reduce draw calls, but you have limited capability to do this with XNA's model objects. As far as I know, you'd have to re-export the model such that there was only one large mesh part that contained the entire thing, and this might actually make the model much larger (if each mesh part's vertex buffer had different attributes) and is complicated by the fact that you'd have to use the same texture and shader for the entire thing, which could also result in much larger textures due to the necessity of having to pack multiple images into one texture object.

Furthermore, if the object is really big you could actually reduce your performance this way, because you couldn't apply any kind of culling to the model to entirely remove draws for parts that are completely off-screen or occluded. It's not always a simple solution, which is why analysis tools and metrics are so important.

\$\endgroup\$
3
  • \$\begingroup\$ +1 for the Hargreaves article. The way used to determine if you're CPU bound is so surprisingly simple, makes you think how you managed otherwise. \$\endgroup\$
    – ChrisC
    Nov 9, 2011 at 23:12
  • \$\begingroup\$ thanx for your kind response Josh, but what about if I use DrawIndexedPrimitive() to draw the model instead of using mesh.Draw(). \$\endgroup\$ Nov 10, 2011 at 7:05
  • \$\begingroup\$ Unless the model uses one vertex buffer behind the scenes (and each part of it is just a subset draw), and you can access that VB, that's not even possible. Even then it is subject to the same constraints in terms of attribute and material issues. \$\endgroup\$
    – user1430
    Nov 10, 2011 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .