Method for judging rasterized triangle coverage points, electronic device, and storage medium

By querying the slope of the triangle's sides in the Fari sequence, the pixels covered by the triangle are determined, solving the problem of high computational complexity in existing technologies and achieving more efficient rasterization judgment.

CN122065769BActive Publication Date: 2026-06-19METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD
Filing Date
2026-04-21
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing methods for rasterizing triangles have high computational complexity, and there is an urgent need for a method to determine the coverage points of rasterized triangles with low computational complexity.

Method used

By obtaining the Fari sequence, the three sides of the triangle are translated to the origin. The actual slope of each side is then queried in the Fari sequence to find the target slope. Based on the target slope, alternative slopes are found to determine the pixels covered by the triangle.

🎯Benefits of technology

This reduces the query complexity of the rasterization method and improves computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122065769B_ABST
    Figure CN122065769B_ABST
Patent Text Reader

Abstract

This invention relates to the field of chip design technology, and in particular to a method for determining the coverage points of rasterized triangles, an electronic device, and a storage medium. It obtains a farri sequence, whose elements are proper fractions of the slopes of discrete points on the screen connected to the origin, arranged in order. These discrete points are either sampling points of pixels on the screen or lateral insertion points between sampling points. The method then obtains the actual slopes of the three sides of the triangle translated to the origin; finds the target slope corresponding to the actual slope of each side in each row within the farri sequence; and obtains the coverage point of the current side in each row based on each target slope and the translation distance of the current side; searches the farri sequence for slopes starting from the candidate slopes of each coverage point, obtaining candidate slopes whose numerators are less than or equal to the candidate slope numerator; and filters out the pixels covered by the triangle based on the discrete points of all candidate slopes corresponding to each side, significantly reducing computational complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of chip design technology, and in particular to a method for determining the coverage points of rasterized triangles, electronic devices, and storage media. Background Technology

[0002] In the field of Computer Graphics (CG), the rasterization process in graphics rendering is crucial. In 3D scene rendering, models are composed of many triangles, and the GPU needs to convert these triangles into pixels on the screen. By determining the pixels covered by a triangle, it's possible to identify which pixels belong to the graphic portion represented by that triangle. Subsequent calculations and filling of color, texture, and other information can then be performed on these pixels, ensuring the graphics are correctly displayed on the screen. Existing GPU-based rasterization methods primarily focus on triangle rasterization, and there are two main methods for triangle rasterization.

[0003] First rasterization method: Please refer to Figure 1 , Figure 1Each small square in the triangle represents a pixel, and the top-left corner of each pixel represents a sample point. If the sample point is inside the triangle, then the pixel is inside the triangle. Depending on the version of the Direct3D application programming interface (API) designed for rendering 2D and 3D graphics, the position of the sample point is determined by the interface version; in some versions, the sample point may be located at the exact center of the pixel. Taking a pixel with its top-left corner as an example, the method for determining if a pixel is inside a triangle is as follows: First, find the bounding box (bdbox) of the current triangle. This bdbox is the rectangle formed by the maximum x and y coordinates, and the minimum x and y coordinates of the triangle's three vertices. Second, slice the bdbox into n×m tiles. The third step involves examining the four vertices of each tile and substituting their coordinates into the system of equations for the three sides of the triangle: F0(x, y) = A0×x + B0×y + c0; F1(x, y) = A1×x + B1×y + c1; F2(x, y) = A2×x + B2×y + c2. If the result of substituting the coordinates of all four vertices into the system of equations is either greater than 0 or less than 0, it means that the current tile is completely inside the triangle, and the current tile is placed into the next stage of the pipeline. If, after substituting the coordinates of the four vertices into the system of equations, some vertices are inside the triangle and some are outside the triangle, the current tile is divided into four equal parts and placed into the next stage of the pipeline. If the current tile is completely outside the triangle, the current tile is discarded. This process is repeated recursively for each quarter of the tiles placed into the next stage of the pipeline until a 2x2 quad is reached. The computational complexity of this method is the number of pixels equal to the area of ​​the triangle. (6 times multiplied + 6 times added + 3 times compared).

