Author Topic: Performance critical loops  (Read 4484 times)

Offline LordSloth

  • Sr. Member Mark III
  • ****
  • Posts: 430
Re: Performance critical loops
« Reply #15 on: February 05, 2011, 02:53:03 pm »
ATI Mobility Radeon HD 5870, which in this particular case uses 3 GB RAM.

But you're right, there isn't any performance hit from the units with lines off. Since it happens with just a caps worth of mark one units, it'd probably drop my FPS to the single digits if it was on for just the AI too. I've got a decent enough feel for the appearance of the symbol of a booster unit, so I just presume from that point on that things are boosted, anyways.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Performance critical loops
« Reply #16 on: February 05, 2011, 04:03:52 pm »
I think for sufficiently awkward and big divisors, you will eventually hit a point where a division algorithm will take less cycles than their equivalent bunch of shifts and additions.

But for many small cases, yea they can be expressed as a nice small sum of bit shifts.
Yea, I've only ever used them for when I was literally multiplying or dividing by a power of 2, and only when handling non-negative integers.  With the parasite thing I wound up doing the *48 with the sum of two shifts.  That's significantly less efficient than finding a way to do it in one shift, but as I said about that particular part of code it wasn't nearly as common-case as the areas where we really have to prune mul and div instructions.

In theory, the compiler should be able to optimize something like "x = x * 2" to "x = x << 1" but in practice it has to be careful about the sign of x (and the signedness of x's type), and if I'm using a variable that happens to store 2 (and I happen to know it only stores powers of 2, like our image side lengths), the compiler simply can't assume that.  Etc.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Nalgas

  • Hero Member
  • *****
  • Posts: 680
Re: Performance critical loops
« Reply #17 on: February 06, 2011, 10:58:41 pm »
ATI Mobility Radeon HD 5870, which in this particular case uses 3 GB RAM.

Wow, really?  It's not nearly as smooth as on my desktop, but I haven't noticed that big of a hit on the sad excuse for a GPU that the GeForce 9400M in my MacBook is.  Really large fights get kind of choppy at times, not surprisingly, but I haven't had obvious/significant problems jump out at me with just individual ship types like munitions/armor boosters, like having those as my starting bonus ship type didn't seem any worse for performance than cutlasses or whatever.