Due to the holidays, I actually have some time to get back to programming. Up until now, my code has been focused on the machine and engine layers…rendering, memory management, job control, debug scaffolding, etc. All of the items which are needed to get things on screen, but do not have any of the behavior nor game play parts.
Most game engines have gone away from trying to describe game objects with explicit C++ class hierarchies. Very quickly, there is a base object called CObject which has everything but the kitchen sink in it. This also creates an interconnected mess between the tick cycles for the object and all of the game systems. It is very hard to parallelize the tick loop and impossible to move the objects off to extra processors such as the SPUs.
Continue Reading »
I made the leap. Today was my last day at Sony. It has been an amazing time there and I am truly honored to have worked with such talented people.
…but something came up…
I am starting a new game studio in San Francisco.
I am heading off for the next few days to an SPU seminar that I am running. At work, I spend a lot of my time dealing with the SPUs on the PS3. In fact, if you are using the libswcache libraries in your game, then you are using code that I wrote. The SPUs are interesting beasts for multiprocessor work. They are not as easy as the homogeneous multicore solution for the XBox360, but for raw processor power, not much can beat the SPUs right now.
My work tends to be around making the SPUs easier for developers to use. Software caching (like libswcache) are ways to deal with non-uniform memory systems and making the architectural complexities more transparent to the end programmer. I have a lot of experience with C++, so I have been looking at how templates and auto_ptr‘s can help. Libraries like these do not give you the peak performance, but it makes it much easier for the general gameplay programmers to work on the SPUs. I have found that game development is a constant trade off between easy to use architectures which any generalist programmer can code for and extremely high performance architectures which require a specialist.
I spent the afternoon adding Lua to my code. It only took about an hour to get the Lua library compiling and running. The rest of the time was setting up the various hooks to make the scripting language actually functional. I did not have time to add an interactive parser, that is on my list of things to do.
I have used Lua on previous games and never been that happy with it. It tends to run slowly and require more memory than you would expect. Also, most people tend to use it during development by reading in text files and doing on demand parsing. This scares me since I prefer doing type checking and variable checking at a compile time…one typo and suddenly your run-time can blow up. In some games, I have made the memory allocator throw an assertion if someone tried to allocate a var, string, etc. that was not seen before. This seems to stop the typo problem, assuming that the game (and testers) have coverage over every script.
Continue Reading »
I have implemented a task system for my brushing program. In many ways, it emulates a PS3 by creating 6 threads which sleep until told to do something. That “something” is a function which does a task and then exits. There are two issues with this that I am resolving at the moment.
- It is hard to debug the tasks when there are hundreds or thousands a frame
- I want to emulate the PS3 SPU local store, which means segmenting my memory space
To make each of these easier to deal with, all of the task entry functions take an argument. This argument is a pointer to a ClTaskArg class. Tasks are expected to derive from this class to get their arguments into, and potentially out of, the task function.
Continue Reading »
I am only 20 pages into it, but The Art of Multiprocessor Programming has become my new reference book. It deals with all kinds of lock-free algorithms, queues, and synchronization methods.
Going forward, it is critical that programmers understand how to deal with multiprocessor systems. While this book focuses on shared memory systems, the concepts are still applicable to the PS3 (which does not have a shared memory system due to the SPUs).
A common discussion in computer architecture is bandwidth versus latency. Each is important, but it is critical to understand the tradeoffs for each.
Imagine a garden hose. Connected to the hose is a hot and cold water faucet. As a user, you can turn on more hot or cold water. Then, at some time later in the future, the water coming out of the end of the hose is that new temperature.
- Bandwidth is how wide the hose is.
- Latency is how long the hose is.
Continue Reading »
I just put up a post on the PlayStation blog about the PlayStation-edu program:
It is a program to get development hardware into the classrooms of universities and colleges.
I am giving a talk about it at the Game Education Summit next week in Dallas.
I just converted my app from Cg to HLSL. No real reason, except that I didn’t want to be locked into nVidia graphics cards.
In general, I find Cg more straightforward than HLSL. However, once I finished, it does not really make any difference to my app code because I have abstracted the shader layer away. Considering that I plan to stick with very straightforward shader files (and not even bother with .fx files), it probably does not matter in the end.
My next step is to create a job management system which runs on multiple threads…
The renderer which I have been working on is based around brushes. At the moment, they are very basic, but they produce some pretty images. As mentioned in previous posts, there is a cube with each side having a different image on it.
I finally hooked up a screenshot function to the app as well as a mode to capture at 30fps. All of those images create a movie. It is not perfect, because the D3D function GetBackBuffer() stalls like crazy. I am still trying to figure out how to capture at a decent framerate without having to use a video capture card.
For the movie, it shows the brushes moving around the images, turning the cube, and a few other effects. Right now, there are very few rules for the brushes, so I need to add some more to see what happens.