decade about graphics and performance programming that’s still relevant to Code Optimization is there too, and even my book Zen of Assembly. Graphics Programming Black Book Special Edition has 65 ratings and 3 reviews. — Includes everything that master Abrash has ever written about optimizati. Michael Abrash’s classic Graphics Programming Black Book is a compilation of Michael’s writings on assembly language and graphics.
|Published (Last):||2 November 2005|
|PDF File Size:||11.37 Mb|
|ePub File Size:||20.60 Mb|
|Price:||Free* [*Free Regsitration Required]|
What was it like working with John Carmack on Quake? Like being strapped onto a rocket during takeoff—in the middle of a hurricane. It seemed like the whole world was watching, waiting to see if id Software could top Doom; every casual e-mail tidbit or conversation with a visitor ended up posted on the Internet within hours.
Toward the end, when I spent most of my time speeding things up, I would spend agrash day in a trance writing optimized assembly code, stagger out of the Town East Tower into the blazing Texas heat, and somehow drive home on LBJ Freeway without smacking into any of the speeding pickups whizzing past me on both sides. Everything happened so fast, and under so much pressure, that sometimes I wonder how any of us made it through that without completely lrogramming out.
At the same time, of course, it was tremendously exciting. Happily, id has an enlightened attitude about sharing information, and was willing to let me write about the Quake technology—both how it worked and how it evolved. Over the two years I worked at id, I wrote a number of columns about Quake in Dr. You can find these in the latter part of this book; they represent a rare look into the development and inner workings of leading-edge software graphixs, and I hope you enjoy reading them as much as I enjoyed developing the technology and writing about it.
Most of Zen of Graphics Programming, 2nd Edition is in there and the rest is on the CD ; all blsck Zen of Code Optimization is there too, and even my book Zen of Assembly Languagewith its long-dated cycle counts but a lot of useful perspectives, is on the CD.
I got my start programming on Apple II computers at school, and almost all of my early work was on the Apple platform. After graduating, it quickly became obvious that I was going to have trouble paying my rent working in the Apple II market in the late eighties, so I was forced to make a very rapid move into the Intel PC environment. What I was able to pick up over several years on the Apple, I needed to learn in the space of a few months on the PC.
Graphics Programming Black Book Special Edition by Michael Abrash
The biggest benefit to me of actually making money as a programmer was the ability to buy all the books and magazines I rpogramming. I bought a lot. I was in territory that I new almost nothing about, so I read everything that I could get my hands on. Feature articles, editorials, even advertisements held information for me to assimilate.
Graphics Programming Black Book Special Edition
John Romero clued me in early to the articles by Michael Abrash. Knowledge and wisdom for the aspiring developer. They were even fun to read.
I looked in every bookstore I visited, but I never did find it. I made do with the articles I could dig up. I learned the dark secrets of the EGA video controller there, and developed a few neat tricks of my own. Some of those tricks became the basis for the Commander Keen series of games, which launched id Software.
A year or two later, after Wolfenstein-3D, I xbrash into Michael in a virtual sense for the first time. I talked myself hoarse that day, explaining all the ins and outs of Doom to Michael and an interested group of his coworkers.
Every few days afterwards, I would get an email from Michael asking for an elaboration bllack one of my points, or discussing an aspect of the future of graphics. Eventually, I popped the question—I offered him a job at id.
A chance blcak do the right thing as a programmer. I kept at it though, and about a year later I finally convinced bkack to come down and take a look at id. I was working on Quake. Going from Doom to Quake was a tremendous step. I was trying a huge number of approaches, and even the failures were teaching me a lot. My enthusiasm abrsah have been contagious, because he took the job. Much heroic programming ensued. Several hundred thousand lines of code were written. Sure, a year from now I will have probably found a new perspective that will make me cringe at the clunkiness of some part of Quake, but at the moment it still looks pretty damn good to me.
I was very happy to have Michael describe much of the Quake technology in his ongoing magazine articles. We learned a lot, and I hope we managed to teach a bit. Progrmaming is not a zero-sum game. The Ferraris are just gravy, honest! This book contains many of the original articles that helped launch my programming career.
Graphics Programming Black Book
I hope my contribution to the contents of the later articles can provide similar stepping stones for others. There are many people to thank—because this book was written over many years, in many different settings, an unusually large number of people have played a part in making this book possible.
Thanks to Dan Illowsky for not only contributing ideas and encouragement, but also getting me started writing articles long ago, when I lacked the confidence to do it on my own—and for teaching me how to handle the business end of things.
Thanks to Will Fastie for giving me my first crack at writing for a large audience in the long-gone but still-missed PC Tech Journaland for showing me how much fun it could be in his even longer-vanished but genuinely terrific column in Creative Computing the most enjoyable single column I have ever read in a computer magazine; I used to haunt the mailbox around the beginning of the month just vraphics see what Will had to say.
Thanks to the Coriolis gang for their tireless hard work: Thanks to Jack Tseng for teaching me a lot about graphics hardware, and even more about how much difference hard bllack can make. And, of course, thanks to Shay and Emily for their generous patience with my passion for writing and computers. This book is devoted to a topic near and dear to my heart: Given run-of-the-mill software, PCs run like the pound-weakling minicomputers they are.
Give them the proper care, however, and those ugly boxes are capable of miracles. The key is this: Only on microcomputers do you have the run of the bool machine, without layers of operating systems, drivers, and the like getting in the way. Is performance still an issue in this era of cheap computers and super-fast Pentium computers? My point is simply this: PCs can work wonders. Before we can create high-performance code, we must understand what high performance is. The objective not graohics attained in creating high-performance software is to make the software able to carry out its appointed tasks so rapidly that it responds instantaneously, as far as the user is concerned.
In other words, high-performance code should ideally run so fast that any further improvement in the code would be pointless. Notice that the above definition most emphatically does not say anything about making the software as fast as possible.
It also does not say anything about using assembly language, or an optimizing compiler, or, for that matter, a compiler at all. You do indeed need tools to build a abgash, but any of many sets of tools will do.
You also need a blueprint, an understanding graphiccs everything that goes into abfash house, and the ability to use the tools. Likewise, high-performance programming requires a clear understanding of the purpose of the software being built, an overall program design, algorithms for implementing particular tasks, an understanding of what the computer can do and of what all relevant software is doing— and solid programming skills, preferably using an optimizing compiler or assembly language.
The optimization at the end is just the finishing touch, however. In the early s, as the first hand-held calculators were hitting the market, I knew a fellow named Irwin.
He was a good student, and was planning to be an engineer. Being an engineer back then meant knowing how to use a slide rule, and Irwin could jockey a slipstick with the best of them. In fact, he was so good that he challenged a fellow with a calculator to a duel—and won, becoming a local legend in the process.
When you get right down to it, though, Irwin was spitting into the wind. In a few short years his hard-earned slipstick skills would be worthless, and the entire discipline would be essentially wiped from the face of the earth. Irwin had basically wasted the considerable effort and time he had spent optimizing his soon-to-be-obsolete skills. What does all this have to do with programming? Making rules abrqsh easy; the hard part is figuring out how to apply them in the real world.
In other words, the program will add each byte in a specified file in turn into a bit value. How are we going to generate a checksum value for a specified file? The logical approach is to get the file name, open the file, read the bytes out of the file, add them together, and print the result. Most of those actions are gdaphics the only tricky part lies in reading the bytes and adding them together. It would be convenient to load the entire file into memory and then sum the bytes in one loop.
The code is compact, easy to write, and functions perfectly—with one slight hitch:. Execution times are given for Listing 1. To drive home the point, Programmihg 1. The assembly language implementation is indeed faster than any of the C versions, as shown in Table 1.
WPbytes in sizeas compiled in the small model with Borland and Microsoft compilers with optimization on opt and off no opt. The lesson is clear: Optimization makes code faster, but without proper design, optimization just creates fast slow code.
Well, then, how are we going to improve our design? Just why is Listing 1. The C library implements the read function by calling DOS to read the desired number of bytes. I figured this out by watching the code execute with a debugger, but you can geaphics library source code from both Microsoft and Borland. That means that Listing 1. For starters, DOS functions are invoked with interrupts, and interrupts are among the slowest instructions of the x86 family CPUs. Then, DOS has to set up internally and branch to the desired function, expending more cycles in the process.
Finally, DOS has to search its own buffers to see if the desired byte has already been read, read it from the disk if not, store the byte in the specified location, and return. All of that takes a long time—far, far longer than the rest of the main loop in Listing 1. In short, Listing 1. You can verify this for yourself by watching the code with a debugger or using a code profiler, but take my word for it: How can we speed up Ggaphics 1.