Possession and the art of PS3 programming

.ram

Editor in Chief
Team-Mitglied
PSN-Name: dethforce
#1
I spent much of last December writing a preview of PS3 zombie shocker, Possession, for the Official PlayStation 2 magazine. The game is a mouth-watering mix of survival horror adventure and squad-based shooter, with you commanding a ravenous undead army against a city stuffed with civilians, cops and soldiers.

The magazine is now out on the shelves, so I can finally talk about meeting up with Possession developer, Volatile, and chatting about what it's like to write games for Sony's next-gen hardware. At the time, the team were working with an emulator rather than a full PS3 dev kit, but already seemed comfortable with the peculiarities of the multi-processor behemoth.

Of course every developer is going to have a different take on PS3, but this is what one of them had to say...

First of all, as with Killzone developer Guerrilla in a recent online Q&A sesh, they were happy to point out that PS3 is not as complicated to write for as we've all been led to believe. Apparently, the machine's use of Open GL as its graphics API means that anyone who's ever written games for the PC will be intimately familiar with the set-up. In fact, PS3 employs a cut-down version named Open GL ES, which is even simpler - as Volatile's lead PS3 programmer, Lyndon Homewood explained:

"ES is designed for things like set-top boxes and mobile phones, where you want the fundamental graphics but don't need some of the fringe stuff that Open GL has. Because you've got that on PS3, it's going to be much easier than the PS2 to get something up and running - there are hundreds of books out there for it, so you can do your background reading. All the documentation is there."

We also got onto talking about how PS3 will deal with Cg - a version of the programming language C, which allows developers to code for advanced graphics processing units, specifically in the area of 3D shaders. (You can read more about Cg here and here). You may be completely up to spec on how this works, but Lyndon gives a decent beginners guide if not:

"Cg gives you a standard documented API for programming graphics chips. The main two segregations of Cg programming are the vertex shader and pixel shader. With the vertex shader you can act on 3D models at the vertex level, so for each triangle you can do something on each corner and then everything in-between is interpolated. So if you want to make your whole shape bigger, you can just push all the vertices out a bit. In this way you could, say, morph your character into a giant just by scaling up all the verts. It's a lot easier to get to that point in the graphics pipeline.

"And then you've got the pixel shaders. When you render each triangle on screen the GPU asks whether you want to do something to each individual pixel you render... so at this point you could run some sort of mathematical algorithm on each individual pixel - perhaps a lighting effect like high dynamic range lighting (a rough Wikipedia entry on HDR lighting can be found here). And that wasn't possible on PS2.

"All of this is already available and won't be a massive leap from what you're seeing on PCs with high-end graphics cards. But obviously on PS3, you've got eight chips to spread the processing cost over - the main PowerPC chip and seven SPE chips. In a PC, there's just one CPU, two in a dual processor machine. Having an eight CPU multi-processor system in your living room is pretty flash.

"At the end of the day it's just a multi-processor architecture. If you can get something running on eight threads of a PC CPU, you can get it running on eight processors on a PS3 - it's not massively different. There is a small 'gotcha' in there though. The main processor can access all the machine's video memory, but each of the seven SPE chips has access only to its own 256k of onboard memory - so if you have, say, a big mesh to process, it'll be necessary to stream it through a small amount of memory - you'd have to DMA it up to your cell chip and then process a little chunk, then DMA the next chunk, so you won't be able to jump around the memory as easily, which I guess you will be able to do on the Xbox 360.

"The graphics capabilities of PS3 will, I think, be slightly above the absolutely top-end graphics cards on the PC, but you've got much more processing power in the box so you're going to see a lot more physics, a lot more generated geometry. With water ripples, for example - they're pretty much algorithms, you have a flat plane of triangles and you run some sort of mathematical algorithm over it to generate a surface rippling effect - well, you will have the processing power to do these sorts of generated geometry effects On PS3. You could actually put one chip aside just to do that..."

According to Homewood, the management of the SPE chips is going to be a major consideration. One way is to assign specific roles to each of the chips - get one handling physics, one working on AI, etc. This might sound tidy, but Volatile are not convinced - partly because certain gameplay events, like a massive shoot-out, are going to create spikes in demand for, say, animation, collision detection and rag doll physics. One SPU working alone on each of these elements won't be able to deal with such spikes efficiently. Also, there's the question of co-ordination:

"The way we're thinking of doing it ourselves is via a job queue. We'll stick the jobs we want to do into a queue on the main processor and then we'll get the SPEs to pull off a queue entry and process it whenever they're free. You want to make sure all of your processors are always running. If you give the chips specific jobs, you'll end up with a lot of them being idle - you won't get the maximum out of PS3 doing that unless you time everything perfectly, so that the time it takes to do the animation on the first chip is exactly the same amount of time to do the physics on the next chip, which is exactly the same length of time it takes to do all your AI on the next chip - I think that would be extremely problematic."

One last thing. Volatile reckon PS3 is going to be much better for HD cinematics than Xbox 360, thanks to its Blu-Ray storage medium. 20 minutes of HD-TV footage takes up around 4.7GB, so an Xbox 360 game would quickly run out of space. This is going to matter more in the coming years as movies and games merge and we see more film elements being brought across to games.

So there you go. PS3 is relatively easy to program for if you have experience with high-end PCs - certainly more straightforward than PS2 with its proprietary graphics APIs. We've also heard lots of talk - from various studios - that Sony's developer support will be a lot stronger with PS3 (it's already much, much better with PSP apparently). Time will tell.

For now, we have screenshots, demos and promises, we have enthusiastic developers taking their first glance at the next generation of Sony hardware. We don't have games.
http://blogs.guardian.co.uk/games/archives/2006/01/27/possession_and_the_art_of_ps3_programming.html
 
Top