Pixel processing method in rasterization stage, graphics processor, readable storage medium and program product

By determining and removing the elements to be removed in advance, the GPU computing pressure problem caused by the increase in the number of elements caused by surface segmentation is solved, the GPU performance is improved, and more efficient graphics processing is achieved.

CN119251040APending Publication Date: 2025-01-03GLENFLY TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411457552.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In graphics processing, surface subdivision leads to an increase in the number of primitives, resulting in double the calculation pressure during the GPU rasterization stage, resulting in excessive resource utilization and affecting performance.

Method used

By obtaining the element and vertex information, determine the element type. If it is an element to be removed, delete the element; if it is not an element to be removed, determine the pixel attributes based on the vertex information for use in the pixel shader. It is not necessary to remove it in advance. The drawn primitives reduce the number of subsequent processing and reduce GPU resource usage.

Benefits of technology

It effectively reduces the computing pressure in the GPU rasterization stage, improves GPU performance, and reduces resource usage and improves overall efficiency by eliminating the ingots that do not need to be drawn in advance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119251040A_ABST
    Figure CN119251040A_ABST
Patent Text Reader

Abstract

The invention relates to a primitive processing method in a rasterization stage, a graphics processor, a computer readable storage medium and a computer program product. The method comprises the following steps: acquiring a primitive and vertex information of the primitive; determining the type of the primitive according to the vertex information; if the type of the primitive is the to-be-removed primitive, deleting the primitive; if the type of the primitive is not the to-be-removed primitive, the pixel attribute of the primitive is determined according to the vertex information of the primitive, and the pixel attribute is used for being input into a pixel shader. By adopting the method, the calculation pressure reduced by the graphics processing unit in the rasterization stage can be reduced, and the performance of the GPU is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image data processing, and in particular to a method for processing primitives in a rasterization stage, a graphics processor, a computer-readable storage medium, and a computer program product. Background Art

[0002] The biggest new feature of 3D graphics is surface subdivision, which uses the hardware acceleration of the Graphics Process Unit (GPU) to split the primitives that make up the 3D model into smaller and finer parts, so as to achieve the effect of making the surface of the rendered object smoother and the edges finer. At the same time, the problem brought about is that the number of primitives has increased greatly, which will double the pressure on the rasterization stage (Rasterizer) on the GPU pipeline, that is, the primitive assembly unit will increase a lot of workload due to the doubling of the number of primitives. Summary of the invention

[0003] Based on this, it is necessary to provide a primitive processing method, a graphics processor, a computer-readable storage medium and a computer program product in the rasterization stage that can reduce the computational pressure in the rasterization stage in order to address the above technical problems.

[0004] In a first aspect, the present application provides a method for processing primitives in a rasterization stage, the method comprising:

[0005] Obtaining primitives and vertex information of the primitives;

[0006] Determine the type of the primitive according to the vertex information;

[0007] If the type of the primitive is a primitive to be removed, deleting the primitive;

[0008] If the type of the primitive is not a primitive to be eliminated, the pixel attributes of the primitive are determined according to the vertex information of the primitive, and the pixel attributes are used to input a pixel shader.

[0009] In one embodiment, the vertex information includes vertex position information; and determining the type of the primitive according to the vertex information includes:

[0010] Determine the edge equation and bounding box information of the primitive according to the vertex position information;

[0011] The type of the primitive is determined according to the edge equation of the primitive and the bounding box information.

[0012] In one embodiment, determining the edge equation and bounding box information of the primitive according to the vertex position information includes:

[0013] For each vertex of the primitive, determining an edge equation of the primitive based on the vertex position information and an initial edge equation;

[0014] For each vertex of the primitive, bounding box information of the primitive is determined based on the extreme value of each vertex position information.

[0015] In one embodiment, determining the type of the primitive according to the edge equation and the bounding box information of the primitive includes:

[0016] If the bounding box information satisfies the preset bounding box condition, the primitive is not the primitive to be eliminated;

[0017] In the case that the bounding box information does not satisfy the preset bounding box condition, determining the size type included in the primitive according to the bounding box information;

[0018] For a primitive of each size type, the type of the primitive is determined according to the bounding box information, the vertex position information and the edge equation.

[0019] In one embodiment, the bounding box information includes bounding box size and bounding box coordinates; and determining the type of the primitive according to the bounding box information, the vertex position information and the edge equation includes:

[0020] Determine a first judgment parameter according to the bounding box coordinates, the vertex position information, and the edge equation;

[0021] Determine a second judgment parameter according to the first judgment parameter, the bounding box size, and the edge equation, wherein the target quantity group is determined based on the bounding box size;

[0022] For each group of second judgment parameters, if there is at least one second sub-judgment parameter that is less than or equal to 0, the primitive is determined to be a primitive to be eliminated.

[0023] In one embodiment, determining the first judgment parameter according to the bounding box coordinates, the vertex position information and the edge equation includes:

[0024] Input the bounding box coordinates, the vertex position information and the edge equation into a first expression to obtain a first judgment parameter;

[0025] Determining a second judgment parameter according to the first judgment parameter, the bounding box size, and the edge equation includes:

[0026] Input the first judgment parameter, the bounding box size and the edge equation into a second expression to obtain a second judgment parameter;

[0027] The bounding box coordinates include the first coordinates of the bounding box; and the first expression is generated by:

[0028] For each vertex of the primitive, substituting the position information of each vertex into the target edge equation corresponding to the vertex to obtain a first equation;

[0029] Substituting the first coordinate of the bounding box of the primitive into the target edge equation to obtain a second equation;

[0030] Determine a first expression based on the second equation and the first equation;

[0031] The bounding box coordinates include the second coordinates of the bounding box; the second coordinates of the bounding box and the first coordinates of the bounding box are determined based on the first coordinate element and the second coordinate element; the second expression is generated in a manner including:

[0032] Substituting the second coordinate of the bounding box of the primitive into the target edge equation to obtain a third equation;

[0033] Based on the third equation, the first equation and the first expression, a second expression is determined.

[0034] In a second aspect, the present application provides a graphics processor, comprising a memory, a geometry shader, a rasterization processing unit and a pixel shader, wherein the memory stores a computer program, the geometry shader is used to process an image to output primitives and corresponding vertex information; the rasterization processing unit implements the steps of the above method when executing the computer program; the pixel shader is used to obtain pixel attributes and perform shading processing according to the pixel attributes.

