Rasterization methods, apparatus, processors, devices, storage media, and program products
By dividing the rasterization process into sub-tiles and determining the target sub-tiles, and adopting a tile rendering architecture, the problem of high resource consumption in existing technologies is solved, and the rasterization efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2026-03-06
AI Technical Summary
In existing technologies, the rasterization process consumes a lot of resources and requires a large amount of processor work, resulting in low rasterization efficiency.
The tile rendering architecture divides the screen space into tiles and identifies target sub-tiles within sub-tiles. By initially determining whether a sub-tile is covered by primitives, the system reduces the need to individually check each pixel of a sub-tile that is not covered by primitives, thus lowering resource consumption.
By performing preliminary judgment on sub-blocks, the workload and resource consumption of pixel coverage judgment are reduced, and the rasterization efficiency is improved.
Smart Images

Figure CN119784872B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to a rasterization method, apparatus, processor, device, storage medium, and program product. Background Technology
[0002] Rasterization is a crucial step in the graphics rendering process. Rasterization involves the processor, based on primitives projected onto the screen space, performing a primitive coverage determination on each pixel in the screen space to identify the pixels covered by primitives. In related technologies, the processor divides the entire screen space into several tiles, acquires the primitives within each tile, and determines the covered pixels by performing a primitive coverage determination on each pixel within that tile.
[0003] However, in related technologies, regardless of the number of pixels a primitive covers in a block, it is necessary to determine the primitive coverage of all pixels in the block, which results in a large resource consumption for rasterization and a large 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 the above, embodiments of this application provide at least one rasterization method, apparatus, processor, device, storage medium, and program product.
[0006] The technical solution of this application embodiment is implemented as follows:
[0007] On one hand, embodiments of this application provide a rasterization method applied to a graphics processor. The graphics processor performs the rasterization process based on a tile rendering architecture. The rasterization method includes: dividing a tile to determine at least one sub-tile; determining at least one target sub-tile in the at least one sub-tile; the target sub-tile being at least partially covered by primitives; the primitives being primitives projected onto the tile; and determining target pixels covered by primitives in the at least one target sub-tile to obtain pixels covered by primitives within the tile.
[0008] On the other hand, embodiments of this application provide a rasterization apparatus, which includes a partitioning unit, a first determining unit, and a second determining unit, wherein: the partitioning unit is used to partition a block and determine at least one sub-block; the first determining unit is used to determine at least one target sub-block in the at least one sub-block; the target sub-block is at least partially covered by primitives, wherein the primitives are primitives projected onto the block; the second determining unit is used to determine target pixels covered by primitives in the at least one target sub-block, so as to obtain the target pixels covered by primitives within the block.
[0009] In another aspect, embodiments of this application provide a graphics processor, which includes the aforementioned rasterization device.
[0010] In another aspect, embodiments of this application provide a computer device, including a memory and a processor. The memory stores a computer program that can run on the processor, and the processor executes the program to implement the steps in the aforementioned rasterization method.
[0011] In another aspect, embodiments of this application provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the aforementioned rasterization method.
[0012] In another aspect, embodiments of this application provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps in the aforementioned rasterization method.
[0013] In this embodiment, the map is divided into at least one sub-map, and a target sub-map is determined within the sub-map. The target sub-map is at least partially covered by primitives. Then, the target pixels covered by primitives in the at least one target sub-map are determined, thus obtaining the pixels covered by primitives within the map. Compared with the related technology, which judges the primitive coverage of each pixel in the map one by one, this embodiment preliminarily judges whether the sub-map is at least partially covered by primitives, eliminating the need to judge the pixels of the sub-map that are not covered by primitives one by one, thus reducing the workload and resource consumption of pixel coverage judgment within the map.
[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 this application. Attached Figure Description
[0015] Figure 1 This is a partial schematic diagram of graphic elements projected onto a screen in related technologies;
[0016] Figure 2 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 1 ;
[0017] Figure 3 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 2 ;
[0018] Figure 4 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 3 ;
[0019] Figure 5 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 4 ;
[0020] Figure 6 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 5 ;
[0021] Figure 7 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 6 ;
[0022] Figure 8 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 7 ;
[0023] Figure 9 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 1
[0024] Figure 10 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 2 ;
[0025] Figure 11 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 3 ;
[0026] Figure 12 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 4 ;
[0027] Figure 13 Workflow of the rasterization method provided in the embodiments of this application Figure 1 ;
[0028] Figure 14 for Figure 13 A schematic diagram illustrating coordinate transformation in the rasterization method;
[0029] Figure 15 for Figure 13 A schematic diagram of sub-tile coverage determination in the rasterization method;
[0030] Figure 16 for Figure 13 A schematic diagram of the target sub-pattern in the rasterization method;
[0031] Figure 17 for Figure 13 A schematic diagram of all pixels covered by a triangular primitive in a rasterization method;
[0032] Figure 18 This is a schematic diagram of the hardware entity of a computer device provided in an embodiment of this application. Detailed Implementation
[0033] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0034] It should be understood that the phrases "embodiments of this application" or "foreign embodiments" throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "embodiments of this application" or "in the foreign embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential 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 this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0035] Figure 1 This is a partial schematic diagram of graphic elements projected onto a screen in related technologies. For example... Figure 1 As shown, the screen consists of multiple pixels p, which divide the screen into several tiles. A coordinate system (x, y) is established globally on the screen. The triangular primitive projected onto tile m is obtained. The three sides of the triangle are the first side L0, the second side L1, and the third side L2. The coordinates of the top-left pixel of tile m are (a, b).
[0036] When a triangular primitive is projected onto the screen, the processor obtains the vertex coordinates of the three vertices of the triangular primitive and, based on these coordinates, derives the equations of the first side L0 as A0*x + B0*y + C0 = 0; the second side L1 as A1*x + B1*y + C1 = 0; and the third side L2 as A2*x + B2*y + C2 = 0. For a pixel p with pixel coordinates (x0, y0), substituting p(x0, y0) into the equation of the first side L0 (A0*x + B0*y + C0 = 0) yields the algebraic expression A0*x0 + B0*y0 + C0; substituting p(x0, y0) into the equation of the second side L1 (A1*x + B1*y + C1 = 0) yields the algebraic expression A1*x0 + B1*y0 + C1; and substituting p(x0, y0) into the equation of the second side L1 (A1*x + B1*y + C1 = 0) yields the algebraic expression A1*x0 + B1*y0 + C1; and substituting p(x0, y0) into the equation of the third side L2 ... 0) Substituting the equation of the third side L2 into the equation A2*x+B2*y+C2=0, we get the algebraic expression 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 triangular primitive.
[0037] Therefore, the processor performs primitive coverage judgment on each pixel p within the image patch m. This yields the target pixel that is covered by the primitives, and its coordinates.
[0038] For a 16 kilobyte (Kb) * 16 Kb screen, with the processor performing primitive coverage judgment at a speed of 16 pixels / frame and each pixel coordinate requiring 14 bits, the processor performs primitive coverage judgment on each pixel by substituting the pixel coordinates into the three edge equations of the primitive. The value of the algebraic expression obtained from substituting into the three edge equations determines whether the pixel is covered by the primitive. An algebraic expression includes the product of the pixel's x-coordinate and the coefficient of x in the edge equation, the product of the pixel's y-coordinate and the coefficient of y in the edge equation, and a constant term in the edge equation. The bit width of the pixel's x-coordinate is 14 bits, the bit width of the coefficient of x in the edge equation is W(A0), and the bit width of the pixel's y-coordinate... 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 computational resources required for one expression are W(A0)*14+W(B0)*14+W(C0). Substituting a pixel into the three edge equations will result in three algebraic expressions. The computational resources consumed for primitive coverage judgment of a pixel are 3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 3. Therefore, it can be deduced that when primitive coverage judgment of 16 pixels is completed in one step, the computational resources consumed in one step are 16*3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 48.
[0039] Understandably, one beat represents one clock cycle.
[0040] It is evident that regardless of what percentage of pixels p in block m the triangular primitive covers, primitive coverage must be determined for all pixels p in block m, resulting in high resource consumption for rasterization. At the same time, the workload of the processor in rasterization is also high.
[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, this application proposes a rasterization method for use in graphics processors.
[0043] In some embodiments, the graphics processor performs rasterization based on a tile-based rendering architecture. In Tile-Based Rendering (TBR), the screen space to be rendered is divided into individual tiles. The coordinates of each tile are stored in system memory as a list via an intermediate buffer. During rendering, each tile is loaded into the on-chip memory of the graphics processing unit (GPU) one by one. The data required for rendering can be obtained from the on-chip memory, thus avoiding slow interaction with system memory. After each tile is rendered, its result is output to the corresponding area in the frame buffer of system memory. Once all tiles have been rendered, the data in the frame buffer is the data for the entire screen to be displayed.
[0044] Figure 2 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 1 In the embodiments of this application, the rasterization method includes at least steps S201 to S203.
[0045] Step S201: Divide the map into sections and determine at least one sub-map.
[0046] Here, the tiles are located within the screen space, and the screen space includes multiple tiles distributed in an array.
[0047] The size of the sub-block relative to the block size can be determined based on actual conditions. In some embodiments, the size of the sub-block can be preset, and the sub-blocks are always divided according to this preset size during the rasterization process. In other embodiments, the size of the sub-block can be adjusted according to the size of the rasterization object, i.e., the primitive. Multiple sub-block sizes can be preset, and the size of the sub-blocks can be flexibly adjusted during the rasterization process.
[0048] For example, if the patch size is 32*32 pixels and the preset sub-patch size is 4*4 pixels, then during the rasterization process, the 32*32 pixel patch is always divided into 4*4 pixel sub-patches.
[0049] For another example, if the tile size is 32*32 pixels, the preset sub-tile size includes 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 tile is divided into sub-tiles of the first size; when the primitive size is generally large, the tile is divided into sub-tiles of the second size; and when the primitive size is small, the tile is divided into sub-tiles of the third size. It should be noted that the above examples are only illustrative of the implementation of step S201 and do not constitute a limitation on the sub-tile size. The sub-tile size can also be 3*3 pixels, 7*7 pixels, or other values. This application does not impose specific limitations on this.
[0050] In some embodiments, a block can be divided to determine a sub-block. This sub-block can be the original block itself, or it can be a sub-block obtained by cropping the original block, where the size of the sub-block is smaller than the size of the original block. In other embodiments, a block can be divided to obtain at least two sub-blocks, where there is no overlap between the at least two sub-blocks, and the size of the sub-block is smaller than the size of the original block.
[0051] Step S202: Determine at least one target sub-block in at least one sub-block; the target sub-block is at least partially covered by primitives; the primitives are primitives projected onto the block.
[0052] Here, "at least partially covered by primitives" means that some pixels of the target sub-plot are located within primitives; or, all pixels of the target sub-plot are located within primitives.
[0053] In some embodiments, determining at least one target sub-block in at least one sub-block can be achieved by: obtaining vertex information of a primitive, which can represent the coverage area of the primitive; on the other hand, determining the coordinate information of each sub-block; correspondingly, comparing the coordinate information of the sub-block with the vertex information, and if the comparison result indicates that the primitive covers at least one pixel of the sub-block, the sub-block is determined as the target sub-block, and the comparison continues to the next sub-block.
[0054] For example, if the vertex information of a primitive includes (37, 38), (60, 44), and (43, 60), then the corresponding coverage area it represents is the region where the x-coordinate value is greater than or equal to 37 and less than or equal to 60, and the y-coordinate value is greater than or equal to 38 and less than or equal to 60, that is, the region where 37 ≤ x-coordinate ≥ 60 and 38 ≤ y-coordinate ≥ 60; the primitive is divided into 64 sub-particles of 4*4 pixels, where the coordinate information of one sub-particle is the x-coordinate value is greater than or equal to 32 and less than or equal to 35, and the y-coordinate value is greater than or equal to 32 and less than or equal to 35, that is, 32 ≤ x-coordinate ≥ 35 and 32 ≤ y-coordinate ≥ 35; the coordinate information of another sub-particle is the x-coordinate value is greater than or equal to 45 and less than or equal to 48, and the y-coordinate value is greater than or equal to 45 and less than or equal to 48, that is, 45 ≤ x-coordinate ≥ 48 and 45 ≤ y-coordinate ≥ 48.
[0055] Therefore, for the previous sub-tile, since there is no overlap between x-coordinate 32 ≤ x-coordinate ≥ 35 and x-coordinate ≥ 60, and no overlap between y-coordinate ≥ 35 and y-coordinate ≥ 60, it can be concluded that the previous sub-tile is not the target sub-tile. For the other sub-tile, since there is overlap between x-coordinate 45 ≤ x-coordinate ≥ 48 and x-coordinate ≥ 60, and y-coordinate ≥ 45 ≤ y-coordinate ≥ 48 and y-coordinate ≥ 60, it can be concluded that the primitive covers at least one pixel of the sub-tile, thus identifying this sub-tile as the target sub-tile. Correspondingly, this method is used to determine whether each sub-tile within this sub-tile is a target sub-tile. In other words, this determination method compares the x-coordinate range of the sub-tile with the x-coordinate range of the primitive, and compares the y-coordinate range of the sub-tile with the y-coordinate range of the primitive. If both x-coordinate and y-coordinate ranges overlap, then the sub-tile is the target sub-tile.
[0056] In some other embodiments, determining at least one target sub-block within at least one sub-block can be achieved as follows: based on the vertices of primitives, the right-hand rule is used to determine whether there are pixels at edge positions covered by primitives within the sub-block. If pixels at edge positions covered by primitives exist, the sub-block is determined as a target sub-block, and so on, to determine whether the next sub-block is a target sub-block. It is understood that the determination result for edge position pixels, i.e., whether they are pixels covered by primitives, can be stored in the rasterization device. In this way, for blocks determined as target sub-blocks, the edge position pixels for which the determination result has already been obtained do not need to be determined again.
[0057] The right-hand rule states that: Determine the two vertices of a primitive in a clockwise direction as the start and end points. Using your right hand, align the direction of your palm towards your fingertips with the direction from the start point to the end point; then grasp the location of the pixel with your hand, and the direction your thumb points is the comparison result. Following this method, at least one comparison result for a pixel is obtained. If at least one comparison result points inwards on the screen, then the pixel is covered by the primitive. It should be noted that the implementation method in this example is used to illustrate the implementation principle; in the actual implementation process, the judgment is made through the corresponding program code.
[0058] For example, if the vertex information of a primitive includes points A, B, and C in a clockwise direction, the primitive is divided into 64 sub-plots of 4*4 pixels each, where the pixels at the edge of one sub-plot include pixels a1, a2, a3, ..., a 12 .
[0059] Therefore, the process for determining whether a sub-tile is the target sub-tile is as follows: First, starting from point A and ending at point B, align the direction of your right hand's fingertips with the direction from point A to point B, and grasp the position of pixel a1 with your right hand. The result is that it extends inwards from the screen. Next, starting from point B and ending at point C, align the direction of your right hand's fingertips with the direction from point B to point C, and grasp the position of pixel a1 with your right hand. The result is that it extends inwards from the screen. Finally, starting from point C and ending at point A, align the direction of your right hand's fingertips with the direction from point C to point A, and grasp the position of pixel a1 with your right hand. The result is that it extends inwards from the screen. Thus, it can be concluded that pixel a1 is covered by primitives, therefore, this sub-tile is determined to be the target sub-tile.
[0060] Here, the aforementioned primitives are those projected onto the tile. That is, for other primitives not projected onto the current tile, there is no need to perform the determination of the target sub-tile for those other primitives, thus reducing computational resources. 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 primitives in at least one target sub-block to obtain the pixel points covered by primitives within the block.
[0062] Here, "coverage" in the context of target pixels covered by primitives means that even though a pixel has an area in the actual structure, its area is equivalent to a single point relative to the entire display screen. Therefore, as the smallest unit in the rasterization process, a pixel is treated as a single point in the determination of whether it is covered by a primitive, regardless of its area. In this embodiment, a pixel's position is represented by its corner or center position. Accordingly, if a pixel's position falls within a primitive area, then that pixel is covered by the primitive, and is thus a target pixel. Specifically, by determining the target pixels of each target sub-block within the block and summing up the target pixels, the pixels covered by primitives within the block are obtained.
[0063] In some embodiments, determining a target pixel covered by a primitive within at least one target sub-block can be achieved by: judging each pixel within the target sub-block one by one to determine whether each pixel is a target pixel. The implementation of determining whether each pixel is a target pixel can refer to the implementation of "determining whether there are pixels at edge positions covered by primitives within the sub-block using the right-hand rule" in step S202. Alternatively, the implementation of determining whether each pixel is a target pixel can be: determining the coordinates of each pixel and the vertex coordinates of the primitive, judging whether the pixel's coordinates fall within the area enclosed by the vertex coordinates, and determining that the pixel is a target pixel if its coordinates fall within the area enclosed by the vertex coordinates.
[0064] For example, the coordinates of a pixel in the target sub-block are (m, n), and the vertex coordinates of the primitive 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 with coordinates (m, n) is covered by the primitive, which is the target pixel of the target sub-block.
[0065] In this embodiment, the map is divided into at least one sub-map, and a target sub-map is determined within the sub-map. The target sub-map is at least partially covered by primitives. Then, the target pixels covered by primitives within the at least one target sub-map are determined, thus obtaining the pixels covered by primitives within the map. Compared to the related technologies that perform primitive coverage judgment on each pixel within the map, this embodiment preliminarily determines whether a sub-map is at least partially covered by primitives. For sub-maps that are not covered by primitives, it is not necessary to judge each pixel individually, thus reducing the workload and resource consumption of pixel coverage judgment within the map.
[0066] Figure 3 A schematic diagram of the implementation process of a rasterization method provided in this application embodiment. Figure 2 .like Figure 3 As shown, based on Figure 2 The rasterization method of this application embodiment may include at least step S301 and step S302 in step S202.
[0067] Step S301: Based on the first region information of each sub-block and the second region information of the graphic element, determine the judgment result of each sub-block, wherein the first region information is used to characterize the region range of the sub-block and the second region information is used to characterize the region range of the graphic element.
[0068] In some embodiments, the first region information may include the first position information of each pixel in the sub-block, and the second region information may include the second position information of the primitive coverage area. Accordingly, it is determined one by one whether the first position information of each pixel falls within the second position information. If there is first position information falling within the second position information, the determination result is yes; otherwise, the determination result is no. It can be understood that in the process of determining the first position information of each pixel, as long as a first position information falling within the second position information is obtained, the determination result of the sub-block corresponding to the first position information is yes, and then the determination result of the next sub-block is proceeded.
[0069] In this embodiment of the application, the method for determining whether the first position information of each pixel falls within the second position information can refer to the implementation of "determining whether there are pixels at the edge position covered by primitives in the sub-block by using the right-hand rule" in step S202 above.
[0070] In other embodiments of this 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. Step S301 can be implemented through steps S303 and S304.
[0071] Step S303: Based on the coordinates of each side equation and the corresponding corner point, determine the result value corresponding to each side equation. The corner point corresponding to the side equation is the corner point closest to the side equation.
[0072] Here, the edge equation refers to the equation of the line containing the edge of a primitive. This edge equation can be determined using the vertex coordinates of the primitive. For example, if the vertex coordinates of a primitive are (1, 2), (5, 8), and (4, 6), then the edge equation based on (1, 2) and (5, 8) is 1.5x - y + 0.5 = 0; based on (5, 8) and (4, 6), the edge equation is 2x - y - 2 = 0; and based on (1, 2) and (4, 6), the edge equation is 4x - 3y + 2 = 0.
[0073] Corner points refer to the pixels of a sub-plot.
[0074] The result value corresponding to each side equation refers to the value obtained by substituting the corner point corresponding to the side equation into the algebraic expression on the left side of the side equation. For example, if the coordinates of the corner point corresponding to the side equation 3x-3y+2=0 are (2,1), then the result value corresponding to the side equation is the value obtained by substituting (2,1) into 3x-3y+2, which is 5.
[0075] Here, the "distance" of the corner point corresponding to the side equation to the corner point closest to the side equation refers to the closest distance to the side equation in the direction of the side equation.
[0076] like Figure 4 The diagram shown illustrates the implementation flow of a rasterization method provided in an embodiment of this application. Figure 3 In this embodiment of the application, before step S303, the rasterization method further includes step S401.
[0077] Step S401: Based on the equation coefficients of the edge equation and the coordinates of each corner point in the sub-block, determine the corner points corresponding to the edge equation.
[0078] Here, the coefficients of an equation refer to the coefficient of each term. For example, if the equation is 3x - 2y + 1 = 0, then the coefficients include the coefficient of the x term (3) and the coefficient of the y term (-2).
[0079] Each edge equation of a primitive has a direction, including positive and negative directions. Connecting the edge equations sequentially along rays with defined directions yields a closed figure. This closed figure is similar to the primitive, meaning it is identical in shape but not necessarily in size.
[0080] In this embodiment, firstly, the slope of the edge equation is determined based on its coefficients. If the slope is non-negative, the edge equation is in a positive direction; if the slope is negative, the edge equation is in a negative direction. Secondly, the distance from the corner point to the line containing the edge equation is obtained based on the coordinates of the corner point of the sub-plot. Thirdly, the corner point corresponding to the edge equation is obtained based on the direction of the edge equation and the distance to the corner point. If the edge equation is in a positive direction, the corner point corresponding to the minimum distance value is determined; if the edge equation is in a negative direction, the corner point corresponding to the maximum distance value is determined.
[0081] In some embodiments, the corner points corresponding to the edge equations are determined based on the equation coefficients of the edge equations and the coordinates of some corner points in the sub-tile. These partial corner points can be corner points on the edges of the sub-tile, or corner points at the four corners of the sub-tile.
[0082] It should be noted that the corner points of a sub-tile refer to the pixels at the four corners of the sub-tile. For example, a 4x4 pixel sub-tile contains 16 pixel coordinates: (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). Therefore, the coordinates of the four corner points of this sub-tile are the pixels corresponding to (1,1), (1,4), (4,1), and (4,4).
[0083] Taking the aforementioned corner points as the four corner points of a sub-plot, and the equation of one side of the primitive being 2x - y - 2 = 0, with the coordinates of the four corner points of the sub-plot being (1, 1), (1, 4), (4, 1), and (4, 4), firstly, based on the coefficient of the x-term being 2 and the coefficient of the y-term being -1, the slope of the side equation is determined to be 2, thus determining that the side equation is in the positive direction. Secondly, the distance from the corner point coordinate (1, 1) to the line containing 2x - y - 2 = 0 is determined to be... The distance from the corner point (1, 4) to the line containing 2x - y - 2 = 0 is determined as follows. The distance from the corner point (4, 1) to the line containing 2x - y - 2 = 0 is determined as follows. The distance from the corner point (4, 4) to the line containing 2x - y - 2 = 0 is determined to be... Next, based on the fact that the side equation is in the positive direction, the minimum distance value is determined. The corresponding corner point (1, 1) is the corner point corresponding to the side equation 2x-y-2=0.
[0084] Step S304: Determine the judgment result of the sub-block based on the result value corresponding to the equation of each side.
[0085] Here, for a subplot, if the result value corresponding to the equation of each side is greater than 0, the judgment result of the subplot is yes; otherwise, the judgment result is no.
[0086] In this embodiment, based on the coordinates of each side equation and the corresponding corner point, the result value corresponding to each side equation is determined, and the corner point corresponding to the side equation is the corner point closest to the side equation. Based on the result value corresponding to each side equation, the judgment result of the sub-block is determined. By comparing the positional relationship between the corner point closest to the side equation and the side equation, the workload and computational resources of comparing other corner points of the sub-block with the side equation are eliminated. Based on the positional relationship between each side equation and the corresponding corner point, it is determined whether the sub-block is at least partially covered by primitives. This reduces the workload of determining the target sub-block in the sub-block and improves the efficiency of determining pixels covered by primitives within the block. Correspondingly, as the number of positional relationships between corner points and side equations that need to be judged decreases, resource consumption is also reduced, thus reducing the cost of rasterization.
[0087] Step S302: Determine the target sub-plot as the sub-plot whose characteristics at least partially overlap with the primitives.
[0088] Here, if the judgment result is yes, the sub-plot represents at least partial overlap with the primitive, and then the sub-plot is determined as the target sub-plot. If the judgment result is no, the sub-plot represents no partial overlap with the primitive.
[0089] In this embodiment, the judgment result of each sub-block is determined based on the first region information of each sub-block and the second region information of the primitive. The first region information is used to characterize the region range of the sub-block, and the second region information is used to characterize the region range of the primitive. Sub-blocks whose judgment results indicate that the sub-block and the primitive at least partially overlap are identified as target sub-blocks. By determining the region range of the sub-block and the region range of the primitive, it is determined whether the two at least partially overlap, which reduces the resource consumption and workload of primitive coverage judgment for each pixel of the uncovered sub-block. The operation is simple, requires less workload and computing resources, and improves the efficiency of determining pixels covered by primitives within the block.
[0090] like Figure 5 The diagram shown illustrates the implementation flow of a rasterization method provided in an embodiment of this application. Figure 4 In the embodiments of this application, based on Figure 2 Step S203 includes at least steps S501 to S503.
[0091] Step S501: Determine at least one judgment benchmark value corresponding to the primitive of the target sub-block.
[0092] Here, the judgment reference value is used as a reference value to determine the positional relationship between a pixel and the edge of a primitive. The number of judgment reference values can be equal to the number of edges of the primitive. In other words, one judgment reference value is set for each edge of the primitive.
[0093] In some embodiments, the criterion value for judging a single edge of a primitive can be the same for multiple target sub-blocks, or they can be set separately. This application does not impose any specific restrictions on this.
[0094] For example, if a map includes a first sub-map and a second sub-map, then the criterion value for judging the first edge of both the first and second sub-maps can be determined to be s1. As another example, the criterion value for judging the first edge of the first sub-map is determined to be s2, and the criterion value for judging the second sub-map is determined to be s... 3。
[0095] Step S502: Based on the judgment benchmark value of the target sub-block, obtain at least one judgment value for each pixel corresponding to the primitive.
[0096] Here, the judgment value is used to characterize the positional relationship between the pixel and the edge of the primitive.
[0097] For a target sub-plot, the number of judgment reference values is the same as the number of judgment values for each pixel corresponding to the primitive.
[0098] For example, if a map includes a first sub-map, the first sub-map includes a pixel p1, and the primitive includes a first side, a second side, and a third side, and the judgment benchmark value of the first sub-map corresponding to the first side is s1, the judgment benchmark value of the first sub-map corresponding to the second side is s2, and the judgment benchmark value of the first sub-map corresponding to the third side is s3, then, based on the judgment benchmark value s1, the judgment value of pixel p1 corresponding to the first side is s1'; based on the judgment benchmark value s2, the judgment value of pixel p1 corresponding to the second side is s2'; and based on the judgment benchmark value s3, the judgment value of pixel p1 corresponding to the third side is s3'.
[0099] Step S503: Determine at least one pixel whose judgment value characterization pixel point is located within the primitive as the target pixel point of the target sub-plot.
[0100] Here, if at least one judgment value is greater than 0, it indicates that the pixel is located within the primitive, and the pixel is determined as the target pixel of the target sub-plot; if at least one judgment value is less than or equal to 0, it indicates that the pixel is not located within the primitive.
[0101] For example, if a target sub-plot contains a pixel, and at least one judgment value of the pixel includes s1', s2' and s3', then if s1', s2' and s3' are all greater than zero, at least one judgment value indicates that the pixel is located within the primitive, and the pixel is determined as the target pixel of the target sub-plot.
[0102] In this embodiment, at least one judgment benchmark value corresponding to a primitive is determined for the target sub-block; based on the judgment benchmark value of the target sub-block, at least one judgment value corresponding to a primitive is obtained for each pixel; the pixel whose pixel is located within the primitive and is represented by at least one judgment value is determined as the target pixel of the target sub-block. It is only necessary to determine the relationship between the pixel and the benchmark position corresponding to the judgment benchmark value, without determining the specific position of the pixel, which reduces the resource consumption of representing the specific position of the pixel. It can be understood that the data length corresponding to the pixel is shortened, the reading workload is reduced, thereby improving the efficiency of rasterization.
[0103] like Figure 6 The diagram shown illustrates the implementation flow of a rasterization method provided in an embodiment of this application. Figure 5 .based on Figure 5 In the rasterization method of this application embodiment, step S501 may include at least step S601 and step S602; step S502 may include at least step S603.
[0104] Step S601: Determine the reference position information of the target sub-block.
[0105] Here, the reference position information represents a reference position used as a reference for determining the position of pixels within the target sub-plot.
[0106] In the embodiments of this application, the same reference position information can be determined for at least one target sub-block, or 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 inside the target sub-block or outside the target sub-block, and the embodiments of this application do not impose specific restrictions on this.
[0107] Step S602: Based on the reference position information and at least one edge information of the graphic element, determine at least one judgment reference value corresponding to the graphic element for the target sub-block.
[0108] Here, edge information indicates the position of the edge of the primitive.
[0109] Here, the reference position information represents a reference position, and the edge information represents the position of the edge of the primitive. Therefore, it can be understood that based on the reference position and the edge position, the relationship between the reference position and the edge position can be obtained. Accordingly, the relationship between the reference position and the edge position is used as the judgment benchmark value for the target sub-plot.
[0110] Step S603: Based on the position information and judgment benchmark value of each pixel of the target sub-block, obtain at least one judgment value for each pixel corresponding to the primitive.
[0111] Here, the position information of each pixel is used to represent the positional difference of the pixel relative to the reference position.
[0112] The judgment reference value represents the positional relationship between the reference position and the edge of the primitive. Therefore, by taking into account the positional difference between the pixel and the reference position, the positional relationship between the pixel and the edge of the primitive can be obtained. Correspondingly, the positional relationship between the pixel and the edge of the primitive is represented 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 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 the judgment reference value.
[0115] Here, the reference coordinates refer to the coordinates of the reference position.
[0116] Substituting into the side equation refers to substituting the algebraic expression on the left-hand side of a side equation when the side equation has two or three terms. In other words, substituting the algebraic expression on the left-hand side of a side equation where the right-hand side equals 0 can be understood as transforming any side equation into one where the right-hand side equals 0.
[0117] For example, if the reference coordinates are (2, 1) and one side's equation is x - 2y + 1 = 0, then substituting (2, 1) into x - 2y + 1 yields a judgment reference value of 1. If the reference coordinates are (2, 1) and one side's equation is y + 2 = 0, then substituting (2, 1) into y + 2 yields a judgment reference value of 3. If the reference coordinates are (2, 1) and one side's equation is y = 0.5x + 0.5, then transforming the equation of that side into x - 2y + 1 = 0, and then substituting (2, 1) into x - 2y + 1, yields a judgment reference value of 1.
[0118] Step S605: Based on the judgment benchmark value and each offset, obtain at least one judgment value for each pixel corresponding to the edge equation.
[0119] Here, the offset can be obtained from the reference coordinates and the pixel coordinates.
[0120] For example, the sub-offset of the pixel relative to the reference position in the horizontal direction is obtained by subtracting the horizontal coordinate of the reference coordinate from the horizontal coordinate of the pixel point; then the sub-offset of the pixel relative to the reference position in the vertical direction is obtained by subtracting the vertical coordinate of the reference coordinate from the vertical coordinate of the pixel point.
[0121] The determination of each pixel's corresponding edge equation involves substituting the pixel's value into a non-constant term of the edge equation, summing the resulting value with the baseline value, and obtaining the determination value for that pixel. In other words, the pixel's x-coordinate is substituted into the corresponding term of the edge equation, and the pixel's y-coordinate is substituted into the corresponding term of the edge equation. The sum of these two substitutions is then summed with the baseline value, and the result is the determination value for that pixel's corresponding edge equation. It should be noted that the substituted edge equation is transformed into a binomial or trinomial equation.
[0122] For example, if the pixel's offset from the reference position in the horizontal direction is 0.5, the pixel's offset from the reference position in the vertical direction is 0.5, and the edge equation is x-2y+1=0, then the judgment reference value 2 corresponds to this edge equation for the target sub-plot. Substituting the pixel's offset of 0.5 from the reference position in the horizontal direction into the x term yields a result of 0.5; substituting the pixel's offset of 0.5 from the reference position in the vertical direction into the -2y term yields a result of -1; the sum of these two results is -0.5. This sum of -0.5 is then added to the judgment reference value 2, and the result 1.5 is the judgment value for the pixel corresponding to the edge equation x-2y+1=0.
[0123] In this embodiment, the reference coordinates are substituted into the edge equation to obtain the judgment reference value; based on the judgment reference value and each offset, the judgment value corresponding to the edge equation for each pixel is obtained. Taking a screen space containing 16Kb*16Kb pixels, a target sub-block containing 4*4 pixels, and a primitive being a triangle as an example, based on the previous description of related technologies, it is known that in related technologies, the computational resources consumed for primitive coverage judgment of 16 pixels are 16*3*[W(A0)*14+W(B0)*14+W(C0)], and the number of calculations is 48; while in the technical solution of this embodiment, the computational resources required for coverage judgment of 16 pixels of a sub-block include The resource for determining whether a pixel is a target sub-plot and the resource for performing a coverage judgment on 16 pixels within it are calculated as follows: the resource for determining whether a pixel is a target sub-plot is 3*[W(A0)*14+W(B0)*14+W(C0)], where "3" represents the sub-result value obtained from the three edge equations; the resource for performing a coverage judgment on the 16 pixels is 16*3*[W(A0)+W(B0)], where "16*3" represents the judgment value obtained from the 16 pixels for the three edge equations. Since the coordinates of the pixels 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 resource W(C0). Therefore, the technical solution of this application embodiment reduces computational resource consumption. Furthermore, in the entire plot, for sub-plots not covered by primitives, the 3 calculations for determining whether a pixel is a target sub-plot replace the 48 calculations required for "performing a coverage judgment on 16 pixels," reducing the workload of determining covered pixels within the plot.
[0124] like Figure 7 The diagram shown illustrates the implementation flow of a rasterization method provided in an embodiment of this application. Figure 6 .based on Figure 2 Step S203 includes at least steps S701 and S702.
[0125] Step S701: Substitute the coordinates of each pixel into at least one side equation to obtain at least one judgment value.
[0126] Here, the above-mentioned substitution of the coordinates of each pixel 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, if a pixel has coordinates (2, 3) and its equation is x - 2y + 1 = 0, then substituting (2, 3) into x - 2y + 1 gives a value of -3.
[0128] Step S702: If at least one judgment value indicates that the pixel is located within the primitive, the pixel is determined as the target pixel.
[0129] Here, the technical solution for step S702 can refer to the implementation method of step S503 described above.
[0130] In other embodiments of this application, before step S201, the rasterization method further includes: obtaining the intersection information of the edge of the primitive and the block when the vertex information of the primitive indicates that the primitive part exceeds the block; generating at least one sub-primitive from the part of the primitive located within the block based on the vertex information and the intersection information, and using the sub-primitive as the primitive.
[0131] Here, vertex information of a primitive is used to indicate the position of its vertices, thus representing the region of the primitive. Intersection information indicates the intersection points between the primitive and the tile, which are used as vertices of sub-primitives.
[0132] In some embodiments, the vertex information of a primitive includes the vertex coordinates of the primitive, and the block includes coordinate range data. The vertex coordinates of the primitive are compared with the coordinate range data of the block. If there are vertex coordinates that exceed the coordinate range data, it indicates that the primitive partially exceeds the block.
[0133] For example, if the vertex coordinates of a primitive include (1, 1), (8, 3), and (5, 6), and the coordinate range of the block is x-coordinate greater than or equal to 1 and less than or equal to 4, then comparing (1, 1) with this coordinate range results in no excess; then comparing (8, 3) with this coordinate range results in excess since 8 is greater than 4. Therefore, (8, 3) is the vertex coordinate that exceeds the coordinate range, and thus, it is concluded that the primitive partially exceeds the block.
[0134] In some embodiments, the intersection information includes intersection coordinates. Accordingly, based on the vertex coordinates of the primitive, the coordinates of multiple pixels containing the edges of the primitive are determined sequentially, with every two pixels in sequence forming a group of pixel coordinates; multiple edge coordinates of the patch are determined based on the patch's coordinate range data; at least one group of pixel coordinates is obtained where one pixel is outside the patch and one pixel is inside the patch, and the pixel coordinates within the patch in this at least one group of pixel coordinates are the intersection coordinates. Specifically, in the phrase "every two pixels in sequence forming a group of pixel coordinates," the second pixel coordinate of the first group is the first pixel coordinate of the second group.
[0135] It should be noted that "in order" in "determining the coordinates of multiple pixels where the edges of the primitives are located in order" can be from the first vertex to the second vertex or from the second vertex to the first vertex, and this application does not limit it in this way.
[0136] For example, if the vertex coordinates of a primitive include (1,1), (8,3), and (5,6), and the coordinate range of the primitive is x-coordinate greater than or equal to 1 and less than or equal to 4, and y-coordinate greater than or equal to 1 and less than or equal to 4, then the pixel coordinates determined in order 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 coordinates determined in order 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); and the pixel coordinates determined in order based on (5,6) and (8,3) include (5,5), (6,4), and (7,3). The edge coordinates are then 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). Correspondingly, a set of pixel coordinates (1,1) and (2,1) are taken, both of which are within the tile. Then, another set of pixel coordinates (2,1) and (3,1) are taken sequentially, both of which are within the tile. Continuing to take another set of pixel coordinates sequentially and determining the relationship between the included pixel coordinates and the tile, it can be seen that for a set of pixel coordinates (4,2) and (5,2), pixel coordinate (4,2) is within the tile, while pixel coordinate (5,2) is outside the tile. Therefore, the pixel coordinate (4,2) within the tile is determined as the intersection point. Similarly, we can see that for a set of pixel coordinates (3, 4) and (4, 4), pixel coordinate (3, 4) is inside the tile, while pixel coordinate (4, 4) is outside the tile. Therefore, the pixel coordinate (3, 4) inside the tile is determined to be the intersection point coordinate.
[0137] In some embodiments, at least one sub-primitive is generated based on the coordinates of at least one intersection point, the coordinates of the corner points of the tile, and the coordinates of the vertices located within the tile.
[0138] In this embodiment, when the vertex information of a primitive indicates that the primitive part extends beyond the block, the intersection information between the primitive edge 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 within the block. The sub-primitive is used as a primitive, which avoids the problem that the part of the primitive located within the block has a complex shape, such as a quadrilateral or pentagon, which increases the computational difficulty of coverage judgment. By generating at least one sub-primitive for the part located within the block and rasterizing the sub-primitive as a primitive, the computational difficulty is reduced, the computational steps are reduced, the resource consumption of primitive rasterization is reduced, and the efficiency of primitive rasterization is improved.
[0139] like Figure 8The diagram shown illustrates the implementation flow of a rasterization method provided in an embodiment of this application. Figure 7 Before step S201, and / or after the sub-primitives are used as primitives, the rasterization method may further include steps S801 and S802.
[0140] Step S801: Based on the vertex information of the primitives and the tiles, the primitives are converted from tiles to intermediate tiles. The intermediate tiles are used to represent the tile region information of any tile.
[0141] Here, the conversion of primitives to intermediate tiles is achieved by converting the vertices of the primitives to the intermediate tiles. In some embodiments, a coordinate system is established in the screen space to be rendered, containing multiple tiles arranged in an array. The tile where the origin is located can be used as an intermediate tile. Accordingly, vertex information includes vertex coordinates. Based on the vertex coordinates and the tile, the vertex coordinates are converted to the intermediate tile. In these embodiments, conversion parameters between the tile and the intermediate tile are determined. The conversion parameters include a horizontal parameter TILE_X and a vertical parameter TILE_Y. The horizontal parameter TILE_X represents the difference between the column number of the tile and the column number of the intermediate tile; the vertical parameter TILE_Y represents the difference between the row number of the tile and the row number of the intermediate tile. The vertex coordinates are converted from the tile to the intermediate tile based on the conversion parameters. In other words, if the tile is in the (TILE_X+1)th column and the (TILE_Y+1)th row of the array of tiles, then the tile is in the (TILE_X+1)th column and the (TILE_Y+1)th row of the array of tiles.
[0142] Step S802: Use the intermediate tile as a tile.
[0143] Here, "using the intermediate tile as a tile" means that the subsequent pixel coverage determination is performed on the intermediate tile; in other words, the coordinate representation of the pixels is completed within this intermediate tile. It can be understood that after step S203, the rasterization method further includes: converting pixels covered by primitives within the tile to the original tile. Here, the original tile is the tile before it was converted to the intermediate tile.
[0144] In some embodiments, "converting pixels covered by primitives within a tile to the original tile" can refer to the implementation of "converting primitives from a tile to an intermediate tile" in step S801. It is understood that step S803 is the inverse coordinate transformation of step S801. For example, if a tile contains 32*32 pixels, and the coordinates of a pixel 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 this embodiment, based on the vertex information of the primitive and the tile, the primitive is converted from a tile to an intermediate tile. The intermediate tile is used to represent the tile area information of any tile. Since the intermediate tile can represent any tile, its position range corresponds to a tile. Within this tile, a pixel is represented. Compared with the related technology, which represents a pixel in the entire screen space, the bit width of the pixel is reduced. Taking a screen space containing 16Kb*16Kb pixels and an intermediate tile containing 32*32 pixels as an example, representing a pixel position in the screen space requires 14 binary bits, while representing a pixel position in the intermediate tile only requires 5 binary bits. Therefore, it can be seen that when performing pixel coverage judgment, the computational resources required to substitute the pixel coordinates into the edge equation are W(A0)*5+W(B0)*5+W(C0), which is lower than the computational resources required by related technologies of W(A0)*16+W(B0)*16+W(C0), thus reducing the consumption of computational resources and saving costs.
[0146] Based on the foregoing embodiments, this application provides an apparatus comprising the included units and the modules included in each unit, which can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0147] Figure 9 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 1 The rasterization device 100 includes a partitioning unit 110, a first determining unit 120, and a second determining unit 130, wherein: the partitioning unit 110 is used to partition a block and determine at least one sub-block; the first determining unit 120 is used to determine at least one target sub-block in the at least one sub-block; the target sub-block is at least partially covered by primitives, wherein the primitives are primitives projected onto the block; the second determining unit 130 is used to determine target pixels covered by primitives in the at least one target sub-block to obtain the target pixels covered by primitives within the block.
[0148] In some embodiments, the first determining unit 120 is further configured to obtain vertex information of a primitive, wherein the vertex information can characterize the coverage area of the primitive; the first determining unit 120 is further configured to determine the coordinate information of each sub-block; correspondingly, the first determining unit 120 is further configured to compare the coordinate information of the sub-block with the vertex information, and if the comparison result indicates that the primitive covers at least one pixel of the sub-block, the first determining unit 120 is further configured to determine the sub-block as the target sub-block.
[0149] In some embodiments, the first determining unit 120 is further configured to determine, based on the vertices of the primitives, whether there are pixels at edge positions covered by the primitives within the sub-block using the right-hand rule. If there are pixels at edge positions covered by the primitives, the first determining unit 120 is further configured to determine the sub-block as the target sub-block.
[0150] In some embodiments, the first determining unit 120 is further configured to determine the judgment result of each sub-map block based on the first region information of each sub-map block and the second region information of the graphic element, wherein the first region information is used to characterize the region range of the sub-map block and the second region information is used to characterize the region range of the graphic element; and to determine the sub-map block whose judgment result indicates that the sub-map block and the graphic element at least partially overlap as the target sub-map block. In some embodiments, the first determining unit 120 is further configured to determine the result value corresponding to each side equation based on each side equation and the coordinates of the corner point corresponding to the side equation, wherein the corner point corresponding to the side equation is the corner point closest to the side equation; and to determine the judgment result of the sub-map block based on the result value corresponding to each side equation.
[0151] Figure 10 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 2 In some embodiments, the rasterization device further includes a third determining unit 140, which is used to 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.
[0152] In some embodiments, the third determining unit 140 is further configured to determine the slope of the side equation based on the equation coefficients of the side equation; obtain the distance value between the corner point and the line where the side equation is located based on the coordinates of the corner point of the sub-plot; and obtain the corner point corresponding to the side equation based on the direction of the side equation and the distance value of the corner point.
[0153] In some embodiments, the second determining unit 130 is further configured to determine at least one judgment benchmark value corresponding to a primitive for the target sub-block; based on the at least one judgment benchmark value of the target sub-block, obtain at least one judgment value corresponding to a primitive for each pixel; and determine the pixel whose at least one judgment value indicates that the pixel is located within the primitive as the target pixel of the target sub-block.
[0154] In this embodiment, at least one judgment benchmark value corresponding to a primitive is determined for the target sub-block; based on the judgment benchmark value of the target sub-block, at least one judgment value corresponding to a primitive is obtained for each pixel; the pixel whose pixel is located within the primitive and is represented by at least one judgment value is determined as the target pixel of the target sub-block. It is only necessary to determine the relationship between the pixel and the benchmark position corresponding to the judgment benchmark value, without determining the specific position of the pixel, which reduces the resource consumption of representing the specific position of the pixel. It can be understood that the data length corresponding to the pixel is shortened, the reading workload is reduced, thereby improving the efficiency of rasterization.
[0155] In some embodiments, the second determining unit 130 is further configured to determine the reference position information of the target sub-block; and based on the reference position information and at least one edge information of the element, determine at least one judgment reference value corresponding to the element of the target sub-block.
[0156] In some embodiments, the second determining unit 130 is further configured to obtain a judgment value corresponding to a primitive for each pixel based on the position information of each pixel of the target sub-plot and the judgment benchmark value.
[0157] In some embodiments, the second determining unit 130 is further configured to substitute the reference coordinates into the side equation to obtain the judgment reference value.
[0158] In some embodiments, the second determining unit 130 is further configured to obtain a judgment value for each pixel corresponding to the edge equation based on the judgment reference value and each offset.
[0159] In some embodiments, the second determining unit 130 is further configured to substitute the coordinates of each pixel into the edge equation to obtain a judgment value; and if the judgment value indicates that the pixel is located within the primitive, the pixel is determined as the target pixel.
[0160] Figure 11 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 3 In some embodiments, the rasterization apparatus further includes a generation unit 150, which is used to obtain the intersection information between the edge of the primitive and the block when the vertex information of the primitive indicates that the primitive part exceeds the block; based on the vertex information and the intersection information, generate at least one sub-primitive for the part of the primitive located within the block, and use the sub-primitive as the primitive.
[0161] Figure 12 A schematic diagram of the composition structure of a rasterization device provided in this application embodiment. Figure 4 In some embodiments, the rasterization device further includes a conversion unit 160, which is used to convert primitives from tiles to intermediate tiles based on the vertex information of primitives and tiles, wherein the intermediate tiles are used to represent the tile region information of any tile; and the intermediate tiles are used as tiles.
[0162] The descriptions of the apparatus embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. In some embodiments, the functions or modules included in the apparatus provided in this application can be used to perform the methods described in the method embodiments above. For technical details not disclosed in the apparatus embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0163] It should be noted that, in the embodiments of this application, if the above-described rasterization method is implemented as a software functional 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 this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the rasterization methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.
[0164] The following example, using a triangular primitive, a screen containing 16Kb*16Kb pixels, and each block containing 32*32 pixels, illustrates the application of the rasterization method provided in this application in a real-world scenario.
[0165] like Figure 13 The diagram illustrates the workflow of the rasterization method provided in this application embodiment. Figure 1 A rasterization method, applied to a rasterization device, may include at least the following steps:
[0166] Step S1301: Obtain the vertex coordinates of the triangle primitive projected onto the screen, and the position information of the target tile containing the triangle primitive relative to the tile containing the screen coordinate origin.
[0167] Here, the rasterization device can be, but is not limited to, a graphics processing unit (GPU) or other device used to implement the rasterization of primitives.
[0168] Step S1302: Based on the position information and vertex coordinates, transform the vertex coordinates to the tile where the screen coordinate origin is located to obtain the judgment coordinates.
[0169] Here, the coordinates refer to the coordinates of the tile where the screen coordinate origin is located. In this embodiment, step S1302 is used to translate the triangular primitive from the target tile to the tile where the screen origin is located.
[0170] For example, Figure 14 for Figure 13 A schematic diagram illustrating coordinate transformation in rasterization methods. (See diagram below.) Figure 14 As shown, a global coordinate system is established in the screen display area. The origin of the global coordinate system is the upper left corner of the screen display area, and the positive direction of the x-axis is the direction pointing from the upper left corner to the upper right corner of the screen display area. After rotating the x-axis 90 degrees clockwise, the positive direction is the positive direction of the y-axis. In other words, the x-axis can be understood as the horizontal direction shown in the figure, and the y-axis can be understood as the vertical direction shown in the figure. Each tile in the screen display area consists of 32*32 pixels.
[0171] In this embodiment of the application, a triangular primitive is projected onto the screen. The rasterization device acquires the target tile projected onto the screen (the tile in the lower right corner shown in the figure), and determines the primitive coordinates of the three vertices of the triangular primitive as (x1, y1), (x2, y2) and (x3, y3) respectively. The position information of the target tile relative to the tile at the screen coordinate origin (0, 0) can be determined based on the coordinates of the upper left corner point O of the target tile.
[0172] Accordingly, the rasterization device performs 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). Here, TILE_X is the integer part of the quotient of the x-coordinate of the top-left corner point O and 32, and TILE_Y is the integer part of the y-coordinate of the top-left corner point O and 32. In other words, TILE_X is the (X+1)th column of the target tile in the entire screen's tile matrix, and TILE_Y is the (Y+1)th row of the target tile in the entire screen's tile matrix, which is the (X+1)th column and (Y+1)th row of the target tile in the entire screen's tile matrix. For example, in the image, TILE_X is 1 and TILE_Y is 1.
[0173] In this embodiment, the target tile is translated to the tile where the screen coordinate origin is located, and the coverage of the pixel is determined by judging the coordinates. Since the coordinate range of the tile where the screen coordinate origin is located is 0 to 32, compared with the related technology, which requires 14 bits to represent the pixel coordinates of the entire screen, this technical solution only requires 5 bits to represent the pixel coordinates of a tile, thus completing the granular normalization of the pixel coordinates and saving one-third of the computing resources compared with the related technology.
[0174] Step S1303: Based on the judgment coordinates, determine the side equations of the three sides of the triangle primitive respectively; split the tile where the screen coordinate origin is located into at least one sub-tile, and determine the corner point corresponding to each side equation for each sub-tile.
[0175] For example, Figure 15 for Figure 13 A schematic diagram illustrating sub-tile coverage determination in rasterization methods. (See diagram below.) Figure 15 As shown, the equation of the first side determined based on (x1, y1) and (x2, y2) is A1*x + B1*y + C1 = 0, the equation of the second side determined based on (x2, y2) and (x3, y3) is A2*x + B2*y + C2 = 0, and the equation of the third side determined based on (x3, y3) and (x1, y1) is A3*x + B3*y + C3 = 0. The first image tile is divided into 8*8 sub-tiles n, each sub-tile n containing 4*4 pixels. Taking the sub-tile in the first row and second column of the first image tile as an example, the corner point corresponding to the first side equation is determined as corner point B, the corner point corresponding to the second side equation is determined as corner point C, and the corner point corresponding to the third side equation is determined as corner point A. Accordingly, the corner points corresponding to each side equation are determined for each of the 8*8 sub-tiles n, that is, each sub-tile determines three corner points, and each corner point has a corresponding side equation. It should be noted that corner point A in the figure is the upper right corner of the sub-block, corner point C in the figure is the upper left corner of the sub-block, and corner point B in the figure is the lower left corner of the sub-block.
[0176] The corner points corresponding to each side equation are determined based on the coefficients in the side equations. For the side 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 bottom left corner point of the sub-plot;
[0178] When A0>0 and B0≤0, the corner point corresponding to the edge equation is the bottom right corner point of the sub-plot;
[0179] When A0 < 0 and B0 ≥ 0, the corner point corresponding to the edge equation is the top-left corner point of the sub-plot;
[0180] When A0≤0 and B0<0, the corner point corresponding to the edge equation is the upper right corner point of the sub-plot.
[0181] Step S1304: Substitute each corner point of the sub-block into the corresponding edge equation to obtain the substitution result for each edge equation, so as to determine whether the sub-block is a target sub-block that is at least partially covered by the triangular primitive.
[0182] For example, see [link to previous article] Figure 15The triangle coverage judgment for the sub-tile n located in the first row and second column of the first tile includes: substituting the judgment coordinates (0, 4) of corner point B into the equation of the first side, which is A1*4 + B1*0 + C 1= 4A1+C1; Substituting the coordinates (0, 0) of corner point C into the equation of the second side, we get A2*4+B2*0+C 2= Substituting the coordinates (4, 0) of corner point A into the equation of the third side, we get A3*4 + B3*0 + C3 = 4A3 + C3. Since the results 4A1 + C1, 4A2 + C2, and 4A3 + C3 are all greater than zero, we conclude that the sub-block n located in the first row and first column of the first tile is covered by a triangular primitive. Accordingly, the above triangular coverage judgment is performed on each sub-block of the first tile to determine the target sub-block covered by the triangular primitive.
[0183] It should be noted that within a given tile, the relative positions of the corner points of each sub-tile determined based on the same side equation are consistent with those corresponding to that side equation. For example, if the corner point of the first sub-tile determined based on the same side equation is the top-left corner, then the corner point of the second sub-tile determined based on the same side equation is also the top-left corner.
[0184] In this embodiment, based on the determined coordinates, the edge equations of the three sides of the triangular primitive are determined respectively; the tile where the screen coordinate origin is located is divided into at least one sub-tile, and the corner point corresponding to each edge equation is determined for each sub-tile; each corner point of the sub-tile is substituted into the corresponding edge equation to obtain the substitution result corresponding to each edge equation, so as to determine whether the sub-tile is a target sub-tile at least partially covered by the triangular primitive. For the sub-tile not covered by the primitive, the number of times the pixel coverage determination is calculated is 3, that is, 3 times the corner point is substituted into the edge equation. The computation time and resource consumption of the equation are 3*[W(A0)*5+W(B0)*5+W(C0)]. Compared with related technologies, for sub-tiles not covered by primitives, the computation time to complete the pixel coverage judgment is 16*3 times, that is, 16 pixels are substituted into 3 edge equations, 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-tiles of a tile are effectively reduced.
[0185] Figure 16 for Figure 13 A schematic diagram of the target sub-pattern in the rasterization method. (See diagram below.) Figure 16 As shown, sub-tile n1 is the target sub-tile, and sub-tile n2 is a sub-tile not covered by triangular primitives. Figure 16In this context, the target sub-blocks are those with diagonal background lines and triangle primitives. Sub-blocks without diagonal background lines are not target sub-blocks. It should be noted that the diagonal background lines under triangle primitives are omitted.
[0186] Step S1305: Substitute the judgment coordinates of each pixel of the target sub-block into the equation of each side of the triangle primitive to obtain the substitution result corresponding to each side equation, and determine the pixel covered by the triangle primitive based on the substitution result.
[0187] For example, such as Figure 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 pixels of this 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 equation of the three sides of the triangular primitive, and determines whether each pixel is covered by the triangular primitive based on the substitution result. Taking the pixel coordinates (4, 4) as an example, substituting (4, 4) into the first side equation A1*x+B1*y+C1=0 yields 4A1+4B1+C1; substituting (4, 4) into the second side equation A2*x+B2*y+C2=0 yields 4A2+4B2+C2; substituting (4, 4) into the third side equation A3*x+B3*y+C3=0 yields 4A3+4B3+C3. Based on the substitution results 4A1+4B1+C1, 4A2+4B2+C2, and 4A3+4B3+C3, if all the substitution results are greater than zero, the pixel is covered by a triangular primitive.
[0188] In this embodiment, by translating the target tile to the tile located at the origin of the screen coordinates, the primitive coordinates are converted into judgment coordinates. Compared to related technologies that require 16 bits to represent the pixel coordinates of a tile, this technical solution only requires 5 bits to represent the pixel coordinates of a tile. Correspondingly, representing the coordinates of a sub-tile also only requires 5 bits. It can be deduced that in this embodiment, the computational resources required to determine whether each pixel of a sub-tile is covered by a triangular primitive are: 16*3*[W(A0)*5+W(B0)*5+W(C0)], where "5" corresponds to the bit width representing the judgment coordinates of a pixel. Compared to the computational resources required by related technologies, which are 16*3*[W(A0)*14+W(B0)*14+W(C0)], this effectively reduces resource consumption and improves resource utilization.
[0189] In some embodiments, step S1305 can be implemented through steps S1307 and S1308.
[0190] Step S1307: In each target sub-block, determine one vertex of the first pixel as the coordinate base point, substitute the judgment coordinates of the coordinate base point into the equation of each side of the triangle primitive, and obtain the equation base value corresponding to each side equation.
[0191] Here, the first pixel refers to the pixel in the target sub-plot that is closest to the origin of the judgment coordinates.
[0192] Step S1308: Based on the equation base value corresponding to each side equation and the judgment coordinates of the coordinate base point, obtain the substitution result of each pixel point corresponding to the side equation, and determine the pixel points covered by the triangle primitive based on the substitution result.
[0193] Here, the substitution result of the edge equation for each pixel is the result of substituting the center position of each pixel as its judgment coordinate point into the edge equation.
[0194] For example, see below. Figure 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 steps S1307 and S1308 is explained. The first pixel is the pixel located in the first row and first column of the target sub-block. The rasterization device determines the upper left vertex of the first pixel as the coordinate base point. The judgment coordinates of the coordinate base point are (4, 4). Substituting (4, 4) into the first side equation A1*x+B1*y+C1=0, we get 4A1+4B1+C1, which is used as the base value base1 of the first equation; substituting (4, 4) into the second side equation A2*x+B2*y+C2=0, we get 4A2+4B2+C2, which is used as the base value of the second equation; substituting (4, 4) into the third side equation A3*x+B3*y+C3=0, we get 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 base point, the substitution results of the equation for the 16 pixels are obtained, which are 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's base value is base1+0.5A1+1.5B1, the first equation's base value is base1+1.5A1+1.5B1, the first equation's base value is base1+2.5A1+1.5B1, and the first equation's base value is base1+3.5A1+1.5B1.
[0197] The first equation's base value is base1+0.5A1+2.5B1, the first equation's base value is base1+1.5A1+2.5B1, the first equation's base value is base1+2.5A1+2.5B1, the first equation's base value is base1+3.5A1+2.5B1;
[0198] The first equation's base value is base1+0.5A1+3.5B1, the first equation's base value is base1+1.5A1+3.5B1, the first equation's base value is base1+2.5A1+3.5B1, the first equation's base value is base1+3.5A1+3.5B1.
[0199] Based on the base value of the second equation and the judgment coordinates (4, 4) of the base point, the substitution results of 16 pixels corresponding to the equation of this side are obtained. Based on the base value of the third equation and the judgment coordinates (4, 4) of the base point, the substitution results of 16 pixels corresponding to the equation of this side are obtained. The above technical solution of "based on the base value of the first equation and the judgment coordinates (4, 4) of the base point, the substitution results of 16 pixels corresponding to the equation of this side" can be referred to.
[0200] In a target sub-plot, based on the three substitution results of the three side equations corresponding to each pixel, if all three substitution results are greater than zero, the pixel is covered by a triangle primitive. Correspondingly, all pixels in a target sub-plot that are covered by triangle primitives can be determined.
[0201] Accordingly, such as Figure 17 As shown, Figure 13 This is a schematic diagram illustrating all pixels covered by triangular primitives in the rasterization method. It can be understood that by performing the aforementioned triangular primitive coverage judgment on each pixel of each target sub-block, all pixels covered by triangular primitives can be obtained.
[0202] In this embodiment, a vertex of the first pixel in the target sub-block is determined as the coordinate base point. The judgment coordinates of the coordinate base point are substituted into the equation of each side of the triangle primitive to obtain the equation base value corresponding to each side equation. The computational resources consumed are 3*(W(A0)*5+W(B0)*5+W(C0)). Based on the equation base value corresponding to each side equation and the judgment coordinates of the coordinate base point, the substitution result of each pixel corresponding to the side equation is obtained. Since the coordinates of each pixel do not affect the constant term in the side equation, there is no need to consume the computational resources of the constant term. Therefore, the computational resources are 16*(W(A0)+W(B0)), which compresses the hardware overhead of implementing "substituting the judgment coordinates of each pixel in each target sub-block into the equation of each side of the triangle primitive, and determining the pixel covered by the triangle primitive based on the substitution result".
[0203] Step S1306: Based on the location information, convert the judgment coordinates of the pixels covered by the triangular primitive into the original coordinates, and the original coordinates are located in the target tile.
[0204] Here, step S1306 is to perform the opposite transformation of the judgment coordinates of the pixels covered by the triangular primitive to step S1302. In other words, step S1302 transforms the coordinates from the target tile to the tile where the screen coordinate origin is located, and step S1306 transforms the coordinates from the tile where the screen coordinate origin is located to the target tile.
[0205] For example, if the coordinates of a pixel are P(P... x0 P y0 ), then its original primitive coordinates are: P' = (P x0 ', P y0 ')=(P x0 +32*TILE_X, P y0 +32*TILE_Y), where TILE_X is the integer division of the x-coordinate of the top-left corner of the target tile where point P is located and 32, and TILE_Y is the integer division of the y-coordinate of the top-left corner of the target tile where point P is located and 32.
[0206] In this embodiment of the application, taking a triangular primitive and a 32Kb*32Kb block as an example, in related technologies, the number of rasterization calculations for the pixels of a block is 32*32*3 = 3072 times. Figure 14 In the example, when using the rasterization method implemented in steps S1307 and S1308, the number of target sub-blocks is 25. Then, the number of rasterization calculations for the pixels of one block is 8*8*3+25*16*3=1392 times. Here, "25" represents 25 target sub-blocks, "16" represents 16 pixels, and "3" represents that the pixel coordinates are substituted into the three side equations respectively, which reduces 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] Meanwhile, in the rasterization method including steps S1307 and S1308, the computational resources required to determine the primitive coverage of 16 pixels are 3*(W(A0)*5+W(B0)*5+W(C0))+16*(W(A0)+W(B0)), where the meaning of computational resources is explained in the aforementioned step S605. Compared with related technologies, the computational resources required to determine the primitive coverage of 16 pixels are 16*3*(W(A0)*14+W(B0)*14+W(C0)). It can be seen that the technical solution of this application embodiment reduces the computational resources required for primitive rasterization. The reduced resource consumption mainly includes: primitive coverage determination of pixels in sub-blocks not covered by triangular primitives; and the operation width of the Arithmetic Logical Unit (ALU).
[0208] This application provides a graphics processor, which includes the aforementioned rasterization device.
[0209] This application provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method.
[0210] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium can be transient or non-transient.
[0211] This application provides a computer program including computer-readable code, wherein when the computer-readable code is executed in a computer device, a processor in the computer device performs some or all of the steps in the above-described method.
[0212] This application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0213] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referred to interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. 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 descriptions of the method embodiments of this application for understanding.
[0214] Figure 18 This application provides a hardware entity diagram of a computer device as an embodiment of the present application, such as... Figure 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 run on the processor 1801, and the processor 1801 executes the program to implement the steps in the method of any of the above embodiments.
[0215] The memory 1802 stores computer programs that can run on the processor. The memory 1802 is configured to store instructions and applications that can be executed by the processor 1801. It can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) in the processor 1801 and various modules in the computer device 1800. It can be implemented by flash memory or random access memory (RAM).
[0216] The processor 1801 executes the steps of any of the above-mentioned rasterization methods when executing a program. The processor 1801 typically controls the overall operation of the computer device 1800.
[0217] This application provides a computer storage medium storing one or more programs that can be executed by one or more processors to implement the steps of the rasterization method as described in any of the above embodiments.
[0218] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0219] The aforementioned processor can be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that other electronic devices can also implement the functions of the aforementioned processor, and this application does not specifically limit the specific implementation.
[0220] The aforementioned computer storage media / memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various terminals that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0221] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above steps / processes do not imply a sequential order of execution; 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 embodiments of this application. The sequence numbers of the above embodiments of this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0222] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0223] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0224] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0225] Furthermore, in the various embodiments of this application, all functional units 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 integrated unit can be implemented in hardware or in a combination of hardware and software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0226] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the rasterization method described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0227] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A rasterization method, characterized by, The rasterization method is applied to a graphics processor and comprises the following steps: dividing a tile into at least one sub-tile; determining at least one target sub-tile in the at least one sub-tile; the target sub-tile is at least partially covered by a primitive; the primitive is a primitive projected on the tile; determining target pixel points in at least one target sub-tile covered by the primitive to obtain pixel points in the tile covered by the primitive; each target sub-tile comprises at least one pixel point, and the determination of the target pixel points in the at least one target sub-tile covered by the primitive comprises the following steps: determining at least one judgment reference value corresponding to the target sub-tile and the primitive; the at least one judgment reference value represents a positional relationship between a reference position and each side of the primitive; obtaining at least one judgment value corresponding to each pixel point and the primitive based on an offset of each pixel point and the at least one judgment reference value of the target sub-tile; the offset is an offset between the pixel point and the reference position; determining a target pixel point of the target sub-tile as a pixel point located in the primitive based on the at least one judgment value.
2. The rasterizing method of claim 1, wherein, The determination of the at least one target sub-tile in the at least one sub-tile comprises the following steps: determining a judgment result of each sub-tile based on first area information of each sub-tile and second area information of the primitive; the first area information is used to represent an area range of the sub-tile, and the second area information is used to represent an area range of the primitive; determining a target sub-tile as a sub-tile at least partially coinciding with the primitive based on the judgment result.
3. The rasterizing method of claim 2, wherein, The first area information comprises coordinates of corner points of the sub-tile, and the second area information comprises at least one side equation of the primitive; The determination of the judgment result of each sub-tile based on the first area information of each sub-tile and the second area information of the primitive comprises the following steps: determining a result value corresponding to each side equation based on the side equation and coordinates of a corner point corresponding to the side equation; the corner point corresponding to the side equation is a corner point closest to the side equation; determining the judgment result of the sub-tile based on the result value corresponding to each side equation.
4. The rastering method of claim 3, wherein, The method further comprises the following steps: determining the corner point corresponding to the side equation based on equation coefficients of the side equation and coordinates of each corner point in the sub-tile.
5. The rastering method of claim 1, wherein, The determination of the at least one judgment reference value corresponding to each target sub-tile and the primitive comprises the following steps: determining reference position information of the target sub-tile; determining the at least one judgment reference value corresponding to the target sub-tile and the primitive based on the reference position information and at least one side information of the primitive.
6. The rastering method of claim 5, wherein, The reference position information comprises reference coordinates, and the side information comprises at least one side equation, The determination of the at least one judgment reference value corresponding to the target sub-tile and the primitive based on the reference position information and at least one side information of the primitive comprises the following step: substituting the reference coordinates into the side equation to obtain the judgment reference value. The at least one judging value corresponding to each of the pixel points is obtained based on the at least one judging reference value of the target sub-tile and the offset corresponding to each of the pixel points.
7. The rastering method of claim 3, wherein, Each of the target sub-tiles includes at least one pixel point, and the second determining unit is further configured to determine at least one judging reference value corresponding to the target sub-tile and the graph element, the at least one judging reference value representing a positional relationship between a reference position and each edge of the graph element, obtain at least one judging value corresponding to each of the pixel points based on the at least one judging reference value of the target sub-tile and the offset corresponding to each of the pixel points, and determine a target pixel point of the target sub-tile as a pixel point of the target sub-tile that is located in the graph element. The coordinates of each of the pixel points are substituted into the at least one edge equation to obtain at least one judging value; In a case where the at least one judging value represents that the pixel point is located in the graph element, the pixel point is determined as the target pixel point.
8. The rastering method according to any one of claims 1 to 7, characterized in that, The rasterization method further includes: In a case where the vertex information of the graph element represents that the graph element partially exceeds the tile, intersection information of an edge of the graph element and the tile is obtained; Based on the vertex information and the intersection information, a part of the graph element located in the tile is generated as at least one sub-graph element, and the sub-graph element is taken as the graph element.
9. The rastering method according to any one of claims 1 to 7, characterized in that, The rasterization method further includes: Based on the vertex information of the graph element and the tile, the graph element is converted from the tile to an intermediate tile, and the intermediate tile is used to represent tile region information of any tile; The intermediate tile is taken as the tile.
10. A rasterizing device, characterized by The rasterization device includes a division unit, a first determining unit and a second determining unit, wherein: The division unit is configured to divide a tile to determine at least one sub-tile; The first determining unit is configured to determine at least one target sub-tile in the at least one sub-tile, the target sub-tile being at least partially covered by a graph element, wherein the graph element is obtained by projecting the graph element on the tile after processing a to-be-rendered scene; The second determining unit is configured to determine at least one target pixel point in the at least one target sub-tile that is covered by the graph element, to obtain a target pixel point in the tile that is covered by the graph element. Each of the target sub-tiles includes at least one pixel point, and the second determining unit is further configured to determine at least one judging reference value corresponding to the target sub-tile and the graph element, the at least one judging reference value representing a positional relationship between a reference position and each edge of the graph element, obtain at least one judging value corresponding to each of the pixel points based on the at least one judging reference value of the target sub-tile and the offset corresponding to each of the pixel points, and determine a target pixel point of the target sub-tile as a pixel point of the target sub-tile that is located in the graph element.
11. A graphics processor, comprising: The graphics processor includes the rasterization device according to claim 10.
12. A computer device comprising a memory and a processor, the memory storing a computer program capable of running on the processor, characterized in that, The processor implements the steps in the rasterization method according to any one of claims 1 to 9 when executing the program.
13. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps in the rasterization method according to any one of claims 1 to 9.
14. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions, when executed by a processor, implement the steps of the rasterization method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Block-based rasterization method and device, and image rendering method and device
CN115841433A
Graphics processor, system, method, electronic device and electronic equipment
CN116957898A