Rasterization method and device, processor, equipment, storage medium and program product
By dividing the tiles and determining the target sub-tiles, only some pixels covered by the primitives are judged, which solves the problem of high consumption of rasterization resources in the prior art, and realizes a more efficient rasterization process.
Patent Information
- Application Number
- CN202411975846.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-30
AI Technical Summary
In the rasterization process, the prior art requires the primitive overlay judgment of all pixel points in the entire tile, resulting in large resource consumption and heavy workload.
By dividing the tiles, at least one sub-tile is determined, and the target sub-tile is determined in the sub-tile. The target sub-tile is at least partially covered by the primitives, and only the pixel points covered by the primitives in the target sub-tile are judged.
The workload and resource consumption of pixel coverage judgment in the tile is reduced, and the efficiency of rasterization is improved.
Smart Images

Figure CN119784872A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a rasterization method, apparatus, processor, device, storage medium and program product. Background Art
[0002] Rasterization is an important step in the implementation of graphics rendering technology. Rasterization includes: the processor performs primitive coverage judgment on the pixels in the screen space one by one based on the primitives projected to the screen space, and obtains the pixels covered by the primitives. In related technologies, the processor divides the entire screen space into several blocks, obtains the primitives in each block respectively, and obtains the pixels covered by the primitives by performing primitive coverage judgment on each pixel in the block.
[0003] However, in the related art, no matter how many pixels of a tile a primitive covers, it is necessary to perform primitive coverage judgment on all pixels of the tile, resulting in high resource consumption for rasterization and high workload for the processor to implement rasterization.
[0004] Therefore, how to reduce the resource consumption of rasterization has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, embodiments of the present application provide at least a rasterization method, apparatus, processor, device, storage medium, and program product.
[0006] The technical solution of the embodiment of the present application is implemented as follows:
[0007] On the one hand, an embodiment of the present application provides a rasterization method, which is applied to a graphics processor. The graphics processor performs a rasterization process based on a tile rendering architecture. The rasterization method includes: dividing the tile to determine at least one sub-tile; determining at least one target sub-tile in at least one sub-tile; the target sub-tile is at least partially covered by a primitive; the primitive is a primitive projected onto the tile; determining a target pixel point covered by the primitive in at least one target sub-tile to obtain a pixel point covered by the primitive in the tile.
[0008] On the other hand, an embodiment of the present application provides a rasterization device, which includes a division unit, a first determination unit, and a second determination unit, wherein: the division unit is used to divide a tile and determine at least one sub-tile; the first determination unit is used to determine at least one target sub-tile in at least one sub-tile; the target sub-tile is at least partially covered by a primitive, wherein the primitive is a primitive projected onto the tile; and the second determination unit is used to determine a target pixel point covered by the primitive in at least one target sub-tile to obtain a target pixel point covered by the primitive in the tile.
[0009] On the other hand, an embodiment of the present application provides a graphics processor, which includes the aforementioned rasterization device.
[0010] On the other hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in the aforementioned rasterization method are implemented.
[0011] On the other hand, an embodiment of the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the aforementioned rasterization method are implemented.
[0012] On the other hand, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in the aforementioned rasterization method.
[0013] In an embodiment of the present application, a tile is divided to determine at least one sub-tile, and a target sub-tile is determined in the sub-tile, the target sub-tile is at least partially covered by a primitive, and then a target pixel point covered by the primitive in at least one target sub-tile is determined to obtain the pixel points covered by the primitive in the tile. Compared with the technical solution in the related art that performs primitive coverage judgment on the pixel points in the tile one by one, the embodiment of the present application preliminarily judges whether the sub-tile is at least partially covered by the primitive, and there is no need to judge the pixel points of the sub-tile not covered by the primitive one by one, thereby reducing the workload and resource consumption of judging the pixel coverage in the tile.
[0014] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a partial schematic diagram of a graphic element projected onto a screen in the related art;
[0016] Figure 2 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 1 ;
[0017] Figure 3 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 2 ;
[0018] Figure 4 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 3 ;
[0019] Figure 5 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 4 ;
[0020] Figure 6 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 5 ;
[0021] Figure 7 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 6 ;
[0022] Figure 8 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 7 ;
[0023] Fig. 9 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 1
[0024] Fig.10 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 2 ;
[0025] Fig.11 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 3 ;
[0026] Fig.12 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 4 ;
[0027] Fig.13 Workflow of the rasterization method provided in the embodiment of the present application Figure 1 ;
[0028] Fig.14 for Fig.13 Schematic diagram of realizing coordinate transformation in the rasterization method;
[0029] Fig.15 for Fig.13 Schematic diagram of sub-tile coverage judgment in the rasterization method;
[0030] Fig.16 for Fig.13 Schematic diagram of the target sub-tile in the rasterization method;
[0031] Fig.17 for Fig.13 Schematic diagram of all pixels covered by triangle primitives in the rasterization method;
[0032] Fig.18 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0034] It should be understood that the "embodiments of the present application" or "the aforementioned embodiments" mentioned throughout the specification mean that specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, "in the embodiments of the present application" or "in the aforementioned embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0035] Figure 1 FIG. 1 is a partial schematic diagram of a graphic element projected onto a screen in the related art. Figure 1 As shown, the screen includes multiple pixel points p, which divide the screen into several blocks. A coordinate system (x, y) is established globally on the screen to obtain a triangle primitive projected on the block m. The three sides of the triangle are the first side L0, the second side L1 and the third side L2. The coordinates of the upper left corner pixel of the block m are (a, b).
[0036] When the triangle primitive is projected onto the screen, the processor obtains the vertex coordinates of the three vertices of the triangle primitive, and obtains the edge equation of the first side L0 as A0*x+B0*y+C0=0 based on the three vertex coordinates; the edge equation of the second side L1 is A1*x+B1*y+C1=0; and the edge equation of the third side L2 is A2*x+B2*y+C2=0. For a pixel point p with pixel coordinates (x0, y0), substitute p(x0, y0) into the edge equation of the first side L0 as A0*x+B0*y+C0=0, and obtain the algebraic expression A0*x0+B0*y0+C0; substitute p(x0, y0) into the edge equation of the second side L1 as A1*x+B1*y+C1=0, and obtain the algebraic expression A1*x0+B1*y0+C1; substitute p(x0, y0) into the edge equation of the second side L1 as A1*x+B1*y+C1=0, and obtain the algebraic expression A1*x0+B1*y0+C1; substitute p(x0, y0) into the edge equation of the third side L2 as A2*x+B2*y+C2=0. 0) Substitute A2*x+B2*y+C2=0 into the edge equation of the third edge L2, and obtain the algebraic formula A2*x0+B2*y0+C2; if the value of A0*x0+B0*y0+C0 is greater than 0, the value of A1*x0+B1*y0+C1 is greater than>0 and the value of A2*x0+B2*y0+C2 is greater than>0, then the pixel point p with pixel coordinates (x0, y0) is covered by the triangle primitive.
[0037] Therefore, the processor performs primitive coverage judgment on each pixel point p in the image block m, and then obtains the target pixel point covered by the primitive and the coordinates of the target pixel point.
[0038] For a 16 kilobyte (Kb)*16Kb screen, when the processor performs primitive coverage judgment at a speed of 16 pixels / beat and each pixel coordinate requires 14 bits to represent, the processor performs primitive coverage judgment on the pixels. For a pixel, the pixel coordinates are substituted into the three edge equations of the primitive respectively. The value of the algebraic expression obtained by substituting the three edge equations is used to obtain whether the pixel is covered by the primitive. An algebraic expression includes the product of the pixel point x coordinate and the x coefficient in the edge equation, the product of the pixel point y coordinate and the y coefficient in the edge equation, and the constant term in the edge equation. The bit width of the pixel point x coordinate is 14 bits (bit), the bit width of the x coefficient in the edge equation is W(A0), and the pixel point y coordinate is W(A1). The bit width is 14 bits, the bit width of the coefficient of y in the edge equation is W(B0), and the bit width of the constant term in the edge equation is W(C0). Therefore, the computing resources required for one expression are W(A0)*14+W(B0)*14+W(C0), and substituting one pixel into the three edge equations will result in three algebraic expressions. The computing resources consumed for primitive coverage judgment on one pixel are 3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 3. Therefore, it can be inferred that when the primitive coverage judgment of 16 pixels is completed in one shot, the computing resources consumed in one shot are 16*3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 48 times.
[0039] It can be understood that one beat represents one clock cycle.
[0040] Obviously, no matter what percentage of pixel points p of tile m are covered by the triangle primitive, primitive coverage judgment needs to be performed on all pixel points p of tile m, resulting in high resource consumption for rasterization and high workload for the processor to implement rasterization.
[0041] Therefore, how to reduce the resource consumption of rasterization has become an urgent problem to be solved.
[0042] In view of the above problems, an embodiment of the present application proposes a rasterization method applied to a graphics processor.
[0043] In some embodiments, the graphics processor performs a rasterization process based on a tile rendering architecture. In a tile rendering architecture (Tile Based rendering, TBR), the screen space to be rendered is divided into tiles, and the coordinates of each tile are saved in the system memory in a list form through an intermediate cache. When rendering, each tile is transferred into the on-chip memory of the graphics processor (Graphic Processing Unit, GPU) one by one, and the data required for rendering can be obtained from the on-chip memory, thereby avoiding slow interactive processing with the system memory. After each tile is rendered, its result will be output to the corresponding area in the frame buffer of the system memory. After all tiles are rendered, the data on the frame buffer is the data of the entire screen that needs to be displayed.
[0044] Figure 2 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 1 In the embodiment of the present application, the rasterization method at least includes step S201 to step S203.
[0045] Step S201: divide the image block to determine at least one sub-image block.
[0046] Here, the tiles are located in the screen space, and the screen space includes a plurality of tiles distributed in an array.
[0047] The size of the sub-tile can be determined according to the actual situation compared to the size of the tile. In some embodiments, the size of the sub-tile can be preset, and in the rasterization process, the sub-tile is always divided according to the preset size. In some other embodiments, the size of the sub-tile can be adjusted according to the size of the rasterized object, that is, the size of the primitive, wherein the sizes of multiple sub-tiles can be preset, and the size of the sub-tile can be flexibly adjusted in the rasterization process.
[0048] Exemplarily, if the block size is 32*32 pixels and the preset sub-block size is 4*4 pixels, then during the rasterization process, the 32*32 pixel block is always divided into 4*4 pixel sub-blocks.
[0049] Another example is that if the block size is 32*32 pixels, the preset sub-block sizes include a first size of 4*4 pixels; a second size of 5*5 pixels; and a third size of 8*8 pixels. When the primitive size is large, the block is divided into sub-blocks of the first size; when the primitive is generally large, the block is divided into sub-blocks of the second size; when the primitive is small, the block is divided into sub-blocks of the third size. It should be noted that the above examples are only illustrative of the implementation method of step S201 and do not constitute a limitation on the sub-block size. The sub-block size can also be 3*3 pixels, 7*7 pixels or other values, and the present application does not make any specific restrictions on this.
[0050] In some embodiments, the image block may be divided to determine a sub-image block, where the sub-image block may be the original image block itself, or may be a sub-image block obtained by cropping the original image block, where the size of the sub-image block is smaller than the size of the original image block. In other embodiments, the image block may be divided to obtain at least two sub-image blocks, where there is no overlapping portion between at least two sub-image blocks, and the size of the sub-image block is smaller than the size of the original image block.
[0051] Step S202: determining at least one target sub-block in at least one sub-block; the target sub-block is at least partially covered by a primitive; and the primitive is a primitive projected onto the block.
[0052] Here, the target sub-image block being at least partially covered by the primitive means that some pixels of the target sub-image block are located in the primitive; or, all pixels of the target sub-image block are located in the image block.
[0053] In some embodiments, determining at least one target sub-block in at least one sub-block can be achieved by: acquiring vertex information of a primitive, which can represent the coverage area of the primitive; on the other hand, determining coordinate information of each sub-block; correspondingly, comparing the coordinate information of the sub-block with the vertex information, and when the comparison result represents that the primitive covers at least one pixel of the sub-block, determining the sub-block as the target sub-block, and continuing to compare with the next sub-block.
[0054] Exemplarily, if the vertex information of the primitive includes (37, 38), (60, 44) and (43, 60), accordingly, the coverage area represented by it is the area with a horizontal coordinate value greater than or equal to 37 and less than or equal to 60, and a vertical coordinate value greater than or equal to 38 and less than or equal to 60, that is, the area with 37≤horizontal coordinate≥60 and 38≤vertical coordinate≥60; the block is divided into 64 sub-blocks of 4*4 pixels, wherein the coordinate information of one sub-block is a horizontal coordinate value greater than or equal to 32 and less than or equal to 35, and a vertical coordinate value greater than or equal to 32 and less than or equal to 35, that is, 32≤horizontal coordinate≥35 and 32≤vertical coordinate≥35; the coordinate information of another sub-block is a horizontal coordinate value greater than or equal to 45 and less than or equal to 48, and a vertical coordinate value greater than or equal to 45 and less than or equal to 48, that is, 45≤horizontal coordinate≥48 and 45≤vertical coordinate≥48.
[0055] Then, for the previous sub-block, since 32≤ horizontal coordinate ≥35 and 37≤ horizontal coordinate ≥60 have no overlap, and 32≤ vertical coordinate ≥35 and 38≤ vertical coordinate ≥60 have no overlap, it can be concluded that the previous sub-block is not the target sub-block. For another sub-block, since 45≤ horizontal coordinate ≥48 and 37≤ horizontal coordinate ≥60 have overlap, and 45≤ vertical coordinate ≥48 and 38≤ vertical coordinate ≥60 have overlap, it can be concluded that the primitive covers at least one pixel of the sub-block, and the sub-block is determined as the target sub-block. Accordingly, this method is used to determine whether each sub-block in the block is a target sub-block. In other words, this judgment method is to compare the horizontal coordinate range of the sub-block with the horizontal coordinate range of the primitive, and compare the vertical coordinate range of the sub-block with the vertical coordinate range of the primitive. If there is overlap in both the horizontal and vertical coordinate ranges, the sub-block is the target sub-block.
[0056] In some other embodiments, determining at least one target sub-block in at least one sub-block may be achieved in the following manner: based on the vertices of the primitives, judging by the right-hand rule whether there are pixel points at the edge position covered by the primitives in the sub-block, and in the case where there are pixel points at the edge position covered by the primitives, determining the sub-block as the target sub-block, and so on, determining whether the next sub-block is the target sub-block. It is understandable that the judgment result of the pixel points at the edge position, that is, whether it is a pixel point covered by the primitive, can be stored in the rasterization device, so that for the block determined as the target sub-block, the pixel points at the edge position that have obtained the judgment result do not need to be judged again.
[0057] Among them, the right-hand rule means: determine the two vertices of the primitive as the starting point and the end point in the clockwise direction, use the right hand, and keep the direction of the palm pointing to the fingertips consistent with the direction of the starting point to the end point; then use the palm to hold the position of the pixel point, and the direction pointed by the thumb is the comparison result. According to this method, at least one comparison result of the pixel point is obtained. If at least one comparison result points to the inside of the screen, the pixel point is covered by the primitive. It should be noted that the implementation method in this embodiment is used to illustrate the implementation principle. In the process of implementing the method, the judgment is realized by the program code corresponding to the principle.
[0058] For example, if the vertex information of the primitive includes points A, B, and C in clockwise order, the block is divided into 64 sub-blocks of 4*4 pixels, where the pixel points at the edge of a sub-block include pixel points a1, a2, a3, ..., a 12 .
[0059] Then, in the process of determining whether the sub-block is the target sub-block, the judgment process for pixel a1 is as follows: first, taking point A as the starting point and point B as the end point, keep the direction of the right palm pointing to the fingertips consistent with the direction of point A pointing to point B, and hold the right hand toward the position of pixel a1. The comparison result is that it extends into the screen; then, taking point B as the starting point and point C as the end point, keep the direction of the right palm pointing to the fingertips consistent with the direction of point B pointing to point C, and hold the right hand toward the position of pixel a1. The comparison result is that it extends into the screen; finally, taking point C as the starting point and point A as the end point, keep the direction of the right palm pointing to the fingertips consistent with the direction of point C pointing to point A, and hold the right hand toward the position of pixel a1. The comparison result is that it extends into the screen. Therefore, it can be concluded that pixel a1 is covered by the primitive, and therefore, the sub-block is determined as the target sub-block.
[0060] The above-mentioned primitives are primitives projected onto the tile. That is, for other primitives that are not projected onto the current tile, it is not necessary to perform the determination of the target sub-tile for the other primitives, thereby reducing computing resources. Here, the process of determining whether a primitive is projected onto a tile can be performed by other functional modules in the graphics processing pipeline.
[0061] Step S203: determine the target pixel points covered by the primitive in at least one target sub-block to obtain the pixel points covered by the primitive in the block.
[0062] Here, the coverage in the target pixel covered by the primitive means: even if the pixel has an area in the actual structure, since its area is equivalent to a point compared to the entire display screen, the pixel is used as the smallest unit in the rasterization process. Therefore, in the judgment process of whether the pixel is covered by the primitive, the pixel is judged as a point, regardless of its area. In an embodiment of the present application, for a pixel, the pixel position is represented by its corner position or center position. Accordingly, when a pixel position falls within the primitive area, the pixel is covered by the primitive, that is, the target pixel. Among them, the target pixel of each target sub-block in the block is determined, and the target pixel is summarized, that is, the pixel covered by the primitive in the block is obtained.
[0063] In some embodiments, determining the target pixel covered by the primitive in at least one target sub-block can be achieved by: judging the pixels in the target sub-block one by one, and determining whether each pixel is a target pixel. The implementation method of determining whether each pixel is a target pixel can refer to the implementation method of "determining whether there is a pixel at an edge position covered by the primitive in the sub-block by the right-hand rule" in step S202. The implementation method of determining whether each pixel is a target pixel can also be: determining the coordinates of each pixel and the vertex coordinates of the primitive, judging whether the coordinates of the pixel fall within the area surrounded by the vertex coordinates, and determining that the pixel is a target pixel when the coordinates of the pixel fall within the area surrounded by the vertex coordinates.
[0064] Exemplarily, the coordinates of a pixel point of the target sub-block are (m, n), and the vertex coordinates of the primitives include (p1, q1), (p2, q2), and (p3, q3). If m≥the minimum value among p1, p2, and p3, and m≤the maximum value among p1, p2, and p3, then the pixel point with the coordinates (m, n) is covered by the primitive, that is, it is the target pixel point of the target sub-block.
[0065] In an embodiment of the present application, a tile is divided to determine at least one sub-tile, and a target sub-tile is determined in the sub-tile, the target sub-tile is at least partially covered by a primitive, and then a target pixel covered by the primitive in at least one target sub-tile is determined to obtain the pixel covered by the primitive in the tile. Compared with the technical solution in the related art that performs primitive coverage judgment on the pixel points in the tile one by one, the embodiment of the present application preliminarily judges whether the sub-tile is at least partially covered by the primitive, and there is no need to judge the pixel points one by one for the sub-tile that is not covered by the primitive, thereby reducing the workload and resource consumption of judging the pixel coverage in the tile.
[0066] Figure 3 A schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application Figure 2 .like Figure 3 As shown, based on Figure 2 , step S202 of the rasterization method in the embodiment of the present application may at least include step S301 and step S302.
[0067] Step S301, determining a judgment result of each sub-block based on first region information of each sub-block and second region information of the primitive, wherein the first region information is used to characterize a region range of the sub-block, and the second region information is used to characterize a region range of the primitive.
[0068] In some embodiments, the first region information may include the first position information of each pixel of the sub-image block, and the second region information may include the second position information of the image element coverage area. Accordingly, it is determined whether the first position information of each pixel falls within the second position information one by one. If there is first position information falling within the second position information, the judgment result is yes; otherwise, the judgment result is no. It can be understood that in the process of determining the first position information of the pixel points one by one, as long as a first position information falling within the second position information is obtained, the judgment result of the sub-image block corresponding to the first position information is yes, and the judgment result of the next sub-image block is determined.
[0069] In an embodiment of the present application, the above-mentioned judgment method of "whether the first position information of each pixel point falls within the second position information" can refer to the implementation method of "using the right-hand rule to determine whether there are pixel points at the edge position covered by the primitive in the sub-block" in the above-mentioned step S202.
[0070] In other embodiments of the present application, the first region information includes the coordinates of the corner points of the sub-block, and the second region information includes at least one edge equation of the primitive, and step S301 can be implemented through steps S303 and S304.
[0071] Step S303: Based on each edge equation and the coordinates of the corner point corresponding to the edge equation, determine the result value corresponding to each edge equation, and the corner point corresponding to the edge equation is the corner point closest to the edge equation.
[0072] Here, the edge equation refers to the equation of the line where the edge of the primitive is located. The edge equation can be determined by the vertex coordinates of the primitive. For example, if the vertex coordinates of the primitive are (1, 2), (5, 8) and (4, 6), then the edge equation can be 1.5x-y+0.5=0 based on (1, 2) and (5, 8); the edge equation can be 2x-y-2=0 based on (5, 8) and (4, 6); and the edge equation can be 4x-3y+2=0 based on (1, 2) and (4, 6).
[0073] Among them, the corner point refers to the pixel point of the sub-block.
[0074] The result value corresponding to each edge equation is the result value obtained by substituting the corner point corresponding to the edge equation into the algebraic expression on the left side of the edge equation. For example, the coordinates of the corner point corresponding to the edge equation 3x-3y+2=0 are (2, 1), so the result value corresponding to the edge equation is the result value of substituting (2, 1) into 3x-3y+2, which is 5.
[0075] Here, the corner point corresponding to the edge equation is the corner point closest to the edge equation, and the "distance" means the corner point closest to the edge equation in the direction of the edge equation.
[0076] like Figure 4 FIG. 1 is a schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application. Figure 3 In the embodiment of the present application, before step S303, the rasterization method further includes step S401.
[0077] Step S401: Determine the corner points corresponding to the edge equation based on the equation coefficients of the edge equation and the coordinates of each corner point in the sub-block.
[0078] Here, the equation coefficient refers to the coefficient of each term. For example, if the edge equation is 3x-2y+1=0, then the equation coefficient includes the x-term coefficient 3 and the y-term coefficient -2.
[0079] Each edge equation of the primitive is provided with a direction, that is, it includes a positive direction and a negative direction. By sequentially connecting the rays determined by the edge equations end to end, a closed figure can be obtained. It can be understood that the closed figure is similar to the primitive, that is, the same in shape but not necessarily in size.
[0080] In an embodiment of the present application, first, the slope of the edge equation is determined based on the equation coefficients of the edge equation. When the slope of the edge equation is a non-negative value, the edge equation is in a positive direction; when the slope of the edge equation is a negative value, the edge equation is in a negative direction. Secondly, based on the coordinates of the corner points of the sub-block, the distance value of the corner point from the straight line where the edge equation is located is obtained. Thirdly, based on the direction of the edge equation and the distance value of the corner point, the corner point corresponding to the edge equation is obtained. When the edge equation is in a positive direction, the corner point corresponding to the minimum distance value is determined as the corner point corresponding to the edge equation; when the edge equation is in a negative direction, the corner point corresponding to the maximum distance value is determined as the corner point corresponding to the edge equation.
[0081] In some embodiments, the corner points corresponding to the edge equation are determined based on the equation coefficients of the edge equation and the coordinates of some corner points in the sub-block, where the some corner points may be corner points at the edge of the sub-block or at the four corners of the sub-block.
[0082] It should be noted that the corner points of the four corners of the sub-block refer to the pixel points at the four corners of the sub-block. For example, a sub-block of 4*4 pixels includes 16 pixel coordinates, namely: (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4), then the coordinates of the four corner points of the sub-block are the pixel points corresponding to (1, 1), (1, 4), (4, 1) and (4, 4).
[0083] Take the aforementioned partial corner points as the corner points of the four corners of the sub-block, the equation of one side of the primitive is 2x-y-2=0, and the coordinates of the four corner points of the sub-block are (1,1), (1,4), (4,1) and (4,4) as an example. First, based on the x-term coefficient being 2 and the y-term coefficient being -1, the slope of the edge equation is determined to be 2, and the edge equation is determined to be in the positive direction. Secondly, the distance value from the corner point coordinate (1,1) to the straight line where 2x-y-2=0 is determined to be Determine the distance from the corner point coordinates (1, 4) to the straight line where 2x-y-2=0 is Determine the distance from the corner point coordinate (4, 1) to the straight line where 2x-y-2=0 is Determine the distance from the corner point coordinate (4, 4) to the straight line where 2x-y-2=0 is Again, based on the positive direction of the edge equation, determine the minimum distance value The corresponding corner point (1, 1) is the corner point corresponding to the edge equation 2x-y-2=0.
[0084] Step S304: Determine the judgment result of the sub-block based on the result value corresponding to each side equation.
[0085] Here, for a sub-block, if the result value corresponding to each side equation is greater than 0, the judgment result of the sub-block is yes; otherwise, the judgment result is no.
[0086] In an embodiment of the present application, based on the coordinates of each edge equation and the corner point corresponding to the edge equation, the result value corresponding to each edge equation is determined, and the corner point corresponding to the edge equation is the corner point closest to the edge equation; based on the result value corresponding to each edge equation, the judgment result of the sub-block is determined, and by comparing the positional relationship between the corner point closest to the edge equation and the edge equation, the workload and computing resources of comparing other corner points of the sub-block with the edge equation are eliminated. Based on the positional relationship between each edge equation and the corresponding corner point, it is obtained whether the sub-block is at least partially covered by the primitive, which reduces the workload of determining the target sub-block in the sub-block and improves the efficiency of determining the pixels covered by the primitives in the block. Accordingly, as the number of positional relationships between the corner points and the edge equations that need to be judged decreases, resource loss is also reduced, thereby reducing the cost of rasterization.
[0087] Step S302: Determine a sub-image block whose judgment result indicates that the sub-image block at least partially overlaps with the image primitive as a target sub-image block.
[0088] Here, if the judgment result is yes, the representation sub-image block and the primitive at least partially overlap, and the sub-image block is determined as the target sub-image block. If the judgment result is no, the representation sub-image block and the primitive do not partially overlap.
[0089] In an embodiment of the present application, a judgment result of each sub-block is determined based on first area information of each sub-block and second area information of the primitive, wherein the first area information is used to characterize the area range of the sub-block, and the second area information is used to characterize the area range of the primitive; a sub-block whose judgment result characterizes that the sub-block and the primitive are at least partially overlapped is determined as a target sub-block, and by determining the area range of the sub-block and the area range of the primitive, it is determined whether the two are at least partially overlapped, thereby reducing resource consumption and workload for performing primitive coverage judgment on each pixel point of the uncovered sub-block, the operation is simple, the workload and computing resources required are less, and the efficiency of determining the pixel points covered by the primitive in the block is improved.
[0090] like Figure 5 FIG. 1 is a schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application. Figure 4 In the embodiment of the present application, based on Figure 2 , step S203 at least includes steps S501 to S503.
[0091] Step S501: Determine at least one judgment reference value corresponding to a primitive of a target sub-block.
[0092] Here, the judgment reference value is used as a reference value for judging the positional relationship between the pixel point and the edge of the primitive. The number of the judgment reference values may be equal to the number of the edges of the primitive. In other words, a judgment reference value is set for each edge of the primitive.
[0093] In some embodiments, the judgment reference values of multiple target sub-blocks corresponding to an edge of a primitive may be the same or may be set separately, and this application does not impose any specific limitation on this.
[0094] Exemplarily, if a block includes a first sub-block and a second sub-block, then it can be determined that the first sub-block and the second sub-block have the same reference value corresponding to the first edge as s1. Another exemplary example is that the first sub-block has the same reference value corresponding to the first edge as s2, and the second sub-block has the same reference value corresponding to the first edge as s1. 3。
[0095] Step S502: Based on the judgment reference value of the target sub-block, at least one judgment value corresponding to each pixel of the image primitive is obtained.
[0096] Here, the judgment value is used to characterize the positional relationship between the pixel point and the edge of the primitive.
[0097] For a target sub-image block, the number of the judgment reference values is the same as the number of the judgment values corresponding to each pixel point of the image primitive.
[0098] Exemplarily, if a block includes a first sub-block, the first sub-block includes a pixel point p1, the primitive includes a first side, a second side, and a third side, the first sub-block has a reference value s1 for the first side, a reference value s2 for the second side, and a reference value s3 for the third side. Then, based on the reference value s1, the reference value s1' of the pixel point p1 corresponding to the first side is obtained; based on the reference value s2, the reference value s2' of the pixel point p1 corresponding to the second side is obtained; based on the reference value s3, the reference value s3' of the pixel point p1 corresponding to the third side is obtained.
[0099] Step S503: Determine a pixel point whose at least one judgment value represents a pixel point located in the primitive as a target pixel point of the target sub-image block.
[0100] Here, when at least one judgment value is greater than 0, the representation pixel point is located in the primitive, and the pixel point is determined as the target pixel point of the target sub-block; when at least one judgment value is less than or equal to 0, the representation pixel point is not located in the primitive.
[0101] Exemplarily, if a target sub-block contains a pixel point, and at least one judgment value of the pixel point includes s1', s2' and s3', then, when s1', s2' and s3' are all greater than zero, at least one judgment value represents that the pixel point is located within the primitive, and the pixel point is determined as the target pixel point of the target sub-block.
[0102] In an embodiment of the present application, at least one judgment reference value of a target sub-block corresponding to a primitive is determined; based on the judgment reference value of the target sub-block, at least one judgment value of each pixel corresponding to the primitive is obtained; a pixel point represented by at least one judgment value and located within the primitive is determined as a target pixel point of the target sub-block. It is only necessary to determine the relationship of the pixel point with respect to the reference position corresponding to the judgment reference value, without determining the specific position of the pixel point, thereby reducing the resource consumption for representing the specific position of the pixel point. It can be understood that the length of data corresponding to the pixel point becomes shorter, and the reading workload is reduced, thereby improving the efficiency of rasterization.
[0103] like Figure 6 FIG. 1 is a schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application. Figure 5 .based on Figure 5 In the rasterization method of the embodiment of the present application, step S501 may at least include step S601 and step S602; step S502 may at least include step S603.
[0104] Step S601: Determine reference position information of a target sub-block.
[0105] Here, the reference position information indicates a reference position, which is used as reference information for determining the position of a pixel point in the target sub-block.
[0106] In an embodiment of the present application, the same reference position information can be determined for at least one target sub-block, or the reference position information can be set for each target sub-block separately; similarly, the reference position represented by the reference position information can be located within the target sub-block or outside the target sub-block, and the embodiment of the present application does not impose any specific restrictions on this.
[0107] Step S602: Determine at least one reference value for determining that the target sub-block corresponds to the primitive based on the reference position information and at least one piece of edge information of the primitive.
[0108] Here, the edge information indicates the position of the edge of the primitive.
[0109] The reference position information indicates a reference position, and the edge information indicates the position of the edge of the primitive. It can be understood that based on the reference position and the position of the edge, the relationship between the reference position and the position of the edge can be obtained. Accordingly, the relationship between the reference position and the position of the edge is used as the judgment reference value of the target sub-block.
[0110] Step S603: based on the position information and the judgment reference value of each pixel of the target sub-block, obtain at least one judgment value corresponding to the primitive of each pixel.
[0111] Here, the position information of each pixel is used to indicate the position difference of the pixel compared with the reference position.
[0112] The judgment reference value indicates the positional relationship between the reference position and the edge of the primitive. Then, by taking into account the positional difference between the pixel point and the reference position, the positional relationship between the pixel point and the edge of the primitive can be obtained. Correspondingly, the positional relationship between the pixel point and the edge of the primitive is indicated by the judgment value.
[0113] In some embodiments, the reference position information includes reference coordinates, the edge information includes edge equations, and the position information includes the offset of each pixel point coordinate from the reference coordinates. Step S602 can be implemented through step S604, and step S603 can be implemented through step S605.
[0114] Step S604: Substitute the reference coordinates into the edge equation to obtain a judgment reference value.
[0115] Here, the reference coordinates refer to the coordinates of a reference position.
[0116] Wherein, substituting into the edge equation means: when the edge equation is a two-term equation or a three-term equation, substituting into the algebraic expression on the left side of the edge equation. In other words, in the edge equation whose right side is equal to 0, substituting into the algebraic expression on the left side of the edge equation, it can be understood that any edge equation can be converted into an edge equation whose right side is equal to 0.
[0117] For example, if the reference coordinates are (2, 1) and the side equation is x-2y+1=0, then (2, 1) is substituted into x-2y+1 to obtain a judgment reference value of 1. If the reference coordinates are (2, 1) and the side equation is y+2=0, then (2, 1) is substituted into y+2 to obtain a judgment reference value of 3. If the reference coordinates are (2, 1) and the side equation is y=0.5x+0.5, then the side equation is converted to x-2y+1=0, and then (2, 1) is substituted into x-2y+1 to obtain a judgment reference value of 1.
[0118] Step S605: Based on the judgment reference value and each offset, obtain at least one judgment value corresponding to the edge equation of each pixel point.
[0119] Here, the offset can be obtained through the reference coordinates and the pixel coordinates.
[0120] Exemplarily, the horizontal coordinate of the reference coordinate is subtracted from the horizontal coordinate of the pixel point coordinate to obtain the sub-offset of the pixel point in the horizontal direction compared to the reference position; then the vertical coordinate of the reference coordinate is subtracted from the vertical coordinate of the pixel point coordinate to obtain the sub-offset of the pixel point in the vertical direction compared to the reference position.
[0121] Among them, obtaining the judgment value of each pixel corresponding to the edge equation means that the pixel is substituted into the non-constant term of the edge equation, the obtained value is summed with the judgment reference value, and the result of the sum is the judgment value of the pixel corresponding to the edge equation. In other words, the horizontal coordinate value of the pixel is substituted into the term corresponding to the horizontal coordinate of the edge equation, and the vertical coordinate value of the pixel is substituted into the term corresponding to the vertical coordinate of the edge equation, and the sum of the two substitution results is obtained, and the sum is summed with the judgment reference value, and the result of the sum is the judgment value of the pixel corresponding to the edge equation. It should be noted that the substituted edge equation is converted into a binomial equation or a trinomial equation.
[0122] Exemplarily, the offset of the pixel point in the horizontal coordinate direction compared to the reference position is 0.5, the offset of the pixel point in the vertical coordinate direction compared to the reference position is 0.5, the edge equation is x-2y+1=0, and the target sub-block corresponds to the judgment reference value 2 of the edge equation. Then, the offset of the pixel point in the horizontal coordinate direction compared to the reference position is 0.5, which is substituted into the x term, and the result is 0.5; the offset of the pixel point in the vertical coordinate direction compared to the reference position is 0.5, which is substituted into the -2y term, and the result is -1; the sum of the two substitution results is -0.5, and then the sum -0.5 is added to the judgment reference value 2, and the sum result 1.5 is the judgment value of the pixel point corresponding to the edge equation x-2y+1=0.
[0123] In an embodiment of the present application, the reference coordinates are substituted into the edge equation to obtain a judgment reference value; based on the judgment reference value and each offset, a judgment value of each pixel corresponding to the edge equation is obtained. The screen space contains 16Kb*16Kb pixels, a target sub-block includes 4*4 pixels, and the primitive is a triangle. For example, based on the previous explanation of the relevant technology, it is known that in the relevant technology, the computing resources consumed for primitive coverage judgment on 16 pixels are 16*3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 48 times; and in the technical solution of the embodiment of the present application, the computing resources required for coverage judgment on 16 pixels of a sub-block include The resources for judging whether it is the target sub-block, and the resources for making coverage judgments on the 16 pixels therein, the resources for judging whether it is the target sub-block are 3*[W(A0)*14+W(B0)*14+W(C0)], where "3" means obtaining the sub-result values corresponding to the 3 edge equations, and the resources for making coverage judgments on the 16 pixels therein are 16*3*[W(A0)+W(B0)], where "16*3" means obtaining the judgment values of the 16 pixels for the three edge equations. Since the coordinates of the pixel points will only affect the unknown terms of the edge equations, there is no need to consume the bit width corresponding to the constant term, i.e., the resources of W(C0). It can be seen that the technical solution of the embodiment of the present application reduces the consumption of computing resources. In addition, in the entire block, for the sub-block that is not covered by the primitive, the 48 calculations required for "making coverage judgments on its 16 pixels" are replaced by 3 calculations to judge whether it is the target sub-block, thereby reducing the workload of determining the covered pixels in the block.
[0124] like Figure 7 FIG. 1 is a schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application. Figure 6 .based on Figure 2 , step S203 at least includes step S701 and step S702.
[0125] Step S701: Substitute the coordinates of each pixel into at least one edge equation to obtain at least one judgment value.
[0126] Here, the above-mentioned substituting the coordinates of each pixel point into the edge equation can refer to the technical solution of "substituting the reference coordinates into the edge equation to obtain the judgment reference value" in the aforementioned step S604.
[0127] For example, the coordinates of a pixel point are (2, 3), and the equation of a side is x-2y+1=0. Then, substituting (2, 3) into x-2y+1, the judgment value is -3.
[0128] Step S702: When at least one judgment value indicates that the pixel is located within the primitive, the pixel is determined as a target pixel.
[0129] Here, the technical solution of step S702 may refer to the implementation of the aforementioned step S503.
[0130] In other embodiments of the present application, before step S201, the rasterization method also includes: when the vertex information of the primitive represents that part of the primitive exceeds the tile, obtaining the intersection information of the edge of the primitive and the tile; based on the vertex information and the intersection information, generating at least one sub-primitive for the part of the primitive located in the tile, and using the sub-primitive as the primitive.
[0131] Here, the vertex information of the primitive is used to indicate the position of the primitive vertex, so as to indicate the region range of the primitive. The intersection information indicates the intersection between the primitive and the block, and is used as the vertex of the sub-primitive.
[0132] In some embodiments, the vertex information of the primitive includes the vertex coordinates of the primitive, and the tile includes coordinate range data. The vertex coordinates of the primitive are compared with the coordinate range data of the tile. If there are vertex coordinates that exceed the coordinate range data, it means that the primitive partially exceeds the tile.
[0133] For example, if the vertex coordinates of the primitive include (1, 1), (8, 3) and (5, 6), the coordinate range data of the block is that the horizontal coordinate is greater than or equal to 1 and less than or equal to 4, and the vertical coordinate is greater than or equal to 1 and less than or equal to 4. Then, (1, 1) is compared with the coordinate range data, and the comparison result is within the range; then (8, 3) is compared with the coordinate range data, and since 8 is greater than 4, the comparison result is beyond the range, and (8, 3) is the vertex coordinate that exceeds the coordinate range data, so it is concluded that the primitive partially exceeds the block.
[0134] In some embodiments, the intersection information includes intersection coordinates. Accordingly, multiple pixel coordinates of the edge of the primitive are determined in sequence based on the vertex coordinates of the primitive, and every two pixel coordinates are used as a group of pixel coordinates in sequence; multiple edge coordinates of the block are determined based on the coordinate range data of the block; at least one group of pixel coordinates is obtained in which one pixel is outside the block and one pixel is inside the block, and the pixel coordinates in the block in the at least one group of pixel coordinates are the intersection coordinates. Among them, the second pixel coordinate of the first group in "every two pixel coordinates are used as a group of pixel coordinates in sequence" is the first pixel coordinate of the second group.
[0135] It should be noted that the "in order" in "determine in order the coordinates of multiple pixel points where the edges of the primitive are located" can be from the first vertex to the second vertex, or from the second vertex to the first vertex, and this application does not impose any restrictions on this.
[0136] Exemplarily, if the vertex coordinates of the primitives include (1, 1), (8, 3) and (5, 6), the coordinate range data of the block is that the horizontal coordinate is greater than or equal to 1 and less than or equal to 4, and the vertical coordinate is greater than or equal to 1 and less than or equal to 4. Then, the pixel point coordinates determined in sequence based on (1, 1) and (8, 3) include (1, 1), (2, 1), (3, 1), (4, 1), (4, 2), (5, 2), (6, 2) and (7, 2); the pixel point coordinates determined in sequence based on (1, 1) and (5, 6) include (1, 1), (1, 2), (2, 2), (2, 3), (3, 3), (3, 4), (4, 4) and (4, 5); the pixel point coordinates determined in sequence based on (5, 6) and (8, 3) include (5, 5), (6, 4) and (7, 3). Then, the edge coordinates are determined based on the coordinate range data, including: (1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (4, 2), (1, 3), (4, 3), (1, 4), (2, 4), (3, 4) and (4, 4). Accordingly, a set of pixel coordinates (1, 1) and (2, 1) are taken, and both pixel coordinates are located in the block; then another set of pixel coordinates (2, 1) and (3, 1) are taken in sequence, and both pixel coordinates are located in the block; continue to take another set of pixel coordinates in sequence and determine the relationship between the included pixel coordinates and the block, and it can be obtained that for a set of pixel coordinates (4, 2) and (5, 2), the pixel coordinate (4, 2) is located in the block, and the pixel coordinate (5, 2) is located outside the block, so the pixel coordinate (4, 2) located in the block is determined as the intersection coordinate. Similarly, it can be obtained that for a set of pixel coordinates (3, 4) and (4, 4), the pixel coordinate (3, 4) is located in the block, while the pixel coordinate (4, 4) is located outside the block, so the pixel coordinate (3, 4) located in the block is determined to be the intersection coordinate.
[0137] In some embodiments, at least one sub-primitive is generated based on at least one intersection point coordinate, a corner point coordinate of the tile, and a vertex coordinate located within the tile.
[0138] In an embodiment of the present application, when the vertex information of a primitive represents that part of the primitive exceeds a block, the intersection information of the edge of the primitive and the block is obtained; based on the vertex information and the intersection information, at least one sub-primitive is generated for the part of the primitive located in the block, and the sub-primitive is used as the primitive, thereby avoiding the problem that the shape of the part of the primitive located in the block is relatively complex, such as a quadrilateral, pentagon, etc., which leads to increased computational difficulty in performing coverage judgment. By generating at least one sub-primitive from the part located in the block and rasterizing the sub-primitive as the primitive, the computational difficulty is reduced, the calculation steps are reduced, the resource consumption of the workload of primitive rasterization is reduced, and the efficiency of primitive rasterization is improved.
[0139] like Figure 8FIG. 1 is a schematic diagram of an implementation process of a rasterization method provided in an embodiment of the present application. Figure 7 Before step S201, and / or after taking the sub-primitive as a primitive, the rasterization method may further include step S801 and step S802.
[0140] Step S801: based on vertex information of the primitive and the tile, convert the primitive from the tile to an intermediate tile, where the intermediate tile is used to represent tile region information of any tile.
[0141] Here, the conversion of the primitive to the intermediate tile is achieved by converting the vertex of the primitive to the intermediate tile. In some embodiments, a coordinate system is established in the screen space to be rendered, and the coordinate system contains multiple tiles distributed in an array, and the tile where the origin is located can be used as the intermediate tile. Correspondingly, the vertex information includes vertex coordinates, and the vertex coordinates are converted to the intermediate tile based on the vertex coordinates and the tile. In these embodiments, the conversion parameters of the tile and the intermediate tile are determined, and the conversion parameters include a horizontal parameter TILE_X and a vertical parameter TILE_Y, wherein the horizontal parameter TILE_X is used to represent the difference between the number of columns where the tile is located and the number of columns where the intermediate tile is located; the vertical parameter TILE_Y is used to represent the difference between the number of rows where the tile is located and the number of rows where the intermediate tile is located. The vertex coordinates are converted from the tile to the intermediate tile based on the conversion parameters. In other words, the number of rows where the tile is located is the TILE_X+1th column, and the number of rows where the tile is located is the TILE_Y+1th row, that is, the tile is in the TILE_X+1th column and the TILE_Y+1th row of the array tile.
[0142] Step S802: Use the middle block as the block.
[0143] Here, "taking the middle block as the block" means that the subsequent pixel coverage judgment is performed in the middle block. In other words, the coordinate representation of the pixel points is completed in the middle block. It can be understood that after step S203, the rasterization method also includes: converting the pixel points covered by the primitives in the block to the original block. Here, the original block is the block before it is converted to the middle block.
[0144] In some embodiments, "converting the pixel points covered by the primitives in the tile to the original tile" can refer to the implementation of "converting the primitives from the tile to the intermediate tile" in step S801. It can be understood that step S803 is the inverse transformation of the coordinates of step S801. Exemplarily, if a tile contains 32*32 pixels, and the coordinates of a pixel point in the intermediate tile are P(Px0, Py0), then its coordinates in the original tile are: P'=(Px0', Py0')=(Px0+32*TILE_X, Py0+32*TILE_Y).
[0145] In an embodiment of the present application, based on the vertex information and tiles of the primitives, the primitives are converted from tiles to intermediate tiles, and the intermediate tiles are used to represent the tile area information of any tile; the intermediate tiles are used as tiles, and since the intermediate tiles can represent any tiles, it can be seen that their position range corresponds to one tile, and pixels are represented in the one tile. Compared with the related art of representing pixels in the entire screen space, the bit width of representing pixels is reduced. Taking the example that the screen space contains 16Kb*16Kb pixels and the middle block includes 32*32 pixels, 14 binary bits are required to represent the pixel position in the screen space, while only 5 binary bits are required to represent the pixel position in the middle block; then, it can be obtained that when making coverage judgment on the pixel points, the computing resources required to substitute the pixel point coordinates into the edge equation are W(A0)*5+W(B0)*5+W(C0), which reduces the consumption of computing resources and saves costs compared to the computing resources of W(A0)*16+W(B0)*16+W(C0) required by the related technology.
[0146] Based on the foregoing embodiments, an embodiment of the present application provides a device, which includes the units included and the modules included in the units, which can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0147] Fig. 9 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 1 The rasterization device 100 includes a division unit 110, a first determination unit 120 and a second determination unit 130, wherein: the division unit 110 is used to divide the block and determine at least one sub-block; the first determination unit 120 is used to determine at least one target sub-block in at least one sub-block; the target sub-block is at least partially covered by a primitive, wherein the primitive is a primitive projected onto the block; the second determination unit 130 is used to determine a target pixel point covered by the primitive in at least one target sub-block to obtain a target pixel point covered by the primitive in the block.
[0148] In some embodiments, the first determination unit 120 is also used to obtain vertex information of a primitive, and the vertex information can represent the coverage area of the primitive; the first determination unit 120 is also used to determine the coordinate information of each sub-block; correspondingly, the first determination unit 120 is also used to compare the coordinate information of the sub-block with the vertex information, and when the comparison result represents that the primitive covers at least one pixel of the sub-block, the first determination unit 120 is also used to determine the sub-block as a target sub-block.
[0149] In some embodiments, the first determination unit 120 is also used to determine whether there are pixel points at the edge position covered by the primitive in the sub-block based on the vertices of the primitive by the right-hand rule. When there are pixel points at the edge position covered by the primitive, the first determination unit 120 is also used to determine the sub-block as the target sub-block.
[0150] In some embodiments, the first determination unit 120 is further used to determine the judgment result of each sub-block based on the first area information of each sub-block and the second area information of the primitive, wherein the first area information is used to characterize the area range of the sub-block, and the second area information is used to characterize the area range of the primitive; the sub-block characterized by the judgment result and the primitive at least partially overlapped is determined as the target sub-block. In some embodiments, the first determination unit 120 is further used to determine the result value corresponding to each edge equation based on each edge equation and the coordinates of the corner point corresponding to the edge equation, wherein the corner point corresponding to the edge equation is the corner point closest to the edge equation; the judgment result of the sub-block is determined based on the result value corresponding to each edge equation.
[0151] Fig.10 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 2 In some embodiments, the rasterization device further includes a third determination unit 140, which is used to determine the corner points corresponding to the edge equation based on equation coefficients of the edge equation and coordinates of each corner point in the sub-block.
[0152] In some embodiments, the third determination unit 140 is also used to determine the slope of the edge equation based on the equation coefficients of the edge equation; based on the coordinates of the corner point of the sub-block, obtain the distance value of the corner point from the straight line where the edge equation is located; based on the direction of the edge equation and the distance value of the corner point, obtain the corner point corresponding to the edge equation.
[0153] In some embodiments, the second determination unit 130 is further used to determine at least one judgment reference value of the target sub-block corresponding to the primitive; based on the at least one judgment reference value of the target sub-block, obtain at least one judgment value of each pixel point corresponding to the primitive; and determine a pixel point whose at least one judgment value represents a pixel point located within the primitive as a target pixel point of the target sub-block.
[0154] In an embodiment of the present application, at least one judgment reference value of a target sub-block corresponding to a primitive is determined; based on the judgment reference value of the target sub-block, at least one judgment value of each pixel corresponding to the primitive is obtained; a pixel point represented by at least one judgment value and located within the primitive is determined as a target pixel point of the target sub-block. It is only necessary to determine the relationship of the pixel point with respect to the reference position corresponding to the judgment reference value, without determining the specific position of the pixel point, thereby reducing the resource consumption for representing the specific position of the pixel point. It can be understood that the length of data corresponding to the pixel point becomes shorter, and the reading workload is reduced, thereby improving the efficiency of rasterization.
[0155] In some embodiments, the second determination unit 130 is further configured to determine reference position information of the target sub-block; and determine at least one reference value of the target sub-block corresponding to the primitive based on the reference position information and at least one edge information of the primitive.
[0156] In some embodiments, the second determining unit 130 is further configured to obtain a judgment value of each pixel corresponding to a primitive based on the position information of each pixel of the target sub-image block and the judgment reference value.
[0157] In some embodiments, the second determination unit 130 is further configured to substitute the reference coordinates into the edge equation to obtain a judgment reference value.
[0158] In some embodiments, the second determination unit 130 is further configured to obtain a determination value of each pixel point corresponding to the edge equation based on the determination reference value and each offset.
[0159] In some embodiments, the second determination unit 130 is further used to substitute the coordinates of each pixel point into the edge equation to obtain a judgment value; when the judgment value indicates that the pixel point is located within the primitive, the pixel point is determined as a target pixel point.
[0160] Fig.11 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 3 In some embodiments, the rasterization device further includes a generation unit 150, which is used to obtain the intersection information between the edge of the primitive and the tile when the vertex information of the primitive represents that part of the primitive exceeds the tile; based on the vertex information and the intersection information, generate at least one sub-primitive for the part of the primitive located in the tile, and use the sub-primitive as the primitive.
[0161] Fig.12 A schematic diagram of the composition structure of a rasterization device provided in an embodiment of the present application Figure 4 In some embodiments, the rasterization device further includes a conversion unit 160, which is used to convert the primitive from the tile to an intermediate tile based on the vertex information of the primitive and the tile, and the intermediate tile is used to represent the tile area information of any tile; and the intermediate tile is used as the tile.
[0162] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0163] It should be noted that in the embodiments of the present application, if the above-mentioned rasterization method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application can be essentially or partly reflected in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the rasterization method of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.
[0164] The following uses a triangle primitive, a screen including 16Kb*16Kb pixels, and each block including 32*32 pixels as an example to illustrate the application of the rasterization method provided in the embodiment of the present application in an actual scenario.
[0165] like Fig.13 As shown, the workflow of the rasterization method provided in the embodiment of the present application is as follows: Figure 1 , a rasterization method, applied to a rasterization device, may at least include the following steps:
[0166] Step S1301, obtaining vertex coordinates of a triangle primitive projected on the screen, and position information of a target block where the triangle primitive is located compared to a block where the screen coordinate origin is located.
[0167] Here, the rasterization device may be, but is not limited to, a graphics processing unit (GPU) or other devices for implementing rasterization of graphic elements.
[0168] Step S1302: Based on the position information and the vertex coordinates, the vertex coordinates are converted to the block where the screen coordinate origin is located to obtain the judgment coordinates.
[0169] Here, the determination coordinates refer to the coordinates of the block where the screen coordinate origin is located. In the embodiment of the present application, step S1302 is used to implement translation of the triangle primitive from the target block to the block where the screen origin is located.
[0170] For example, Fig.14 for Fig.13 Schematic diagram of implementing coordinate transformation in the rasterization method. Fig.14 As shown, a global coordinate system is established in the screen display area. The global coordinate system takes the upper left corner of the screen display area as the origin, the direction from the upper left corner to the upper right corner of the screen display area as the positive direction of the x-axis, and the direction of the positive direction after the x-axis is rotated 90 degrees clockwise as the positive direction of the y-axis. In other words, the x-axis can be understood as the horizontal direction indicated in the figure, and the y-axis can be understood as the vertical direction shown in the figure. Each block in the screen display area includes 32*32 pixels.
[0171] In an embodiment of the present application, a triangle primitive is projected onto a screen, and a rasterization device obtains a target tile (the tile in the lower right corner shown in the figure) where the triangle primitive is projected onto the screen, and determines that the primitive coordinates of the three vertices of the triangle primitive are (x1, y1), (x2, y2), and (x3, y3), respectively. The position information of the target tile relative to the tile where the screen coordinate origin (0, 0) is located can be determined based on the coordinates of the upper left corner point O of the target tile.
[0172] Correspondingly, the rasterization device implements coordinate transformation: (x1, y1) is converted to (x1-32*TILE_X, y1-32*TILE_Y), (x2, y2) is converted to (x2-32*TILE_X, y2-32*TILE_Y), and (x3, y3) is converted to (x3-32*TILE_X, y3-32*TILE_Y), where TILE_X is equal to the integer quotient of the x-coordinate of the upper left corner point O and 32, and TILE_Y is equal to the integer quotient of the y-coordinate of the upper left corner point O and 32. In other words, TILE_X is the X+1th column of the target tile in the tile of the entire screen, and TILE_Y is the Y+1th row of the target tile in the tile of the entire screen, that is, the X+1th column and Y+1th row of the target tile in the tile of the entire screen. Taking the figure as an example, TILE_X is 1 and TILE_Y is 1.
[0173] In an embodiment of the present application, the target tile is translated to the tile where the screen coordinate origin is located, and the judgment coordinates are used to perform pixel coverage judgment. Since the coordinate range of the tile where the screen coordinate origin is located is 0 to 32, compared to the related art, 14 bits are required to represent the pixel coordinates on the entire screen. The present technical solution only requires 5 bits to represent the pixel coordinates of a tile, completing the granularity normalization of the pixel coordinates, saving one-third of the computing resources compared to the related art.
[0174] Step S1303: based on the determined coordinates, determine the edge equations of the three edges of the triangle primitive respectively; split the block where the screen coordinate origin is located into at least one sub-block, and determine the corner point corresponding to each edge equation for each sub-block.
[0175] For example, Fig.15 for Fig.13 Schematic diagram of sub-tile coverage judgment in the rasterization method. Fig.15 As shown, the first edge equation determined based on (x1, y1) and (x2, y2) is A1*x+B1*y+C1=0, the second edge equation determined based on (x2, y2) and (x3, y3) is A2*x+B2*y+C2=0, and the third edge equation determined based on (x3, y3) and (x1, y1) is A3*x+B3*y+C3=0. The first block is split into 8*8 sub-blocks n, each sub-block n includes 4*4 pixels. Taking the sub-block in the first row and second column of the first block as an example, the corner point corresponding to the first edge equation is determined to be corner point B, the corner point corresponding to the second edge equation is determined to be corner point C, and the corner point corresponding to the third edge equation is determined to be corner point A. Accordingly, the corner point corresponding to each edge equation is determined for the 8*8 sub-blocks n, that is, three corner points are determined for each sub-block, and each corner point has a corresponding edge equation. It should be noted that the corner point A in the figure is the upper right corner point of the sub-block, the corner point C in the figure is the upper left corner point of the sub-block, and the corner point B in the figure is the lower left corner point of the sub-block.
[0176] The corner points corresponding to each edge equation are determined according to the coefficients in the edge equation. For the edge equation A0x+B0y+C0=0, the determination method includes:
[0177] When A0≥0 and B0>0, the corner point corresponding to the edge equation is the lower left corner point of the sub-block;
[0178] When A0>0 and B0≤0, the corner point corresponding to the edge equation is the lower right corner point of the sub-block;
[0179] When A0<0 and B0≥0, the corner point corresponding to the edge equation is the upper left corner point of the sub-block;
[0180] When A0≤0 and B0<0, the corner point corresponding to the edge equation is the upper right corner point of the sub-block.
[0181] Step S1304: Substitute each corner point of the sub-tile into the corresponding edge equation to obtain a substitution result corresponding to each edge equation to determine whether the sub-tile is a target sub-tile at least partially covered by a triangle primitive.
[0182] For example, continue to see Fig.15, the triangle coverage judgment of the sub-block n located in the first row and second column of the first block includes: substituting the judgment coordinates (0, 4) of the corner point B into the first side equation, that is, A1*4+B1*0+C 1= 4A1+C1; Substitute the coordinates (0,0) of the corner point C into the equation of the second side, which is A2*4+B2*0+C 2= 4A2+C2; Substitute the judgment coordinate (4, 0) of the corner point A into the equation of the third side, that is, A3*4+B3*0+C3=4A3+C3. When the substitution results 4A1+C1, 4A2+C2 and 4A3+C3 are all greater than zero, it is concluded that the sub-block n located in the first row and first column of the first block is covered by the triangle primitive. Accordingly, the above triangle coverage judgment is performed on each sub-block of the first block to determine the target sub-block covered by the triangle primitive.
[0183] It should be noted that, in a block, based on the same edge equation, the relative positions of the corner points corresponding to the edge equation of each sub-block are consistent. For example, for the same edge equation, if the corner point corresponding to the edge equation of the first sub-block is determined to be the upper left corner point, then the corner point corresponding to the edge equation of the second sub-block is also determined to be the upper left corner point.
[0184] In the embodiment of the present application, based on the judgment coordinates, the edge equations of the three sides of the triangle primitive are determined respectively; the block where the screen coordinate origin is located is split into at least one sub-block, and the corner point corresponding to each edge equation is determined for each sub-block; each corner point of the sub-block is substituted into the corresponding edge equation, and the substitution result corresponding to each edge equation is obtained to determine whether the sub-block is a target sub-block that is at least partially covered by the triangle primitive. For the sub-block that is not covered by the primitive, the number of calculations for the pixel coverage judgment is 3, that is, the corner point is substituted into the edge equation 3 times. The number of times the equation is calculated, the resource consumption is 3*[W(A0)*5+W(B0)*5+W(C0)]. Compared with the related art, for the sub-blocks not covered by the primitives, the number of calculations to complete the pixel coverage judgment is 16*3 times, that is, 16 pixels are substituted into the three edge equations respectively, and the resource consumption is 16*3*[W(A0)*14+W(B0)*14+W(C0)]. It can be concluded that the workload and resource consumption of performing pixel coverage judgment on all sub-blocks of a block are effectively reduced.
[0185] Fig.16 for Fig.13 Schematic diagram of the target sub-tile in the rasterization method. Fig.16 As shown, sub-block n1 is the target sub-block, and sub-block n2 is the sub-block not covered by the triangle primitive. Fig.16In the figure, the block with the diagonal shading and the triangle primitive is the target sub-block, and the sub-block without the diagonal shading is not the target sub-block. It should be noted that the diagonal shading under the triangle primitive is omitted.
[0186] Step S1305: Substitute the determined coordinates of each pixel point of the target sub-block into each edge equation of the triangle primitive to obtain a substitution result corresponding to each edge equation, and determine the pixel points covered by the triangle primitive based on the substitution result.
[0187] For example, Fig.16 As shown, taking the target sub-block located in the second row and second column of the first block as an example, the judgment coordinates of the pixel points of the target sub-block are (4, 4), (4, 5), (4, 6), (4, 7); (5, 4), (5, 5), (5, 6), (5, 7); (6, 4), (6, 5), (6, 6), (6, 7); (7, 4), (7, 5), (7, 6), (7, 7). The rasterization device substitutes each judgment coordinate into the three edge equations of the triangle primitive, and obtains whether each pixel point is covered by the triangle primitive based on the result of the substitution. Taking the judgment coordinates (4, 4) of the pixel point as an example, substitute (4, 4) into the first side equation A1*x+B1*y+C1=0 to obtain 4A1+4B1+C1; substitute (4, 4) into the second side equation A2*x+B2*y+C2=0 to obtain 4A2+4B2+C2; substitute (4, 4) into the third side equation A3*x+B3*y+C3=0 to obtain 4A3+4B3+C3. Based on the substitution results 4A1+4B1+C1, 4A2+4B2+C2, and 4A3+4B3+C3, when the substitution results are all greater than zero, the pixel point is covered by the triangle primitive.
[0188] In the embodiment of the present application, by translating the target block to the block where the origin of the screen coordinates is located, the primitive coordinates are converted into judgment coordinates. Compared with the related art that requires 16 bits (Bit) to represent the pixel coordinates of a block, the present technical solution only requires 5 bits to represent the pixel coordinates of a block, and accordingly, only 5 bits are required to represent the coordinates of a sub-block. It can be inferred that in the embodiment of the present application, to determine whether each pixel of a sub-block is covered by a triangle primitive, the required computing resources are: 16*3*[W(A0)*5+W(B0)*5+W(C0)], where "5" corresponds to the bit width of the judgment coordinates representing a pixel point, compared with the related art that requires 16*3*[W(A0)*14+W(B0)*14+W(C0)], which effectively reduces the loss of resources and improves resource utilization.
[0189] In some embodiments, step S1305 may be implemented by steps S1307 and S1308.
[0190] Step S1307: In each target sub-block, determine a vertex of the first pixel as a coordinate base point, substitute the determined coordinates of the coordinate base point into each edge equation of the triangle primitive, and obtain the equation base value corresponding to each edge equation.
[0191] Here, the first pixel point refers to the pixel point in the target sub-block that is closest to the origin of the judgment coordinates.
[0192] Step S1308: Based on the equation base value corresponding to each edge equation and the determined coordinates of the coordinate base point, obtain the substitution result corresponding to the edge equation for each pixel point, and determine the pixel points covered by the triangle primitive based on the substitution result.
[0193] Here, the result of substituting each pixel point into the edge equation corresponds to: taking the center position of each pixel point as its judgment coordinate point and substituting it into the result of substituting into the edge equation.
[0194] For example, continue to see Fig.16 , taking the target sub-block located in the second row and second column of the first block as an example, the execution process of step S1307 and step S1308 is explained. The first pixel point is the pixel point located in the first row and first column of the target sub-block. The rasterization device determines that the upper left vertex of the first pixel point is the coordinate base point, and the judgment coordinates of the coordinate base point are (4, 4). Substituting (4, 4) into the first edge equation A1*x+B1*y+C1=0 obtains 4A1+4B1+C1, which is used as the base value base1 of the first equation; substituting (4, 4) into the second edge equation A2*x+B2*y+C2=0 obtains 4A2+4B2+C2, which is used as the base value of the second equation; substituting (4, 4) into the third edge equation A3*x+B3*y+C3=0 obtains 4A3+4B3+C3, which is used as the base value of the third equation.
[0195] Based on the base value of the first equation and the judgment coordinates (4, 4) of the coordinate base point, the substitution results of 16 pixel points corresponding to the edge equation are obtained, namely, the base value of the first equation base1+0.5A1+0.5B1, the base value of the first equation base1+1.5A1+0.5B1, the base value of the first equation base1+2.5A1+0.5B1, and the base value of the first equation base1+3.5A1+0.5B1;
[0196] The first equation base value base1+0.5A1+1.5B1, the first equation base value base1+1.5A1+1.5B1, the first equation base value base1+2.5A1+1.5B1, the first equation base value base1+3.5A1+1.5B1;
[0197] The first equation base value base1+0.5A1+2.5B1, the first equation base value base1+1.5A1+2.5B1, the first equation base value base1+2.5A1+2.5B1, the first equation base value base1+3.5A1+2.5B1;
[0198] The base value of the first equation is base1+0.5A1+3.5B1, the base value of the first equation is base1+1.5A1+3.5B1, the base value of the first equation is base1+2.5A1+3.5B1, and the base value of the first equation is base1+3.5A1+3.5B1.
[0199] Based on the base value of the second equation and the judgment coordinates (4, 4) of the coordinate base point, the substitution results of 16 pixel points corresponding to the edge equation are obtained. Based on the base value of the third equation and the judgment coordinates (4, 4) of the coordinate base point, the substitution results of 16 pixel points corresponding to the edge equation are obtained. Refer to the above-mentioned "Based on the base value of the first equation and the judgment coordinates (4, 4) of the coordinate base point, the substitution results of 16 pixel points corresponding to the edge equation are obtained" technical solution.
[0200] In a target sub-block, based on the three substitution results corresponding to the three edge equations for each pixel, when the three substitution results are all greater than zero, the pixel is covered by the triangle primitive. Correspondingly, all the pixels covered by the triangle primitives in a target sub-block can be determined.
[0201] Accordingly, if Fig.17 As shown, Fig.13 It can be understood that by performing the above-mentioned triangle primitive coverage judgment on each pixel of each target sub-block, all the pixels covered by the triangle primitive can be obtained.
[0202] In an embodiment of the present application, a vertex of the first pixel point in the target sub-block is determined as the coordinate base point, and the judged coordinates of the coordinate base point are substituted into each edge equation of the triangle primitive to obtain the equation base value corresponding to each edge equation. The computing resources consumed are 3*(W(A0)*5+W(B0)*5+W(C0)); based on the equation base value corresponding to each edge equation and the judged coordinates of the coordinate base point, the substitution result of each pixel point corresponding to the edge equation is obtained. Since the coordinates of each pixel point will not affect the constant term in the edge equation, there is no need to consume the computing resources of the constant term. Then, the computing resources are 16*(W(A0)+W(B0)), which compresses the hardware overhead of realizing "substituting the judged coordinates of each pixel point of each target sub-block into each edge equation of the triangle primitive, and determining the pixel points covered by the triangle primitive based on the substitution result".
[0203] Step S1306: based on the position information, convert the determined coordinates of the pixel points covered by the triangle primitive into original coordinates, where the original coordinates are located in the target block.
[0204] Here, step S1306 transforms the determined coordinates of the pixel points covered by the triangle primitive opposite to step S1302. In other words, step S1302 transforms the coordinates from the target block to the block where the screen coordinate origin is located, and step S1306 reversely transforms the coordinates from the block where the screen coordinate origin is located to the target block.
[0205] For example, if the judgment coordinate of a pixel point is P(P x0 , P y0 ), then the original primitive coordinates are: P'=(P x0 ',P y0 ')=(P x0 +32*TILE_X,P y0 +32*TILE_Y), where TILE_X is equal to the integer quotient of the x-coordinate of the upper left corner of the target tile where point P is located and 32, and TILE_Y is equal to the integer quotient of the y-coordinate of the upper left corner of the target tile where point P is located and 32.
[0206] In the embodiment of the present application, a triangle primitive, a 32Kb*32Kb block is taken as an example. In the related art, the number of calculations for rasterizing the pixels of a block is 32*32*3=3072 times. Fig.14 In the example, when the rasterization method implemented by steps S1307 and S1308 is adopted, the number of target sub-blocks is 25, then the number of calculations for rasterization of the pixels of a block is 8*8*3+25*16*3=1392 times, wherein "25" represents 25 target sub-blocks, "16" represents 16 pixels, and "3" represents that the pixel coordinates are substituted into three edge equations respectively, thereby reducing the workload of rasterization. It can be understood that the smaller the area of the primitive, the more the rasterization workload is reduced by this technical solution.
[0207] At the same time, in the rasterization method implemented by step S1307 and step S1308, the computing resources consumed for primitive coverage judgment on 16 pixel points are 3*(W(A0)*5+W(B0)*5+W(C0))+16*(W(A0)+W(B0)), wherein the meaning of computing resources is explained in the aforementioned step S605; compared with the related art, the computing resources consumed for primitive coverage judgment on 16 pixel points are 16*3*(W(A0)*14+W(B0)*14+W(C0)), which shows that the technical solution of the embodiment of the present application reduces the computing resources required for primitive rasterization, wherein the reduced resource loss mainly includes: primitive coverage judgment of pixel points of sub-blocks not covered by triangle primitives; and the operation width of the arithmetic logic unit (ALU) during operation.
[0208] An embodiment of the present application provides a graphics processor, which includes the aforementioned rasterization device.
[0209] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0210] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.
[0211] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.
[0212] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc.
[0213] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.
[0214] Fig.18 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Fig.18 As shown, the hardware entity of the computer device 1800 includes: a processor 1801 and a memory 1802, wherein the memory 1802 stores a computer program that can be run on the processor 1801, and the processor 1801 implements the steps in the method of any of the above embodiments when executing the program.
[0215] The memory 1802 stores computer programs that can be run on the processor. The memory 1802 is configured to store instructions and applications executable by the processor 1801. It can also cache data to be processed or processed by the processor 1801 and various modules in the computer device 1800 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0216] When the processor 1801 executes the program, the steps of any of the above-mentioned rasterization methods are implemented. The processor 1801 generally controls the overall operation of the computer device 1800.
[0217] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the rasterization method of any of the above embodiments.
[0218] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0219] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application do not specifically limit this.
[0220] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.
[0221] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.
[0222] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0223] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0224] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0225] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.
[0226] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the rasterization method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0227] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A rasterization method, characterized in that: Applied to a graphics processor, the rasterization method includes: Dividing the image block to determine at least one sub-image block; Determine at least one target sub-image block in the at least one sub-image block; the target sub-image block is at least partially covered by a primitive; the primitive is a primitive projected on the image block; A target pixel point covered by the primitive in at least one of the target sub-blocks is determined to obtain pixel points covered by the primitive in the block.
2. The rasterization method according to claim 1, characterized in that: The determining at least one target sub-picture block in the at least one sub-picture block comprises: Determine a judgment result of each sub-image block based on first region information of each sub-image block and second region information of the image element, wherein the first region information is used to characterize the region range of the sub-image block, and the second region information is used to characterize the region range of the image element; The sub-image block whose judgment result indicates that the sub-image block at least partially overlaps with the image primitive is determined as the target sub-image block.
3. The rasterization method according to claim 2, characterized in that: The first region information includes coordinates of corner points of the sub-block, and the second region information includes at least one edge equation of the primitive; The determining the judgment result of each sub-image block based on the first region information of each sub-image block and the second region information of the image element comprises: Determine a result value corresponding to each edge equation based on the coordinates of each edge equation and the corner point corresponding to the edge equation, the corner point corresponding to the edge equation being the corner point closest to the edge equation; Based on the result value corresponding to each edge equation, the judgment result of the sub-block is determined.
4. The rasterization method according to claim 3, characterized in that: The method further comprises: Based on the equation coefficients of the edge equation and the coordinates of each corner point in the sub-block, the corner point corresponding to the edge equation is determined.
5. The rasterization method according to claim 1, characterized in that: Each of the target sub-blocks includes at least one pixel point, and determining the target pixel point covered by the primitive in at least one of the target sub-blocks includes: Determining at least one judgment reference value that the target sub-block corresponds to the primitive; Based on at least one judgment reference value of the target sub-image block, obtaining at least one judgment value corresponding to the image primitive for each pixel point; A pixel point whose at least one judgment value represents that the pixel point is located within the primitive is determined as a target pixel point of the target sub-image block.
6. The rasterization method according to claim 5, characterized in that: The determining of at least one judgment reference value that each of the target sub-blocks corresponds to the primitive comprises: determining reference position information of the target sub-block; and determining at least one judgment reference value that the target sub-block corresponds to the primitive based on the reference position information and at least one edge information of the primitive; The method of obtaining at least one judgment value of each pixel corresponding to the primitive based on the judgment reference value of each target sub-picture block includes: obtaining at least one judgment value of each pixel corresponding to the primitive based on the position information of each pixel of the target sub-picture block and the judgment reference value.
7. The rasterization method according to claim 6, characterized in that: The reference position information includes reference coordinates, the edge information includes at least one edge equation, the position information includes an offset between the coordinates of each pixel point and the reference coordinates, and determining at least one judgment reference value of the target sub-block corresponding to the primitive based on the reference position information and at least one edge information of the primitive includes: substituting the reference coordinates into the edge equation to obtain the judgment reference value; The method of obtaining at least one judgment value of each pixel corresponding to the primitive based on the position information of each pixel of the target sub-block and the judgment reference value comprises: obtaining at least one judgment value of each pixel corresponding to the edge equation based on the judgment reference value and each offset.
8. The rasterization method according to claim 3, characterized in that: Each of the target sub-blocks includes at least one pixel point, and determining the target pixel point covered by the primitive in at least one of the target sub-blocks includes: Substituting the coordinates of each pixel point into the at least one edge equation to obtain at least one judgment value; In a case where the at least one judgment value represents that the pixel point is located within the primitive, the pixel point is determined as the target pixel point.
9. The rasterization method according to any one of claims 1 to 8, characterized in that: The rasterization method further comprises: When the vertex information of the primitive indicates that the primitive partially exceeds the block, obtaining the intersection information of the edge of the primitive and the block; Based on the vertex information and the intersection information, at least one sub-primitive is generated for the portion of the primitive located in the block, and the sub-primitive is used as the primitive.
10. The rasterization method according to any one of claims 1 to 8, characterized in that: The rasterization method further comprises: Based on the vertex information of the primitive and the tile, convert the primitive from the tile to an intermediate tile, where the intermediate tile is used to represent tile region information of any of the tiles; The middle tile is used as the tile.
11. A rasterization device, characterized in that: The rasterization device comprises a dividing unit, a first determining unit and a second determining unit, wherein: The division unit is used to divide the image block to determine at least one sub-image block; The first determining unit is configured to determine at least one target sub-image block in the at least one sub-image block; the target sub-image block is at least partially covered by a primitive, wherein the primitive is obtained by processing a scene to be rendered and then projecting it onto the image block; The second determining unit is used to determine the target pixel points covered by the primitive in at least one of the target sub-blocks to obtain the target pixel points covered by the primitive in the block.
12. The rasterization device according to claim 11, characterized in that: The second determination unit is further used to determine at least one judgment reference value of the target sub-block corresponding to the primitive; based on the at least one judgment reference value of the target sub-block, obtain at least one judgment value of each pixel corresponding to the primitive; and determine a pixel point whose at least one judgment value represents that the pixel point is located within the primitive as a target pixel point of the target sub-block.
13. A graphics processor, characterized in that: The graphics processor comprises a rasterizer according to claim 11 or 12.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps of the rasterization method according to any one of claims 1 to 10 are implemented.
15. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the rasterization method according to any one of claims 1 to 10 are implemented.
16. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the rasterization method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Architecture for interleaved rasterization and pixel shading for virtual reality and multi-view systems
CN109196550A
Method and device for accelerating rasterization traversal, and computer storage medium
CN111127299A
Block-based rasterization method and device, and image rendering method and device
CN115841433A
Graphics processor, system, method, electronic device and electronic equipment
CN116957898A
Block-based rasterization method and device, image rendering method and device
TW202435161A
Cited By
Method and device for determining processing starting point of target primitive and chip
CN121639775A
A method, device and chip for determining a starting point of processing of a target primitive
CN121639775B