Abstract

This disclosure describes an apparatus, such as a wireless communication device, that applies a direct evaluation technique to render triangles for the 3D graphical environment. The apparatus includes a rendering engine that defines a rectangular area of pixels, referred to as a bounding box, that bounds the area to be rendered. The rendering engine evaluates coordinates associated with the pixels of the rectangular area to selectively render those pixels that fall within the triangular area. The direct evaluation triangle rendering algorithm may require fewer complex operations than the more computationally intensive interpolation process employed by other systems. As a result, the apparatus may present a 3D graphical environment while preserving as much as possible the available power.

Description

CROSS REFERENCE TO RELATED APPLICATIONS

This application claims priority from U.S. Provisional Application Ser. No. 60/455,923, filed Mar. 18, 2003, and is a divisional of U.S. patent application Ser. No. 10/617,455, filed Jul. 10, 2003, entitled “TRIANGLE RENDERING USING DIRECT EVALUATION,” the entire content of which is incorporated herein by reference.

TECHNICAL FIELD

The invention relates to mobile computing devices and, in particular, to techniques for rendering graphics for display by the mobile computing devices.

One fundamental operation of a 3D graphics application is triangular rendering. In particular, a 3D graphical object is typically defined by a set of triangles in a 3D space. Each triangle is defined by three vertices within the 3D space and associated attributes of each vertex, including color attributes, texture coordinates, or both. Each triangle is graphically rendered using an interpolation process that fills the interior of the triangle based on the location and attribute information defined at the three vertices. More specifically, each starting and ending coordinate is computed for each line of pixels within the triangle using the interpolation process. The pixels along each line are sequentially filled to render the entire triangle.

One challenge for mobile computing devices, however, is the typical limitation of available power. Unlike a desktop computing environment, mobile computing devices typically have limited battery power. As a result, the computationally intensive interpolation process required for triangular rendering may place a significant strain on the available power of the mobile computing device.

SUMMARY

The disclosure is directed to techniques for rendering a triangular area of pixels for presentation on a display device. The techniques may be particularly useful in a mobile computing environment presenting limited power resources.

In one embodiment, a method comprises computing data that defines a rectangular area of pixels that bounds a triangular area of the pixels, and evaluating coordinates of the pixels of the rectangular area to determine which pixels fall within the triangle area. The method further comprises updating pixel data for the pixels that fall within the triangle area to render the triangular area.

In another embodiment, an apparatus comprises a rendering engine that defines a rectangular area of pixels that bounds a triangular area of the pixels. The rendering engine evaluates coordinates associated with the pixels of the rectangular area to selectively render the pixels that fall within the triangular area.

In another embodiment, a mobile communication device comprises a display, a processor, and a rendering engine. The processor generates video output data for presentation by the display as a graphical environment. The rendering engine applies a direct evaluation algorithm to render a triangle for the graphical environment, wherein the direct evaluation algorithm applies linear equations to render the triangle without interpolating between edges of the triangle.

The details of one or more embodiments of the invention are set forth in the accompanying drawings and the description below. Other features, objects, and advantages of the invention will be apparent from the description and drawings, and from the claims.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating an example embodiment of a mobile computing device.

Processor 6 may take the form of an embedded microprocessor, specialized hardware, software, e.g., a control software module, or combinations thereof. Moreover, DSP 10, processor 6, rendering engine 12, as well as other components of mobile computing device 2, may be implemented in one or more application-specific integrated circuits (ASICs), as multiple discrete components, or combinations thereof.

As described herein, DSP 10 and a rendering engine 12 interact to apply a direct evaluation technique to render triangles for the 3D graphical environment. More specifically, DSP 10 issues commands to rendering engine 12 to direct the rendering engine to render triangles within a 3D space. In response, rendering engine 12 applies a direct evaluation triangle rendering algorithm that requires fewer division operations than the more computationally intensive interpolation process employed by conventional systems. As a result, mobile computing device 2 may present a 3D graphical environment while preserving as much as possible the power available to the mobile computing device.