[0035] In one embodiment, the rasterization processing unit includes a primitive assembly unit, and the computational logic unit of the primitive assembly unit is provided with a first signal input port, a second signal input port, a third signal input port and a signal output port; wherein the first signal input port is used to receive a first coordinate element signal; the second signal input port is used to receive a second coordinate element signal; the third signal input port is used to receive a size type signal of the primitive; and the signal output port is used to output a flag signal of whether to discard the primitive.

[0036] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a rasterization processing unit.

[0037] In a fourth aspect, the present application provides a computer program product, including a computer program, which implements the steps of the above method when executed by a rasterization processing unit.

[0038] The primitive processing method, graphics processor, computer-readable storage medium and computer program product in the above-mentioned rasterization stage first obtains the primitive and the vertex information of the primitive; secondly, determines the type of the primitive based on the vertex information; finally, adopts different processing operations according to the type of the primitive. If the type of the primitive is a primitive to be eliminated, the primitive is deleted; if the type of the primitive is not a primitive to be eliminated, the pixel attribute of the primitive is determined based on the vertex information of the primitive, and the pixel attribute is used to input the pixel shader. The primitives that do not need to be drawn are eliminated in advance before calculating the pixel attributes of the primitives, which greatly reduces the number of primitives that need to be processed later, thereby reducing the resource occupation of the GPU in the rasterization stage and improving the performance of the GPU. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0040] FIG1 is a schematic diagram of a high-detail model and other models in one embodiment;

[0041] FIG2 is a schematic diagram of triangles to be removed and triangles to be retained in one embodiment;

[0042] FIG3 is a schematic diagram of a traditional GPU architecture in one embodiment;

[0043] FIG4 is a schematic diagram of a flowchart of a method for processing a primitive in a rasterization stage according to an embodiment;

[0044] FIG5 is a schematic diagram of a process of determining a primitive type in one embodiment;

[0045] FIG6 is a schematic diagram of a process for determining edge equations and bounding box information in one embodiment;

[0046] FIG7 is a schematic diagram of a bounding box of a primitive in one embodiment;

[0047] FIG8 is a schematic diagram of a process of determining a primitive type in another embodiment;

[0048] FIG9 is a schematic diagram of a flow chart of primitive type determination in another embodiment;

[0049] FIG10 is a schematic diagram of a flow chart of determining a primitive type in another embodiment;

[0050] FIG11 is a schematic diagram of a flow chart of a first judgment parameter and a second judgment parameter in one embodiment;

[0051] FIG12 is a schematic diagram of a process for determining a first expression and a second expression in one embodiment;

[0052] FIG13 is a schematic diagram of triangles to be removed and triangles to be retained in another embodiment;

[0053] FIG14 is a schematic diagram of a GPU architecture after improving a primitive assembly unit in one embodiment;

[0054] FIG. 15 is a schematic diagram of the architecture of a computing logic unit of a primitive assembly unit in one embodiment. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0056] The biggest new feature of Direct3D 11 is surface subdivision, which uses GPU hardware acceleration to split the primitives that make up the three-dimensional model into smaller and finer parts, so as to achieve the effect of making the surface of the rendered object smoother and the edges finer. Take the primitive as an example, as shown in Figure 1, Figure 1 (a) is a traditional 3D graphic, and Figure 1 (b) is a Direct3D 11 graphic. The number of triangles in Figure 1 (b) is much greater than that in Figure 1 (a). When processing the 3D graphics in Figure 1 (b), the pressure on the rasterizer stage on the GPU pipeline will double, that is, the triangle assembly unit will increase a lot of workload due to the doubling of the number of triangles. Take the data given in "3D Graphics Becomes Basics - Based on DirectX11" as an example.

[0057] Table 1 Comparison parameters of high-detail model and other models

[0058]

[0059] As can be seen from the table above, when using a high-detail model, the number of triangles is large, which will cause the 3D pipeline to be overloaded. After analysis and statistics, a large number of triangles generated by surface subdivision are small triangles. In order to achieve a more ideal drawing effect, high-detail models mostly use small triangles. These small triangles sometimes do not cover pixel sampling points, and ultimately do not need to be drawn. As shown in Figure 2, Figure 2 is a 4*4 pixel image block, each point represents the center of a pixel, and T0 and T3 do not need to be drawn in the end because they do not cover the pixel sampling points. According to the analysis and prediction of GPU performance, in the Direct3D 11 Benchmark test, approximately 2.39%~13.75% of the small triangles do not need to be drawn in the end. Among them, the pixel sampling points are determined based on the coordinates of the bounding box.

[0060] For small triangles that do not need to be drawn in the end, the traditional design of GPU architecture is used, as shown in Figure 3. The primitive vertex information output by the geometry shader GS (Geometry Shader) includes the position information (Position) of the vertex and the attribute information (Attribute) of the vertex. The rasterizer unit (Rasterizer Unit) will receive the primitive vertex information. The rasterizer unit (Rasterizer Unit) includes a primitive setup unit (PSU), which can be a triangle setup unit (TSU). The rasterizer unit (RasterizerUnit) also includes an attribute setup unit ASU (Attribute Setup Unit), a mask generation unit MGU (Mask Generation Unit) and an attribute interpolation unit AIU (Attribute Interpolation Unit). Their functions are:

[0061] PSU: Specifically, it can be a triangular assembly unit TSU, which performs calculations based on vertex position information to obtain the straight line equation (edge ​​function) of the primitive.

[0062] ASU: Calculate the slope of the attribute value along the x and y axes based on the vertex attribute information and vertex position information.

[0063] MGU: Based on the straight line equation, calculate the screen pixels covered by the primitive and generate the corresponding mask (Pixel Mask).

[0064] AIU: According to the mask and attribute change gradient, the attribute value of each pixel is interpolated and sent to the pixel shader PS (Pixel Shader).

[0065] According to the above process, the current triangle will not be discarded until the mask generation unit is completed and the mask (Pixel Mask) generated by the current triangle is 0. This means that these small triangles that do not need to be drawn still occupy the calculation of the mask generation unit MGU, as well as the triangle assembly unit TSU and attribute assembly unit ASU before the MGU unit, and complex edge function and attribute slop calculations are required.

