Resolving PS3 callstacks

October 29, 2011 – 6:06 pm

Hopefully, your engine includes a crash handler. If it does not, stop reading, add one (here’s simple example) and then continue. In most cases, when something goes wrong, log files contains fully resolved callstack. However, sometimes, especially at the last stage and (semi) final builds, crash reporter might be disabled and now all we have is a list of addresses. Luckily, it’s still possible to resolve those, using Sony’s tools (that’s also what I use in PS3 version of MemTracer). It’s a little bit cumbersome, as you need to run commandline utility for every address. I had to do this recently and it was annoying enough to make me hack a quick Perl script that automates the whole process. It’s really simple, just copy your stack trace from log to text file and run ps3bin.pl self_file txt_file_with_trace . It’ll try to resolve any hexadecimal numbers it’ll find in the text file. Script can be found here.

The Broken Windows Theory

October 3, 2011 – 12:43 am

The broken windows theory is a criminological theory first introduced in 1982 article by James Q. Wilson and George L. Kelling. The gist of it is given in this example: “Consider a building with a few broken windows. If the windows are not repaired, the tendency is for vandals to break a few more windows. Eventually, they may even break into the building, and if it’s unoccupied, perhaps become squatters or light fires inside.”

I have first found out about it when reading about zero tolerance policy in NY in early nineties. Some studies claim it was one of main reason for sudden drop of crime in NYC during Bratton/Giuliani era (if you’re interested in one of alternative theories – read Freakonomics, not sure if it makes more sense, but surely is more entertaining).

If you think about it, similar analogy can be applied to software. We start with a clean plate and build something from nothing. Everyone has seen examples of mature code bases. Do you think their current shape matches the initial plan?

Read the rest of this entry »

Trailer time!

September 30, 2011 – 4:49 am

Two trailers released recently. Starbreeze showed first footage of their Syndicate remake:

I mostly worked on cancelled Bourne project when I was there, but lots of friends still at SBZ, so I’m glad to see their hard work is coming to fruition.

Few days before, 2K released trailer for the game I’ve been working on for the last 15 months – Darkness 2:

I really like it, mostly because it explains the setting/first game events a little bit. There’s still lots of work ahead of us, but we’re on the homestretch.

Optimizing without fear

August 21, 2011 – 5:59 pm

As you can probably tell from this blog, I spent fair chunk of my time optimizing code/thinking about optimizations. One of the main problems with optimizing code is making sure we didn’t break anything in the process. It might be tricky, especially when modifying algorithms with many edge cases, but even simple changes are dangerous, probably because people don’t test them so thoroughly. I still feel a little bit nervous upon seeing “Little optimization in XXX” in P4 changelist description (heck, I’ll be the first one to admit, I broke code as recently as last week…). What can we do to make optimization process a little bit less scary?

Read the rest of this entry »

STL interface

July 25, 2011 – 12:00 am

As you are probably aware, game developers have mixed feelings about STL. Sure, it has advantages, it’s already there, doesn’t have to be coded from scratch, it’s standard. On the other hand, the guidelines are very broad, implementations can vary wildly. Performance/memory guarantees seems to be hard to enforce. Even if the interface is always the same, there’s enough wiggle room underneath to seriously break some applications. Take clear() method for example. All it guarantees is that size() == 0 afterwards. It doesn’t say anything about memory. I’ve heard of at least one STL implementation that would free container memory in clear().

Read the rest of this entry »

Hard Reset

July 18, 2011 – 1:20 pm

My buddies at Flying Wild Hog have announced their first project recently. It’s a dynamic cyberpunk FPS with character progression elements. Make sure to check out the teaser:

Been a long time since I’ve been to Poland so had no chance to play it, but after talking with people who did and knowing the team behind it — I expect good stuff.

Flattening trees

July 3, 2011 – 5:21 pm

Trees are one of the most popular structures in game development. Your skeletal hierarchy, your attachments — all this can be represented using trees. They lend nicely to short & clean code, especially with recursive functions — you typically perform your operation on a root, then call the same function for all children. Problem is — it’s not always the most effective way of doing things. Consider the most canonic form of tree traversal:

void NodeFunc(Node* n)
{
  DoSomethingWithNode(n);
  for (int  i = 0; i < n->children.size(); ++i)
  {
    NodeFunc(n->children[i]);
  }
}

Clean, concise and not very cache friendly. Unless we’re careful with our allocation strategies, accessing nodes results in a cache miss in majority of cases. On top of that, C++ compilers usually have a hard time with optimizing recursion, so we’ll pay the price for pushing/popping arguments and it also makes it harder for compiler to precalc things that do not change during traversal. Here’s a quick trick that I like to employ to flatten tree structures.
Read the rest of this entry »

Hidden enemy

June 20, 2011 – 1:20 am

Consider the following piece of code:

void FindFrames(const S* seq, float d, UINT& outFrameA)
{
    const UINT n= static_cast<UINT>(seq->fd.size());
    outFrameA = 0;
    while(outFrameA + 1 < n && seq->fd[outFrameA + 1] < d)
    {
        ++outFrameA;
    }
}

Looks innocent, right? Well, it was slow enough to show up quite high in the profiler… It might seem surprising at first, but if you’ve done some console programming in the past, you can probably recognized our old foe – load-hit-store here.
Read the rest of this entry »

Demoscene tribute – Camorra

June 9, 2011 – 4:39 am

Camorra was a Polish demoscene group. They might have not gained same level recognition as Sunflower/Pulse, but they sure were one of the best squads in the first years of Polish PC scene. Camorra actually won the first Polish PC party – General Probe 1995. Sadly, couldn’t find this winning demo (Gust) anywhere. Let’s start with Gustation then. It’s their 64k intro from CAF 1995, took 2nd place behind Why by Adrar Design:

Camorra was pretty much Maf (coder) + Ari. They’ve been cooperating with other musicians (Snoopy, XTD) and artists on per-production basis. Camorra’s signature trait was very clean design with perfect music synchronization, but later they started to include some really advanced effects. Disgust was probably peak of this technological race. This demo won General Probe 1996 (…2nd place taken by yours truly+Raiden+Falcon+Draken):


I remember being really impressed after seeing this 8k polys Porsche (OK, so it wasn’t perfectly smooth, but it was 8k!! :).

Later Maf started experimenting with more artistic approach + fake hi-color modes, inspired probably by Orange demos. Results are Gu-star:


… and especially their magnum opus and – in my opinion – one of the best Polish demos ever made – Planet Logus-T5:


Logus was released at the Intel Outside 3 party. After that they also released Jest (64k intro, Assembly 1997), which sadly was the last production from Camorra…

Maf wasn’t done with coding, though. In 2001 he started Kurnik.pl – one of the first Polish portals with online games, probably the most popular one to this day.

Riddle

June 3, 2011 – 3:22 am

Normally, I try to avoid C++ bashing, so trendy nowadays. It is what it is, but we’ve to use it anyway. Today, however I encountered a funny bug that made me wonder a little bit. Consider the following snippet:

void Lol(float x, bool b)
 {
const float y = x + b ? 1.f : 0.f;
rde::Console::Printf("Y = %f\n", y);
 }
...
Lol(5.f, true);

What will be printed to the screen?
Read the rest of this entry »