• Advertisement
Sign in to follow this  

Too many draw calls

This topic is 1669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so if I'm going to start simple, I'm going to only draw the sides of the cube that I can see. Can anyone point me to a tutorial on how to do that or give an example?

Share this post


Link to post
Share on other sites
Advertisement

That's not starting simple. That's a more advanced optimization... which sides of a cube are visible depend on where it is in relation to the camera, and evaluating that for each cube individually isn't going to get you any perf win (unless you have an orthographic projection from a fixed angle...). In your current implementation, your performance is almost certainly CPU-bound, not GPU-bound.

 

The simplest thing is, like I explained befored, just to put all your cubes in a single vertex buffer at startup and draw that. That will get you interactive frame rates. (Yes, if you need to add/remove cubes at runtime and still have that be fast, then that will be more work... but you said "I'm going to start simple").

 

The next simplest thing is to use instancing. You have one cube model, and a separate dynamic vertex buffer with instance data in it. There is a tutorial on the XNA site here: http://xbox.create.msdn.com/en-US/education/catalog/sample/mesh_instancing. It will require you write your own shader, because your vertex shader needs to compute the position from the cube vertex base position plus the instance position. This won't be any faster, but it will use less memory, and it will be slightly faster to add/remove cubes.

Share this post


Link to post
Share on other sites
Thanks. I'd rather start with instancing if I can remove blocks. It wouldn't make sense to draw a big chunk and not be able to change the blocks in it

Share this post


Link to post
Share on other sites

Thanks. I'd rather start with instancing if I can remove blocks. It wouldn't make sense to draw a big chunk and not be able to change the blocks in it

 

I think you should do some searching for a good tutorial or book and start from the beginning. Other than that, I don't think anyone here is going to say anything that hasn't already been said.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement