Computer Graphics on a Stream Architecture
Total Page:16
File Type:pdf, Size:1020Kb
COMPUTER GRAPHICS ON A STREAM ARCHITECTURE A DISSERTATION SUBMITTED TO THE DEPARTMENT OF DEPARTMENT OF ELECTRICAL ENGINEERING AND THE COMMITTEE ON GRADUATE STUDIES OF STANFORD UNIVERSITY IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY John Douglas Owens November 2002 c Copyright by John Douglas Owens 2003 All Rights Reserved ii I certify that I have read this dissertation and that, in my opin- ion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. William J. Dally (Principal Adviser) I certify that I have read this dissertation and that, in my opin- ion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. Patrick Hanrahan I certify that I have read this dissertation and that, in my opin- ion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. Matthew Regan Approved for the University Committee on Graduate Stud- ies: iii Abstract Media applications, such as signal processing, image and video processing, and graphics, are an increasing and important part of the way people use computers today. However, modern microprocessors cannot provide the performance necessary to meet the demands of these media applications, and special purpose processors lack the flexibility and pro- grammability necessary to address the wide variety of media applications. For the proces- sors of the future, we must design and implement architectures and programming models that meet the performance and flexibility requirements of these applications. Streams are a powerful programming abstraction suitable for efficiently implement- ing complex and high-performance media applications. This dissertation focuses on the design, implementation, and analysis of a computer graphics pipeline on a stream architec- ture using the stream programming model. Rendering on a stream architecture can sustain high performance on stream hardware while maintaining the programmability necessary to implement complex and varied programmable graphics tasks. We demonstrate a complete implementation of an OpenGL-like pipeline in the stream programming model, and that the algorithms developed for this implementation are both well-suited for the stream programming model and make efficient and high-performance use of stream hardware. We identify and discuss aspects of our system that impact its performance, including triangle size, rasterization algorithm, batch size, and short stream effects, and discuss the implications of programmability in the pipeline. We demonstrate and analyze the scalability of the algorithms and the implementation in order to anticipate performance on future generations of stream processors. And finally, we describe, imple- ment, and analyze a second rendering pipeline, the Reyes pipeline, and compare it to our OpenGL pipeline in order to show the flexibility of the programming model and to explore alternative directions for future stream-based rendering pipelines. iv Foreword Rendering of photorealistic scenes from geometric models is a pervasive and demanding application. Over a hundred times more arithmetic operations are performed in the graphics processor of a modern PC than in its CPU. As powerful as modern graphics processors are, their flexibility is limited. They perform a fixed function pipeline with just one or two programmable stages. Rendering tasks that fit within this pipeline they perform with blinding speed; rendering tasks that don’t conform to the fixed pipeline cannot be handled at all. In this pioneering work, John Owens shows how a programmable stream processor can achieve performance comparable to modern fixed-function graphics processors while hav- ing the flexibility to support arbitrary rendering tasks. John demonstrates the performance and flexibility of stream-based rendering by implementing diverse rendering pipelines: an OpenGL pipeline that renders polygons and a Reyes pipeline that uses subdivision surfaces on the Imagine stream processor. He also demonstrates flexibility by compiling several shaders, described in a programmable shading language, to execute on a stream processor. The techniques John demonstrates go far beyond the capabilities of contemporary graphics hardware and show that programmable hardware can smoothly tradeoff frame rate against rendering features. A number of novel methods were developed during the implementation of these render- ing pipelines. The use of barycentric rasterization was employed to reduce the burden of carrying large numbers of interpolants through the rasterization process. A novel load bal- ancing mechanism using conditional streams was developed to maintain high duty factor in the presence of unequal-sized triangles. Also, a compositor based on hashing and sorting was developed to ensure in-order semantics when triangles are rendered out-of-order. v John deeply analyzes the pipelines he has developed shedding considerable insight onto the behavior of streaming graphics and of stream processing in general. He looks at issues such as short-stream effects to show how performance is gained and lost in a typical stream pipeline. He also looks beyond the Imagine processor to study how well these pipelines would work as stream processors are scaled or are augmented with special-purpose units— such as a rasterizer or texture cache. Contemporary graphics processors have already adopted some of the technology of stream processors. They incorporate programmable vertex and fragment shading stages that are in effect small stream processors embedded in a fixed-function pipeline. As time goes on, one can imagine more pipeline stages becoming programmable until commercial graphics processors become general purpose stream processors capable of performing a wide range of intensive streaming computations. William J. Dally Stanford, California vi Acknowledgements I have had the privilege and pleasure to work with incredibly talented and motivated col- leagues during my time at Stanford. The success of the Imagine project is the direct result of the dedication and hard work of the graduate students who worked on it. I would partic- ularly like to acknowledge those with whom I’ve collaborated most closely—Ujval Kapasi, Brucek Khailany, Peter Mattson, Scott Rixner, and Brian Towles—for their creativity and effort over the past five years. More recently, Jung Ho Ahn, Abhishek Das, and Ben Sere- brin have been instrumental in bringing up the Imagine system, and I know the project will be left in good hands with them. In addition to my colleagues in the Imagine group, the talented graduate students in both the Concurrent VLSI Architecture Group and the Computer Graphics Laboratory helped guide this work through formal talks and informal conversations as well as made my time at Stanford full of intellectual challenge and stimulation. It has been an honor and a priv- ilege to have been part of two such outstanding research groups with their overwhelming excitement and energy. Working with Kekoa Proudfoot and Bill Mark on the shading language backend to their Real-Time Shading Language was also a treat. Their system was incredibly well designed and I appreciate their time in helping me integrate my changes and additions into it. Kekoa also wrote the first draft of Section 4.1. The first version of the OpenGL pipeline described in Chapter 4 was published as joint work with Bill Dally, Ujval Kapasi, Peter Mattson, Scott Rixner, and Ben Mowery. Brucek Khailany and Brian Towles did the initial work on the Reyes pipeline of Chapter 8 as part of a class project, and our resulting paper on that pipeline was also coauthored with Bill Dally with substantial input from Pat Hanrahan. Kekoa Proudfoot and Matthew Eldridge vii aided in acquiring the commercial hardware and software comparisons in Section 5.2. Jung Ho Ahn helped get the texture cache results in Section 6.5 and Ujval Kapasi aided with the single-cluster comparison of Section 5.2.4 and the integration of the hardware rasterizer of Section 6.6. Finally, David Ebert provided the marble shader used in the MARBLE scene, described in Section 5.1. The ideas and results in this dissertation have been influenced by the candid comments and criticisms of a large number of people besides those named above. Thanks to Kurt Akeley, Russ Brown, Matthew Eldridge, Henry Moreton, Matt Papakipos, Matt Pharr, and the Flash Graphics Group for many productive conversations. Previous to Imagine, I enjoyed working on (and learned how to do research in!) the Lightning project with Matthew Eldridge under the capable direction of Pat Hanrahan. Gordon Stoll and Homan Igehy also worked in the Flash Graphics group and were helpful resources as I began my research career. Other senior graduate students who provided guidance for me both before and after I arrived at Stanford were John Chapin, David Heine, Mark Heinrich, Robert Jones, Jeff Kuskin, Phil Lacroute, and Dave Ofelt. My advisor, Bill Dally, has ably led the Imagine project and has provided valuable guid- ance as I have progressed through my graduate studies. Working for Bill put this graduate student in overdrive—he properly demands much from his students. I have appreciated Bill’s intelligence, his experience, and his honesty and ability to take criticism during our conversations, as well as his leadership in fearless descents of too-steep ski slopes and his more general desire to work hard and play hard with his graduate students. Pat Hanrahan was my advisor when I started