[0066] When faced with such a huge amount of small triangle data calculation, the load on the 3D pipeline is likely to be unbalanced: the resources of the triangle assembly unit TSU and the attribute assembly unit ASU will be very tight, because for each triangle, the edge equation and attribute change gradient must be calculated, but in the end only a few pixels of data may be generated, or even discarded because the triangle is too small. In other words, the pressure on the front end of the pipeline (Rasterizer and triangle assembly unit TSU, attribute assembly unit ASU and mask generation unit MGU) is significantly greater than that on the back end (attribute interpolation unit AIU, pixel shader PS and its subsequent modules).

[0067] According to the analysis and prediction of GPU performance, in the test of Direct3D 11 benchmark software (Benchmark), about 2.39%~13.75% of small triangles do not need to be drawn in the end. If these small triangles that do not need to be drawn can be eliminated as early as possible on the GPU pipeline, the calculation pressure of the rasterization stage will be greatly reduced, and the overall performance of the GPU will be improved.

[0068] The primitive processing method in the rasterization stage provided in the embodiment of the present application can be applied to a GPU, which includes a geometry shader GS, a rasterization processor RSU and a pixel shader PS, and can also be applied to the rasterization processor RSU in the GPU.

[0069] In an exemplary embodiment, as shown in FIG. 4 , a method for processing primitives in the rasterization stage is provided, and the method is applied to a GPU as an example for explanation, and includes the following steps S402 to S408 . Among them:

[0070] Step S402, obtaining the primitive and its vertex information.

[0071] The output primitives that describe the geometric elements of an object are called geometric primitives, or primitives for short. Such as points, line segments, circles, quadratic curves, surfaces, triangles, polygons, etc. Primitives (such as line segments, triangles, circles, and other geometric figures) are composed of vertices + edges. Vertex information includes vertex position information and vertex attribute information.

[0072] Optionally, the GPU outputs primitives and primitive vertex information through the geometry shader GS, where the primitive vertex information includes vertex position information (Position) and vertex attribute information (Attribute). The GPU receives the primitives and primitive vertex information output by the geometry shader GS through the rasterization processor RSU. For example, the GPU receives triangles and triangle vertex information output by the geometry shader GS through the rasterization processor RSU. For another example, the GPU receives polygons and polygon vertex information output by the geometry shader GS through the rasterization processor RSU.

[0073] Step S404, determining the type of the primitive according to the vertex information.

[0074] The types of the primitives can be primitives to be eliminated or primitives not to be eliminated.

[0075] Optionally, the GPU determines the type of the primitive based on vertex information, such as vertex position information, through the rasterization processor RSU. If the GPU receives triangles and triangle vertex information output by the geometry shader GS through the rasterization processor RSU, the GPU determines that the triangle is a triangle to be culled based on the vertex position information of the triangle through the rasterization processor RSU. If the GPU receives polygons and polygon vertex information output by the geometry shader GS through the rasterization processor RSU, the GPU determines that the polygon is a polygon to be culled based on the vertex position information of the polygon through the rasterization processor RSU.

[0076] Step S406: If the type of the primitive is a primitive to be removed, delete the primitive.

[0077] Optionally, if the type of the primitive is a primitive to be eliminated, the GPU deletes the primitive through the rasterization processor RSU without performing the processing of the attribute assembly unit ASU, the mask generation unit MGU, and the attribute interpolation unit AIU as shown in FIG. 3 .

[0078] Step S408: If the type of the primitive is not a primitive to be eliminated, the pixel attributes of the primitive are determined according to the vertex information of the primitive, and the pixel attributes are used to input into the pixel shader.

[0079] Optionally, if the type of primitive is not a primitive to be eliminated, the GPU calculates the primitive's straight line equation (edge ​​function) based on the vertex position information through the primitive assembly unit PSU in the rasterization processor RSU; the GPU calculates the attribute change gradient of the attribute value along the x and y axes based on the vertex attribute information and vertex position information through the ASU in the rasterization processor RSU. The GPU calculates the screen pixels covered by the primitive based on the straight line equation through the MGU in the rasterization processor RSU and generates the corresponding mask (Pixel Mask). The GPU interpolates the attribute value of each pixel based on the mask and attribute change gradient through the AIU in the rasterization processor RSU and sends it to the pixel shader PS (Pixel Shader).

[0080] It should be noted that the primitives may be triangles, polygons, straight line segments, quadratic curves, surfaces, triangles, polygons, and the like.

[0081] In the primitive processing method in the above rasterization stage, firstly, the primitive and its vertex information are obtained; secondly, the type of the primitive is determined according to the vertex information; finally, different processing operations are performed according to the type of the primitive. If the type of the primitive is a primitive to be eliminated, the primitive is deleted; if the type of the primitive is not a primitive to be eliminated, the pixel attributes of the primitive are determined according to the vertex information of the primitive, and the pixel attributes are used to input the pixel shader. The primitives that do not need to be drawn are eliminated in advance before calculating the pixel attributes of the primitives, which greatly reduces the number of primitives that need to be processed later, thereby reducing the resource occupation of the GPU in the rasterization stage and improving the performance of the GPU.

[0082] In an exemplary embodiment, as shown in FIG5 , the vertex information includes vertex position information; determining the type of the primitive according to the vertex information includes steps S502 to S504. In which:

[0083] Step S502, determining the edge equation and bounding box information of the primitive according to the vertex position information.

[0084] Among them, the bounding box is an algorithm for solving the optimal bounding space of a discrete point set. The basic idea is to use a geometric shape with a slightly larger volume and simpler characteristics to approximate complex geometric objects.

[0085] If the primitive is a triangle, for a triangle, assume that its three vertices are V0, V1, and V2, and the corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The primitive assembly unit PSU can be specifically a triangle assembly unit TSU. The GPU calculates the three edge equations V0V1, V1V2, and V2V0 through the triangle assembly unit TSU in the rasterization processor RSU. According to the three vertices of the triangle being V0, V1, and V2, and the corresponding screen coordinates being (x0, y0), (x1, y1), and (x2, y2), the bounding box information is calculated.

[0086] If the primitive is a quadrilateral, for a quadrilateral, assume that its four vertices are V0, V1, V2, and V3, and their corresponding screen coordinates are (x0, y0), (x1, y1), (x2, y2), and (x3, y3). The primitive assembly unit PSU can be a quadrilateral assembly unit. The GPU calculates the four edge equations V0V1, V1V2, V2V3, and V3V0 through the quadrilateral assembly unit in the rasterization processor RSU. The bounding box information is calculated based on the four vertices of the quadrilateral and the corresponding screen coordinates.