[0004] The second rasterization method involves decomposing the triangle into three line segments and applying the Bresemham algorithm to each segment. If the height of the current triangle's bounding box is m, the computational complexity is 3 × m × (1 addition + 1 comparison).

[0005] The two methods mentioned above have high computational complexity. Therefore, there is an urgent need for a method for determining the coverage points of rasterized triangles with low computational complexity. Summary of the Invention

[0006] To address the aforementioned technical problems, the present invention employs the following technical solution: a method for determining the coverage points of rasterized triangles, the method comprising the following steps:

[0007] S100, Obtain the farse sequence, wherein the elements in the farse sequence are the slopes of the lines connecting discrete position points on the screen to the origin, and the slopes in the farse sequence are proper fractions arranged in ascending or descending order, wherein the discrete position points are sampling points of pixels on the screen or horizontal insertion points between sampling points.

[0008] S200, translate the three sides of the triangle to the origin. When the ordinate of the translated endpoint is greater than its abscissa, swap the values ​​of the ordinate and abscissa to obtain the actual slope of each side; where the slope k of the i-th side is... i Satisfying k i =y i / x i , where y i Let x be the ordinate of the endpoint of the i-th edge furthest from the origin. i Let x be the x-coordinate of the endpoint of the i-th edge that is furthest from the origin.

[0009] S300, find the target slope corresponding to the actual slope of each edge in each row in the Fari sequence, K≥1; and obtain the coverage point of the current edge in each row according to each target slope and the translation distance of the current edge; use the candidate slope of each coverage point as the starting point to search for the slope in the Fari sequence in order, and obtain the candidate slope with a numerator less than or equal to the candidate slope numerator.

[0010] S400, determine the horizontal coordinate range based on the discrete position points of all candidate slopes corresponding to each side, and select slopes with the same numerator and denominator belonging to the horizontal coordinate range from all candidate slopes. The discrete position points corresponding to the slopes selected from all three sides are the pixel points covered by the triangle.

[0011] Furthermore, the present invention also provides a non-transitory computer-readable storage medium storing at least one instruction or at least one program segment, wherein the at least one instruction or the at least one program segment is loaded and executed by a processor to implement the above-described method.

[0012] In addition, the present invention provides an electronic device including a processor and the aforementioned non-transitory computer-readable storage medium.

[0013] The present invention has at least the following beneficial effects:

[0014] This invention provides a method, electronic device, and storage medium for rasterizing pixels. The method involves translating the three sides of a triangle to the origin, then querying the target slope of each side in the farithmic sequence. Based on the target slope, the farithmic sequence is searched again to obtain multiple candidate slopes. These candidate slopes are then used to determine all pixels covered by the triangle. This method primarily determines candidate slopes by querying the farithmic sequence, significantly reducing the query complexity compared to the first and second rasterization methods. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A schematic diagram illustrating the relationship between triangles and pixels on a screen, provided for existing technology;

[0017] Figure 2 A flowchart illustrating a method for determining the coverage point of a rasterized triangle, as provided in an embodiment of the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] Unless otherwise defined, all technical and scientific terms used in the embodiments of this invention have the same meaning as commonly understood by those skilled in the art.

[0020] Please see Figure 1 It illustrates a method for determining the coverage points of rasterized triangles, the method comprising the following steps:

[0021] S100, Obtain the farse sequence, wherein the elements in the farse sequence are the slopes of the lines connecting discrete position points on the screen to the origin, and the slopes in the farse sequence are proper fractions arranged in ascending or descending order, wherein the discrete position points are sampling points of pixels on the screen or horizontal insertion points between sampling points.

[0022] In one embodiment, the sampling point is the center point of the pixel or a vertex of the pixel, or it can be the centroid or incenter of the pixel, etc. Other types of sampling points used to represent pixels are all within the protection scope of this invention.

