Skip to content
Features

Inside the Xbox 360, part I: procedural synthesis and dynamic worlds

Hannibal did some digging on the architecture at the heart of the Xbox 360 and …

Jon Stokes – | 0
Story text

Introduction

When word first got out that Microsoft was planning to get into the game console business, I was skeptical. First, I was skeptical that the rumors were true, and when they turned to be true I was skeptical that the console would have any impact on the market. Today, as an Xbox owner myself, I’m glad to say I was wrong. Microsoft was able to leverage their software expertise and deep pockets to rapidly develop a console that didn’t just have an impact on the console market, but went from zero to second place in terms of market share.

Despite the fact that Microsoft scored a touchdown with the Xbox, there’s no denying that the console was something of a "Hail Mary" pass. With a slim, 19-month gap between the Xbox program’s start to the shipment of the first unit, the Xbox didn’t exactly represent a major investment of resources for the world’s number one software maker. However, things were different this time around.

Microsoft started work on the successor to the Xbox in 2002, and they went into the project gunning for the top spot in the console market. Unlike the original Xbox’s Intel x86 CPU and nVidia-based graphics core, the hardware that powers the Xbox 360 is custom-made from the ground up to run games, high-definition video, and digital audio.

In a move that surprised all of us, Microsoft tapped IBM to design the microprocessor that powers the Xbox 360. IBM drew on the results of the same Broadband Processor Architecture (BPA) initiative that produced the Playstation 3’s Cell processor in order to furnish the next-generation Xbox with a truly next-generation core that looks set to last at least the five-year life of the average game console.

Codenamed Xenon, the multicore PowerPC CPU that IBM designed for the Xbox 360 boasts a number of unique features that set it apart from any microprocessor seen to date. The present article covers these features in detail, from the processor’s triple-core design, to its caches, deep pipeline, lack of an instruction window, and expected performance.

Before we talk in detail about the way that IBM put together the Xenon CPU, we should first discuss Microsoft’s vision for the role that Xenon should play in powering the next generation of games. Thus Part I of this series will be devoted to exploring the types of applications for which the Xbox 360 was designed, with a particular emphasis on 3D gaming and the real-time procedural synthesis of in-game geometry.

Download the PDF
(This feature for Premier subscribers only.)

Introduction to procedural synthesis on the Xbox

Dynamic worlds

Since at least 2003, Microsoft has been talking up the idea of “procedural synthesis” in games. In addition to the information on the technique provided in interviews, Microsoft has filed a very detailed patent that outlines how this will work on the Xbox 360. Since the unvieling of the new console and the confirmation of many details that had previously been only unconfirmed rumor, it’s now possible to read this patent with the actual Xbox 360 implementation details in mind in order to learn exactly what Microsoft’s ideas for procedural synthesis are and how those ideas function in their next-generation console.

In a nutshell, procedural synthesis is about making optimal use of system bandwidth and main memory by dynamically generating lower-level geometry data from statically stored higher-level scene data. In order to understand how procedural synthesis works, let’s look at how 3D graphics are rendered on a traditional PC system with a GPU.

For 3D games, artists use a 3D rendering program to produce content for the game, e.g. character models and environmental objects like trees, terrain, buildings, etc. Each model that an artist produces is translated into a collection of polygons, which are themselves represented in the computer’s memory as collections of vertices. When the computer is rendering a scene in a game in real-time, the models that are being displayed on the screen start out in main memory as stored vertex data. That vertex data is fed from main memory into the GPU (under the direction of the CPU on which the game engine runs), where it is then rendered into a 3D image and output to the monitor as a sequence of frames.


Rendering a wind-blown tree, the conventional way

Every object that you see in the game must be painstakingly crafted by an artist—every fire hydrant, light pole, tree, hill and valley—and stored on disk as vertex data to be placed in system memory. It costs a lot of money and worker hours to populate an large, rich, 3D world with convincing-looking representations of objects, which is why in most games many common objects look exactly alike. Artists make one fire hydrant model, and use that same model on every curb; or they make a small number of tree models, and populate an entire forest with just a few trees.

The larger the game world, the more the practice of reusing a limited collection of models makes that environment look repetitive and unconvincing. You might think that game studios could overcome this problem by throwing money at it. In other words, just hire more artists to make more models, so that no two models look alike.

Limitations

There are two problems with this idea, the first being that it’s more expensive than it sounds. The costs of creating art assets for a 3D game are going through the roof along with the size and complexity of the games themselves. The “hire more artists” approach just doesn’t scale well when you consider that the games of the future will have large, richly detailed, extremely realistic environments that consume tens gigabytes of storage space. A common number that I’ve seen tossed around as a budget for the next generation of games is US$20 million, which puts game development in the same league as the movies in terms of production costs. (See this GDC session transcript for game developers ranting about soaring development costs.)

While art asset costs are rising, programmer time is getting cheaper all the time. Part of the idea behind procedural synthesis is to shift some of the burden of making game environments realistic from the art department to the programming department and to the game console hardware itself. But before I explain how this works, let’s talk about the other, more pressing problem with the “hire more artists” approach to increasing scene realism.

Let’s say that we were developing a game that takes place in a large forest, and we want to have highly detailed trees, with each tree in the forest being unique. This being the case, using a small collection of tree models to populate the entire forest is out of the question. So let’s also say that our development budget is fantastically huge (which it may very well be), and that we can hire artists to craft by hand a unique, high-polygon-count 3D model for each individual tree in our vast forest.

Even if all of the above were true, our game would still face a major technical hurdle that we couldn’t overcome without some help from the hardware. I said above that the objects that populate a 3D scene must be stored as vertex data in system memory and then moved onto the GPU for rendering. In the case of a hillside vista that takes in a view of a few thousand unique tree models, that’s a lot of vertex data that must be stored in main memory and pushed to the GPU. Storing all of that vertex data would take a massive amount of system memory, and moving all of that data into the GPU would take a massive amount of bus bandwidth. So as it turns out, the main factors limiting scene realism in console games are not really rising asset costs but the console hardware’s limited main memory sizes and limited bus bandwidth.

A solution

The Xbox 360’s solution to this problem is to store high-level descriptions of objects in main memory, and have the CPU procedurally generate the geometry (i.e., the vertex data) of the objects on the fly. So in the case of our forest, main memory stores information about the tree, like the type, size, location of each leaf, etc., along with other relevant data like the direction of the prevailing wind. This information is passed into the Xbox 360’s Xenon CPU, where the vertex data that defines the polygons out of which the tree is made are generated by one or more running threads. These threads then feed that vertex data directly into the GPU (by way of a special set of write buffers in the L2 cache, but more on that later). The GPU then takes that vertex information and renders the trees normally, just as if it had gotten that information from main memory.


Rendering a wind-blown tree on the Xbox 360

The end result of all this is that the amount of data that is stored in main memory and moved into the CPU is much less than the amount of data that the CPU puts out and that the GPU ends up processing. Microsoft refers to this ratio of stored scene data to rendered vertex data as a compression ratio, the idea being that main memory stores a “compressed” version of the scene, while the GPU renders a “decompressed” version of the scene.

The technique of compressing scene data for storage in main memory and then decompressing it by means of procedural synthesis allows game developers to do more with a console’s limited system memory. The console provides plenty of CPU-to-GPU bandwidth and enough computing power to procedurally render objects in real time, and the developer provides higher-level scene descriptions that allow a richer, more realistic world to be described using less storage space.

More procedural synthesis

Real-time tessellation

The 3D models produced by graphic artists are essentially a collection of surfaces in 3D space, and these surfaces can be described by the use of higher order curves like b-splines, bezier curves, etc. However, GPUs don’t render higher order curves; they render polygonal objects, which are a patchwork of triangles stitched together to approximate the surface described by the higher order curve.

The process of taking a higher order curve and approximating it with a network of small, flat surfaces is called tessellation. I’ve tried to depict this process in the figure above, by showing how a circle can be approximated using polygons. The more sides there are on the polygon that’s produced as a result of tessellation, the better that polygon approximates the original curve.

