Abstract:
A system and method for rendering a graphic object that recursively subdivides a frame buffer into rectangular regions in an order determined by a space-filling curve. Each rectangular region is tested to determine if the region includes at least part of the object to be rendered. If it contains at least part of the object to be rendered, then the region is subdivided. In accordance with the present invention, the same tests are performed on the subdivided regions. This proceeds until the size of a subdivided rectangular region reaches a predetermined limit, whereupon the pixels in the subdivided region are rendered on a pixel-by-pixel basis.

Description:
FIELD OF THE INVENTION 
     The field of the invention is computer graphics, and particularly relates to recursively subdividing a frame buffer in an order determined by a space-filling curve to render a graphic object such as a primitive. 
     BACKGROUND OF THE INVENTION 
     In the field of computer graphics, an image is represented as a rectangular grid of picture elements. Each picture element is called a pixel. A pixel is a piece of information (data) that represents one solid color, and is stored in a part of a computer&#39;s memory called the frame buffer. 
     An image is displayed on a screen. An example of a screen is a cathode ray tube (CRT), which is commonly used as the display for a computer. An image is displayed on a screen by mapping the pixels stored in the frame buffer onto the screen. 
     An image stored as pixels in a frame buffer can be generated mathematically, i.e., as the result of mathematical calculations performed by a computer processor. An example of such a processor is an Application Specific Integrated Circuit (ASIC), which is specifically designed to efficiently and rapidly perform computer graphics functions. 
     The processor sends drawing instructions to an apparatus called a display controller. An example of some drawing instructions is as follows: 
     (1) set the fill color to red 
     (2) start at location  74 , 19  on the screen 
     (3) draw a square that is 15 pixels wide 
     These drawing instructions tell the display controller to make every pixel inside the image red (1), start at a location 74 pixels from the left of the screen and 19 pixels down from the top of the screen, and then draw a square 15 pixels wide. The display controller uses these drawing instructions to set the right values for the correct pixels in the frame buffer which, when they are mapped to the screen, will produce the red square described in the drawing instructions. 
     A primitive is an image that can be drawn directly from drawing instructions to the frame buffer by the display controller. Primitives are typically simple shapes such as a triangle, a square, a line, a circle, a point, a regular polygon, etc. The use of primitives can facilitate the drawing of complex images to the frame buffer. Together, these primitives produce the image when the frame buffer is mapped to the screen. 
     The process of translating drawing instructions to pixels in a frame buffer is called rendering. In one known rendering system, the value of all of the pixels in an image are computed once for each object in the image. After the effect of a single object on all of the pixels is computed, the effect of the next object on the value of the pixels is determined. Thus, a pixel can be revisited and its value adjusted numerous times. This rendering method becomes slower as the number of objects in an image increases. An example of this type of rendering is called Z-buffering, which renders one object at a time onto the frame buffer, and thus a single pixel can be revisited many times. 
     Certain techniques render pixels without regard to the certain efficiencies that can be realized from the fact that they are part of the same object, or simply near each other within the same object. For example, in FIG. 1, pixels labeled  1 ,  2  and  5  are part of the same object, but the rendering technique ignores this fact, and shifts computations from pixels in this group to pixels outside the group (e.g., pixels  3  and  8 ), before returning to the pixels inside the object. This makes inefficient use of caches in rendering the object. 
     The values of pixels that are nearby to each other in the same object can be more efficiently computed when considered together, rather than in some arbitrary fashion that ignores the fact that they are part of the same object. Certain space-filling curves (such as the Peano curve 901 and Hilbert curve 902 shown in FIG. 2) can exploit coherence in two dimensions because they are self-similar at multiple resolutions. If a space-filling curve visits all of the pixels corresponding to a particular object area at one level of resolution, then it can be presumed to have the same property for larger and smaller object areas. This suggests that space filling curves can be used recursively in a rendering scheme. A space-filling curve is topologically continuous, so the areas it visits are always adjacent to each other. 
     The space-filling curve is used to determine the order in which regions or pixels are checked. As shown in FIG. 3, this order is specified by a Hilbert Curve. Pixels in an 4×4 grid are checked in the order shown by the numbers on the Hilbert Curve shown in FIG.  3 . 
     The recursive use of space-filling curves as a traversal sequence in rendering objects is described in  Space-Filling Curves and a Measure of Coherence , by Douglas Voorhies, Hewlett Packard Co., Chelmsford, Mass., 1991, published in  Graphics Gems II , edited by James Arvo, Program of Computer Graphics, Cornell University, Ithaca, N.Y., Academic Press, Inc., 1991, pp. 26-30, 485-486. However, this article does not disclose how to efficiently use a recursive space-filling curve traversal sequence to render a primitive on a screen. Further, the article does not disclose any specific computational techniques at the Boolean level that can make the use of recursive space-filling curve especially efficient. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 shows prior art example of a pixel map. 
     FIG. 2 shows prior art examples of a Peano curve and a Hilbert Curve. 
     FIG. 3 shows how a Hilbert curve is used to specify the order in which pixels and/or regions are checked in a 4×4 grid. 
     FIG. 4 shows an apparatus in accordance with an embodiment of the present invention. 
     FIG. 5 shows an embodiment of the method in accordance with the present invention. 
     FIG. 6 shows a frame buffer subdivided in accordance with an embodiment of the present invention. 
     FIG. 7 shows a frame buffer that contains a segment of a line to be rendered in accordance with the present invention. 
    
    
     DETAILED DESCRIPTION 
     An embodiment of the present invention advantageously exploits the coherence of a graphic object in two dimensions by rendering the object by recursively using a space-filling curve as a traversal sequence. 
     An embodiment of the present invention is shown in FIG. 4. A processor  201  is coupled to a memory  202  that stores rendering instructions  203  adapted to be executed by processor  201  to render a graphic object by recursively using a space filling curve as a traversal sequence in accordance with the method of the present invention. Memory  202  also includes a frame buffer  204 . Memory  202  is coupled to processor  201 . The embodiment of the present invention shown in FIG. 4 also includes a port  205  adapted to be coupled to a display  206  on which the graphics rendered in accordance with the present invention are shown. Port  205  is coupled to memory  202  and processor  201 . 
     An example of processor  201  is an ASIC (e.g., a graphics accelerator) that is manufactured to at least partly embody rendering instructions  203 . In one embodiment, processor  201  is a single integrated circuit. In another embodiment, it is a plurality of integrated circuits adapted to interoperate so as to practice the method of an embodiment of the present invention. An example of a graphics acceleration systems is the Impact® graphics subsystem in the Octane® product line manufactured by Silicon Graphics, Incorporated of Mountain View, California (see &lt;http://www.sgi.corn/octane/graphics.html, visited Jan. 25, 1998&gt;). 
     Examples of memory  202  include a hard disk, Read Only Memory (ROM), Random Access Memory (RAM), a floppy disk, flash memory, and any other medium or combinations of media capable of storing digital information. 
     Rendering instructions  203  can be distributed in accordance with the present invention stored on a medium. Examples of a medium that store the transaction instructions adapted to be executed by processor  201  include a hard disk, a floppy disk, a Compact Disk Read Only Memory (CD-ROM), flash memory, and any other device that can store digital information. In one embodiment, the instructions are stored on the medium in a compressed and/or encrypted format. As used herein, the phrase “adapted to be executed by a processor” is meant to encompass instructions stored in a compressed and/or encrypted format, as well as instructions that have to be compiled or installed by an installer before being executed by the processor. 
     An embodiment of the method in accordance with the present invention for rendering a triangle is illustrated in the flow chart shown in FIG.  5 . For the purpose of clarity, an embodiment of a frame buffer  400  with a triangle primitive  401  is shown in FIG.  6 . Further for the purpose of clarity, the “triangle to be rendered”  401  will be referred to as TRIANGLE  401 . The frame buffer in this embodiment is recursively subdivided into four rectangular regions. The first subdivision is shown as the four rectangular regions  402 ,  403 ,  404  and  405 , step  301 . 
     The signed area TRIANGLE  401  is calculated for each rectangular region  402 ,  403 ,  404  and  405 , in an order determined by a space-filling curve, step  302 . The signed area of a triangle is calculated using the triangle&#39;s coordinates. For example, consider a triangle whose vertices are defined by the coordinates (x a ,y a ), (x b ,y b ) and (x c ,y c ). Then the signed area of the triangle is calculated using the following formula:                  1   2                     x   a           y   a         1             x   b           y   b         1             x   c           y   c         1                =       1   2          (         x   a          y   b       +       x   b          y   c       +       x   c          y   a       -       y   a          x   b       -       y   b          x   c       -       y   c          x   a         )               (   1   )                                
     Note that the sign of the resulting area can change by making a non-cyclic group rotation of the lines in the above determinate. This means that the same convention for the order of the coordinates should be used throughout any application of the method in accordance with the present invention. In other words, the area should be calculated using vertice values either in a clockwise direction or a counterclockwise direction from any starting vertex. The requirement is one of consistency in the signed areas—if a clockwise convention is used, it should be used throughout. Likewise for a counterclockwise convention. The general rule for polygon primitives is any cyclic rotation of the vertice values from either a clockwise or counterclockwise order is acceptable. 
     Although a Peano curve may be used, it can be more efficient to use a Hilbert curve in accordance with the present invention. For each rectangular region  402 ,  403 ,  404  and  405 , the signed area of a triangular region (e.g.,  406 ) defined by each distinct two vertices  407 ,  408  and  409  of TRIANGLE  401  and each corner (shown in FIG. 6 as  410 ,  411 ,  412  and  413  for rectangular region  402 ) of each rectangular region  402 ,  403 ,  404  and  405  is also calculated, to obtain twelve signed triangular region numbers, step  303 . In other words, twelve triangular regions are achieved by using the vertices  407 ,  408  and  409  with the respective corners  410 ,  411 ,  412  and  413 . 
     A bounding box  414  is drawn around the TRIANGLE  401 , step  304 , the edges of the bounding box  414  being parallel to the edges of the frame buffer. The box  414  is drawn such that each vertex of TRIANGLE  401  contacts an edge or a corner of the box. 
     It is then determined if for each edge of TRIANGLE  401 , at least one corner  410 ,  411 .  412 , and  413  of the rectangular region  402  forms a triangle (e.g.,  406 ) with an area of the same sign as that of the area of TRIANGLE  401 , step  305 . If step  305  is true, then it is further determined if the rectangular region  402  falls at least partly within the boundaries of the bounding box  414 , step  306 . In the embodiment shown in FIG. 6, rectangular region  402  does fall at least partly within the boundaries of bounding box  414 . If step  306  is true, then it is determined if the size of the rectangular area is equal to mxn pixels, where m and n are integers, step  307 . This can be carried out efficiently in accordance with the present invention if both m and n are equal to 2. In one embodiment of the present invention, if either of steps  305  or  306  is not true, then the rectangular region (e.g.,  402 ) is not further recursively subdivided. Indeed, in one embodiment, if either step  305  or  306  is not true, then this indicates that no part of the image being rendered falls within the rectangular region being tested by these steps. If step  307  is true, then the pixels are rendered, step  308 , and the rectangular region is no longer further recursively subdivided. If step  307  is not true, then the rectangular region (e.g.,  402 ) is further recursively subdivided, step  309 , and the process is repeated at the next lower level of subdivision. 
     In accordance with another embodiment of the present invention, the primitive to be rendered is a polygon. This embodiment of the method of the present invention is the same as the method described for rendering a triangle, with the following differences. First, the bounding box that circumscribes the polygon (analogous to box  414  in FIG. 6) is drawn so that the edges of the box are parallel to the edges of the frame buffer, and the boundaries of the box enclose the minimum area needed to entirely contain the polygon. Second, the signed areas of triangular regions (similar to region  406  in FIG. 6) are calculated for each distinct pair of vertices of the polygon. Similar conditions apply in determining whether to further subdivide or render the pixels in a subdivided rectangular region. For example, The rectangular region must fall at least partly within the region of the box around the polygon, and at least one triangular region formed by a distinct pair of vertices of the polygon and a corner of the rectangular region must be of the same sign as the area of the polygon to subdivide the rectangular region or render the pixels in the rectangular region. 
     Yet another embodiment of the present invention renders a line. In actuality, a line is rendered as a quadrilateral, as it cannot be rendered as truly one dimensional. As shown in FIG. 7, the quadrilateral (line) is formed by the two parallel edges  501  and  502  and two “caps”, which are edges  503  and  504  formed by the intersection of the two parallel edges  501  and  502  with the edges  505  and  506  of the frame buffer  507 . The method for rendering the line is the same as that disclosed above for a polygon, where the polygon is quadrilateral. 
     The present invention also provides computational advantages in rendering primitives. In accordance with the present invention, only the coordinates of a single corner of each rectangular region need be passed along from one recursive level to the next. Such a corner is called a reference corner. At the next recursive level, other corners are efficiently generated from the reference corner by applying predetermined deltas in horizontal, vertical and/or diagonal directions from the reference corner. For example, if the coordinates of a reference corner are (x,y), then the coordinates of a rectangular region at the next recursive level can be computed by applying predetermined as follows: 
     Corner to right of reference corner=(x+A, y) 
     Comer below reference corner=(x, y+B) 
     Comer diagonally across from reference corner=(x+A, y+B) 
     where A is the horizontal offset and B is the vertical offset. 
     Further, since only the signs of the areas (e.g., of the polygon to be rendered and of the triangles formed by the edges of the polygon and the corners of the rectangular region) are needed to determine if a rectangular area should be further recursively subdivided (and eventually rendered), only the carry of the sign bits needs to be propagated. This advantageously allows the processor to ignore some of the less significant bits in the area calculations (because the value of the area is not needed in accordance with the present invention), advantageously improving the efficiency and speed with which an object is rendered. 
     Furthermore, since the value of the intermediate results are computed by simple addition, with only reduced-precision carry propagation for the signs, the adds can be implemented in “carry-save” form. This well-known technique allows the intermediate adds to be computed without any carry propagation, by keeping the “sum” and “carry” results of the additions separate. By this method, additions of three numbers can be reduced to a carry-save form sum and carry (two numbers) by one stage of single-bit full adders. This is both faster and uses fewer gates than a full carry-propagated add, but accomplishes the same result. Carry propagations are required only when and where the sign bits are needed. This saves significant amounts of hardware both because of the elimination of the intermediate carry propagations, and the reduced number of pipeline registers needed to ran at high clock rates. 
     Further optimizations can be made to reduce the precision necessary for the carry propagations. In one embodiment of the present invention, the least significant bits can be truncated. This improves efficiency at the cost of rendering the inclusion test slightly over-inclusive. When the inclusion test is slightly over-inclusive, a few unnecessary recursive subdivisions will be carried out. However, experience has shown that the additional efficiency introduced by truncating the least significant bits far outweighs the inefficiency introduced by the consequent slight over-inclusiveness of the test. 
     Likewise, in another embodiment, the most significant bits can be truncated in addition to the least significant bits after determining at a higher recursive level that the rectangular region at the present recursive level is entirely on one side or the other of an edge of the object to be rendered. In this embodiment, only about eight bits of precision are needed throughout the subdivision process, a substantially smaller number than that needed by known techniques. As a result, the present invention advantageously uses substantially less processing power than known techniques. Thus, the present invention can be implemented by a general purpose processor, and obviates the need for a special purpose rendering co-processor that works in tandem with the general purpose processor. This advantageously reduces the cost and complexity of implementing hardware designed to render an object. 
     The present invention is substantially more efficient and economical than known methods for rendering graphic objects.