[0023] In one implementation, the lateral insertion point between sampling points is a point obtained after further fine-grained division of the distance between sampling points. This helps to subsequently confirm the specific location of the slopes of the three sides of the triangle between two sampling points, thereby determining the slope closest to the current side slope. It should be noted that the slopes of the sampling points and their insertion points are included in the farse sequence.

[0024] In one implementation, the slope is represented as the ratio of the original coordinate values, without reduction, retaining the original coordinate values. It should be noted that the same slope corresponds to multiple original coordinates.

[0025] In one embodiment, step S100, obtaining the lateral insertion point between the sampling points, includes:

[0026] S110, initialize the first slope.

[0027] In one embodiment, the first slope is 1 / 2, and other values ​​of the first slope also fall within the protection scope of this invention.

[0028] S120, starting from the first slope, perform a cyclic expansion to obtain the Fari sequence; wherein, set variable j, if the current slope is y f / x f When j=2, perform the following operations in a loop:

[0029] S121, when j < W × D, execute S22, where W is the pixel width and height of the screen, and D is the number of horizontal insertion points between two sampling points; otherwise, end the loop and obtain the Fari sequence.

[0030] It should be noted that when j≥W×D, it will exceed the physical width of the screen, and the excess part is invalid. Therefore, it is used as the condition to end the loop.

[0031] S122, when y f ×j≤W×D, and x f When ×j≤W×D, y f ×j / x f ×j is inserted into the Fari sequence y f / x f The value of j is increased by 1.

[0032] The fari sequence obtained through S110-S120 includes the slopes of the lines connecting the sampling points and the origin, as well as the slopes of the lines connecting the horizontal insertion points and the origin. In other words, the fari sequence pre-stores the slopes of the lines connecting all sampling points and their horizontal insertion points on the screen to the origin. When a side of a triangle is translated to the origin, the smaller the difference between the slope of the line connecting an insertion point to the origin and the slope of the current side, the closer the horizontal distance between the insertion point and the current side. Based on this, the position of the slope of the current side in the fari sequence can be obtained by searching the fari sequence, and then the constraint of the horizontal and vertical coordinates of the current side can be used to determine whether the corresponding sampling point is covered. Therefore, this fari sequence can be used as the basis for determining whether a pixel is covered during triangle rasterization. The search complexity is log2U, where U is the length of the fari sequence, reducing the computational complexity.

[0033] It should be noted that for all triangles on the screen, the same fari sequence is queried, and it is not necessary to rebuild the fari sequence each time.

[0034] S200, translate the three sides of the triangle to the origin. When the ordinate of the translated endpoint is greater than its abscissa, swap the values ​​of the ordinate and abscissa to obtain the actual slope of each side; where the slope k of the i-th side is... i Satisfying k i =y i / x i , where y i Let x be the ordinate of the endpoint of the i-th edge furthest from the origin. i Let x be the x-coordinate of the endpoint of the i-th edge that is furthest from the origin.

[0035] In this process, for each translated edge, one endpoint is moved to the origin, and the coordinates of the other endpoint after translation determine the slope of the current edge. It should be noted that when the angle between a side of the triangle and the horizontal axis is not equal to 90 degrees, the absolute values ​​of the slopes before and after the translation are the same.

[0036] It should be noted that a triangle has three sides: the left side, the right side, and the bottom side. The slope of the left side is greater than 0, the slope of the right side is less than 0, and the bottom side can be either a left or right side. Therefore, for a side with a slope less than 0, it needs to be translated to the origin first, and then reversed symmetrically about the y-coordinate to become a side with a slope greater than 0. It should also be noted that the distance between the side before and after the translation and the nearest point it covers is the same.

[0037] Swapping the values ​​of the x and y coordinates allows the slope to be a proper fraction, simplifying calculations and facilitating data storage and retrieval.

[0038] In one embodiment, the decimal part of the endpoint coordinates is represented by L fixed-point numbers, where L = log₂D. D is the number of lateral insertion points between two sampling points. In one embodiment, D = 256. Other values ​​of D also fall within the scope of protection of this invention.

