Performance Question

Aug 24, 2009 at 11:45 PM

hello, i'm developing a game that i plan on porting to xbox360 when i'm finished with it. however, i can't actually test it until i buy a creators account, and i'm putting that off til the end. so my question i guess is this; what sort of performance should i expect to get on the xbox with farseer? currently on my pc, the game starts to get issues after loading around 35 to 40 bodies. has anybody tested this on xbox? how many bodies can it load before getting slowdown?

also, what are some techniques i can use to ease up the load on my pc? i don't exactly have a great computer (pentium 4, 2.4 ghz) but my game starts to die a little as soon as somebody shoots 4 or 5 bullets. granted, they never go away, but still it's a little ridiculous, and i can't realistically assume that between 4 players, they will use less then 5 bullets at a time. is there anything i can do to make the bullets less cpu heavy? i'm really only using farseer for collision on them, but it's really the only way i can think of. it would be great if i could perhaps just use a geom without a body, seeing as it is just going straight. is this possible? (if so, how?)

Coordinator
Aug 25, 2009 at 12:49 AM
Edited Aug 25, 2009 at 12:51 AM

35-40 geometries sounds really low to me. Farseer can handle about 800 geometries on my computer.

I've still not received the Xbox I ordered about 3 weeks ago, but from what I've heard, you should not expect too much from the Xbox platform. As for techniques to speed up your game, you could take a look at my blog: http://ianqvist.blogspot.com/

Scroll down a bit, there is a post series called "Performance tips and tricks" you might want to take a look at. I will make a Xbox 360 tips and tricks series whenever I receive it and have done some testing on its architecture.

Here are some additional tips:

1. Use pools.

We use the Pool<> generic class inside Farseer Physics to reuse objects instead of disposing them and create garbage. It is also very good for stuff like bullets where you have to reuse the geometries all the time.

2. Remember to use cloning if you create several geometries.

Simply use the factories (GeomFactory.Instance.CreateGeom()) to create clones of already existing geometries. Using clones will cut down in the time it takes to compute the distance grid.

3. Split work up into several physics simulators

If you have a background with falling boxes or something like that. Use a separate physics simulator for that and put it into its own thread. Remember that you can't collide stuff between several physics simulators.

4. Change broad phase collider

You might want to see if any of the other broad phase colliders fit your game more than the default one. Some of them might also fit better on the Xbox 360

---

Oh, almost forgot. No, you can't use a geometry without a body. Not to worry, the body adds no overhead to the geometry since it is just a point in space that the geometry is placed at. You wrote you only used the collision detection part, what exactly does this include? if two geometries collide and they separate from each other, you also use physics - if you don't need that, you can turn it off.

Edit: My 800 geometries figure is when I compile under release mode. You should get 2x performance in release mode.

Aug 25, 2009 at 2:29 AM

I think you should be able to have more than 35 geoms on a 2.4ghz p4 but you may be doing alot of other stuff or something too.

I have made a few games for the 360 using farseer and have found that whatever your pc can do (if your pc is around 2ghz) divide it by about 4 if you are just using bodys and geoms and if you are using lots of chains, springs, and joints divide it by 10.
With full physics i can get about 50 bodys (circles for instance) at about 25 fps on 360. On pc that number goes to about 260 at 30fps (on a 2.6ghz core 2) (i dont know how you hit 800 but boxes would be a bit faster i suppose).

Also you could look at multithreading farseer on 360, there are 4 hardware threads for you to use. Also 1 xbox 360 thread running c# code with the garbage collector and all that is about equal to a 600mhz pentuim 3 so the xbox version will run wayyyy slower. However its graphics card is equal to a geforce 7800 or a mid range radeon 3000 series.

 

Hope this helps.
Also look at genboxs optimization blog its good :)

Aug 25, 2009 at 3:20 AM

well this is a little embarassing. turns out i turned the iterations up to 200 a while back and forgot about it. i turned it back to default and now i can get around 170 bodies.

thanks for the tips tho, i'm sure they'll come in handy.

Coordinator
Aug 25, 2009 at 5:22 PM

@danthekilla: I can hit 800 boxes (boxes are the simplest of forms in the eyes of the physics simulator - even more simple than triangles since a box that is stacked fills its AABB) with release mode where some geometries are stacked and some are falling in free fall. I remember tuning the contacts, allowed penentration and iterations to reach 800 while maintaining stability.

@SlimeQ: That is a good improvement you got right there. Tuning the parameters of the engine can greatly increase performance. All the algorithms are still high in complexity (quadratic complexity in big O notation), but you can shave some time off by reducing iterations, lower contact count and the like. It is a matter of accuracy vs. performance.