Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
Are the models big enough that they aren't always visible? Culling? –  Daniel Nov 9 '11 at 20:54
add comment

1 Answer

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.

share|improve this answer
    
+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. –  ChrisC Nov 9 '11 at 23:12
    
thanx for your kind response Josh, but what about if I use DrawIndexedPrimitive() to draw the model instead of using mesh.Draw(). –  Afzal Ahmad Nov 10 '11 at 7:05
    
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. –  Josh Petrie Nov 10 '11 at 15:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.