[0039] S300, find the target slope corresponding to the actual slope of each edge in each row in the Fari sequence, K≥1; and obtain the coverage point of the current edge in each row according to each target slope and the translation distance of the current edge; use the candidate slope of each coverage point as the starting point to search for the slope in the Fari sequence in order, and obtain the candidate slope with a numerator less than or equal to the candidate slope numerator.

[0040] The Fari sequence includes the slopes of all sampling points and the lines connecting their lateral insertion points to the origin. Therefore, the actual slope corresponds to multiple target slopes. For the ordinate of each row of sampling points, the actual slope corresponds to a target slope for each row.

[0041] In one implementation, S300 further includes a step for finding the target slope, wherein k i The steps for finding the target slope include: S310, based on the k i Search the Fari sequence, and for each slope found, compare it with k. i Comparison, when the k i Satisfy: k i =y f / x f At that time, the k i The target slope is y f / x f When the k i Satisfy: y f / x f <k i <y f / (x f When +1 / D), the k i The target slope is y f / (x f +1 / D).

[0042] In one implementation, after finding the target slope, the x-coordinate of the target slope and the lateral translation distance can be compared to determine the points covered by the current edge. Specifically, in S300, the coverage points of the current edge in each row satisfy the following conditions: when d > dd, the next sampling point is determined as the coverage point closest to the current edge; where d is the lateral translation distance of the current edge, and dd is the lateral distance between the insertion point corresponding to the target slope and the current sampling point; when d ≤ dd, the current sampling point is the coverage point closest to the current edge.

[0043] In one implementation, S300 further includes, when k i The target slope is y f / x f When the i-th edge covers the point T(x) in row t. t ,y t The step of obtaining the candidate slope includes: S330, starting from the candidate slope of the coverage point T, sequentially searching for the slope in the Faris sequence, if the numerator of the slope is less than or equal to y t If the slope is found to be the closest to the i-th edge, then save it as a candidate slope; otherwise, skip and check the next slope; until the slope closest to the i-th edge is found. t One alternative slope.

[0044] It's important to note that the slope is expressed as the ratio of the original coordinate values, not a simplified fraction. Therefore, the numerator of the slope is actually the ordinate of the current discrete position, and the denominator is the abscissa. The discrete positions corresponding to the selected alternative slopes are actually points with ordinates smaller than the current discrete position.

[0045] S400, determine the horizontal coordinate range based on the discrete position points of all candidate slopes corresponding to each side, and select slopes with the same numerator and denominator belonging to the horizontal coordinate range from all candidate slopes. The discrete position points corresponding to the slopes selected from all three sides are the pixel points covered by the triangle.

[0046] It should be noted that the candidate slopes are slopes that have already been filtered for the vertical coordinate. Then, the horizontal coordinate is filtered according to the range of the horizontal coordinate, so that the pixels covered by the triangle can be selected.

[0047] In summary, this invention provides a method for determining the coverage points of a rasterized triangle. This method involves translating each of the three sides of the triangle to the origin, then querying the target slope of each side in the normal sequence. Based on the target slope, the normal sequence is searched again to obtain multiple candidate slopes. These candidate slopes are then used to determine all pixels covered by the triangle. This method primarily determines candidate slopes by querying the normal sequence, significantly reducing the query complexity compared to the first and second rasterization methods.

[0048] Embodiments of the present invention also provide a non-transitory computer-readable storage medium that can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a method in the method embodiments, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiments.

[0049] Embodiments of the present invention also provide an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0050] Embodiments of the present invention also provide a computer program product including program code, which, when the program product is run on an electronic device, causes the electronic device to perform the steps of the methods described above in various exemplary embodiments of the present invention.

[0051] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0052] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of this invention is defined by the appended claims.

Claims

