Conservative rasterization method and system, graphics processor
By adjusting the initial edge equations and bounding boxes of the geometric primitives to the target edge equations and bounding boxes, a conservative rasterization effect is achieved, reducing computational load and improving efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GLENFLY TECH CO LTD
- Filing Date
- 2026-05-12
- Publication Date
- 2026-07-31
AI Technical Summary
Existing conservative rasterization methods involve large computational costs, leading to increased hardware consumption and low rasterization efficiency.
By obtaining the initial edge equations and bounding boxes of geometric primitives, adjusting them to target edge equations and bounding boxes according to preset rules, and then using the target edge equations and bounding boxes for rasterization, a primitive pixel mask is generated.
This reduces the computational cost per pixel, improves the efficiency of conservative rasterization, and solves the problem of high computational cost.
Smart Images

Figure CN122492466A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a conservative rasterization method and system, and a graphics processor. Background Technology
[0002] In computer graphics, rasterization is the process of converting a geometric primitive into pixels, a core step in modern graphics processing units (GPUs) rendering 3D images. In traditional rasterization, a pixel is considered covered by a geometric primitive only if its center point falls inside the primitive. This results in significant blurring at the edges of geometric primitives.
[0003] To address this graphic imperfection caused by traditional rasterization, researchers proposed conservative rasterization. Conservative rasterization ensures that every pixel that might be covered, and even those that are truly completely covered, is accurately identified by moderately expanding (conservative over-rasterization) or shrinking (conservative under-rasterization) the geometric primitives within screen space. However, to implement conservative rasterization, GPU hardware needs to calculate four sampling points per pixel (the four corner points of the pixel) instead of one per pixel in traditional rasterization. This significantly increases computational load, leading not only to increased hardware consumption but also to lower rasterization efficiency. Summary of the Invention
[0004] The purpose of this invention is to provide a conservative rasterization method and system, and a graphics processor, to solve the problem of the large computational load in existing conservative rasterization methods.
[0005] To solve the above-mentioned technical problems, the present invention provides a conservative rasterization method, comprising: Obtain geometric primitives; Calculate the initial edge equations and initial bounding boxes of geometric primitives; According to preset rules, adjust the initial edge equation and initial bounding box to obtain the target edge equation and target bounding box; Rasterization is performed using the target edge equation and the target bounding box to generate primitive pixel masks.
[0006] Optionally, in the conservative rasterization method, the method for calculating the initial edge equations and initial bounding boxes of the computational geometric primitives includes: Get the vertices of the geometric primitives; Using the coordinate information of the vertices, calculate the edge equation corresponding to each side of the geometric primitive to obtain the initial edge equation; Using the coordinate information of the vertices, calculate the minimum bounding rectangle of the geometric primitives to obtain the initial bounding box.
[0007] Optionally, in the aforementioned conservative rasterization method, the method of calculating the edge equation corresponding to each side of the geometric primitive using the coordinate information of the vertices to obtain the initial edge equation includes: Arrange the vertices of the geometric primitives sequentially by connecting them in a clockwise direction; Using the coordinate information of two adjacent vertices, construct a linear equation in two variables to obtain the initial edge equation of the edge formed by the two adjacent vertices.
[0008] Optionally, in the conservative rasterization method, the method of calculating the minimum bounding rectangle of the geometric primitives using the vertex coordinate information to obtain the initial bounding box includes: Filter out the minimum, maximum, minimum, and maximum x-coordinates from the coordinate information of all vertices of the geometric primitive; The coordinates corresponding to the minimum x-coordinate and the minimum y-coordinate are taken as the first vertex, and the coordinates corresponding to the maximum x-coordinate and the maximum y-coordinate are taken as the second vertex. Construct a rectangle using the first and second vertices to obtain the initial bounding box.
[0009] Optionally, in the conservative rasterization method, the method of adjusting the initial edge equation and the initial bounding box according to preset rules to obtain the target edge equation and the target bounding box includes: Set the first and second parameters; Based on preset rules, determine whether conservative rasterization needs to be enabled; If it is determined that conservative rasterization needs to be enabled, then determine whether conservative overrasterization needs to be enabled, and / or whether conservative underrasterization needs to be enabled. If it is determined that conservative overpassing needs to be enabled, the initial edge equation and initial bounding box are adjusted using the first parameter to obtain the target edge equation and target bounding box. If it is determined that conservative underrasterization needs to be enabled, the initial edge equation and initial bounding box are adjusted using the second parameter to obtain the target edge equation and target bounding box.
[0010] Optionally, in the conservative rasterization method, the method for setting the first parameter and the second parameter includes: Determine the type of edge corresponding to the initial edge equation based on the coefficients of the initial edge equation; Set the corresponding first and second parameters according to the type of edge.
[0011] Optionally, in the conservative rasterization method described above, the initial edge equation is expressed as: Ax + By + C = 0 Where x represents the x-coordinate, y represents the y-coordinate, and A, B, and C represent coefficients; The method for determining the type of edge corresponding to the initial edge equation based on the coefficients of the initial edge equation includes: If A≥0 and B>0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the first type; If A > 0 and B ≤ 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the second type. If A < 0 and B ≥ 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the third type. If A≤0 and B<0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the fourth type.
[0012] Optionally, in the conservative rasterization method, the first parameter includes a first horizontal parameter and a first vertical parameter, and the second parameter includes a second horizontal parameter and a second vertical parameter; the method of setting the corresponding first and second parameters according to the type of the edge includes: If the type of the edge corresponding to the initial edge equation is the first type, then the first horizontal parameter is -1, the first vertical parameter is -1, the second horizontal parameter is +1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the second type, then the first horizontal parameter is -1, the first vertical parameter is +1, the second horizontal parameter is +1, and the second vertical parameter is -1. If the type of the edge corresponding to the initial edge equation is the third type, then the first horizontal parameter is +1, the first vertical parameter is -1, the second horizontal parameter is -1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the fourth type, then the first horizontal parameter is +1, the first vertical parameter is +1, the second horizontal parameter is -1, and the second vertical parameter is -1.
[0013] Optionally, in the conservative rasterization method, the method of adjusting the initial edge equation and the initial bounding box using the first parameter to obtain the target edge equation and the target bounding box includes: The x and y coordinates in the initial edge equation are translated using the first parameter to obtain the target edge equation. At this time, the edge corresponding to the target edge equation is expanded outward compared to the edge corresponding to the initial edge equation. The coordinates of the first vertex and the second vertex in the initial bounding box are adjusted using the uncertain region and the first parameter to obtain the first target vertex and the second target vertex; Construct a rectangular box using the first and second target vertices to obtain the target bounding box.
[0014] Optionally, in the conservative rasterization method, the method of adjusting the initial edge equation and the initial bounding box using the second parameter to obtain the target edge equation and the target bounding box includes: The second parameter is used to translate the x and y coordinates in the initial edge equation to obtain the target edge equation. At this time, the edge corresponding to the target edge equation is shrunken compared to the edge corresponding to the initial edge equation. The coordinates of the first vertex and the second vertex in the initial bounding box are adjusted using the uncertain region and the second parameter to obtain the first target vertex and the second target vertex; Construct a rectangular box using the first and second target vertices to obtain the target bounding box.
[0015] To address the aforementioned technical problems, the present invention also provides a conservative rasterization system for implementing the conservative rasterization method as described in any of the preceding claims, wherein the conservative rasterization system comprises: The acquisition module is used to acquire geometric primitives; The calculation module is used to calculate the initial edge equations and initial bounding boxes of geometric primitives; The adjustment module is used to adjust the initial edge equation and the initial bounding box according to preset rules to obtain the target edge equation and the target bounding box; The rasterization module is used to rasterize using the target edge equation and the target bounding box to generate primitive pixel masks.
[0016] To address the aforementioned technical problems, the present invention also provides a graphics processor that performs the conservative rasterization method as described in any of the preceding claims.
[0017] The conservative rasterization method and system, and graphics processor provided by this invention, include: acquiring geometric primitives; calculating the initial edge equations and initial bounding boxes of the geometric primitives; adjusting the initial edge equations and initial bounding boxes according to preset rules to obtain target edge equations and target bounding boxes; and performing rasterization using the target edge equations and target bounding boxes to generate primitive pixel masks. By adjusting the initial edge equations and initial bounding boxes to obtain outward or inward target edge equations and target bounding boxes, the conservative rasterization effect can be achieved directly using existing rasterization methods based on the target edge equations and target bounding boxes. This requires only one sampling point to be calculated for each pixel instead of four sampling points, greatly reducing the computational load and solving the problem of high computational cost in existing conservative rasterization methods. Attached Figure Description
[0018] Figure 1 A flowchart of the conservative rasterization method provided in this embodiment; Figure 2 This is a schematic diagram of the vertex coordinates of the geometric primitives provided in this embodiment; Figure 3 A schematic diagram of the initial bounding box of the geometric primitives provided in this embodiment; Figure 4 This is a flowchart illustrating the logical process of step S3 provided in this embodiment; Figure 5 This is a schematic diagram showing the relationship between the graph formed by the target edge equation obtained by conservative over-rasterization provided in this embodiment and the original geometric primitives. Figure 6 This is a schematic diagram showing the relationship between the graph formed by the target edge equation obtained by conservative under-rasterization in this embodiment and the original geometric primitives. Figure 7 This is a schematic diagram showing the pixel coverage of the upper left edge by existing rasterization and conservative rasterization. Figure 8 This is a schematic diagram illustrating the pixel coverage of the upper left edge by conservative over-rasterization provided in this embodiment; Figure 9 This is a schematic diagram illustrating the pixel coverage of the upper left edge by conservative underrasterization in this embodiment. Figure 10 This is a structural block diagram of the conservative rasterization system provided in this embodiment. Detailed Implementation
[0019] The conservative rasterization method and system, and graphics processor proposed in this invention, will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the drawings are all in a very simplified form and use non-precise scales, and are only used to facilitate and clarify the illustration of the embodiments of this invention. Furthermore, the structures shown in the drawings are often part of the actual structure. In particular, different figures may emphasize different aspects and sometimes use different scales.
[0020] It should be noted that the terms "first," "second," etc., used in the specification, claims, and drawings of this invention are used to distinguish similar objects in order to describe embodiments of the invention, and are not used to describe a specific order or sequence. It should be understood that such uses of terminology are interchangeable where appropriate. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0021] This embodiment provides a conservative rasterization method, such as Figure 1 As shown, it includes: S1, obtain geometric primitives; S2, calculates the initial edge equations and initial bounding boxes of geometric primitives; S3, according to preset rules, adjust the initial edge equation and initial bounding box to obtain the target edge equation and target bounding box; S4. Rasterization is performed using the target edge equation and the target bounding box to generate primitive pixel masks.
[0022] The conservative rasterization method provided in this embodiment obtains the target edge equation and target bounding box by adjusting the initial edge equation and the initial bounding box, which can expand or shrink the target edge equation and the target bounding box. This allows the conservative rasterization effect to be achieved directly using existing rasterization methods based on the target edge equation and the target bounding box. In this way, only one sampling point needs to be calculated for each pixel instead of four sampling points, which greatly reduces the amount of computation and solves the problem of large computational load in existing conservative rasterization.
[0023] Specifically, in this embodiment, step S1 involves acquiring geometric primitives.
[0024] In practical applications, geometric primitives can be closed shapes enclosed by any number of sides. In this embodiment, only triangles are used as geometric primitives to illustrate the implementation scheme of the conservative rasterization method provided in this application. Those skilled in the art can understand, based on the examples in this application, how to implement conservative rasterization of other geometric primitives using the conservative rasterization method provided in this application, and this application will not elaborate further on this.
[0025] Furthermore, in this embodiment, step S2 involves calculating the initial edge equations and initial bounding boxes of the geometric primitives.
[0026] Specifically, in this embodiment, step S2 may include: S21, obtain the vertices of the geometric primitives.
[0027] Specifically, such as Figure 2 As shown, the triangle (geometric primitive) has three vertices, denoted as V0, V1, and V2. V0, V1, and V2 are transformed using a viewport to obtain vertex coordinates based on screen pixels, denoted as V0(x0,y0), V1(x1,y1), and V2(x2,y2).
[0028] S22. Using the coordinate information of the vertices, calculate the edge equation corresponding to each side of the geometric primitive to obtain the initial edge equation.
[0029] Specifically, in this embodiment, firstly, considering that if the vertex order is arranged clockwise, then if a pixel falls within a geometric primitive, the pixel should be located to the right of each edge of the geometric primitive; if the vertex order is arranged counterclockwise, then if a pixel falls within a geometric primitive, the pixel should be located to the left of each edge of the geometric primitive. To facilitate determining the positional relationship of the pixel relative to the geometric primitive, this embodiment arranges the vertices of the geometric primitive in a clockwise sequential connection manner, i.e., in the order of V0-V1-V2.
[0030] Then, using the coordinate information of two adjacent vertices, a linear equation in two variables is constructed to obtain the initial edge equation of the edge formed by these two adjacent vertices. Specifically, for the edge V0-V1, its edge equation can be expressed as:
[0031]
[0032] Similarly, the edge equations corresponding to the edges of V1-V2 can be expressed as:
[0033]
[0034] Furthermore, the edge equation corresponding to V2-V0 can be expressed as:
[0035]
[0036] To determine the positional relationship between a point and a line, substitute the coordinates of the point into the line function (side equation). If the result is greater than 0, it indicates that the point is located on the right side of the line; if the result is less than 0, it indicates that the point is located on the left side of the line; if the result is equal to 0, it indicates that the point is located on the line.
[0037] Thus, if the pixel coordinates (x, y) are substituted into the edge equations of the geometric primitive, the results are as follows: if all the edge equations are greater than 0, it indicates that the pixel is located inside the geometric primitive; if at least one edge equation is less than 0, it indicates that the pixel is located outside the geometric primitive; if one edge equation is 0, it indicates that the pixel is located on the edge corresponding to that edge equation of the geometric primitive; if two edge equations are 0, it indicates that the pixel is located at the vertex where the edges corresponding to those two edge equations of the geometric primitive intersect.
[0038] S23. Using the coordinate information of the vertices, calculate the minimum bounding rectangle of the geometric primitives to obtain the initial bounding box.
[0039] Specifically, in this embodiment, firstly, the minimum xmin, maximum xmax, minimum ymin, and maximum ymax of the horizontal coordinates are selected from the coordinate information of all vertices of the geometric primitive, which can be expressed as: xmin=(x0,x1,x2) xmax=(x0,x1,x2) ymin=(y0,y1,y2) ymax=(y0,y1,y2) Then, the coordinates corresponding to the minimum xmin and minimum ymin of the horizontal coordinate are taken as the first vertex, that is, the coordinates of the first vertex are (xmin, ymin), and the coordinates corresponding to the maximum xmax and maximum ymax of the horizontal coordinate are taken as the second vertex, that is, the coordinates of the second vertex are (xmax, ymax).
[0040] Finally, a rectangular bounding box is constructed using the first and second vertices. Specifically, the first and second vertices are used as the diagonal vertices of the bounding box to construct the outer rectangle of the geometric primitives, thus obtaining the initial bounding box. For example... Figure 3 As shown in the dashed box.
[0041] Furthermore, in this embodiment, step S3 involves adjusting the initial edge equation and the initial bounding box according to preset rules to obtain the target edge equation and the target bounding box.
[0042] Specifically, in this embodiment, such as Figure 4 As shown, step S3 may include: S31, set the first and second parameters.
[0043] In this embodiment, the first parameter includes a first horizontal parameter xoffset1 and a first vertical parameter yoffset1 for adjusting the initial edge equation, and a first compensation parameter for adjusting the initial bounding box; the second parameter includes a second horizontal parameter xoffset2 and a second vertical parameter yoffset2 for adjusting the initial edge equation, and a second compensation parameter for adjusting the initial bounding box.
[0044] In this embodiment, for the first horizontal parameter, first vertical parameter, second horizontal parameter, and second vertical parameter used to adjust the initial edge equation, the type of the edge corresponding to the initial edge equation is first determined based on the coefficients of the initial edge equation. Specifically, for the initial edge equation Ax+By+C=0, this embodiment provides a method for determining the edge type: If A > 0 and B > 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the upper left edge. If A = 0 and B > 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the upper edge. In this embodiment, the upper left edge and the upper edge are classified as the first type. If A > 0 and B < 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the bottom left edge. If A > 0 and B = 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the left edge. In this embodiment, the bottom left edge and the left edge are classified as the second type. If A < 0 and B > 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the upper right edge. If A < 0 and B = 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the right edge. In this embodiment, the upper right edge and the right edge are classified as the third type. If A < 0 and B < 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the bottom right edge. If A = 0 and B < 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the bottom edge. In this embodiment, the bottom right edge and the bottom edge are classified as the fourth type.
[0045] Then, based on the type of edge, the corresponding first and second parameters are set. Specifically, in this embodiment: If the type of the edge corresponding to the initial edge equation is the first type, then the first horizontal parameter is -1, the first vertical parameter is -1, the second horizontal parameter is +1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the second type, then the first horizontal parameter is -1, the first vertical parameter is +1, the second horizontal parameter is +1, and the second vertical parameter is -1. If the type of the edge corresponding to the initial edge equation is the third type, then the first horizontal parameter is +1, the first vertical parameter is -1, the second horizontal parameter is -1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the fourth type, then the first horizontal parameter is +1, the first vertical parameter is +1, the second horizontal parameter is -1, and the second vertical parameter is -1.
[0046] It should be noted that in this embodiment, "1" in the above parameters represents one unit. In practical applications, a unit can be assigned a specific meaning, such as taking 1 pixel as a unit, or taking 1 mm as a unit. Of course, 1 / 2 pixel or 1 / 512 pixel can also be taken as a unit, and this application does not limit this.
[0047] Furthermore, in this embodiment, the first and second compensation parameters used to adjust the initial bounding box need to be set according to the uncertainty region level supported by the hardware. In a specific embodiment, the first compensation parameter can be expressed as the sum of the uncertainty region level and the compensation unit value, and the second compensation parameter can be expressed as the sum of the uncertainty region level and the compensation unit value, wherein the compensation unit value can specifically be 1 / 2 pixel.
[0048] S32 determines whether conservative rasterization needs to be enabled based on preset rules.
[0049] In practical applications, it can be reasonably determined whether conservative rasterization needs to be enabled based on actual needs. If conservative rasterization is not required, the initial edge equations and initial bounding boxes can be directly used as the target edge equations and target bounding boxes.
[0050] S33, if it is determined that conservative rasterization needs to be enabled, then determine whether conservative overrasterization needs to be enabled, and / or whether conservative underrasterization needs to be enabled.
[0051] In practical applications, conservative over-rasterization or conservative under-rasterization can be enabled only, or both can be enabled simultaneously. When both conservative over-rasterization and conservative under-rasterization are enabled simultaneously, two sets of target edge equations and target bounding boxes need to be obtained using the first and second parameters respectively, to correspond to conservative over-rasterization and conservative under-rasterization.
[0052] S34-1, if it is determined that conservative transgrating needs to be enabled, the initial edge equation and the initial bounding box are adjusted using the first parameter to obtain the target edge equation and the target bounding box.
[0053] Specifically, in this embodiment, the x and y coordinates in the initial edge equation are translated using the first parameter to obtain the target edge equation. Figure 5Taking the geometric primitives shown as an example, the V0-V1 edge is the upper left edge, with its first horizontal parameter being -1 and its first vertical parameter being -1. Graphically, this means shifting the V0-V1 edge one unit in the negative x-direction (left) and one unit in the negative y-direction (upward), i.e., adjusting V0 to V3 and V1 to V4. V3-V4 is the newly generated edge after expanding V0-V1. Similarly, the V2-V0 edge is the upper right edge, with its first horizontal parameter being +1 and its first vertical parameter being -1. Graphically, this means shifting the V2-V0 edge one unit in the positive x-direction (right) and one unit in the negative y-direction (upward). The first edge is shifted one unit to the right and one unit to the left (y-direction, upwards), i.e., V0 is adjusted to V5 and V2 is adjusted to V6. V6-V5 is the newly generated edge after expanding V2-V0. The second edge, V1-V2, is the bottom edge, with its first horizontal parameter +1 and first vertical parameter +1. Graphically, this means shifting V1-V2 one unit to the right and one unit to the left (y-direction, downwards), i.e., adjusting V1 to V7 and V2 to V8. V7-V8 is the newly generated edge after expanding V1-V2. At this point, as... Figure 5 As shown, the edge corresponding to the target edge equation is expanded outward compared to the edge corresponding to the initial edge equation.
[0054] Preferably, in this embodiment, the first compensation parameter can also be used to correct the obtained target edge equation to obtain a more accurate target edge equation. Specifically, taking the V0-V1 edge as an example, after enabling conservative over-rasterization, the coordinates of the new edge vertex V3 are (x0+xoffset1,y0+yoffset1)=(x0-1,y0-1), and the coordinates of V4 are (x1+xoffset1,y1+yoffset1)=(x1-1,y1-1). The edge equation coefficients of the V3-V4 edge are represented by A', B', and C', which can be obtained as follows:
[0055] Then, the above edge equations are further adjusted using the first compensation parameter to obtain the final target edge equation, which can be expressed as:
[0056] in, Indicates an uncertain region level. Indicates the unit value of compensation. This represents the first compensation parameter.
[0057] Furthermore, considering that adjusting only the edge equations without adjusting the bounding box might lead to deviations in the results and affect the accuracy of the rasterization, this embodiment also requires adjustment of the bounding box.
[0058] Specifically, firstly, the coordinates of the first and second vertices in the initial bounding box are adjusted using the uncertain region and a first parameter to obtain the first and second target vertices. In practical applications, the first compensation parameter is used to adjust the coordinates of the first and second vertices in the initial bounding box. Specifically, for xmin, the adjusted coordinates xmin_adj1 = xmin - (UR + 0.5 pixel); for xmax, the adjusted coordinates xmax_adj1 = xmax + (UR + 0.5 pixel); for ymin, the adjusted coordinates ymin_adj1 = ymin - (UR + 0.5 pixel); and for ymax, the adjusted coordinates ymax_adj1 = ymax + (UR + 0.5 pixel). At this point, the coordinates of the first target vertex are (xmin_adj1, ymin_adj1), and the coordinates of the second target vertex are (xmax_adj1, ymax_adj1).
[0059] Then, a rectangle is constructed using the first and second target vertices to obtain the target bounding box. The method of constructing the rectangle is the same as that of obtaining the initial bounding box, and will not be described in detail here.
[0060] S34-2, if it is determined that conservative underrasterization needs to be enabled, the initial edge equation and initial bounding box are adjusted using the second parameter to obtain the target edge equation and target bounding box.
[0061] This process is similar to step S34-1. Specifically, with... Figure 6 Taking the geometric primitives shown as an example, the V0-V1 edge is the top-left edge, with its second horizontal parameter being +1 and its second vertical parameter being +1. Graphically, this means shifting the V0-V1 edge one unit in the positive x-direction (to the right) and one unit in the positive y-direction (downward), that is, adjusting V0 to V9 and V1 to V10. V9-V10 is the newly generated edge after the V0-V1 edge is shrunk. Similarly, the V2-V0 edge is the top-right edge, with its second horizontal parameter being -1 and its second vertical parameter being +1. Graphically, this means shifting the V2-V0 edge in the negative x-direction (to the left). One unit is shifted one unit in the positive y-direction (downwards), that is, V0 is adjusted to V11 and V2 is adjusted to V12. V12-V11 is the newly generated edge after shrinking V2-V0. Also, the V1-V2 edge is the bottom edge, with its second horizontal parameter being -1 and its second vertical parameter being -1. Graphically, this means shifting the V1-V2 edge one unit in the negative x-direction (leftwards) and one unit in the negative y-direction (upwards), that is, adjusting V1 to V137 and V2 to V14. V13-V14 is the newly generated edge after shrinking V1-V2. At this point, as... Figure 6 As shown, the edge corresponding to the target edge equation is shrunken compared to the edge corresponding to the initial edge equation.
[0062] Preferably, in this embodiment, the second compensation parameter can also be used to correct the obtained target edge equation to obtain a more accurate target edge equation. Specifically, taking the V0-V1 edge as an example, after enabling conservative under-rasterization, the coordinates of the new edge vertex V9 are (x0+xoffset2,y0+yoffset2)=(x0+1,y0+1), and the coordinates of V10 are (x1+xoffset2,y1+yoffset2)=(x1+1,y1+1). The edge equation coefficients of the V3-V4 edge are represented by A', B', and C', and then we can obtain:
[0063] Then, the above edge equations are further adjusted using the second compensation parameter to obtain the final target edge equation, which can be expressed as:
[0064] in, Indicates an uncertain region level. Indicates the unit value of compensation. This represents the second compensation parameter.
[0065] Furthermore, the method for adjusting the bounding box during conservative underrasterization includes: First, adjusting the coordinates of the first vertex and the second vertex in the initial bounding box using the uncertain region and the second parameter to obtain the first target vertex and the second target vertex. In practical applications, the second compensation parameter is used to adjust the coordinates of the first vertex and the second vertex in the initial bounding box, where, for xmin, the adjusted coordinates xmin_adj2 = xmin + (UR + 0.5 pixel); for xmax, the adjusted coordinates xmax_adj2 = xmax - (UR + 0.5 pixel); for ymin, the adjusted coordinates ymin_adj2 = ymin + (UR + 0.5 pixel); and for ymax, the adjusted coordinates ymax_adj2 = ymax - (UR + 0.5 pixel). At this point, the coordinates of the first target vertex are (xmin_adj2, ymin_adj2), and the coordinates of the second target vertex are (xmax_adj2, ymax_adj2).
[0066] Then, a rectangle is constructed using the first and second target vertices to obtain the target bounding box. The method of constructing the rectangle is the same as that of obtaining the initial bounding box, and will not be described in detail here.
[0067] Furthermore, in this embodiment, step S4 involves rasterization using the target edge equation and the target bounding box to generate a primitive pixel mask.
[0068] Specifically, for the upper left edge V0-V1, according to the traditional rasterization method, that is, using the pixel center point as the sampling point for calculation, the covered pixels are as follows: Figure 7 As shown in the diagonally filled box in Figure (a), conservative overrasterization requires calculating the four corners of the pixel as sampling points, covering the pixels as shown in the diagonally filled box in Figure (b). Conversely, conservative underrasterization also requires calculating the four corners of the pixel as sampling points, covering the pixels as shown in the diagonally filled box in Figure (c). The current conservative rasterization process requires four times the computational cost of existing rasterization methods, resulting in a massive computational burden.
[0069] In this embodiment, during conservative over-rasterization, the upper left edge V0-V1 is shifted one unit (e.g., 1 / 2 pixel) to the upper left. The position of the edge relative to the pixel is as follows: Figure 8 As shown. At this point, the pixels to be covered are determined using the traditional rasterization method, and the result obtained is consistent with the result of the existing conservative traversal, that is, conservative traversal is achieved.
[0070] Furthermore, corresponding to this embodiment, during conservative underrasterization, the upper left edge V0-V1 is shifted to the lower right by one unit, for example, 1 / 2 pixel. The position of the edge relative to the pixel at this time is as follows: Figure 9 As shown. At this point, the pixels to be covered are determined using the traditional rasterization method, and the result obtained is consistent with the result of the existing conservative underrasterization, that is, conservative underrasterization is achieved.
[0071] The conservative rasterization method provided in this embodiment only requires adjusting the initial edge equations and the initial bounding box. It then utilizes existing simple rasterization methods to perform rasterization based on the adjusted target edge equations and target bounding box, achieving conservative over-rasterization or conservative under-rasterization. The entire process does not require increasing pixel sampling points, thus greatly reducing computational load and improving the efficiency of conservative rasterization.
[0072] The conservative rasterization method provided in this embodiment is applicable to various rasterization algorithms, such as edge function algorithms and scan line algorithms, and does not require significant modifications to existing hardware architectures that do not support conservative rasterization. It only requires adding hardware or software components to adjust the initial edge equations and initial bounding boxes, thus reducing the system development cycle and difficulty.
[0073] This embodiment also provides a conservative rasterization system for implementing the conservative rasterization method described above, such as... Figure 10 As shown, the conservative rasterization system includes: The acquisition module is used to acquire geometric primitives; The calculation module is used to calculate the initial edge equations and initial bounding boxes of geometric primitives; The adjustment module is used to adjust the initial edge equation and the initial bounding box according to preset rules to obtain the target edge equation and the target bounding box; The rasterization module is used to rasterize using the target edge equation and the target bounding box to generate primitive pixel masks.
[0074] Furthermore, this embodiment also provides a graphics processor that performs the conservative rasterization method described above.
[0075] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to mutually. In addition, different parts between embodiments can also be combined with each other, and this invention does not limit this.
[0076] The conservative rasterization method and system, and graphics processor provided in this embodiment include: acquiring geometric primitives; calculating the initial edge equations and initial bounding boxes of the geometric primitives; adjusting the initial edge equations and initial bounding boxes according to preset rules to obtain the target edge equations and target bounding boxes; and performing rasterization using the target edge equations and target bounding boxes to generate primitive pixel masks. By adjusting the initial edge equations and initial bounding boxes to obtain the outward or inward target edge equations and target bounding boxes, the conservative rasterization effect can be achieved directly using existing rasterization methods based on the target edge equations and target bounding boxes. This requires only one sampling point to be calculated for each pixel instead of four sampling points, greatly reducing the computational load and solving the problem of high computational cost in existing conservative rasterization methods.
[0077] The above description is merely a description of preferred embodiments of the present invention and is not intended to limit the scope of the present invention in any way. Any changes or modifications made by those skilled in the art based on the above disclosure shall fall within the protection scope of the claims.
Claims
1. A conservative rasterization method, characterized in that, include: Obtain geometric primitives; Calculate the initial edge equations and initial bounding boxes of geometric primitives; According to preset rules, adjust the initial edge equation and initial bounding box to obtain the target edge equation and target bounding box; Rasterization is performed using the target edge equation and the target bounding box to generate primitive pixel masks.
2. The conservative rasterization method according to claim 1, characterized in that, The method for calculating the initial edge equations and initial bounding boxes of geometric primitives includes: Get the vertices of the geometric primitives; Using the coordinate information of the vertices, calculate the edge equation corresponding to each side of the geometric primitive to obtain the initial edge equation; Using the coordinate information of the vertices, calculate the minimum bounding rectangle of the geometric primitives to obtain the initial bounding box.
3. The conservative rasterization method according to claim 2, characterized in that, The method for calculating the edge equation corresponding to each side of a geometric primitive using the coordinate information of the vertices to obtain the initial edge equation includes: Arrange the vertices of the geometric primitives sequentially by connecting them in a clockwise direction; Using the coordinate information of two adjacent vertices, construct a linear equation in two variables to obtain the initial edge equation of the edge formed by the two adjacent vertices.
4. The conservative rasterization method according to claim 2, characterized in that, The method for calculating the minimum bounding rectangle of geometric primitives using vertex coordinate information to obtain the initial bounding box includes: Filter out the minimum, maximum, minimum, and maximum x-coordinates from the coordinate information of all vertices of the geometric primitive; The coordinates corresponding to the minimum x-coordinate and the minimum y-coordinate are taken as the first vertex, and the coordinates corresponding to the maximum x-coordinate and the maximum y-coordinate are taken as the second vertex. Construct a rectangle using the first and second vertices to obtain the initial bounding box.
5. The conservative rasterization method according to claim 1, characterized in that, The method for adjusting the initial edge equation and initial bounding box according to preset rules to obtain the target edge equation and target bounding box includes: Set the first and second parameters; Based on preset rules, determine whether conservative rasterization needs to be enabled; If it is determined that conservative rasterization needs to be enabled, then determine whether conservative overrasterization needs to be enabled, and / or whether conservative underrasterization needs to be enabled. If it is determined that conservative overpassing needs to be enabled, the initial edge equation and initial bounding box are adjusted using the first parameter to obtain the target edge equation and target bounding box. If it is determined that conservative underrasterization needs to be enabled, the initial edge equation and initial bounding box are adjusted using the second parameter to obtain the target edge equation and target bounding box.
6. The conservative rasterization method according to claim 5, characterized in that, The method for setting the first parameter and the second parameter includes: Determine the type of edge corresponding to the initial edge equation based on the coefficients of the initial edge equation; Set the corresponding first and second parameters according to the type of edge.
7. The conservative rasterization method according to claim 6, characterized in that, The initial edge equation is expressed as: Ax + By + C = 0 Where x represents the x-coordinate, y represents the y-coordinate, and A, B, and C represent coefficients; The method for determining the type of edge corresponding to the initial edge equation based on the coefficients of the initial edge equation includes: If A≥0 and B>0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the first type; If A > 0 and B ≤ 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the second type. If A < 0 and B ≥ 0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the third type. If A≤0 and B<0 in the initial edge equation, then the type of the edge corresponding to the initial edge equation is determined to be the fourth type.
8. The conservative rasterization method according to claim 7, characterized in that, The first parameter includes a first horizontal parameter and a first vertical parameter, and the second parameter includes a second horizontal parameter and a second vertical parameter; the method for setting the corresponding first and second parameters according to the type of edge includes: If the type of the edge corresponding to the initial edge equation is the first type, then the first horizontal parameter is -1, the first vertical parameter is -1, the second horizontal parameter is +1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the second type, then the first horizontal parameter is -1, the first vertical parameter is +1, the second horizontal parameter is +1, and the second vertical parameter is -1. If the type of the edge corresponding to the initial edge equation is the third type, then the first horizontal parameter is +1, the first vertical parameter is -1, the second horizontal parameter is -1, and the second vertical parameter is +1. If the type of the edge corresponding to the initial edge equation is the fourth type, then the first horizontal parameter is +1, the first vertical parameter is +1, the second horizontal parameter is -1, and the second vertical parameter is -1.
9. The conservative rasterization method according to claim 5, characterized in that, The method of adjusting the initial edge equation and initial bounding box using the first parameter to obtain the target edge equation and target bounding box includes: The x and y coordinates in the initial edge equation are translated using the first parameter to obtain the target edge equation. At this time, the edge corresponding to the target edge equation is expanded outward compared to the edge corresponding to the initial edge equation. The coordinates of the first vertex and the second vertex in the initial bounding box are adjusted using the uncertain region and the first parameter to obtain the first target vertex and the second target vertex; Construct a rectangular box using the first and second target vertices to obtain the target bounding box.
10. The conservative rasterization method according to claim 5, characterized in that, The method of adjusting the initial edge equation and initial bounding box using the second parameter to obtain the target edge equation and target bounding box includes: The second parameter is used to translate the x and y coordinates in the initial edge equation to obtain the target edge equation. At this time, the edge corresponding to the target edge equation is shrunken compared to the edge corresponding to the initial edge equation. The coordinates of the first vertex and the second vertex in the initial bounding box are adjusted using the uncertain region and the second parameter to obtain the first target vertex and the second target vertex; Construct a rectangular box using the first and second target vertices to obtain the target bounding box.
11. A conservative rasterization system for implementing the conservative rasterization method as described in any one of claims 1 to 10, characterized in that, The conservative rasterization system includes: The acquisition module is used to acquire geometric primitives; The calculation module is used to calculate the initial edge equations and initial bounding boxes of geometric primitives; The adjustment module is used to adjust the initial edge equation and the initial bounding box according to preset rules to obtain the target edge equation and the target bounding box; The rasterization module is used to rasterize using the target edge equation and the target bounding box to generate primitive pixel masks.
12. A graphics processor, characterized in that, The graphics processor performs the conservative rasterization method as described in any one of claims 1 to 10.