Introduction to Graphics OptimizationNavigation |
The High Level ProcessSubmitted by epreisz on Sun, 02/11/2007 - 07:26.
At the most abstract level, optimization occurs in a cycle that contains three phases: design, detection, and implementation. When we are learning how to program, we usually only focus on design and implementation, but a third piece, detection, allows us to optimize our applications efficiently. The design and implementation phase can range from months to minutes, while the detection phase should only take minutes. Design Phase It is important to note that optimization includes the design phase. Many people believe you cannot optimize code until you have written it. This is not the case. We can solve 90% of our optimization issues by designing flexible, well designed code. A well designed object hierarchy, even with the overhead of a language like C++, can be much faster than pure assembly code that is poorly written. There is a saying among many of the graphics cards companies that states, “the fastest triangle you can render, is the one you don’t draw”. We can also apply this concept to memory, calculations, I/O, and API calls. The fastest way to use all of these elements is to not use them at all. Culling is the name of the processes we use to determine what calculations we don’t need to do. Usually we think of culling on the level of a single graphical object. By culling an object, we are determining whether or not we should render it. By quickly reducing our potentially visible set, we have greatly reduced the amount of processing. Design Example Let’s examine a simple example that would optimize the rendering of a scene. Figure 2 contains two scenes of trees. Let’s assume that it takes 10 milliseconds to render a tree and 5 milliseconds to cull an object. Rendering the entire scene would take 110 milliseconds. 11 * 10 = 110 msec Now, let’s try frustum culling. Culling 11 objects would take 55 milliseconds. By culling those 11 objects we have determined that we will need to render two trees. That means our cost for this scene is: 11 * 5 msec + 2 * 10 = 75 msec Fantastic! We have reduced the time spent from 110 to 75 msec. That’s a dramatic increase in performance. 7 msec + 5 * 5 msec + 2 * 10 = 52 msec Another increase! We have cut the time we are processing in half! |
User login |