Sign in to follow this  

Hardware Instancing in DirectX vs XNA

This topic is 3462 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

Hello everyone, Im struggling with Hardware Instancing for the XNA platform. I want to render a lot (25000) of almost the same boxes in one scene. So HI should be the technique to use, but i cant get it to perform right with XNA. First i tried the example from Focused Games, but this was giving me hardly 5~6 FPS with only a 1000 rotating textured squares (2 triangles; 4 vertices makes 4000 vertices in total). While searching for a solution i found a DirectX example on this forum. I tried this example to check wheter HI was working on my system in the first place. This example gave me 35~40 FPS with 64000 textured cubes on the screen! So HI is working, but not (yet) with XNA. Now ive converted this DirectX code to render the 64000 using XNA. The result is slightly better compared to the focused games example (got 8~10 FPS now), but still not what i was looking for. Can someone check if i have overlooked something in the creation of the vertexBuffer? Or maybe it is something else i missed. My converted code is available here: http://paste-it.net/public/dbef85b/ Specs: Intel Duo Core @ 2.2GHz 2GB RAM nVidia GeForce 6200 (128MB) Windows XP Pro XNA 2.0 Visual Studio 2005 DirectX 9.0c

Share this post


Link to post
Share on other sites
Thanks, this sample is finally working as it should!

I only tried this sample for HI in XNA, but apparently it isnt working properly.

Ive been looking through the code briefly but couldnt find a major difference between my code and the code of your sample, so i guess HI is very sensative to minor changes in its configuration. Ill read through the documentation.

Share this post


Link to post
Share on other sites
Support for hardware instancing is somewhat "spotty" across D3D9-class hardware (especially on ATI R300 and R400-based GPU's), so yeah it's going to be pretty sensitive to your configuration. If you need your app to run on the full range of D3D9 hardware, you'll probably want to also implement shader constant instancing as a fallback.

Share this post


Link to post
Share on other sites

Just to confirm what MJP said, hardware instancing support is indeed *very* spotty on D3D9 hardware (officially SM3 only). In my experience, it may not even improve performance by as much as you would expect on ATI hardware at least, with real performance gains only nociable for > 10K models. YMMV of course.

To enable hardware instancing on ATI SM2 hardware (before the X1n00 models), there's a little hack detailed in that topic you linked to. I'm not sure if this will work with XNA (certainly not on the 360), but you might want to give this a shot if you're targeting ATI SM2 hardware:

graphics.GraphicsDevice.RenderState.PointSize = unchecked((float)1414745673);

Share this post


Link to post
Share on other sites

This topic is 3462 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this