Tessellation is usually done by the artist who’s rendering the model for use in a game. The model is tessellated so that it can be stored on the game distribution media as a list of vertices, a list that will later be moved into system memory and then into the GPU as described in the previous section.

Microsoft’s Xbox 360 can use the Xenon CPU to tessellate curves in real-time. The higher order curves can be stored in compact form in main memory, and then transferred to the Xenon where they’re tessellated into vertex data. As with the procedural geometry generation described above, this dynamically generated vertex data is then passed directly to the GPU for rendering.

Real-time tessellation has a few advantages. First, storing models as collections of higher order curves is a more compact than storing them as vertex lists. This is especially true for high-polygon-count models, where the higher number of polygons approximates the original curves better but also makes for more vertex data. So real-time tessellation is another form of data compression that lets developers use a limited amount of source data, main memory, and bus bandwidth to render a highly detailed, data-intensive scene.

The second upside to dynamic tessellation is that a model that is tessellated in real-time can be rendered using a variable number of polygons, depending on the demands of the particular scene that’s rendering at the moment. This allows the software to control the level of detail (LOD) of each model dynamically.

Dynamic LOD, which has appeared in various forms in 3D games for some time now, is useful for keeping the total number of polygons in a scene under control. Objects that are far away from the viewer can be rendered with a low LOD (i.e., with fewer polygons), while objects that are closer can be rendered with a higher LOD (i.e., with more polygons).

Real-time skinning

This patent (patent number 20050099417) that Microsoft was recently granted covers a method for using procedural synthesis to do real-time skinning of 3D characters. The basic idea behind the patent appears to be as follows. Artists using standard tools (i.e.., motion capture, 3D rendering tools, etc.) generate a character model along with a series of key poses in an animation for that model. This model consists of a set of bones that have been skinned with a deformable skin.

The Xenon uses the key poses that are stored in system memory and interpolates new poses as needed based on the stored poses. These new poses have skin that deforms in natural ways, and are essentially new 3D models that are generated on the fly by the procedural synthesis code. This is yet another example of the use of procedural synthesis to cut down on the amount of data stored in memory. Instead of storing a sequence of models for a character animation, the Xenon is able to generate the animation sequence dynamically from a few exemplary forms.

Interestingly enough, the patent also appears to cover a feature that allows the procedural synthesis logic to send only the vertices that have changed between two poses along to the GPU, so that the entire model doesn’t have to be retransmitted across the bus. This will help cut down on bus traffic in instances where the characters’ movements in between frames are slight.

The mechanics of procedural synthesis

The Xbox 360’s Xenon CPU consists of three identical PowerPC cores connected to a shared 1MB L2 cache. The overall layout of Xenon is depicted in the diagram below:


The Xenon Processor

Each of the cores, which I’m going to call a PowerPC Processing Element (PPE) from here on out, has a 64K split L1 cache (32K instructions/32K data) and can handle up two simultaneous threads of execution using simultaneous multithreading (SMT). This means that the Xenon can execute up to six threads at once. (We’ll talk in more detail about the nuts and bolts of the Xenon’s hardware in Part II of this series, so stay tuned. Also, note that the functional unit breakdown given above is not confirmed at this time, but is based on released information and best estimates.)

All of those threads are going to come in handy in games that use procedural rendering to its fullest. According to Microsoft’s patents, Microsoft envisions a procedurally rendered game as having at least two primary components.

  • Host thread: A game’s host thread will contain the main thread of execution for the game. This thread will handle the high-level parts of the 3D engine, and will control the data generation thread.
  • Data generation thread: The actual procedural synthesis of object geometry takes place in this thread. This thread outputs vertex lists that represent objects in the game and are intended to be consumed by the GPU.

These two threads could run on the same PPE, or they could (more likely) run on two separate PPEs. In addition to the these two threads, the game could make use of separate threads for handling physics, artificial intelligence, player input, etc. Note also that there can be more than one data generation thread running at once.