[0087] Step S504: determine the type of the primitive according to the edge equation and bounding box information of the primitive.

[0088] Optionally, the GPU determines whether the type of the primitive is a primitive to be eliminated or not a primitive to be eliminated according to edge equations and bounding box information of the primitive through a primitive assembly unit PSU in a rasterization processor RSU.

[0089] It should be noted that the type of the primitive may also be determined according to the vertices and vertex coordinates of different primitives.

[0090] In this embodiment, the type of the primitive is determined in advance based on the edge equation and bounding box information of the primitive. When the type of the primitive is a primitive to be eliminated, the primitive is deleted, and there is no need for subsequent primitive attribute assembly, mask generation, and pixel attribute calculation, thereby reducing the resource usage of the GPU in the rasterization stage and improving the performance of the GPU.

[0091] Continuing with the above embodiment, as shown in FIG6 , the edge equation and bounding box information of the primitive are determined according to the vertex position information, including steps S602 to S604. Among them:

[0092] Step S602, for each vertex of the primitive, determine the edge equation of the primitive based on the vertex position information and the initial edge equation.

[0093] The initial edge equation in the two-dimensional space (screen space) is expressed in the form of Ax+By+C = 0. The vertex position information may be vertex coordinate information.

[0094] Optionally, if the primitive is a triangle, for a triangle, assuming that its three vertices are V0, V1, and V2, the corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The primitive assembly unit PSU can be specifically a triangle assembly unit TSU. The GPU substitutes the coordinates of each vertex into the initial edge equation through the triangle assembly unit TSU in the rasterization processor RSU, and obtains:

[0095] The edge equation is A0*X+B0*Y+C0=0:

[0096]

[0097] The side equation is A1*X+B1*Y+C1=0:

[0098]

[0099] The side equation is A2*X+B2*Y+C2=0:

[0100]

[0101] Optionally, if the primitive is a polygon, such as a quadrilateral, for a quadrilateral, assume that its four vertices are V0, V1, V2, and V3, and the corresponding screen coordinates are (x0, y0), (x1, y1), (x2, y2), and (x3, y3). The primitive assembly unit PSU can be a quadrilateral assembly unit. The GPU substitutes the coordinates of each vertex into the initial edge equation through the quadrilateral assembly unit in the rasterization processor RSU, and obtains:

[0102] The edge equation is A0*X+B0*Y+C0=0:

[0103]

[0104] The side equation is A1*X+B1*Y+C1=0:

[0105]

[0106] The edge equation of V2V3 is A2*X+B2*Y+C2=0:

[0107]

[0108] The edge equation of V3V0 is A3*X+B3*Y+C3=0:

[0109]

[0110] For the convenience of explanation, take a triangle as an example. For a pixel (x, y), substitute the three straight line equations A0*X+B0*Y+C0, A1*X+B1*Y+C1, A2*X+B2*Y+C2 generated by EDGE_ALU. If all three results are greater than 0, it means that the pixel is inside the triangle; if one or more results are less than 0, it means that the pixel is outside the triangle. If one result is 0, it means that the point is on the edge of the triangle; if two results are 0, it means that the point is the vertex of the triangle where two edges intersect. Similarly, the same is true for polygons.

[0111] Step S604 : for each vertex of the primitive, determine the bounding box information of the primitive based on the extreme value of the position information of each vertex.

[0112] The coordinate system is one with the x-axis pointing to the right and the y-axis pointing downward, and other coordinate systems are also possible.

[0113] Optionally, the GPU needs to calculate the bounding box according to its vertex coordinates through the primitive assembly unit PSU in the rasterization processor RSU.

[0114] Take a triangle as an example. For a triangle, assume that its three vertices are V0, V1, and V2, and their corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The bounding box coordinates are (xmin, ymin), (xmax, ymax). Take the coordinate system with the x axis pointing right and the y axis pointing downward as an example. Here, xmin and ymin refer to the upper left point of the bounding box of the primitive, and xmax and ymax refer to the lower right point of the bounding box of the primitive.

[0115] Then, the calculation of the bounding box is: select the minimum X and minimum Y from the coordinates of each vertex as the coordinates of the upper left point of the bounding box; select the maximum X and maximum Y from the coordinates of each vertex as the coordinates of the lower right point of the bounding box. Thus, the bounding box information is obtained, as shown in Figure 7, and the calculation results are as follows:

[0116] Xmin = min(x0, x1, x2);

[0117] Ymin = min(y0, y1, y2);

[0118] Xmax = max(x0, x1, x2);

[0119] Ymax = max(y0, y1, y2);

[0120] In order to facilitate unified description, the bounding box is adjusted so that xmin, xmax, ymin, and ymax are all on valid sampling points, and the bounding box is a closed interval, that is, the part that may be drawn is in the x-axis direction: [xmin, xmax], and the y-axis direction: [ymin, ymax].

[0121] In this embodiment, edge equations and bounding box information are calculated through primitive vertex position information, and the type of the primitive can be judged subsequently by the edge equations and bounding box information to determine whether the primitive needs to be culled in advance.

[0122] Continuing with the above embodiment, as shown in FIG8 , the type of the primitive is determined according to the edge equation and bounding box information of the primitive, including steps S802 to S806. In which:

[0123] Step S802: When the bounding box information satisfies the preset bounding box condition, the primitive is not a primitive to be eliminated.

[0124] The most common bounding box size in performance analysis and prediction can be the preset bounding box condition. For example, if performance analysis and prediction find that there are many triangles with bounding boxes occupying 2x2 (number of pixels in the x direction * number of pixels in the y direction) pixels, the preset bounding box condition can be that the bounding box occupies 2x2 pixels.

[0125] Optionally, continuing to take the primitive as a triangle as an example, the GPU does not cull triangles whose bounding boxes are larger than 2x2, and the size type is REJTYPE_NULL; the primitive is not a primitive to be culled.

[0126] When RejType == REJTYPE_NULL, it means that there is no need to perform small triangle culling judgment, and the output item Rej of Edge_ALU = false, indicating that the triangle is not culled.