To invoke rendering engine 12, DSP 10 issues a command that specifies the three vertices of the triangle to be rendered. For example, as illustrated in the example triangle depicted by FIG. 2, DSP 10 issues a command that defines triangle 20 with a first vertex (X0,Y0), a second vertex (X1,Y1), and a third vertex (X2,Y2), where each of the vertices represents a coordinate within a 2D slice of a 3D environment. Consequently, the vertices define a triangle having edges 24A, 24B and 24C.

In response to the command, rendering engine 12 computes a “bounding box” 22, which refers to a rectangular area defined to bound a minimum and a maximum of the x,y coordinates of the triangle. Bounding box 22, for example, is defined by an upper-left coordinate (Xmin,Ymin) and a lower-right coordinate (Xmax,Ymax). As illustrated in the example of FIG. 2, bounding box 22 may be defined to cover a minimum area within the 2D slice to encompass triangle 20. In other embodiments, minimum dimensions for bounding box 22 may be computed as function of a block size of video blocks stored by cache 15. In particular, DSP 10 and rendering engine 12 may process output video data of video memory 14 in a “tiled” fashion, i.e., in block fashion along rows and columns. Moreover, the block size may be set based on the capacity of cache 15. For example, the block size may equal the capacity of the cache. In this manner, the dimensions of bounding box 22 may be defined to be equal to or less than the dimensions of a video block in the event a triangle to be rendered lies completely within a single video block. For triangles spanning more than one video block, a bounding box may be used that has dimensions calculated to encompass the overlap between the bounding box of the triangle and the video block, as illustrated by bounding box 22A. This may advantageously reduce the number of memory accesses required for retrieving and rendering pixel data associated with the triangle, which translates into power savings.

After calculating the bounding box, e.g., bounding box 22 of FIG. 2, rendering engine 12 processes each pixel line encompassed by the bounding box and selectively enables those pixels that fall within triangle 20. Specifically, rendering engine 12 scans the pixels lines, e.g., in a leftward and downward fashion, and applies linear equations to determine whether each pixel falls within triangle 20. For those pixels within the edges 24A, 24B and 24C, rendering engine 12 updates the current attributes for the pixels, e. g., based on z-value, color information, texture information, or the like, associated with triangle 20.

FIG. 3 is a flowchart illustrating example operation of rendering engine 12 in application of a direct evaluation algorithm for rendering a triangle. Initially, rendering engine 12 receives a command from DSP 10 that specifies three vertices of a triangle to be rendered, i.e., a first vertex (X0,Y0), a second vertex (X1,Y1), and a third vertex (X2,Y2) (step 30 of FIG. 3).

In response to the command, rendering engine 12 computes data, e.g., an upper left coordinate and a height and width, that defines the bounding box that encompasses the triangle defined by the vertices (step 32).

In addition, rendering engine 12 computes a coefficient matrix M−1 for computing the linear coefficients of the linear equations that describe the attributes of each pixel within the triangle, and a coefficient matrix MC for computing the linear coefficients of the linear equations that describe the three edges of the triangle (step 34). Specifically, an attribute value ν for a pixel located inside the triangle can be represented as a linear function of the x,y location in the screen space as follows:
ν=Ax+By+C. (1)

Consequently, the linear coefficients, A, B, and C for eq. (1) can be obtained from the three equations associated with the three vertices:
ν0=Ax0+By0+C
ν1=Ax1+By2+C (2)
ν2=Ax2+By2+C
where νi(i=0, 1, 2), is the attribute value defined at vertex i, and (xi,yi)(i=0, 1, 2) are the screen coordinates of vertex i. Using matrix notations, the vertices can be represented as:
[vov1v2]=[x0y01x1y11x2y21]=[ABC].(3)

Thus, the coefficients for attribute interpolation can be expressed as:
[ABC]=M-1⁡[vov1v2].⁢where(4)M=[x0y01x1y11x2y21](5)

