ECE4893A/CS4803MPG – Homework #6

ECE4893A/CS4803MPG – Homework #6

ECE4893A/CS4803MPG: Multicore and GPU Programming for Video Games

Fall 2008

Homework #: Aperture Science Xbox Multicorification Center

4A checkpoint due: Tuesday, Nov. 14 at 23:59:59 (via T-square)

4B boss battle due: Wednesday, Nov. 21 at 17:00:00 (via T-square)

Late policy: The “4A checkpoint” will be graded out of 20 points;
the “4B boss battle” will be graded out of 100 points. We will
accept late submissions; however,
for every day that a submission is overdue (including weekend days),
we will subtract 10 points (for 4A) or 20 points from
the total (for 4B).
(We understand that sometimes multiple assignments hit at once, or other
life events intervene, and hence you have to make some tough choices. We’d
rather let you turn something in
late, with some points off, than have a “no late assignments
accepted at all”
policy, since the former encourages you to still do the assignment
and learn something from it, while the latter just grinds down your soul.)
The due date was chosen so that the assignment will not be hanging over your
head over Thanksgiving break, so you really want to have it done before
you leave for Thanksgiving. We will give another (simpler) assignment
to hang over your head over Thanksgiving break.

<!–[I’ve gotten some good questions on this homework; I’ve included some
clarifications and modifications in the writeup below in boldface.]

Discussion board: We will set up a “HW #4” discussion board where
students can discuss the homework and in particular ask questions that
the professors, TA, and other students can help answer.

Hello and again
welcome to the Aperture Science Xbox Multicorification Center.
Your application for employment has been reviewed, and
on the basis of your participation in the Georgia Tech
class “Multicore and GPU Programming for Video Games,” we have elected to
detain you for further testing to determine your suitibility for
employment as a Multicorifier.

Multicorifiers at the Aperture Science Xbox Multicorification Center
are responsible for transforming legacy single-threaded game
code into multi-threaded game code in preparation for the incorporation
of enhanced features that would overwhelm a single-threaded

To demonstrate your 1337 multithreading skills, please find an
interesting single-threaded XNA game from the web that you would like
to work on. Be sure to select a game with a design that
emphasizes the real-time nature of the medium, such as an arcade
game, a first-person or third-person shooter, a martial arts game, a
real-time strategy game, sports game, flight simulator, etc., and
not something like a Bejeweled or chess. Because variety is the
spice of life,
do not use the Spacewar game that comes with XNA or the
Racing Game availble from the XNA Creators website. Ideally, each applicant
would be working on a diferent game, although we realize that the same
game may be independenly chosen by multiple students.

Here are some links of places to start looking. Google may turn up more.

(Aperture Science in no way warrants the usefulness of the code available
at any of the above
links. Any particular piece of code may be full of bugs, poorly written,
may not run on the PC, may not run on the Xbox 360, or may not compile
at all.)

Spend some time looking at a different
games and poking at a lot of source code before you commit to one, since
you will be spending a lot of time with the source code of whatever game
you pick.

A huge amount of tutorial information and sample code illustrating
various techniques is available all over the
web, particularly
at <A HREF=""

You will probably wish to do most of your development and debugging on the PC,
and then use appropriate compiler directives to set thread affinities
for your Xbox 360 version. Your code must successfully run on the Xbox 360.
If you do not personally own a machine that supports DirectX 9,
you may use the machines in Klaus 2440 or the States cluster to run and debug
your code on the PC side,
although you should remember that you can edit and compile your code even
if you are on a machine that cannot support DirectX 9.

The five Xbox 360s in Klaus 1446 are available for your use. Note that over
30 other subjects are being tested for suitability
as Multicorifiers. Please be courteous
about sharing the limited resources available. In particular, do not
expect to monopolize one of the 360s the day the project is due; we
recommend trying to finish ahead of the due date. (We may develop
some sort of “signup” system where you may reserve a block of time on
a 360).

As part of this test, you will enhance your selected game in two ways:

1) Modify your single-threaded example program to use multiple threads
running on multiple cores. Your enhanced program
should be using all three cores at least some of the time (but not
necessarily all of the time). When designing your strategy, keep in
mind the various issues presented in Session 22, 23, and 24 of your
“Multicore and GPU Programming for Video Games” class,
as well as the words of wisdom given in the articles by Bruce Dawson
linked under Session 23. You need not try to “max out” the processor and/or
parallelize every computation within the game, since side effects of
such attempts may include insanity, and such side effects
are not part of this test.
You should keep your strategy simple. Designing code which is
intended to be multithreaded from the beginning is tricky; taking
code that was never intended to be multithreaded and making it multithreaded
can be even trickier, so you should not try to be too ambitious. Simplicity
is key.
We will not be worried if your multithreaded implementation
does not run any faster, since making it work at all without
unpredicable bugs will likely prove sufficiently challenging. However,
it should not run significantly slower on the Xbox 360 (although it
will probably
run slower on the PC, since the three cores will not be available there).