[0127] Step S804: when the bounding box information does not satisfy the preset bounding box condition, determine the size type included in the primitive according to the bounding box information.

[0128] Optionally, the GPU needs to perform small triangle culling for triangles with bounding box sizes less than or equal to 2x2, that is, when the bounding box information does not meet the preset bounding box conditions, it is necessary to cull triangles with bounding box sizes less than or equal to 2x2. The size types included in the primitives are determined based on the bounding box information. Taking the number of pixels in the x direction and the number of pixels in the y direction as 2 as an example, the size types included in the primitives are as follows:

[0129] REJTYPE_1X1: The width of the triangle's bounding box is less than or equal to 1, and the height is less than or equal to 1.

[0130] REJTYPE_2X1: The width of the triangle's bounding box is less than or equal to 2, and the height is less than or equal to 1.

[0131] REJTYPE_1X2: The width of the triangle's bounding box is less than or equal to 1, and the height is less than or equal to 2.

[0132] REJTYPE_2X2: The width of the triangle's bounding box is less than or equal to 2, and the height is less than or equal to 2.

[0133] When RejType == REJTYPE_MxN (M represents the number of pixels in the x direction, and N represents the number of pixels in the y direction), it means that small triangle culling judgment can be performed. The judgment process is shown in Figure 9.

[0134] Step S806: for each size type, determine the type of the primitive according to the bounding box information, vertex position information and edge equation.

[0135] The types of primitives include primitives to be eliminated and primitives that cannot be eliminated.

[0136] Optionally, for each size type, the GPU determines the type of the primitive through the rasterization processor RSU according to the bounding box information, vertex position information and edge equations.

[0137] Optionally, for the four size types REJTYPE_1X1, REJTYPE_2X1, REJTYPE_1X2 and REJTYPE_2X2, the GPU determines through the rasterization processor RSU, based on the bounding box information, vertex position information and edge equations, that the type of the primitive with 2 pixels in the x direction and 2 pixels in the y direction is the primitive to be culled or the primitive that cannot be culled.

[0138] In this embodiment, it is further determined whether the primitive needs to be eliminated.

[0139] In the above embodiment, as shown in FIG10 , the bounding box information includes the bounding box size and the bounding box coordinates; according to the bounding box information, the vertex position information and the edge equation, the type of the primitive is determined, including steps S1002 to S1006. Among them:

[0140] Step S1002, determining the first judgment parameter according to the bounding box coordinates, vertex position information, and edge equation.

[0141] Among them, the bounding box coordinates need to be transformed, such as the bounding box coordinates [xmin, xmax], [ymin, ymax], after the transformation (xmin + M-1) == xmax && (ymin + N-1) == ymax, the transformed bounding box coordinates are [xmin, xmin + M-1], [ymin, ymin + N-1]. The bounding box coordinates only contain two coordinate elements, xmin and ymin.

[0142] Take a triangle as an example. The three vertices of the triangle are V0, V1, and V2, and their corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The A and B of the three edge equations of the triangle are: edge_v0v1: A0, B0; edge_v1v2: A1, B1; edge_v2v0: A2, B2. The bounding box coordinates are [xmin,xmin + M-1], [ymin, ymin + N-1].

[0143] Optionally, the GPU calculates the first judgment parameter D according to the bounding box coordinates, vertex position information and edge equation through the rasterization processor RSU. The calculation formula of the first judgment parameter D is as follows.

[0144]

[0145]

[0146]

[0147] Where D0 D1 D2 is the first judgment parameter, A0, B0, A1, B1, A2, B2 are edge equations, xmin and ymin are bounding box coordinate elements, (x0, y0), (x1, y1), (x2, y2) are vertex coordinates.

[0148] Step S1004, determining a second judgment parameter of the target quantity group according to the first judgment parameter, the bounding box size, and the edge equation, wherein the target quantity group is determined based on the bounding box size.

[0149] Optionally, when the bounding box size is M*N, taking M equals 2 and N equals 2 as an example, the GPU determines the target number group, that is, 2*2 groups of second judgment parameters E, through the rasterization processor RSU according to the first judgment parameter, the bounding box size, and the edge equation, which are the second judgment parameter under the 1X1 size type, that is, E corresponding to (x0, y0), the second judgment parameter under the 2X1 size type, that is, E corresponding to (x0+1, y0), the second judgment parameter under the 1X2 size type, that is, E corresponding to (x0, y0+1), and the second judgment parameter under the 2X2 size type, that is, E corresponding to (x0+1, y0+1).

[0150] The second judgment parameter E includes second sub-judgment parameters E0-E2, and the calculation formula is as follows.

[0151]

[0152]

[0153]

[0154] In the formula, D0 D1 D2 is the first judgment parameter, A0, B0, A1, B1, A2, B2 are edge equations, M and N are the number of pixels occupied by the bounding box, and m and n are the pixel indexes inside the bounding box (starting from 0). The size of the bounding box is based on the number of pixels occupied by the bounding box, which can be specifically expressed as M*N.

[0155] Step S1006: for each group of second judgment parameters, if there is at least one second sub-judgment parameter that is less than or equal to 0, the primitive is determined to be a primitive to be eliminated.

[0156] The second judgment parameter includes a second sub-judgment parameter.

[0157] Optionally, if there is one or more sets of m, n, such as 2*1 size type, so that the corresponding second sub-judgment parameters E0~E2 are all greater than 0, then this triangle (with 2 pixels in the x direction and 2 pixels in the y direction) needs to be drawn, that is, Rej = false. Otherwise, the primitive is to be eliminated.

[0158] In an optional embodiment, a certain primitive is a triangle with 2 pixels in the x direction and 2 pixels in the y direction. Correspondingly, there are 4 groups of second judgment parameters, namely, the second judgment parameter E corresponding to (x0, y0), the second judgment parameter E corresponding to (x0+1, y0), the second judgment parameter E corresponding to (x0, y0+1), and the second judgment parameter E corresponding to (x0+1, y0+1). In these four groups of second judgment parameters E, each group of second judgment parameters E contains one or more second sub-judgment parameters E0, E1, E2 less than or equal to 0, which means that it is a primitive to be eliminated, that is, Rej = true.

