Introduction to Graphics OptimizationNavigation |
About this siteSubmitted by epreisz on Sat, 11/17/2007 - 03:03.
Video game optimization is exciting. No, really, it is. Video games, and video game technologies, are revolutionizing the way we live, teach, and entertain. The demand for these technologies supports R&D budgets that drive the innovation of the most novel, and powerful, computer components. Using these components to their fullest capability is what we do when we optimize. Are you excited yet? If not, maybe now is the correct time to mention that efficient video game optimization requires a strong understanding of all components of the graphics system, not just individual subsystems. We don’t just optimize one subsystem of this incredible hardware, we optimize all systems. We optimize the hardware resources together because they work together to accomplish one goal. In video game development, that goal is to create a visually stunning, immersive, world by flashing 80 million colored dots on a screen every second. If you are still not excited, let me share another piece of information. Video game optimization is easier than you may think. There are several factors that may lead you to believe it is difficult. First, video game optimization is easy, but it challenges different parts of your brain. Video game optimization requires proper detection of performance draining operations. We do this by using tools that focus on hotspots and bottlenecks that are likely to yield the biggest performance gain. The process is also seemingly difficult because there are many false tips about what coding and API techniques are the most optimal. Once you understand the hardware at an abstract level, many of these false optimization tips are easy to spot. With a basic understanding of the process and tools, optimizing games will be much easier than you may believe. Now you are ready to embark on this exciting process to achieve the best performance with the least amount of effort. The techniques in this book will provide a holistic process that will enable you to efficiently optimize the biggest, most complex, game engines for the world’s fastest processing computer hardware, even if you don’t thoroughly know the engine. If that’s not exciting, than what is? Holistic Video Game Optimization This book provides a top down approach to optimizing video games. Many optimization discussions focus only on optimizing one component of the entire graphics system; however, without considering all components, the optimizations may not yield large gains in frame rate. A holistic approach to optimizing games will help focus optimizations on the hotspots and bottlenecks that will yield the biggest gains in performance with the least amount of effort. About the Hardware The foundation for understanding video game optimization is knowledge about the hardware. Hardware, especially in graphics hardware, creates new opportunities for us to enhance performance. Performing a task in specialized hardware, when done correctly, is many times faster than in a general hardware. A good example of specialized hardware’s ability to achieve performance over a general computation resource is evident when we execute a shader on the CPU. A shader that runs at 60 hertz when running on a graphics card will not execute faster than 1 hertz when on the CPU. The reason this happens is because of the graphics cards ability, due to its design, to perform parallel operations on pixels and vertices. Through-out this book we will explore many different hardware resources, all of them are important, and all of them have strengths and weaknesses. The CPU focuses on low latency operations; the GPU focuses on high throughput. Matching the correct computational task with the correct resource is essential. Another topic to cover is a growing similarity across many of our hardware resources. That similarity is parallelism. Chip designers are moving from increasing performance to increasing cores. Instruction level parallelism allows us to perform fine grain parallelism on the both the CPU and the GPU. In some cases, especially on the CPU, the hardware performs instruction level parallelism without us being aware of the optimization. The downside to the increased parallelism is the resultant increase of underutilize parallel resources. It is very common for us to underutilize the hardware. Performance and parallelism are closely related and the relationship between both elements is likely to grow as we see the number of cores increase. About the Tools Tools provide us the ability to gather the information required to make educated guesses about where we need to optimize. Without tools, our ability to detect the optimization that yields the biggest performance gain is reliant on our best guess. It is improbable that we can guess where the slowest code is. This is especially true when considering that a game utilizes a game engine, some of which are 300,000 lines of code, drivers, the operating system, a PCIe or AGP bus, and megabytes of textures and vertex resources. Without our tools, the job of a video game optimization guru is many times more difficult. There is no single tool that we can use to optimize video games. To perform holistic optimization, we will consider all resources, and no single tool covers all resources. Some tools expose special hardware counters that are proprietary to that specific vendor. Those tools supply us with very detailed data, but they are usually incompatible with their competitor’s hardware. Most tools only give us detailed information on one resource, to evaluate the other resources, we must use different tools. In order to optimize a game to its fullest potential, an optimization guru must be proficient in several optimization tools. Understanding the Trends This book will focus on current and emerging hardware and software trends. There are many parts of our graphics system that haven’t changed in the past 5 years. Graphics cards have been reliant on parallel operation. As a graphics programmer, it is our responsibility to ensure that our use of the graphics API doesn’t cause sequential operation. This trend is unlikely to change. GPUs have recently exposed geometry shaders. The geometry shader enhances our ability to efficiently modify the geometry without intervention from our CPU. The new trend in game technology will generate new techniques for higher fidelity graphics and impressive graphics performance. Video game hardware has short and long term trends. By understanding them, programmers and artists can make prudent decisions about how to design their games for optimal performance. What this book is not about Optimization is a broad topic defined differently by different people; one way to describe this books definition is to describe what this book is not about. Many people believe that optimization means using assembly. This was certainly truer a decade ago when novel hardware, not specifically designed for the types of data used in video games, did not exist on the consumer market. Assembly code, assuming you are able to write faster assembly then your compiler, will only increase the performance of the code you wrote. It is very common for a hotspot or bottleneck to occur in code we use, but didn’t write. If the best opportunity for optimization occurs in the graphics drivers, the assembly you write in the game engine will have no effect on the drivers hotspot or bottleneck. In the average game, there are usually more, higher yielding optimizations available then those exposed by writing assembly. An important consideration in optimization is application design. It is sufficient to say that one of the game engine’s primary job is to perform optimally using algorithms that expose performance. This book is not about those algorithms. Those books are readily available, and although this book may reference them, a detailed discussion on their implementation is outside the intended scope. |
User login |