The data generation threads are the heart of the Xbox 360’s procedural synthesis capability, so they’re also the heart of the “decompression” process that turns a small amount of higher-order source data into a large amount of geometry data. The compression ratio that the data generation threads provide can be varied in real-time according to certain criteria. The Microsoft patents don’t list any possible criteria, but I imagine such criteria would be selected so that system bandwidth and GPU rendering capabilities are used optimally.

I said above that data generation threads produce vertex lists that are intended for the GPU, but I didn’t tell you that these lists don’t exactly go directly to the GPU. There are two options for the vertex data output of these threads, one of which is that they can be moved into main memory for later use by the GPU. This would happen in situations where the GPU doesn’t need the data immediately and would like to stream it from memory at a later time. The other, more commonly taken option for the data generation thread’s output is that it is sent to the GPU by way of the L2 cache.

The Xenon’s cache hierarchy: when is a cache not a “cache”?

Level 1 and level 2 caches sit logically (if not physically) between the CPU and main memory, replicating the contents of main memory and reducing the amount of time that the CPU has to wait on code and data. The complex process of moving code and data between main memory and different levels of the cache hierarchy happens out of the sight of the programmer and is under the control of the hardware, which also concerns itself with keeping the information that is stored and replicated at different levels of the hierarchy in sync. Thus the two hallmarks of a "cache" as it’s conventionally understood are: a) that it temporarily stores (or "caches") information near the CPU and b) that it’s managed by the CPU and not by the programmer.

Xenon’s L1 and L2 caches can function in the conventional manner described above, but they can also function quite differently. More specifically, Xenon invests programmers with an unprecedented level of control over how their applications use the caches. Insofar as they can fall under the explicit control of the programmer, the Xenon’s caches, and its L2 cache in particular, can function remarkably like the “local storage” that’s attached to each of the Synergistic Processing Elements (SPEs) in IBM’s Cell processor. (For more on the Cell and its SPEs, see Part I and Part II of my Cell coverage.)

Producing, consuming, and buffering

In the kinds of traditional real-time rendering applications described previously in this article, main memory and the GPU have a producer-consumer relationship: main memory produces vertex data and the GPU consumes it. In the Xbox 360’s procedural synthesis scheme, the GPU is still a consumer, but the role of the producer that feeds it is played by the Xenon CPU. The Xenon can produce “decompressed” vertex data in greater volumes and at a much higher rate than traditional main memory could, which is the whole point of procedural synthesis. Often, however, the Xenon will produce vertex data faster than the GPU can consume it.

When Xenon overproduces vertex data, that data has to be stored somewhere while it waits for consumption by the GPU. Fortunately, the Xenon’s PPEs have a very fast data store that is both near at hand and sits directly between the PPEs and the GPU. This data store is the Xenon’s shared L2 cache.

If the Xenon’s L2 cache were a “normal” L2, then constant stream of vertex data output from even a single data generation thread would soon fill up the cache and begin to squeeze out the data associated with other threads. As new vertex data is written into the cache, the cache would think that this data was “recently used” and is therefore likely to be used again shortly. The cache would have no way of knowing that this data would not be used again, so it would fill up cache block after cache block with vertex data that it would keep around needlessly until a compulsory miss caused by another thread forced a block of it out. In other words, even one data generation thread running wide open would cause a 1MB cache to “thrash,” thereby degrading the performance of the host thread and of the whole system. The Xenon’s designers solved this problem by allowing each data generation thread to use the cache in a special way.

The Xenon’s L2 is arranged as an n-way set associative cache (the value of n hasn’t been publicly disclosed as of yet). A programmer can place a thread in write streaming mode, which means that the system will wire down (to use traditional virtual memory terminology) or lock (to use Microsoft’s terminology) a set of cache lines and attach that set directly and exclusively to a particular thread. This set is then initialized as a FIFO queue, so that it can act as a write buffer to store the output of a data generation thread. The data generation thread feeds its vertex data output directly into this FIFO queue (bypassing the L1 cache entirely), and the GPU reads that vertex data directly from this queue using a modified DMA protocol. Thus the write buffer logically couples a single data generation thread to the GPU by acting as a conduit for vertex data.