[0159] In practical applications, the rasterization stage needs to retain 1 / 256 precision, and 8 decimal places need to be retained in binary representation. Assuming that a GPU can support 4K*4K images, the integer part of the screen coordinates is in the range of: 0 <= X < 2^10, 0 <= Y < 2^10, that is, the screen coordinates x and y, in binary representation, each require 19 bits of fixed-point numbers (fix sign bit. integer bit. decimal place), recorded as fix1.10.8, where "1" is the sign bit, "10" is the integer bit, and "8" is the decimal place. For formulas (1) and (2):

[0160] Formula (1)

[0161] Formula (2)

[0162] The bounding box of the triangle is limited to M x N pixels, so |XMIN-Xi|<=M, |YMIN-Yi|<=N, |Ai|<=M, |Bi|<=N; then Ai*(BXMIN-Xi)<=M x M, Bi*(BYMIN-Yi)<=N x N. Then for D and E, Ai*(BXMIN-Xi) + Bi*(BYMIN-Yi)<=MxM+NxN.

[0163] Take the example of eliminating small triangles whose bounding boxes are less than or equal to 2x2 pixels. The bounding box of the triangle is within two pixels, so |XMIN-Xi|<3, |YMIN-Yi|<3, that is, the bit width required for |XMIN-Xi|, |YMIN-Yi| is fix1.2.8. Similarly, because the triangle to be judged is limited to within two pixels, |Ai|<3, |Bi|<3, that is, the bit width of A and B is fix1.2.8. Ai*(BXMIN-Xi)<9, Bi*(BYMIN-Yi)<9, that is, the bit width is fix1.4.16. Then for D, E, and F, Ai*(BXMIN-Xi) + Bi*(BYMIN-Yi)<18, that is, the bit width is fix1.5.16. The bit width calculated for each step is shown in Table 2 below:

[0164] Table 2 Calculation bit width of small triangles with bounding boxes less than or equal to 2x2 pixels

[0165]

[0166] In this embodiment, the bit width of the GPU can be saved by determining whether a primitive is a primitive to be eliminated by using the first judgment parameter and the second judgment parameter.

[0167] In an exemplary embodiment, as shown in FIG11 , the calculation of the first judgment parameter and the second judgment parameter includes steps S1102 to S1104. In which:

[0168] Step S1102, input the bounding box coordinates, vertex position information and edge equation into the first expression to obtain the first judgment parameter.

[0169] Optionally, the GPU inputs a first expression through a rasterization processor RSU according to the bounding box coordinates, vertex position information and edge equation, as shown in formula (1), to obtain a first judgment parameter.

[0170] Formula (1)

[0171] Step S1104, input the first judgment parameter, the bounding box size and the edge equation into the second expression to obtain the second judgment parameter.

[0172] Optionally, the GPU determines the second judgment parameter through the rasterization processor RSU according to the first judgment parameter, the bounding box size, and the edge equation input into the second expression, as shown in formula (2).

[0173] Formula (2)

[0174] As shown in FIG12 , the bounding box coordinates include the first bounding box coordinates; the bounding box coordinates include the second bounding box coordinates; the second bounding box coordinates and the first bounding box coordinates are determined based on the first coordinate element and the second coordinate element; the first expression and the second expression include steps S1202 to S1210. Wherein:

[0175] Step S1202: for each vertex of the primitive, substitute the position information of each vertex into the target edge equation corresponding to the vertex to obtain a first equation.

[0176] The principle is explained by taking the elimination of triangles whose bounding boxes are less than or equal to 2x1 as an example:

[0177] The three vertices of the triangle are V0, V1, and V2, and their corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). When the triangle covers two pixels (2x1), the bounding box is [xmin, xmax], [ymin,ymax], where (xmin + 1) == xmax && ymin == ymax. The point (xmin, ymin) is the sampling point (also the center point) of the pixel that may be covered. For the convenience of description, it is recorded as P0 (Pixel Center 0); the point (xmax, ymax) is the sampling point (also the center point) of the pixel that may be covered. For the convenience of description, it is recorded as P1 (Pixel Center 1). For a TYPE_2X1 triangle, we need to determine whether the two pixel sampling points (xmin, ymin) and (xmin+1, ymin) are outside or inside the triangle. If both points are outside the triangle, the triangle does not need to be drawn and can be culled. As shown in Figure 13 below, triangle ① does not cover two pixel sampling points and does not need to be drawn, while triangle ② covers one pixel sampling point and needs to be drawn. This application uses the first judgment parameter and the second judgment parameter to determine whether the primitive covers the sampling point; the method of directly substituting the sampling point coordinates into the edge equation to determine whether the primitive covers the sampling point is not used because the bit width required to directly substituting the sampling point coordinates into the edge equation is very large, which will waste precious hardware resources. The specific analysis is as follows:

[0178] Directly substitute (xmin, ymin) into the edge equation. Taking edge V0V1 as an example, we can calculate it using formula (3):

[0179] Formula (3)

[0180] Unlimited and The range of , means that only these two parts need the bit width of fix1.20.16 respectively. Compared with the calculation bit width in Table 2, the calculation amount is obviously large and the cost is higher.

[0181] Therefore, whether the primitive is a primitive to be eliminated is determined by using the first judgment parameter and the second judgment parameter to determine whether the primitive needs to be eliminated.

[0182] D0~D2 are used to determine whether P0 is inside or outside the triangle, and E0~E2 are used to determine whether P1 is inside or outside the triangle. If one or more of P0 or P1 is inside the triangle, the triangle needs to be drawn and cannot be eliminated; if both P0 and P1 are outside the triangle, the triangle does not need to be drawn and can be eliminated.

[0183] Optionally, taking vertex V1 (x1, y1) as an example, the corresponding target edge equation is A0*X+B0*Y+C0=0. The GPU substitutes V1 (x1, y1) into A0*X+B0*Y+C0=0 through the rasterization processor RSU to obtain the first equation, as shown in formula (4).

[0184] A0* x1+B0* y1+C0=0… …Formula (4)

[0185] Step S1204, substitute the first coordinate of the bounding box of the primitive into the target edge equation to obtain a second equation.

[0186] Optionally, the GPU uses the first coordinate (xmin, ymin) of the bounding box as the first sampling point through the rasterization processor RSU, substitutes the value of A0*X+B0*Y+C0=0 as D0, and obtains the second equation, as shown in formula (5).

[0187] A0*xmin+B0*ymin+C0=D0 Formula (5)

[0188] Step S1206, determining a first expression according to the second equation and the first equation.