1. A method of determining rasterized triangle coverage, the method comprising: The method includes the following steps: S100, Obtain the farse sequence, wherein the elements in the farse sequence are the slopes of the lines connecting discrete position points on the screen to the origin, and the slopes in the farse sequence are proper fractions arranged in ascending or descending order, wherein the discrete position points are sampling points of pixels on the screen or horizontal insertion points between sampling points. S200, translate the three sides of the triangle to the origin. When the ordinate of the translated endpoint is greater than its abscissa, swap the values ​​of the ordinate and abscissa to obtain the actual slope of each side; where the slope k of the i-th side is... i Satisfying k i =y i / x i , where y i Let x be the ordinate of the endpoint of the i-th edge furthest from the origin. i Let x be the x-coordinate of the endpoint of the i-th edge that is furthest from the origin; S300, find the target slope corresponding to the actual slope of each edge in each row in the Fari sequence, K≥1; and obtain the coverage point of the current edge in each row according to each target slope and the translation distance of the current edge; use the candidate slope of each coverage point as the starting point to search the slope in the Fari sequence in order to obtain the candidate slope numerator less than or equal to the candidate slope numerator; S400, determine the horizontal coordinate range based on the discrete position points of all candidate slopes corresponding to each side, and select slopes with the same numerator and denominator belonging to the horizontal coordinate range from all candidate slopes. The discrete position points corresponding to the slopes selected from all three sides are the pixel points covered by the triangle.

2. The method of claim 1, wherein, In S100, the step of obtaining the lateral insertion point between the sampling points includes: S110, initialize the first slope; S120, cyclically expanding from the first slope as a starting point to obtain the Farey sequence; wherein a variable j is set, and if the current slope is y f / x f then, starting from j=2, the following operations are cyclically executed: S121, when j < W × D, execute S22, where W is the pixel width and height of the screen, and D is the number of horizontal insertion points between two sampling points; otherwise, end the loop and obtain the Fari sequence. S122, when y f ×j≤W×D, and x f When ×j≤W×D, y f ×j / x f ×j is inserted into the Fari sequence y f / x f The value of j is increased by 1.

3. The method of claim 1, wherein, S300 also includes a step for finding the target slope, where k i The steps for finding the target slope include: S310, according to the k i Search the Fari sequence, and for each slope found, compare it with k. i Comparison, when the k i Satisfy: k i =y f / x f At that time, the k i The target slope is y f / x f When the k i Satisfy: y f / x f <k i <y f / (x f When +1 / D), the k i The target slope is y f / (x f +1 / D).

4. The method of claim 1, wherein, In S300, the points covered by the current edge in each row satisfy the following: When d > dd, the next sampling point is determined to be the coverage point closest to the current edge; where d is the lateral translation distance of the current edge, and dd is the lateral distance between the insertion point corresponding to the target slope and the current sampling point; When d ≤ dd, the current sampling point is the coverage point closest to the current edge.

5. The method of claim 1, wherein, The S300 also includes, when k i The target slope is y f / x f When the i-th edge covers the point T(x) in row t. t ,y t The steps for obtaining the alternative slopes include: S330, starting from the candidate slope of the coverage point T, sequentially search for the slope in the Faris sequence. If the numerator of the slope is less than or equal to y... t If the slope is found to be the closest to the i-th edge, then save the slope as a candidate slope; otherwise, skip and check the next slope; until the slope closest to the i-th edge is found. t One alternative slope.

6. The method of claim 2, wherein, The fractional part of the endpoint coordinates described in S200 is represented by an L-digit fixed-point number, where L = log2D.

7. The method of claim 1, wherein, The slope is expressed as the ratio of the original values ​​of the coordinate points.

8. The method of claim 1, wherein, The sampling point is either the center point of the pixel or a vertex of the pixel.

9. A non-transitory computer-readable storage medium, wherein the storage medium stores at least one instruction or at least one program segment, characterized in that, The at least one instruction or the at least one program segment is loaded and executed by the processor to implement the method as described in any one of claims 1-8.

10. An electronic device, comprising: Includes a processor and the non-transitory computer-readable storage medium as described in claim 9.

Citation Information

Patent Citations

  • Clipping method and clipping module with effective area and multiplex function in embedded GPU (Graphics Processing Unit)

    CN103400338A

  • GPU acceleration method and system for electrically large target radar imaging

    CN111562976A