SMOOTH RASTERIZATION OF POLYGONAL GRAPHICS PRIMITIVES
A method and system for smooth rasterization of graphics primitives. The method includes receiving a graphics primitive for rasterization in a raster stage of a processor, rasterizing the graphics primitive by generating a plurality of fragments related to the graphics primitive, and determining a coverage value for each of the plurality of fragments. If one edge of the graphics primitive lies within a predetermined inter-pixel distance from a pixel center, the one edge is used to calculate the coverage value by using a distance to the pixel center. If two edges of the graphics primitive lie within the predetermined inter-pixel distance from the pixel center, a distance to the pixel center of each edge is used individually to calculate the coverage value. The resulting coverage values for the plurality of fragments are output to a subsequent stage of the processor for rendering.
Latest NVIDIA CORPORATION Patents:
- Cloud execution of audio/video compositing applications
- Machine learning-based seatbelt detection and usage recognition using fiducial marking
- Transposed sparse matrix multiply by dense matrix for neural network training
- Energy efficient liquid-cooled datacenters
- GENERATING VARIATIONAL DIALOGUE RESPONSES FROM STRUCTURED DATA FOR CONVERSATIONAL AI SYSTEMS AND APPLICATIONS
This application is a continuation of U.S. patent application Ser. No. 11/592,826, SMOOTH RASTERIZATION OF POLYGONAL GRAPHICS PRIMITIVES, by Franklin C. Crow, filed on Nov. 2, 2006, attorney docket number NVID-P002084.
CROSS REFERENCE TO RELATED APPLICATIONThis application is related to the commonly assigned United States Patent Application APPARATUS, SYSTEM, AND METHOD FOR GAMMA CORRECTION OF SMOOTH PRIMITIVES, by Crow et al., filed on ______, attorney docket number NVID-P000680, and is incorporated herein in its entirety.
FIELD OF THE INVENTIONThe present invention is generally related to hardware accelerated graphics computer systems.
BACKGROUND OF THE INVENTIONRecent advances in computer performance have enabled graphic systems to provide more realistic graphical images using personal computers, home video game computers, handheld devices, and the like. In such graphic systems, a number of procedures are executed to “render” or draw graphic primitives to the screen of the system. A “graphic primitive” is a basic component of a graphic picture, such as a point, line, polygon, or the like. Rendered images are formed with combinations of these graphic primitives. Many procedures may be utilized to perform 3D graphics rendering.
Specialized graphics processing units (e.g., GPUs, etc.) have been developed to optimize the computations required in executing the graphics rendering procedures. The GPUs are configured for high-speed operation and typically incorporate one or more rendering pipelines. Each pipeline includes a number of hardware-based functional units that are optimized for high-speed execution of graphics instructions/data, where the instructions/data are fed into the front end of the pipeline and the computed results emerge at the back end of the pipeline. The hardware-based functional units, cache memories, firmware, and the like, of the GPU are optimized to operate on the low-level graphics primitives (e.g., comprising “points”, “lines”, “triangles”, etc.) and produce real-time rendered 3D images.
A problem exists however with the ability of prior art 3D rendering architectures to efficiently handle high-quality anti-aliasing of the complex 3D scenes of modern real-time 3D applications. Traditional low cost 3D graphics rendering systems generate images in which polygonal edges appear jagged or “aliased”. Aliasing artifacts result from the fact that the images are drawn against a finite resolution grid of pixels of a frame buffer. A continuous image is sampled at discreet pixel centers and displayed on a finite resolution screen. Anti-aliasing is an image quality enhancing method that reduces aliasing effects apparent in the rendered image and gives the polygonal edges a much smoother appearance.
In general, anti-aliasing functions are implemented in the rasterization stage of a typical 3D graphics rendering pipeline. The rasterization stage determines which polygon fragments belong to which discreet pixels of the display. A fragment is a portion of a primitive (e.g., polygon, etc.) that covers a pixel. A pixel may contain fragments from many polygons, with each polygon typically covering more than one pixel. A pixel has a finite area and is generally considered to have square shape.
The implementation of high-quality anti-aliasing imposes a heavy computational burden on the graphics rendering pipeline. Each fragment belonging to a pixel contributes its color to the overall color of the pixel. A primary factor in this contribution is the area of the fragment. The color of a pixel is a weighted blend of colors of all fragments contained within the pixel. The fragment area is used as a blending weight. Thus, the fragment area plays a very important role in the anti-aliasing process, and therefore an accurate computation of the fragment area is required. However, computing fragment area directly from its shape is very processor intensive, since the shape of a fragment can vary depending upon the polygon's shape and orientation.
The high computational burden required for high-quality anti-aliasing has led to a number of prior art shortcut schemes to provide anti-aliased image quality while reducing the computational workload. Such schemes involve, for example, the use of coverage masks, the use of multiple sample points per pixel, and the like. However each of these prior art schemes involve trade-offs in the accuracy of the estimation of fragment area, in image quality, and in computational speed.
Thus, a need exists for a rasterization method that can produce high-quality anti-aliased images while minimizing the additional overhead computations needed to support such anti-aliasing.
SUMMARY OF THE INVENTIONEmbodiments of the present invention provide a method and system for an anti-aliasing process that can produce high-quality anti-aliased images while minimizing the additional overhead computations needed to support such anti-aliasing.
In one embodiment, the present invention is implemented as a method for the smooth rasterization of graphics primitives. The method includes receiving a graphics primitive (e.g., a triangle polygon) for rasterization in a raster stage of a processor (e.g., a GPU), rasterizing the graphics primitive by generating a plurality of fragments related to the graphics primitive, and determining a coverage value for each of the plurality of fragments. If one edge of the graphics primitive lies within a predetermined distance from a pixel center, the one edge is used to calculate the coverage value by using a distance to the pixel center. If two edges of the graphics primitive lie within a predetermined distance from the pixel center, a distance to the pixel center of each edge is used individually to calculate the coverage value. The resulting coverage values for the plurality of fragments are output to a subsequent stage of the processor for rendering. In one embodiment, the predetermined distance is half an inter-pixel distance. In one embodiment, the half interpixel distances may be increased or decreased in order to optimize the overall effectiveness of the coverage value calculation process.
In one embodiment, three normalized edges of a triangle (e.g., the graphics primitive) are evaluated at the center of each pixel related to the triangle. If one edge lies within a predetermined distance from the pixel center, then the one edge can be used to calculate the coverage value by using a signed distance to the pixel center. In one embodiment, if two edges lie within half an inter-pixel distance from the pixel center, then the coverage value for each of the two edges can be calculated individually, summed, and then the coverage value of a fully covered pixel subtracted to obtain a total coverage. If a pixel lies more than half an inter-pixel distance outside any one of the edges of the graphics primitive, the pixel can be considered uncovered, and similarly, if a pixel lies more than half an inter-pixel distance inside all edges of the graphics primitive, the pixel can be considered fully covered. In each case, a lookup table can be indexed with a plurality of distances to a pixel center to obtain respective coverage values for the respective distances to the pixel center.
The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements.
Reference will now be made in detail to the preferred embodiments of the present invention, examples of which are illustrated in the accompanying drawings. While the invention will be described in conjunction with the preferred embodiments, it will be understood that they are not intended to limit the invention to these embodiments. On the contrary, the invention is intended to cover alternatives, modifications and equivalents, which may be included within the spirit and scope of the invention as defined by the appended claims. Furthermore, in the following detailed description of embodiments of the present invention, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be recognized by one of ordinary skill in the art that the present invention may be practiced without these specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail as not to unnecessarily obscure aspects of the embodiments of the present invention.
Notation and Nomenclature:Some portions of the detailed descriptions, which follow, are presented in terms of procedures, steps, logic blocks, processing, and other symbolic representations of operations on data bits within a computer memory. These descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. A procedure, computer executed step, logic block, process, etc., is here, and generally, conceived to be a self-consistent sequence of steps or instructions leading to a desired result. The steps are those requiring physical manipulations of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated in a computer system. It has proven convenient at times, principally for reasons of common usage, to refer to these signals as bits, values, elements, symbols, characters, terms, numbers, or the like.
It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the following discussions, it is appreciated that throughout the present invention, discussions utilizing terms such as “ processing” or “accessing” or “ executing” or “ storing” or “rendering” or the like, refer to the action and processes of a computer system (e.g., computer system 100 of
The CPU 101 and the GPU 110 can also be integrated into a single integrated circuit die and the CPU and GPU may share various resources, such as instruction logic, buffers, functional units and so on, or separate resources may be provided for graphics and general-purpose operations. Accordingly, any or all the circuits and/or functionality described herein as being associated with the GPU 110 can also be implemented in, and performed by, a suitably equipped CPU 101. Additionally, while embodiments herein may make reference to a GPU, it should be noted that the described circuits and/or functionality can also be implemented and other types of processors (e.g., general purpose or other special-purpose coprocessors) or within a CPU.
System 100 can be implemented as, for example, a desktop computer system or server computer system having a powerful general-purpose CPU 101 coupled to a dedicated graphics rendering GPU 110. In such an embodiment, components can be included that add peripheral buses, specialized audio/video components, IO devices, and the like. Similarly, system 100 can be implemented as a handheld device (e.g., cellphone, etc.) or a set-top video game console device such as, for example, the Xbox®, available from Microsoft Corporation of Redmond, Wash., or the PlayStation3®, available from Sony Computer Entertainment Corporation of Tokyo, Japan. System 100 can also be implemented as a “system on a chip”, where the electronics (e.g., the components 101, 115, 110, 114, and the like) of a computing device are wholly contained within a single integrated circuit die. Examples include a hand-held instrument with a display, a car navigation system, a portable entertainment system, and the like.
Embodiments of the Invention:Embodiments of the present invention implement a method and system for the smooth rasterization of graphics primitives. The method includes receiving a graphics primitive (e.g., a triangle polygon) for rasterization in a raster stage of a processor (e.g., a GPU), rasterizing the graphics primitive by generating a plurality of fragments related to the graphics primitive, and determining a coverage value for each of the plurality of fragments. If one edge of the graphics primitive lies within half an inter-pixel distance from a pixel center, the one edge is used to calculate the coverage value by using a distance to the pixel center. If two edges of the graphics primitive lie within half an inter-pixel distance from the pixel center, a distance to the pixel center of each edge is used individually to calculate the coverage value. The resulting coverage values for the plurality of fragments are output to a subsequent stage of the processor for rendering. Embodiments the present invention and their benefits are further described below.
In one embodiment, as depicted in
Thus, as depicted in
Additional details regarding boustrophedonic pattern rasterization can be found in U.S. Patent Application “A GPU HAVING RASTER COMPONENTS CONFIGURED FOR USING NESTED BOUSTROPHEDONIC PATTERNS TO TRAVERSE SCREEN AREAS” by Franklin C. Crow et al., Ser. No. 11/304,904, filed on Dec. 15, 2005, which is incorporated herein in its entirety.
It should be noted that although embodiments of the present invention are described in the context of boustrophedonic rasterization, other types of rasterization patterns can be used. For example, the algorithms and GPU stages described herein for rasterizing pixels can be readily applied to traditional left-to-right, line-by-line rasterization patterns.
Embodiments of the present invention implement a method whereby the three normalized edges of a triangle (e.g., the graphics primitive) are evaluated at the center of each pixel related to the triangle.
If one edge of the graphics primitive lies within half an inter-pixel distance from a pixel center, the one edge is used to calculate the coverage value by using a distance to the pixel center. This is shown in
Thus, as shown in
In one embodiment, the distance 510 is used to index a coverage lookup table (e.g., coverage lookup table 1103 shown in
As shown in
It should be noted that in each case, the distances 611 and 612 are used to index a coverage lookup table (e.g., covers lookup table 1103 shown in
Additionally, it should be noted that if a pixel lies more than half an inter-pixel distance outside any one of the edges of the graphics primitive, the pixel is considered uncovered. Similarly, if a pixel lies more than half an inter-pixel distance inside all edges of the graphics primitive, the pixel is considered fully covered. It should be noted that the half-pixel distance as used herein is exemplary. Different predetermined distances can be utilized to optimize the obtained results. For example, differing implementations can use different values for this distance for different situations.
It should be noted that in some cases, a triangle polygon may exist such that all three edges of the triangle lie within the same pixel. In such cases, the calculated coverage from the third edge reduces the coverage due to the first edge and second edge of the triangle. In one embodiment, the reduction is computed by scaling the coverage due to the first and second edges by the ratio of the coverage due to the third edge over the full pixel area (e.g., the coverage of a fully covered pixel).
The rasterizer unit 1102 provides fragment data and fragment program instructions to the fragment unit 1104. One or more fragment programs configure the fragment unit 1104 to process fragment data by specifying computations and computation precision. The raster unit 1102 further includes a coverage lookup table 1103 for looking up coverage values corresponding to distances from a pixel center, as described above.
Referring still to
Process 1200 begins in step 1201, where a graphics primitive is received for rasterization in a raster stage of a graphics processor. In step 1202, the graphics primitive is rasterized by generating a plurality of fragments related to the primitive on a pixel grid. As described above, fragments are those portions of a polygon that cover a pixel, and a pixel may contain fragments from many polygons. Each fragment belonging to a pixel contributes its color to the overall color of the pixel and the weight of this contribution depends upon the area, or percent a pixel coverage, of the fragment.
In step 1203, a determination is made as to whether one edge of the graphics primitive lies within a predetermined distance from a pixel center. If so, process 1200 proceeds to step 1204, where the one edge is used to calculate the coverage value by using the distance to the pixel center. As described above, this distance can be used to index a lookup table (e.g., coverage lookup table 1103) and obtain a corresponding coverage value there from. In step 1205, a determination is made as to whether two edges of the graphics primitive lie within a predetermined distance from a pixel center. If so, process 1200 proceeds to step 1206 where the coverage is calculated for each edge individually using the respective distance, and then combined to generate the coverage value. For example, as described above, where a triangle passes two of its edges through a pixel, the coverage value for each of the edges is first calculated individually, and then added together. The sum of the two coverage values minus one gives the corrected total coverage value for the triangle. Subsequently, in step 1207, the resulting coverage values for each of the plurality of fragments are output to a subsequent stage of the graphics processor for rendering.
The foregoing descriptions of specific embodiments of the present invention have been presented for purposes of illustration and description. They are not intended to be exhaustive or to limit the invention to the precise forms disclosed, and many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, to thereby enable others skilled in the art to best utilize the invention and various embodiments with various modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims appended hereto and their equivalents.
Claims
1. A method for rasterizing graphics primitives, comprising:
- generating a plurality of fragments related to a graphics primitive in a raster stage of a processor; and
- determining a coverage value for each of the plurality of fragments by:
- if one edge of the graphics primitive lies within an inter-pixel distance from a pixel center, using the one edge to calculate the coverage value by using a distance to the pixel center; and
- if a plurality of edges of the graphics primitive lie within the inter-pixel distance, using a distance to the pixel center of each of the plurality of edges to calculate the coverage value.
2. The method of claim 1, wherein the graphics primitive is a triangle and three normalized edges of the triangle are evaluated at the center of each pixel related to the triangle.
3. The method of claim 1, wherein if the one edge lies within the predetermined inter-pixel distance from the pixel center, then the one edge is used to calculate the coverage value by using a signed distance to the pixel center plus one-half
4. The method of claim 1, wherein if the plurality of edges lie within the predetermined inter-pixel distance from the pixel center, then the coverage value for each of the plurality of edges is calculated individually, summed, and a coverage value of a fully covered pixel subtracted to obtain a total coverage.
5. The method of claim 1, wherein if a pixel lies more than the predetermined inter-pixel distance outside any one of the edges of the graphics primitive, the pixel is considered uncovered, and wherein if a pixel lies more than the predetermined inter-pixel distance inside all edges of the graphics primitive, the pixel is considered fully covered.
6. The method of claim 1, wherein the predetermined distance is half an inter-pixel distance.
7. The method of claim 1, wherein the resulting coverage values are clamped to zero to prevent negative coverage values from being output to the subsequent stage of the processor for rendering.
8. The method of claim 1, further comprising:
- subdividing the pixel into a plurality of daughter sub pixels if a point of the graphics primitive lies within the pixel.
9. The method of claim 1, wherein if a pixel includes a first edge, a second edge, and a third edge of a triangle polygon, a coverage from the third edge causes a reduction in coverage due to the first edge and second edge, and wherein the reduction is computed by scaling the coverage due to the first edge and the second edge by a ratio of the coverage from the third edge over the pixel area.
10. A GPU (graphics processor unit), comprising:
- a raster unit for rasterizing polygons, wherein the raster unit receives a graphics primitive and rasterizes the graphics primitive by generating a plurality of fragments related to the graphics primitive and determines a coverage value for each of the plurality of fragments by:
- if one edge of the graphics primitive lies within an inter-pixel distance from a pixel center, using the one edge to calculate the coverage value by using a distance to the pixel center; and
- if two edges of the graphics primitive lie within the inter-pixel distance from the pixel center, using a distance to the pixel center of each edge individually to calculate the coverage value.
11. The GPU of claim 10, wherein the predetermined distance is one half and inter-pixel distance, and wherein the graphics primitive is a triangle and three normalized edges of the triangle are evaluated at the center of each pixel related to the triangle.
12. The GPU of claim 10, wherein if the one edge lies within the predetermined inter-pixel distance from the pixel center, then the one edge is used to calculate the coverage value by using a signed distance to the pixel center plus one-half
13. The GPU of claim 10 wherein if the two edges lie within the predetermined inter-pixel distance from the pixel center, then the coverage value for each of the two edges is calculated individually, summed, and a coverage value of a fully covered pixel subtracted to obtain a total coverage.
14. The GPU of claim 10, wherein if a pixel lies more than the predetermined inter-pixel distance outside any one of the edges of the graphics primitive, the pixel is considered uncovered.
15. The GPU of claim 10, wherein if a pixel lies more than the predetermined inter-pixel distance inside all edges of the graphics primitive, the pixel is considered fully covered.
16. The GPU of claim 10, wherein a lookup table is indexed with a plurality of distances to a pixel center to obtain a respective coverage value for a respective distance to a pixel center.
17. A computer system, comprising:
- a system memory;
- a central processor unit coupled to the system memory; and
- a graphics processor unit communicatively coupled to the central processor unit;
- a raster unit for rasterizing polygons, wherein the raster unit receives a graphics primitive and rasterizes the graphics primitive by generating a plurality of fragments related to the graphics primitive and determines a coverage value for each of the plurality of fragments by:
- if one edge of the graphics primitive lies within an inter-pixel distance from a pixel center, using the one edge to calculate the coverage value by using a distance to the pixel center; and
- if two edges of the graphics primitive lie within the inter-pixel distance from the pixel center, using a distance to the pixel center of each edge individually to calculate the coverage value.
18. The system of claim 17, wherein the graphics primitive is a triangle and three normalized edges of the triangle are evaluated at the center of each pixel related to the triangle.
19. The system of claim 17, wherein if the one edge lies within half an inter-pixel distance from the pixel center, then the one edge is used to calculate the coverage value by using a signed distance to the pixel center plus one-half
20. The system of claim 17 wherein if the two edges lie within half an inter-pixel distance from the pixel center, then the coverage value for each of the two edges is calculated individually, summed, and one subtracted to obtain a total coverage.
21. The system of claim 17, wherein if a pixel lies more than half an inter-pixel distance outside any one of the edges of the graphics primitive, the pixel is considered uncovered, and wherein if a pixel lies more than half an inter-pixel distance inside all edges of the graphics primitive, the pixel is considered fully covered.
22. The system of claim 17, wherein the pixel is subdivided into a plurality of daughter sub-pixels if a point of the graphics primitive lies within the pixel.
Type: Application
Filed: Aug 7, 2012
Publication Date: Jul 11, 2013
Applicant: NVIDIA CORPORATION (Santa Clara, CA)
Inventor: Franklin C. Crow (Portola Valley, CA)
Application Number: 13/569,071