[0189] Optionally, the GPU subtracts the first equation from the second equation through the rasterization processor RSU to obtain a first expression, as shown in formula (6).

[0190] Formula (6)

[0191] Step S1208, substitute the second coordinate of the bounding box of the primitive into the target edge equation to obtain the third equation.

[0192] Optionally, the GPU uses the second coordinate (xmin+1, ymin) of the bounding box as the second sampling point through the rasterization processor RSU, substitutes the value of A0*X+B0*Y+C0=0 into E0, and obtains the third equation, as shown in formula (7).

[0193] A0*xmin+B0*ymin+A0+C0=E0… Formula (7)

[0194] Step S1210, determining a second expression based on the third equation, the first equation and the first expression.

[0195] Optionally, the GPU substitutes the expression obtained after subtracting the third equation from the first equation into the first expression through the rasterization processor RSU to determine the second expression, as shown in formula (8).

[0196] ……Formula (8)

[0197] Similarly, D1, D2, E1, and E2 can be derived:

[0198]

[0199]

[0200]

[0201]

[0202] To determine whether P0 is inside or outside the triangle, that is, to determine the positive or negative situation of D0~D2, the second equation is no longer used, but the first expression is used, which can save the bit width of the calculation logic unit in the GPU rasterization processor RSU. Similarly, to determine whether P1 is inside or outside the triangle, that is, to determine the positive or negative situation of E0~E2, the third equation is no longer used, but the second expression is used, which can save the bit width of the calculation logic unit.

[0203] It should be noted that when D or E is equal to 0, it means that the pixel sampling point is located on the edge of the triangle. In this case, it is necessary to determine whether the point on the edge of the triangle belongs to the interior of the triangle according to specific rasterization rules.

[0204] In this embodiment, the first expression and the second expression are inferred, and the bounding box coordinates, vertex position information and edge equation are input into the first expression to obtain the first judgment parameter, and the first judgment parameter, bounding box size and edge equation are input into the second expression to obtain the second judgment parameter. The second judgment parameter is used to determine whether the point on the edge of the triangle belongs to the interior of the triangle, thereby saving bit width.

[0205] In an exemplary embodiment, the GPU receives the triangle and triangle vertex information output by the geometry shader GS through the rasterization processor RSU. For a triangle, assume that its three vertices are V0, V1, and V2, and the corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The primitive assembly unit PSU can be specifically a triangle assembly unit TSU. The primitive assembly unit PSU can be specifically a triangle assembly unit TSU. The GPU substitutes the coordinates of each vertex into the initial edge equation through the triangle assembly unit TSU in the rasterization processor RSU, and obtains:

[0206] The edge equation is A0*X+B0*Y+C0=0:

[0207]

[0208] The side equation is A1*X+B1*Y+C1=0:

[0209]

[0210] The side equation is A2*X+B2*Y+C2=0:

[0211]

[0212] For a triangle, assume that its three vertices are V0, V1, and V2, and their corresponding screen coordinates are (x0, y0), (x1, y1), and (x2, y2). The bounding box coordinates are (xmin, ymin), (xmax, ymax), and the x-axis of the coordinate system points to the right and the y-axis points downward. Here, xmin and ymin refer to the upper left point of the bounding box of the primitive, and xmax and ymax refer to the lower right point of the bounding box of the primitive.

[0213] Then, the calculation of the bounding box is: select the minimum X and minimum Y from the coordinates of each vertex as the coordinates of the upper left point of the bounding box; select the maximum X and maximum Y from the coordinates of each vertex as the coordinates of the lower right point of the bounding box. Thus, the bounding box information is obtained, and the calculation results are as follows:

[0214] Xmin = min(x0, x1, x2);

[0215] Ymin = min(y0, y1, y2);

[0216] Xmax = max(x0, x1, x2);

[0217] Ymax = max(y0, y1, y2);

[0218] If performance analysis and prediction find that there are many triangles whose bounding boxes occupy 2x2 (number of pixels in the x direction * number of pixels in the y direction) pixels, the preset bounding box condition can be that the bounding box occupies 2x2 pixels. At this time, the GPU will use REJTYPE_NULL for triangles whose bounding boxes are larger than 2x2. When RejType == REJTYPE_NULL, it means that there is no need to perform small triangle culling judgment, and the output item Rej of Edge_ALU = false, indicating that the triangle is not culled. When RejType ==REJTYPE_MxN, it means that small triangle culling judgment can be performed. If the output item Rej of Edge_ALU is false, it means that the triangle cannot be culled. If Rej is true, it means that the triangle can be culled.

[0219] Determine whether the triangle can be culled based on the parameters and convert it into EDGE_ALU output signal Rej. Rej = false means the triangle cannot be culled, and Rej = true means the triangle can be culled.

[0220] For triangles whose bounding box width and height are less than or equal to M and N respectively (M represents the number of pixels occupied by the bounding box in the x direction; N represents the number of pixels occupied by the bounding box in the y direction), small triangle culling optimization is performed on them. That is, the bounding box is [xmin, xmax], [ymin, ymax], then (xmin + M-1) == xmax && (ymin + N-1) == ymax.

[0221] The three vertices of the triangle are V0, V1, V2, and their corresponding screen coordinates are (x0, y0), (x1, y1), (x2, y2). The A and B of the three edge equations of the triangle are: edge_v0v1: A0, B0; edge_v1v2: A1, B1; edge_v2v0: A2, B2.

[0222] According to the above data, the RSU calculates the first judgment parameters D0, D1, D2 as follows:

[0223]

[0224]

[0225]

[0226] Whether small triangles can be culled is determined based on the second judgment parameters E0, E1, and E2:

[0227]

[0228]

[0229]

[0230] If there is one or more sets of m, n, such that the corresponding E0~E2 are all greater than 0, then the triangle needs to be drawn, that is, Rej = false. On the contrary, that is, in each set of m, n, E0~E2, at least one is less than or equal to 0, the triangle can be eliminated, that is, Rej = true.

[0231] If the type of the primitive is not a primitive to be culled, the pixel attributes of the primitive are determined according to the vertex information of the primitive, and the pixel attributes are used to input the pixel shader.