The coefficient matrix M−1 for computing the coefficients for attribute interpolation can be computed using Laplace expansion as follows
M-1=1det⁡(M)⁢MCT(6)
where
det(M)=|M|=x1y2+x2y0+x0y1−x2y1−x0y2−x1y0 (7)
MC, the companion matrix of M, can be calculated as:
Mc=[y1-y2x2-x1x1⁢y2-x2⁢y1y2-y0x0-x2x2⁢y0-x0⁢y2y0-y1x1-x0x0⁢y1-x1⁢y0].(8)

Upon calculating the coefficient matrices M−1 and MC, rendering engine 12 computes coefficients A, B, C, for all attributes associated with the pixels (step 36). In particular, the coefficient matrix M−1 can be used for computing the coefficients of different attributes, although the values at the vertices, (ν0,ν1,ν2), are different for different attributes.

Next, rendering engine 12 initializes all attribute values at a starting pixel of the bounding box, e.g., (Xmin,Ymin) of FIG. 2, (step 38). In addition, rendering engine 12 initializes current pixel index values (XC, YC) to a first pixel of a first scan line of the bounding box, i.e., XMIN and YMIN (step 39).

During the direct evaluation rasterization process, rendering engine 12 tests the current pixel (XC, YC) to determine whether the pixel falls within the triangle (step 39). Specifically, rendering engine 12 applies the previously calculated matrix MC based on a set of edge equations delineating the triangle to determine whether the location of the current pixel falls within the triangle. These equations are uniquely defined by the coordinates of the three vertices. In particular, for a given starting vertex (xi, yi), and ending point (xj, yj), on a 2D plane, for example, the edge equation is,
y-yix-xi=yj-yixj-xi(9)or,(yi-yj)⁢x+(xj-xi)⁢y+xi⁢yj-xj⁢y=0.(10)
For the three edges with starting vertex index, i=1, 2, 0, and ending vertex index, j=2, 0, 1, three edge equations in matrix format can be expressed as:
[e1e2e3]=MC⁡[XCYC1]=[000].(11)
Thus, rendering engine 12 applies the matrix MC to the current pixel (XC, YC), and determines that the pixel is inside the triangle when all of e1, e2, e3 are less than zero.

If the pixel is not within the triangle (no branch of 39), rendering engine 12 proceeds to the next pixel along the scan line of the bounding box, i.e., increments XC (step 46) and, assuming the end of the scan line has not been reached (step 48), tests that pixel in accordance with equation (11) to determine whether the pixel is within the triangle (step 39).

If application of equation (11) indicates that the current pixel is within the triangle, rendering engine 12 determines whether the current pixel is visible (step 40). Specifically, rendering engine 12 determines the position of the current pixel along the z-axis to determine whether the pixels is visible, or whether pixels from other slices of the 3D graphic environment prevent the pixel from being visible to the user, i.e., are on top of the current pixel. In one embodiment, rendering engine 12 compares a z-value, zc, of the current pixel with the corresponding z-value, zb, of a z-buffer to determine if the pixel is visible, i.e., if zc<zb.

If the pixel is not visible (no branch of step 40), rendering engine 12 proceeds to the next pixel (step 46). If, however, the pixel is visible, rendering engine 12 computes attribute values, e.g., texture and color values, for the pixel based on equation (1) (step 42). Upon computing the attribute values, rendering engine 12 updates the value of the current pixel within video memory 14 based on the computed attributes (step 44).

After updating the value of the current pixel within video memory 14, rendering engine 12 proceeds to the next pixel (step 46). This process is repeated until the end of the current scan line is reached, i.e., XC>XMAX or the current pixel exits the triangle (step 48), causing rendering engine 12 to proceed to the beginning of the next scan line, i.e., set XC=XMIN and incrementing YC (step 50). Rendering engine 12 traverses each scan line of the bounding box testing each pixel in this manner, and terminates the rendering process when the last scan line has been completed, i.e., YC>YMAX (step 52).

FIG. 4 is a block diagram illustrating an example embodiment of rendering engine 12. In the illustrated embodiment, rendering engine 12 includes a vertex buffer 60 for buffering vertices for triangles to be rendered in accordance with the direct evaluation techniques. In particular, rendering engine 12 receives commands from DSP 10 that specify triangles in the form of three vertices. Each vertex is defined by at least an x and y coordinate, and may include one or more attribute values k, such as z-values, color values, texture values, and the like.