2) HW #3 gave you some experience with modifying shader code. Many of you
said that you would have had more fun implementing your own shaders
“from scratch.” Now is your chance! Add an
interesting and nontrivial
shader effect to the game. The effect should “make sense” within the
context of the game and make it appear to be a more professional product.
In addition to the kinds of 3-D rendering effects you looked at in HW #3,
you may want to read about 2-D “post-processing” effects such as bloom and
motion blur. You are welcome to adapt code you find on the web, as long
as you properly cite your sources. The challenge then will be melding
whatever example code you find with your main game code.

You should feel free to make whatever other tweaks to the art assets or
gameplay that you would like, although such tweaks are not required for
this test.

Before beginning the test, you should watch the video for “Session 26,” which
your Prof. Lanterman taped in his home office, and make sure that you
have XNA Game Studio Express running on your own machine.

Warning: Most peripheral I/O, such as loading and saving games or reading
from the controller, seems to want to take place on the main thread.
Peripherals such as those
seem to be less accessible from spawned threads.

Remember, the Xbox 360s contain no user servicable parts. Do not
submerge the Xbox 360s in water, even partially.

For the “4A checkpoint,” please describe 1) what game you are modifying,
including a URL pointer to the game,,
2) a paragraph describing what strategy you plan to take to multicorify the
game, and why you chose that particular approach, and 3) what cool
shader effect you plan to add and where you plan to add it. Upload a
photo (a cheap camera cell phone or camera PDA photo will do) to T-square
of an Xbox 360 running the game (showing it running in its original
unmodified state is OK), with you next to it, smiling
proudly, to prove that you can run the code on the Xbox 360. (Note some
XNA source code that has only been run on Windows may require a bit of
tweaking to deploy on the Xbox 360). If you do not access to a digital
camera, try to drag along a friend who does. If all else fails, you can
show it running to Prof. Lanterman in person, but he would rather not
make 30 appointments to meet in Klaus 1446, so surely you know
someone with a camera?

For the “4B boss battle,” upload a zip file with all the assets needed
to compile and deploy your game on the Xbox 360. Include a README file
of some sort that describes what changes you made to the code, why
you made the choices you did, and what difficulties you
encountered. Note that some of this may wind up being copied from your
responses to (2) and (3) for the “4A checkpoint,” or it may be entirely
new material.

When you submit 4B, please tell us an approximate number of hours
you spent working on the total of homework #4,
as well your thoughts on the homework, particularly
suggestions for improving it in the future. (If you don’t have any suggestions,
that’s OK, just tell us an approximate number of hours.)

Note that we are not requiring that your final “4B boss battle”
submission actually use the multicorifying strategy and shader effect
you described in the “4A checkpoint” submission. You may come up with
what seems like some good ideas, only to run into insurmountable
road blocks when you try implementing them, or you might otherwise
think of a better idea. That’s OK. The purpose of the “4A checkpoint”
is to make sure that, at an EARLY stage, you have thought about what
game you want to use, successfully run it on an Xbox 360 (to make sure
you are comfortable with doing that), and given some thought to what
you are going to do with the code.

Be sure to finish sufficiently in
advance of the deadline that you will
be able to work around any troubles
T-square gives you to successfully
submit before the deadline. If you have
trouble getting T-square to work,
please e-mail your compressed
file to,
with “MPG HW #4A” or “MPG HW #4B” and your full
name in the header line;
please only
use this e-mail submission as a last resort if T-square isn’t working.

When you submit your homework, please tell us an approximate number of hours
you spent working on it, as well your thoughts on the homework, particularly
suggestions for improving it in the future. (If you don’t have any suggestions,
that’s OK, just tell us an approximate number of hours.) This will help us
with future offerings of the class.

Ground rules:
The ground rules on this assignment differ from the others.
Since most people will be working on different code, you should feel
free to look at one another’s code in detail, ask others for help with
debugging your code, brainstorm strategies for your paricular game with
your friends, etc. The only exception to this rule is if you find that
someone else happened to pick the same game as you; in this case, you
should not be looking at each other’s code, but you can discuss high-level
issues. In your README file, be sure to give proper credit to people
who helped you, i.e. “Thanks to such-and-such for helping me find the
infinite recursion in blahblah.cs.”

Also, if you use adapt code from other sources (such as a shader effect
you might find), be sure to credit the source both in your README and
in the code itself.