[0232] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0233] In one embodiment, a graphics processor is also provided, including a memory, a geometry shader, a rasterization processing unit and a pixel shader, wherein the memory stores a computer program, the geometry shader is used to process an image to output primitives and corresponding vertex information; the rasterization processing unit implements the steps in the above-mentioned method embodiments when executing the computer program, and the pixel shader is used to obtain pixel attributes and perform shading processing according to the pixel attributes.

[0234] In one embodiment, a graphics processor is also provided, wherein the rasterization processing unit includes a primitive assembly unit, and the computational logic unit of the primitive assembly unit is provided with a first signal input port, a second signal input port, a third signal input port and a signal output port; wherein the first signal input port is used to receive a first coordinate element signal; the first signal input port is used to receive a second coordinate element signal; the third signal input port is used to receive a size type signal of a primitive; and the signal output port is used to output a flag signal indicating whether to discard a primitive.

[0235] As shown in FIG14 , the graphics processor includes a geometry shader GS, a rasterization processing unit RSU, and a pixel shader PS. The rasterization processing unit RSU includes a primitive assembly unit PSU, an attribute assembly unit ASU, a mask generation unit MGU, and an attribute interpolation unit AIU. The geometry shader GS is connected to the primitive assembly unit PSU and the attribute assembly unit ASU, and the primitive assembly unit PSU and the attribute assembly unit ASU are connected; the primitive assembly unit PSU is connected to the mask generation unit MGU; the mask generation unit MGU and the attribute assembly unit ASU are connected to the attribute interpolation unit AIU. The attribute interpolation unit AIU is connected to the pixel shader PS.

[0236] As shown in Figure 15. A first signal input port, a second signal input port, a third signal input port and a signal output port are newly set in the calculation logic unit of the primitive assembly unit PSU in the rasterization processing unit RSU; wherein the first signal input port is used to receive a first coordinate element signal, such as xmin; the second signal input port is used to receive a second coordinate element signal, such as ymin; the third signal input port is used to receive a size type signal rejtype of the primitive; and the signal output port is used to output a flag signal rej indicating whether to discard the primitive.

[0237] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a rasterization processing unit, the steps in the above-mentioned method embodiments are implemented.

[0238] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above-mentioned method embodiments when executed by a rasterization processing unit.

[0239] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0240] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0241] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for processing primitives in a rasterization stage, characterized in that: The method comprises: Obtaining primitives and vertex information of the primitives; Determine the type of the primitive according to the vertex information; If the type of the primitive is a primitive to be eliminated, deleting the primitive; If the type of the primitive is not a primitive to be eliminated, the pixel attributes of the primitive are determined according to the vertex information of the primitive, and the pixel attributes are used to input a pixel shader.

2. The method according to claim 1, characterized in that The vertex information includes vertex position information; and determining the type of the primitive according to the vertex information includes: Determine the edge equation and bounding box information of the primitive according to the vertex position information; The type of the primitive is determined according to the edge equation of the primitive and the bounding box information.

3. The method according to claim 2, characterized in that Determining the edge equation and bounding box information of the primitive according to the vertex position information includes: For each vertex of the primitive, determining an edge equation of the primitive based on the vertex position information and an initial edge equation; For each vertex of the primitive, bounding box information of the primitive is determined based on the extreme value of each vertex position information.

4. The method according to claim 2, characterized in that: The determining the type of the primitive according to the edge equation and the bounding box information of the primitive includes: If the bounding box information satisfies the preset bounding box condition, the primitive is not the primitive to be removed; In the case that the bounding box information does not satisfy the preset bounding box condition, determining the size type included in the primitive according to the bounding box information; For each size type, the type of the primitive is determined according to the bounding box information, the vertex position information and the edge equation.

5. The method according to claim 4, characterized in that The bounding box information includes bounding box size and bounding box coordinates; and determining the type of the primitive according to the bounding box information, the vertex position information and the edge equation includes: Determine a first judgment parameter according to the bounding box coordinates, the vertex position information, and the edge equation; Determine a second determination parameter of a target quantity group according to the first determination parameter, the bounding box size, and the edge equation, wherein the target quantity group is determined based on the bounding box size; For each group of second judgment parameters, if there is at least one second sub-judgment parameter that is less than or equal to 0, the primitive is determined to be a primitive to be eliminated.

6. The method according to claim 5, characterized in that Determining a first judgment parameter according to the bounding box coordinates, the vertex position information and the edge equation includes: Input the bounding box coordinates, the vertex position information and the edge equation into a first expression to obtain a first judgment parameter; Determining a second judgment parameter according to the first judgment parameter, the bounding box size, and the edge equation includes: Input the first judgment parameter, the bounding box size and the edge equation into a second expression to obtain a second judgment parameter; The bounding box coordinates include the first coordinates of the bounding box; and the first expression is generated by: For each vertex of the primitive, substituting the position information of each vertex into the target edge equation corresponding to the vertex to obtain a first equation; Substituting the first coordinate of the bounding box of the primitive into the target edge equation to obtain a second equation; Determine a first expression based on the second equation and the first equation; The bounding box coordinates include the second coordinates of the bounding box; the second coordinates of the bounding box and the first coordinates of the bounding box are determined based on the first coordinate element and the second coordinate element; the second expression is generated in a manner including: Substituting the second coordinate of the bounding box of the primitive into the target edge equation to obtain a third equation; Based on the third equation, the first equation and the first expression, a second expression is determined.

7. A graphics processor, comprising a memory, a geometry shader, a rasterization processing unit and a pixel shader, wherein the memory stores a computer program, characterized in that: The geometry shader is used to process an image to output primitives and corresponding vertex information; the rasterization processing unit implements the steps of the method described in any one of claims 1 to 6 when executing the computer program; the pixel shader is used to obtain pixel attributes and perform shading processing according to the pixel attributes.

8. The graphics processor according to claim 7, characterized in that: The rasterization processing unit includes a primitive assembly unit, and a computing logic unit of the primitive assembly unit is provided with a first signal input port, a second signal input port, a third signal input port and a signal output port; wherein the first signal input port is used to receive a first coordinate element signal; the second signal input port is used to receive a second coordinate element signal; the third signal input port is used to receive a size type signal of the primitive; and the signal output port is used to output a flag signal of whether to discard the primitive.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a rasterization processing unit, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a rasterization processing unit, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Geometric processing method, system, processor, equipment, medium and product

    CN121437714A

  • Pixel processing method and device, equipment, storage medium and program product

    CN121708137A