Various embodiments of the invention have been described. These and other embodiments are within the scope of the following claims.

Claims (14)

1. A method comprising:

computing data that defines a rectangular area of pixels that bounds a triangular area of the pixels;

selecting a line of pixels within the rectangular area of pixels;

sequentially evaluating coordinates associated with the pixels of the line of pixels to determine whether the pixels fall within the triangle area;

ceasing evaluation of the coordinates associated with the pixels of the line of pixels upon determining that at least one pixel of the line falls within the triangle area and a current pixel no longer falls within the triangle area; and

updating pixel data for the pixels that fall within the triangle area to render the triangular area.

2. The method of claim 1, wherein evaluating coordinates comprises evaluating the coordinates of the pixels in accordance with a set of linear equations for computing edges of the triangular area.

3. The method of claim 1, wherein evaluating the coordinates of the pixels comprises:

computing a coefficient matrix MC for computing linear coefficients for the set of linear equations; and

applying the coefficient matrix MC to each of the pixels within the rectangular area to determine whether each of the pixels falls within the triangular area.

4. The method of claim 3, wherein applying the coefficient matrix MC comprises applying the coefficient matrix MC to a current one of the pixels (XC, YC) within the rectangular area to determine whether:

vertices v0(x0,y0), v1(x1,y1), and v2(x2,y2) are vertices of the triangular area.

5. The method of claim I, wherein updating pixel data comprises computing pixel data for the pixels of the rectangular area that fall within the triangle area in accordance with a set of linear equations that describe one or more attributes associated with the triangular area.

6. The method of claim 5, wherein the attribute values comprise at least one of color values and texture values.

7. The method of claim 5, wherein updating pixel data comprises:

computing a coefficient matrix M−1 for computing linear coefficients of the set of linear equations; and

applying the linear coefficients to each of the pixels that falls within the triangular area to compute an attribute value for each of the pixels.

8. The method of claim 7, wherein applying the coefficient matrix M−1 comprises applying the coefficient matrix M−1 to compute the linear coefficients A, B, and C, for an attribute associated with vertices v0(x0,y0), v1(x1,y1), and v2(x2,y2) of the triangle as:

[ABC]=M-1⁡[vov1v2],

where the coefficient matrix M−1 equals:

M=[x0y01x1y11x2y21],and

an attribute value for each pixel (XC, YC) is computed as

ν=AXC+BYC+C.

9. The method of claim 1, further comprising:

determining whether each of the pixels within the rectangular area is visible; and

selectively rendering each of the pixels based on the determination.

10. The method of claim 9, wherein determining whether each of the pixels is visible comprises comparing a z-value, zc, of the current pixel with a corresponding z-value, zb, of a z-buffer to determine if zc<zb.

11. The method of claim 1, wherein computing data comprises computing a first coordinate and a second coordinate that represent opposite corners of the rectangular area.

12. The method of claim 1, wherein

updating pixel data comprises processing the pixel data within a cache memory having a block size; and

computing data to define a rectangular area comprises computing the data to define the rectangular area as a function of the block size of the cache.

13. The method of claim 1, further comprising:

selecting a subsequent line of pixels within the rectangular area of pixels;

sequentially evaluating coordinates of pixels of the subsequent line of pixels to determine whether the pixels fall within the triangle area;

ceasing evaluation of the coordinates of the pixels of the subsequent line of pixels upon determining that at least one pixel of the subsequent line falls within the triangle area and a current pixel no longer falls within the triangle area; and

updating pixel data for the pixels that fall within the triangle area to render the triangular area.

14. A method comprising:

computing data that defines a rectangular area of pixels that bounds a triangular area of the pixels;

computing a coefficient matrix for computing a set of linear coefficients of a set of linear equations that describe edges of the triangular area;

applying the coefficient matrix to each of the pixels within the rectangular area to determine whether each of the pixels falls within the triangular area; and

updating pixel data for the pixels that fall within the triangle area to render the triangular area.