The Art of PS3 Programming 99
The Guardian Gamesblog has a longish piece talking with Volatile Games, developers of the title Possession for the PS3, about what it's like to make a game for Sony's next-gen console. From the article: "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."
Re:Halo (Score:2, Offtopic)
It uses OpenGL (Score:5, Informative)
As a programmer, I can attest to OpenGL being a God-send. Not only are programmers intimately familiar with the technology, but it was designed from the beginning with portability in mind. Direct3D, OTOH, tends to follow Microsoft's practices of hiding what's really going on behind the scenes. It's been a little while since I've bothered with Direct3D, but one of Microsoft's biggest features used to be their own SceneGraph known as "Retained Mode". For some reason, Microsoft believed that everyone would want to use their Scenegraph only and damn technological progress. Most programmers who were in the know immediately bypassed this ridiculousness and went straight for the "Immediate Mode" APIs, which weren't as well documented. (Thanks Microsoft)
Wikipedia has a comparison of Direct3D vs. OpenGL here: http://en.wikipedia.org/wiki/Direct3D_vs._OpenGL [wikipedia.org]
Other than that, a computer is a computer, and game programming has always required a strong knowledge of how computers operate. So it's not too surprising that it would be "just like any other programming +/- a few gotchas".
Re:It uses OpenGL (Score:2, Informative)
We can tell Immediate Mode/Retained Mode is ancient history..
Re:It uses OpenGL (Score:1, Flamebait)
Thank God. It was stupid to begin with, yet Microsoft kept pushing it version after version. I know it was still there at least as high as DirectX 5.0.
With OpenGL having been ported to just about every platform in existence, it just doesn't make that much sense to bother with DirectX unless you really have to. (Which thanks to Microsoft's interference, does happen to professional developers. Poor bastards.)
Re:It uses OpenGL (Score:1, Flamebait)
Re:It uses OpenGL (Score:2, Informative)
Re:It uses OpenGL (Score:5, Insightful)
Look, you're welcome to hate Microsoft if you choose, but your memory is rather inaccurate.
Get this: Retained mode was not meant for games. Microsoft never "pushed" it for games. Immediate mode was always there for games to use. Games were always supposed to use immediate mode.
It's been a while since I read the documentation for ancient DirectX versions, but IIRC it actually said, right there, quite explicitly, in the documentation, that retained mode was not meant for high-performance graphics and that games should use immediate mode.
The idea of retained mode was that it provided a much simpler interface. It was intended for use by multimedia applications that did not require the power and flexiblity of immediate mode, but just wanted to throw a few 3D meshes on screen and move them about a bit, without all the hassle of coding all the data structures and transformations by hand. It didn't catch on, and it eventually died, but it wasn't stupid by any means, and something very similar will be making a comeback in Windows Vista.
At least, I say it wasn't stupid. Maybe it was stupid. I don't see how providing a simplified API for simple applications, and a complex API for complex applications, is "stupid", but then I use Microsoft software out of choice, so clearly I don't hate Microsoft badly enough yet for me to be able to judge their decisions objectively.
Re:It uses OpenGL (Score:2)
Re:It uses OpenGL (Score:2)
Re:It uses OpenGL (Score:5, Informative)
Re:It uses OpenGL (Score:3, Informative)
OpenGL is a God-send for a couple of reasons, IMHO:
1) The API is well known by developers, and has remained stable from version to version. This reduces the amount of R&D and training that need to be done for a game.
2) Use of OpenGL allows for portable code. While you can't completely get away with writing the same code between a PC version and a Console version, much of the rendering engine at least has a chan
Re:It uses OpenGL (Score:5, Insightful)
Uh most games nowadays use D3D.
2) Use of OpenGL allows for portable code. While you can't completely get away with writing the same code between a PC version and a Console version, much of the rendering engine at least has a chance of getting reused.
If you write a flexible enough rendering engine this wont matter so much.
3) Carmack says so.
yeah, ok. good reason
4) New features actually go through a standards process, meaning that they get more documentation than just "whatever Microsoft feels like telling you".
Which also means it takes long YEARS for a new version to come out, how long have we been waiting on OpenGL 2.0? Some cool things have come out since and OpenGL is always playing catch now.
5) DirectX is a non-portable skill. It ties you to Windows and the X-Box(s). OpenGL "ties" you to the Gamecube, Windows, PS2, PS3, Linux, Macintosh, etc.
Graphics Programming is a portable skill, I've never met a good graphics programmer who couldnt switch between the two on the fly. Honestly if you can only do graphics in 1 or the other that's pretty worthless.
I'm sorry the whole DX vs OGL war is really old and really lame, Neither are a "god-send". They are both tools, use the one that is best for the job.
Re:It uses OpenGL (Score:2)
Most games for windows use D3D. Consoles are still a big business, and OpenGL rules the day on those. Also, major engines like Doom III and UnrealEngine 3 have Direct3D and OpenGL modes to help with portability.
3) Carmack says so.
yeah, ok. good reason
That's a joke. Smile.
Which also means it takes long YEARS for a new version to come out, how long have we been waiting on OpenGL 2.0?
I believe you mean, "how long were we waiting on OpenGL 2.0?" And you're right. Quite aw
Lockout chips (Score:1)
Most games for windows use D3D. Consoles are still a big business
And most independent games are for Windows.
Re:Lockout chips (Score:2)
Why not code in OpenGL?
OpenGL drivers are freely available on evey major platform, just as C compilers are. Why limit yourself to a single market when you can target them all?
Re:Lockout chips (Score:2)
Re:It uses OpenGL (Score:2)
Correct me if I'm wrong, but I seem to recall, for example, Doom 3 having several different OpenGL 'paths;' straight-OpenGL, Geforce, Geforce 3+, ATI, and something-or-other else, mainly due to propriatry extensions.
Re:It uses OpenGL (Score:2)
Re:It uses OpenGL (Score:2)
True, but part of the reason why you use a graphics API is to spare programmers the work of rolling their own rendering engine in the first place, right? A wrapper layer shields the layers above (maybe), but somebody's still gonna have to write the layers under it. Far from trivial.
I mostly agree, but... (Score:2)
-There's the joke that goes "Don't buy anything from microsoft until at least the third version.". Direct3D definitely fits into that stigma. The early versions of directx were apparently garbage I think Direct3D v3.0 was the version that Carmack blasted when he opted to use OpenGL. I've read that nowadays he is much happier with the API, and he's even working on an Xbox360 game - which is noteable considering that the PS3 uses OpenGL.
DirectX is a non-p
Re:It uses OpenGL (Score:2)
Read anything from Carmack in the last year or so? He's big into pimping XNA [microsoft.com], which means he's presumably gone all the way over to DirectX.
Re:It uses OpenGL (Score:2)
Too bad it's not cross platform
Re:It uses OpenGL (Score:1)
They didnt choose OpenGL as opposed to Direct3D They chose it as opposed to a proprietry API. Thats quite different.
There are plenty of arguments for Direct3D being just as capable as OpenGL a good quantity of people believe its better. This, however, is largely irrelevant to Sony, who are in direct opposition to the people who make Direct3D.
So instead of choosing OpenGL as a wise development move its far more likely they chose it because
Re:Yet another reason (Score:1, Insightful)
Re:Yet another reason (Score:1)
Re:Yet another reason (Score:3, Informative)
Re:Yet another reason (Score:2)
8 Threads? (Score:2, Informative)
ok controller input on one..
graphics on another..
physics on a third
networking on a fourth
sound... ok no problems here, thats 5.
See, even dividing it up into 5 threads causes problems, you need to make sure that you are allowed to do something on
Re:8 Threads? (Score:5, Informative)
TFA says they are contemplating a job-queue organization, with cores taking jobs as they become available. Provided the size of the 'jobs' are limited so they fit comfortably within the overall time it takes to calculate a frame, it should work fairly well. A lot of physical-simulation problems are close to 'embarassingly parallel', anyway.
Re:8 Threads? (Score:3, Funny)
6) Monsters
7) Aliens
8) Baddies
Re:8 Threads? (Score:2)
Re:8 Threads? (Score:2)
7) Aliens
8) Baddies
So obviously, any PS3 game that is lacking one or more of these elements is not harnessing the full power of the console.
Re:8 Threads? (Score:5, Informative)
Just because you have critical sections in one thread that may have to hang out waiting for another thread, doesn't mean that at some point in time the two threads can't execute simultaneously while not needing data from one another. At times like that, you get speedup (especially since you have seperate cores/processing units/whatever)
Re:8 Threads? (Score:3, Informative)
The article suggests that this be done by having a single "controller" processor rapid fire the tasks to the other processors. While this would work, it's also less efficient tha
Re:8 Threads? (Score:3, Interesting)
Controlers- no reason to have a thread, you use interrupts and wake up once a second when an input changes. No thread needed.
Sound- unless you're doing heavy duty software mixing (not hardware mixing or channels), you don't need a thread, its all interrupt driven.
Network IO- a thread probably isn't the best way to do it for the client. Just poll for IO once a frame. Or use select to sleep if you have no other processing to do
AI- this one makes more sense, a smart AI can try and pr
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:2)
Streaming? Thats the very definition of what DMA is meant for. No need for a thread to stream content- you decode it to me
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:2)
Re:8 Threads? (Score:1)
But, I was under the impression, and I'm not some expert, that the benchmarks showed games like these running better on processors that don't necessarily have better threading capabilities, which leaves me with the impression that while these games are multithreaded the bulk of the work still relies on only a handful or even one thread. Again, no expert so I could be totally wrong.
I know personally I love threading
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:2)
Thats exactly the problem the industry is trying to fix. The move to more than one threads to make things efficient.
Take a look at it this way. Processors are made on 65nm processes, which will go down to 45nm processes. We're reaching the limits of moore's law. Their overclockability will increase as dies are stacked like PCBs, but that will reach an end too. Next step really is a break from the traditional sin
Game Dev Conf: Go Multithreaded (Score:2)
At last years game developer conference both Intel and AMD were saying that games should go multithreaded, that future CPU performance improvements were largely going to come from multiple cores not clock rate. Intel and AMD were both demonstrating current games taking advantage of threading. I forget what the game was but one racing game uses a second thread for optional effects. When running a single thread you get a small amount of dust, smoke, flames, etc. Ho
Re:8 Threads? (Score:2)
Re:8 Threads? (Score:1)
You don't simply break up a game into 8 threads. Remember 7 of those 8 processors are not really general-purpose CPUs, but SPEs, more like vector processors. Moreover, the SPEs don't have direct access to main memory, they have to be spoon fed from the main processor or some sort of DMA controller.
So the main CPU would have to set up the SPEs and then handle all of the networking and I/O and stuff, while the SPEs would handle the
Pipeline them or divy up loops (Score:2, Informative)
If your intention is to put independent tasks out to different processors, you will run into huge issues like the ones you describe.
Instead, consider the beginning of each logical step in the game loop as a "constriction/delegation" point: You constrict, meaning that only one thread is running right now. Then, say, it's time for particles. You now wake up your eight particle worker threads, divy up the gargantuan 2000 particle emitter loop into 250 emitters each. You the
Re:8 Threads? (Score:5, Insightful)
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:2)
Re:8 Threads? (Score:1)
2) cut the screen horizontally 3 times
3) ???
4) profit from 8 cores
Re:8 Threads? To fix what I hate most (Score:1)
You can make good ripples on water, and do other geometry things. Make the trees have REAL leaves (like that great Cell demo). Make more individual blades of grass and such. Just little things that act correct so the world looks more "real" and less "here is a random bush so you don't notice there are no bushes".
Hair, clothes, weapons. Make them a
controller input on one??? (Score:2)
Re:8 Threads? (Score:1)
For instance take a simple pool simulator with 4 or 5 balls. You hit the cue ball in to the triangle of pool balls. Collision detection isnt utilized until after the balls have been moved so you simply give each ball and SPE to work out where its moved to and you are processing them all at once. Not to hard.
The process can be used for testing actual collisions as well so that can be done for each ball on each SPE as well.
Thing is there are som
Re:8 Threads? (Score:1)
Re:8 Threads? (Score:2)
SPE overhead (Score:4, Insightful)
(If the OS analogy is flawed, sorry).
Re:SPE overhead (Score:2)
Re:SPE overhead (Score:2)
So, you don't just get to create 8 threads all of which can do arbitrary jobs, but you must explicitely split and divide the jobs and assigned them to specific processors (and do this from the thread that runs on the master processor). In a SMP system, the OS can move threads across processors freely, but not so here, and because of that pro
Re:SPE overhead (Score:1)
Er, I wasn't trying to make it sound different than this. Sorry if I did.
The need to constantly copy chunks of memory between individual processors would require either a very clever OS, or much hard work for the programmer.
Yeah, it'll be interesting to see what tricks pe
Re:SPE overhead (Score:2)
Re:"i guess"? (Score:1)
Anyone that did have that impression, and was supposed to be developing for the PS3, should be out of a job.
When it comes down to it, any speculation or flaming about how difficult or easy it is to write code for the PS3 is idiotic. It doesn't change the reality of it - difficult or not - and in the end, the games are the only thing that m
Re:"i guess"? (Score:2)
If you don't think it matters, try writing a game - any game - in assembler. You'll soon realize that how much time you spend dicking around with a stupid interface (API would be too much of a compliment) translates real well to how good your game will be.
Re:"i guess"? (Score:2)
All I'm saying is that spouting off about it on slashdot doesn't change how hard it is, and in the end, even if it is hard - if we still get good games, what does it matter us as end users?
Of course, if we don't get good games because it's too hard, then it does matter, but bitching about it on slashdot still won't fix it.
Re:"i guess"? (Score:1)
Re:"i guess"? (Score:2)
DMA? (Score:1)
I think you misspelled DRM
Missing the point. (Score:5, Informative)
Don't think
Processor 1 = AI
Processor 2 = Physics
Processor 3 =
etc.
Instead picture the main CPU going through a normal game loop (simplified here)
Step 1: Update positions
Step 2: Check for collisions
Step 3: Perform motion caluclations
Step 4: AI
At the beginning of each step the main CPU farms out the work to the SPE's. So, you have a burst of activity in the SPE's for each step, thun a lull as the main core figures out what to do next.
Re:Missing the point. (Score:1)
Re:Missing the point. (Score:1)
Unless I completely mis-understood all of my processor architecture / optimizing compiler classes, to get the best usage of a processor's resources you want all of those resources to be
At the end of day... (Score:3, Funny)
Unlike PC !!! (Score:2)
What bus contention? (Score:1, Insightful)
You do realize that the memory in each SPE is *local* memory, right? The 7 SPEs can all run flat out without creating any bus contention whatsoever on memory access.
And as for the DMA hardware and interconnect buses, those have immense bandwidth. I really wouldn't be concerned about contention on DMA to main memory.
The more likely problem is DMA latency, since small DMA requests may get delayed by longer ones. However, even that is unlikel
The PS3 creams the Xbox 360. (Not a troll) (Score:4, Insightful)
The limiting factor on computing speed in the last several years has not been processor design or clock speed, but memory speed. Normal architectures feature two levels of fast SRAM to insulate the processor from the latencies inherent with accessing DRAM over a shared bus. That doesn't get rid of multi-cycle delays, it just tries to reduce their likelihood. Data cache misses are expensive, but instruction cache misses are even more expensive -- all the pipelining that modern processors use to handle large workloads efficiently will break down every time the processor stalls loading instructions from main memory.
The PS3's Cell processor offers a different solution to the problem -- sub-processors with fast local memory, and an explicitly programmed way to copy memory areas between processors (the "DMA" that the article mentions). The SPEs allow significant chunks of the batch-processing-style parts of a game to run on a processor that has no memory latencies, for data or instructions. Since memory-stall delays can run into the double digits, you can expect the performance increase from fast memory to be in the double digit range too. I've seen a public demo of some medical-imaging software that ran ~50x faster when rewritten for Cell. (The private demos I've seen are similarly impressive, but I can't describe those in detail. :-)
A traditional multi-processing architecture, like the 3 dual-core chips in the X360, has no such escape from the memory latencies. All coordination of memory state between processors (i.e. through the level 2 cache) is done on demand, when a processor suddenly finds it has a need for it. Prefetching is of course possible, but the minor efficiency gains to be made from prefetching (when they can be found at all) is vastly outweighed by the inherent efficiency of explicitly-programmed DMA transfers. Multi-buffering the DMA transfers allows the SPEs to run uninterrupted, without having to wait for the next batch of data to arrive -- something that isn't really possible with a traditional level-2-cache in a traditional multiprocessing system.
In short, the very nontraditional setup of the PS3's Cell chip is capable of vastly outpowering the traditional multiprocessor setup of the X360, mostly due to successfully eliminating memory latency.
Yes, writing code that can run like this is a major freaking pain in the ass. But so what? The biggest reason most code is hard to run on such an architecture is that the code was poorly thought out, poorly designed, and not documented. Any decently-written application can be re-factored to run like this. Besides, this is the future: Cell really does seem to solve the memory latency problem that's crippling traditional computing architectures, and the performance difference is astounding. If you can't rise to the level of code written for such a complex architecture, then your job is in danger of getting outsourced to Third World nations for $5 an hour...as it should be. So quit your whining.
(First post in ten months. Feels good!)
Re:The PS3 creams the Xbox 360. (Not a troll) (Score:1)
Re:The PS3 creams the Xbox 360 (Score:2)
>cycles (about 5 nanoseconds). It only had 24MB of it, but any
>speed problems you may encounter were not a result of memory
>latency. This is also why even the 1st generation Gamecube games
>ran with silky smooth framerates.
Bullshit. How can you compare cycles for GC (485Mhz) with those of Cell (3.2Ghz)? Besides on this official specsheet (http://www.nintendo.co.jp/ngc/specific/ [nintendo.co.jp]) the access speed of 1T-SRAM is 10ns, not 5ns.
The PS3 creams the Xbox 360 (nice try Mr. Gates) (Score:3, Insightful)
The Cell has been available for programming for a while now. I think reference platforms (i.e. other than PS3 prototypes) might even be available. Cell is being used for far more than the PS3. Also, sure the PS3 might run faster than 3.2 GHz, but you make that sound like a bad thing!
Re:The PS3 creams the Xbox 360 (nice try Mr. Gates (Score:2)
I deal with that type of software on an almost daily basis. Not necessarily with games programming, but in embedded applications I design the hardware for. It seems that no matter how powerful I design the platform, some bonehead seems to cripple it with crap code exactly like you describe.
Thank you!
-dh
Re:The PS3 creams the Xbox 360. (Not a troll) (Score:1)