In the Xenon’s L2 cache, an arbitrary number of the sets can be locked and turned into FIFO queues for private, exclusive use by individual data generation threads. The sets that aren’t locked look to the Xenon like normal L2 cache. This means that non-write-streaming threads can use the non-locked L2 cache space normally, as can threads that are write-streaming.

A write-streaming data generation thread that has its own private locked set can also access the pool of generally available, non-locked L2 cache just like any other thread, but with the exception that it can’t use too much of it. A write-streaming thread is not allowed to get greedy and use too much L2, because the system will restrict its L2 usage so that it plays nicely with the other running threads.

In sum, write streaming allows the programmer to carve up the L2 cache into small chunks of private, local storage shared between each thread and the GPU. This local storage, in the form of a FIFO queue, acts kind of like a pipe that transports data directly through the L2 without allowing that data to spill over and pollute the rest of the L2.

Xenon’s L2 vs. Cell’s local storage, and some notes on IBM/Nintendo’s Gekko

If this idea of small pools of per-thread private, local storage that is accessible to the GPU via switching network sounds familiar, then you must have read my Cell coverage. This is essentially what the SPE local storage provides for the Cell’s individual SPE. Xenon achieves this same effect using the L2, and Xenon’s scheme has the advantage that it is more dynamically adaptable to the needs of the application, since it’s a single store that can be partitioned dynamically. However, what the Xenon gains in adaptability it loses in flexibility, since unlike the SPE local storage, which is just a flat memory space that can be used in any way the programmer sees fit, the Xenon’s write buffers can only be configured in one specific way and for one specific purpose (as described above).

Before finishing off the topic of locked sets in the L2 cache, it’s important to note that while I may have gleaned this information from a Microsoft patent, a similar technique is already in use in an IBM chip: the Nintendo Gamecube’s “Gekko” processor. The Gekko allows a programmer to lock half of the chip’s 32KB, 8-way set associative L1 cache to prevent streaming writes from polluting the L1. Data from the locked half of the L1 bypasses the L2 entirely and goes directly to the Gekko’s bus interface unit and out onto the memory bus.

The Gekko’s L1 cache locking scheme doesn’t provide the same degree of control and flexibility as the Xenon’s L2 cache locking scheme described above, but it doesn’t have to. Gekko is a single-issue, single-threaded design, whereas Xenon can have up to six simultaneous threads running.

Read streaming

The other way that the programmer can explicitly control the cache hierarchy is by placing a thread in read streaming mode. Like write streaming, read streaming provides a way of preventing streaming media data that won’t be reused from polluting the caches. When a thread is in read streaming mode, it can read data directly from the system bus into either the L1 cache or the registers. In other words, the programmer has the option of bypassing the L2 and streaming data directly into the L1, or of bypassing the entire cache hierarchy and streaming data directly into the registers.

In conclusion, both read streaming and write streaming combine to give the programmer an unprecedented level of control over the Xenon’s caching hierarchy. This means that it will be up to the programmer to use the right combination of data prefetching commands and read- and write-streaming modes to squeeze optimal performance out of the memory hierarhcy.

Conclusion to Part I

In all, the Xbox 360’s procedural synthesis capabilities show great promise. Of course, the big question is going to be how many polygons per second can it produce in real-time. It’s way too early to tell what percentage of the polygons in the average scene will be procedurally rendered, or what kind of impact this technique is going to have on the first generation of games. But perhaps we’ll get some hard data once the first generation of games are out and developers can talk in more detail about the hardware and what it can do. I’ll definitely be keeping an eye out for this data, and if any developers would like to contact me on or off the record with their impressions of the role that procedural synthesis will play in their games, I’d love to hear from them.

Part II of this series will take a closer look at the actual microarchitecture of the Xenon. I’ll talk about the makeup of the PPEs, as well as the mysterious 128-register version of VMX that will make its debut on the new core. Finally, I’ll discuss the general approach and design philosophy of the Xenon as a CPU, and I’ll outline how many of the same forces and trends that shaped its approach also shaped the Playstation 3’s Cell processor.

0 Comments