Game Development Reference
In-Depth Information
'
Just click the
ll be inside the shader debugger. You
can single-step through the shader and watch exactly how it executed.
PIX is an extremely powerful tool. I strongly suggest you check out a few tutorials
and get acquainted with it if you plan to do any graphics programming at all.
Debug Pixel (x, y)
link, and you
Debugging Techniques
I think I could write an entire book about debugging. Certainly many people have,
and for good reason. You can
t be a good programmer unless you have at least pass-
able debugging skills. Imagine for a moment that you are a programmer who never
writes buggy code. Hey, stop laughing. I also want you to close your eyes and imag-
ine that you have absolutely no skill at debugging. Why would you? Your code is
always perfect! But the moment you are assigned to a team of programmers, your
days are numbered. If you can
'
'
t solve logic problems caused by another program-
mer
s code, you are useless to a team.
If you have good debugging skills, you
'
ve
always looked at really tough bugs as a puzzle. Computers are deterministic, and
they execute instructions without interpretation. That truth paves your way to solve
every bug if you devote enough patience and skill to the problem.
'
ll have much more fun programming. I
'
Debugging Is an Experiment
When you begin a bug hunt, one implication is that you know how to recognize a
properly running program. For any piece of code, you should be able to predict its
behavior just by carefully reading each line. Debugging a program requires that you
figure out why the behavior of the program is different than what you expect. Cer-
tainly the computer
t surprised. It executes exactly what you instructed.
This delta is the cornerstone of debugging. As each instruction executes, the pro-
grammer tests the new state of the process against the predicted state by looking at
memory and the contents of variables. The moment the prediction is different than
the observed, the programmer has found the bug.
Clearly, you have to be able to predict the behavior of the system given certain sti-
muli, such as user input or a set of game data files. You should be able to repeat the
steps to watch the behavior on your machine or anyone else
'
s CPU isn
'
s machine. When the
bug manifests itself as a divergence from nominal operation, you should be able to
use what you observed to locate the problem or at least narrow the source of the
problem. Repeat these steps enough times, and you
'
'
ll find the bug. What I
'
ve just
described is the method any scientist uses to perform experiments.
 
 
 
Search WWH ::




Custom Search