A graphics processing method, apparatus, device and medium

By calculating the coefficients of linear equations in a fixed-point format, primitives of arbitrary size can be processed directly, solving the performance bottleneck caused by CPU clipping and the increased GPU load in existing technologies, and achieving more efficient primitive processing.

CN116601662BActive Publication Date: 2026-01-20HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202080107803.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-11
Publication Date
2026-01-20
Estimated Expiration
2040-12-11

AI Technical Summary

Technical Problem

When processing very large primitives, existing GPUs require the CPU to perform clipping, which makes the CPU a performance bottleneck and increases the GPU's load and power consumption, resulting in low processing efficiency.

Method used

By using the linear equation coefficients in a fixed-point format, primitives of any size can be processed directly without cropping, improving the accuracy and speed of primitive coverage fragments on the screen.

Benefits of technology

It improves the speed and accuracy of primitive processing, reduces the load on the CPU and GPU, and avoids the performance loss caused by clipping processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116601662B_ABST
    Figure CN116601662B_ABST
Patent Text Reader

Abstract

The application discloses a graphics processing method, device, equipment and medium, improves the processing primitive speed, and does not need to cut the primitive. The method comprises the following steps: acquiring a to-be-processed primitive, wherein the vertex coordinates of the primitive are in a floating-point number format; determining equation coefficients of a fixed-point number format corresponding to straight lines where any two adjacent vertices of the primitive are located according to the coordinates of the two vertices; determining target fragments in a screen according to equation coefficients corresponding to a plurality of straight lines, wherein the plurality of straight lines comprise the straight lines where every two adjacent vertices in the primitive are located; and coloring the target fragments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of graphics processing, and more particularly to a graphics processing method, apparatus, device, and medium. Background Technology

[0002] Graphics processing units (GPUs) are widely used in graphics-related fields such as gaming, video, and modeling, serving as dedicated hardware acceleration processors for image rendering. During the rasterization process of primitives in a GPU's fixed hardware pipeline, the coordinates of the primitives are used to determine the fragments included in the primitive outline. However, due to factors such as design complexity, hardware cost, and computational accuracy, the range of primitive coordinates that can be directly calculated and processed by the current GPU rasterization fixed rendering pipeline is limited; for example, it can only handle coordinates exceeding 10^60 latencies. 9 Primitives with coordinate ranges (for ease of description, these primitives are referred to as ultra-large primitives) cannot be directly calculated. For ultra-large primitives, existing technology provides a 3D clipping tool for processing them.

[0003] like Figure 1 As shown, if a primitive is completely outside the screen (e.g., the first primitive), it means that the first primitive has no impact on the rendering result displayed on the screen and does not need to be processed. In other words, the GPU discards the first primitive during primitive processing. If a primitive is completely inside the screen (e.g., the second primitive), since the coordinate range of the second primitive is within the screen area, the GPU's fixed hardware pipeline can use the primitive's coordinates to determine the fragments included in the primitive's outline. If part of a primitive is inside the screen and another part is outside the screen (e.g., the third primitive), this type of primitive is a very large primitive that cannot be directly calculated by the existing GPU's rasterization fixed rendering pipeline. Typically, the third primitive is clipped by the central processing unit (CPU) or by the GPU's internal shader. The portion of the third primitive △V0V1V2 that intersects with the screen (quadrilateral V3V4V5V6) is clipped into two triangular primitives △V3V4V6 and △V3V5V6, which are then used as two new primitives. Then, rasterization or fragment shading is performed on these two new primitives respectively. To ensure rendering quality, the CPU also needs to use interpolation to calculate the attribute data corresponding to the intersection of the new primitive and the screen, based on the color, normal vector, and texture coordinates of the third primitive's vertices.

[0004] In the existing technology, if the CPU processes the ultra-large primitives, it needs to perform clipping before inputting the primitives into the GPU, increasing the CPU load and making the CPU the system performance bottleneck. Furthermore, after clipping the primitives, the CPU needs to recalculate the attribute data of the intersection point between the third primitive and the screen. If the number of attribute types in the attribute data is large, the processing speed will decrease significantly. Moreover, since the new primitive corresponding to the third primitive is multiple primitives, the GPU actually processes multiple primitives during the rendering of the third primitive, increasing the GPU load and causing a loss in GPU performance and power consumption. Therefore, the existing technology's processing flow for a pair of ultra-large primitives is complex, increases the load on computing resources, and is inefficient. Summary of the Invention

[0005] This application provides a graphic processing method, apparatus, device, and medium for improving the processing speed of graphic elements without requiring graphic element clipping.

[0006] Firstly, this application provides a graphics processing method that can be executed by an electronic device. Specifically, the method includes the following steps: the electronic device acquires a primitive to be processed, wherein the vertex coordinates of the primitive are in floating-point format; then, for any two adjacent vertices of the primitive, the electronic device determines the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices based on the coordinates of the two vertices. The electronic device determines a target fragment on the screen based on the equation coefficients corresponding to multiple straight lines, wherein the multiple straight lines include the straight lines containing every two adjacent vertices of the primitive, and colors the target fragment.

[0007] In this embodiment, the electronic device can determine the equation coefficients of the lines containing any two adjacent vertices of a primitive in fixed-point format based on the vertex coordinates in floating-point format. The electronic device can process primitives of arbitrary size without requiring clipping. It can determine the target fragments covered by the primitive on the screen based on the equation coefficients of multiple lines corresponding to the primitive in fixed-point format, reducing the computational load on the fragments covered by the primitive and improving processing speed. Furthermore, fixed-point calculations offer high precision; by using the linear coefficients in fixed-point format to determine the target fragments, the electronic device can further improve the accuracy of determining the fragments covered by the primitive on the screen, thus contributing to improved graphics processing quality.

[0008] In one possible design, the x-coordinate or y-coordinate of at least one vertex of the primitive is greater than a preset value; the maximum y-coordinate of all vertices of the rectangular outline of the primitive is greater than the minimum y-coordinate of the screen's coordinate range, and the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range; the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range, and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range; when the electronic device determines the equation coefficients of the fixed-point format corresponding to the line containing the two vertices based on their coordinates, it can determine the equation coefficients of the floating-point format corresponding to the line containing the two vertices based on their coordinates. Then, based on the equation coefficients of the floating-point format and a target threshold, a scaling factor is determined, where the target threshold is the maximum value that the fixed-point format can represent. Finally, the equation coefficients of the fixed-point format are determined based on the equation coefficients of the floating-point format and the scaling factor.

[0009] In this embodiment, the electronic device can also identify and process primitives that exceed a preset range, i.e., ultra-large primitives. The electronic device can first determine the floating-point equation coefficients of the lines containing the adjacent vertices of the primitive using floating-point calculations. Since the floating-point format can represent a large range of values, the electronic device can also determine the floating-point equation coefficients of the lines corresponding to each side of the ultra-large primitive. Then, the electronic device scales the floating-point coefficients of each line according to the scaling factor corresponding to each line to obtain the fixed-point equation coefficients of each line. The computational cost of determining the fixed-point coefficients of the lines corresponding to each side of the ultra-large primitive is less than the computational cost of clipping the ultra-large primitive, and it can shorten the processing time for ultra-large primitives, thus improving the processing speed.

[0010] In one possible design, the x-coordinate and y-coordinate values ​​of all vertices of the primitive are less than preset values. The maximum y-coordinate value among all vertices of the primitive's rectangular outline is greater than the minimum y-coordinate value within the screen's coordinate range, and the minimum y-coordinate value among all vertices is less than the maximum y-coordinate value within the coordinate range. Conversely, the maximum x-coordinate value among all vertices is greater than the minimum x-coordinate value within the coordinate range, and the minimum x-coordinate value among all vertices is less than the maximum x-coordinate value within the coordinate range. When determining the equation coefficients in a fixed-point number format corresponding to the lines containing the two vertices based on their coordinates, the electronic device can convert the coordinates of the two vertices into a fixed-point number format. Then, based on the converted coordinates of the two vertices, the equation coefficients in the fixed-point number format are determined.

[0011] In this embodiment, because fixed-point number calculation has high accuracy, when processing normal graphic elements, the electronic device can first convert the coordinates of two adjacent vertices of the graphic element into a fixed-point number format. Then, by calculating the equation coefficients of the straight lines containing the two vertices using fixed-point number calculation, the accuracy of determining the straight lines containing each side of the graphic element can be improved, thereby improving the accuracy of determining the fragments covered by the graphic element on the screen and helping to improve the quality of graphic element processing.

[0012] In one possible design, the equation coefficients include abscissa coefficients, ordinate coefficients, and a constant term. The abscissa coefficients are determined based on the difference between the ordinate values ​​of the first and second vertices. The ordinate coefficients are determined based on the difference between the abscissa values ​​of the second and first vertices. The constant term is determined based on the difference between a first value and a second value, where the first value is the product of the abscissa of the first vertex and the ordinate of the second vertex, and the second value is the product of the abscissa of the second vertex and the ordinate of the first vertex. The vertices of the primitives are ordered according to a preset order, with the first vertex preceding the second vertex.

[0013] In this embodiment, for both super-large and normal primitives, the coordinates of two adjacent vertices of a primitive have the same relationship with the equation coefficients of the line containing those two vertices, simplifying the primitive processing and facilitating implementation. The electronic device uses the floating-point coordinates of two adjacent vertices to determine the equation coefficients of the line through floating-point calculations. Alternatively, the electronic device can use the fixed-point coordinates of two adjacent vertices to determine the equation coefficients of the line through fixed-point calculations.

[0014] In one possible design, the electronic device determines a target fragment on the screen based on the equation coefficients corresponding to all straight lines. For any fragment on the screen, it can determine whether the fragment satisfies a preset positional relationship corresponding to the i-th straight line based on the equation coefficients corresponding to the i-th straight line. The preset positional relationship of the i-th straight line is that the fragment is on a preset direction side of the i-th straight line, where i = {1, 2, 3... N}, and N is the number of straight lines. If the fragment satisfies the preset positional relationships corresponding to the multiple straight lines, the electronic device determines that the fragment is the target fragment.

[0015] In this embodiment, the electronic device can determine the positional relationship between each piece and the lines containing each edge of the graphic element by using the equation coefficients of the fixed-point number format of the straight line and the coordinates of each piece on the screen through fixed-point number calculation. Because the fixed-point number calculation has high precision, the electronic device can accurately determine the positional relationship between each piece and the lines containing each edge of the graphic element. Thus, the electronic device can accurately determine the pieces covered by the graphic element on the screen based on the preset positional relationships corresponding to each straight line.

[0016] In one possible design, before determining the equation coefficients of the fixed-point number format corresponding to the straight line containing the two vertices based on their coordinates, the electronic device determines to discard the graphic element to be processed if it is determined that the minimum ordinate value among all coordinate vertices of the rectangular outline of the graphic element to be processed is greater than the maximum ordinate value in the coordinate range of the screen, or the maximum ordinate value among all vertices is less than the minimum ordinate value in the coordinate range, or the minimum abscissa value among all vertices is greater than the maximum abscissa value in the coordinate range, or the maximum abscissa value among all vertices is less than the minimum abscissa value in the coordinate range.

[0017] In this embodiment, the electronic device filters the graphic element before determining the equation coefficients of the fixed-point format of the straight lines containing each side of the graphic element. If the electronic device determines that any part of the graphic element is not within the coordinate range of the screen, it discards the graphic element and does not process it. Since the graphic element is not within the coordinate range of the screen, it will not be displayed on the screen, so discarding the graphic element does not affect the display effect on the screen.

[0018] In one possible design, before determining the coefficients of the fixed-point number format equations corresponding to the lines containing the two vertices based on their coordinates, the electronic device can classify the primitive according to a preset value, the coordinates of all vertices of the primitive, the coordinates of all vertices of the primitive's rectangular outline, and the coordinate range of the screen. If the electronic device determines that the x-coordinate or y-coordinate of at least one vertex of the primitive is greater than the preset value, the maximum y-coordinate of all vertices of the primitive's rectangular outline is greater than the minimum y-coordinate of the screen's coordinate range, and the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range, and the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range, and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range, then the primitive is determined to be an oversized primitive. If an electronic device determines that the x-coordinate and y-coordinate values ​​of all vertices of the graphic element are both less than preset values, the maximum y-coordinate value among all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate value in the coordinate range of the screen, and the minimum y-coordinate value among all vertices is less than the maximum y-coordinate value in the coordinate range, and the maximum x-coordinate value among all vertices is greater than the minimum x-coordinate value in the coordinate range, and the minimum x-coordinate value among all vertices is less than the maximum x-coordinate value in the coordinate range, then the graphic element is determined to be a normal graphic element.

[0019] In this embodiment, the electronic device can classify the graphic elements to be processed. If the electronic device determines that the maximum ordinate value among all vertices of the rectangular outline of a graphic element is greater than the minimum ordinate value within the coordinate range of the screen, and the minimum ordinate value among all vertices is less than the maximum ordinate value within the coordinate range, and the maximum abscissa value among all vertices is greater than the minimum abscissa value within the coordinate range, and the minimum abscissa value among all vertices is less than the maximum abscissa value within the coordinate range, then the electronic device can determine that the graphic element intersects with the screen. The electronic device can determine that a graphic element intersecting with the screen is a normal graphic element if the coordinate values ​​of all vertices of the graphic element are less than a preset threshold. Conversely, it can determine that a graphic element intersecting with the screen is an oversized graphic element. The electronic device can use different methods to determine the fixed-point number format equation coefficients corresponding to multiple straight lines of a graphic element for different types of graphic elements.

[0020] Secondly, this application provides a graphics processing apparatus, including a rasterizer and a shader. The rasterizer is used to acquire primitives to be processed, wherein the vertex coordinates of the primitives are in floating-point format; and for any two adjacent vertices of the primitive, to determine the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices based on the coordinates of the two vertices; and to determine target fragments in the screen based on the equation coefficients corresponding to multiple straight lines, wherein the multiple straight lines include the straight lines containing every two adjacent vertices of the primitive. The shader is used to color the target fragments.

[0021] In one possible design, the x-coordinate or y-coordinate of at least one vertex of the primitive is greater than a preset value; the maximum y-coordinate of all vertices of the rectangular outline of the primitive is greater than the minimum y-coordinate of the screen's coordinate range; and the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range; the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range; and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range. When the rasterizer determines the equation coefficients of the fixed-point format corresponding to the line containing the two vertices based on their coordinates, it specifically performs the following steps: determining the equation coefficients of the floating-point format corresponding to the line containing the two vertices based on their coordinates; determining a scaling factor based on the floating-point format equation coefficients and a target threshold, where the target threshold is the maximum value that the fixed-point format can represent; and then determining the equation coefficients of the fixed-point format based on the floating-point format equation coefficients and the scaling factor.

[0022] In one possible design, the x-coordinate and y-coordinate values ​​of all vertices of the primitive are both less than preset values. The maximum y-coordinate value among all vertices of the rectangular outline of the primitive is greater than the minimum y-coordinate value within the coordinate range of the screen, and the minimum y-coordinate value among all vertices is less than the maximum y-coordinate value within the coordinate range. Conversely, the maximum x-coordinate value among all vertices is greater than the minimum x-coordinate value within the coordinate range, and the minimum x-coordinate value among all vertices is less than the maximum x-coordinate value within the coordinate range. When the rasterizer determines the equation coefficients of the fixed-point format corresponding to the line containing the two vertices based on their coordinates, it specifically converts the coordinates of the two vertices into a fixed-point format. And based on the converted coordinates of the two vertices, it determines the equation coefficients of the fixed-point format.

[0023] In one possible design, the equation coefficients include abscissa coefficients, ordinate coefficients, and a constant term. The abscissa coefficients are determined based on the difference between the ordinate values ​​of the first and second vertices. The ordinate coefficients are determined based on the difference between the abscissa values ​​of the second and first vertices. The constant term is determined based on the difference between a first value and a second value, where the first value is the product of the abscissa of the first vertex and the ordinate of the second vertex, and the second value is the product of the abscissa of the second vertex and the ordinate of the first vertex. The vertices of the primitives are ordered according to a preset order, with the first vertex preceding the second vertex.

[0024] In one possible implementation, when the rasterizer determines a target fragment in the screen based on the equation coefficients corresponding to multiple straight lines, it specifically performs the following: for any fragment in the screen, based on the equation corresponding to the i-th straight line, determines whether the fragment satisfies a preset positional relationship corresponding to the i-th straight line, wherein the preset positional relationship of the i-th straight line is that the fragment is on a preset direction side of the i-th straight line, where i = {1, 2, 3... N}, and N is the number of the multiple straight lines. If the fragment satisfies the preset positional relationships corresponding to the multiple straight lines respectively, then the fragment is determined to be the target fragment.

[0025] In one possible implementation, the graphics processing device further includes a memory for data required for graphics processing or data generated during graphics processing. For example, the memory stores data such as the coordinate range of the screen and the vertex coordinates of primitives.

[0026] Thirdly, embodiments of this application provide an electronic device, including a processor, a display screen assembly, and a graphics processing device as described in any one of the second aspects. The processor is configured to display the fragment output obtained by the graphics processing device on the display screen assembly.

[0027] Fourthly, embodiments of this application provide a chip that can be coupled to a display screen assembly in an electronic device to execute the technical solutions of the first aspect of this application and any possible design of the first aspect. In this application, "coupling" refers to two components being directly or indirectly combined with each other. Specifically, the chip can acquire a primitive to be processed, wherein the vertex coordinates of the primitive are in floating-point format; for any two adjacent vertices of the primitive, determine the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices based on the coordinates of the two vertices; determine a target fragment in the screen based on the equation coefficients corresponding to multiple straight lines, wherein the multiple straight lines include the straight lines containing every two adjacent vertices of the primitive; and color the target fragment. The chip can instruct the display screen assembly to display the target fragment.

[0028] Fifthly, embodiments of this application provide a circuit system. This circuit system can be one or more chips, such as a system-on-a-chip. The circuit system includes: at least one processing circuit; the at least one processing circuit is used to acquire a primitive to be processed, wherein the vertex coordinates of the primitive are in floating-point format. For any two adjacent vertices of the primitive, the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices are determined based on the coordinates of the two vertices. Based on the equation coefficients corresponding to multiple straight lines, a target fragment in the screen is determined, the multiple straight lines including the straight lines containing every two adjacent vertices of the primitive. The target fragment is then colored.

[0029] In a sixth aspect, embodiments of this application provide a computer-readable storage medium comprising a computer program that, when executed on a processor, causes the processor to perform the technical solutions of the first aspect of this application and any possible design of the first aspect.

[0030] In a seventh aspect, a computer program product according to an embodiment of this application, when the computer program product is run on an electronic device, causes the electronic device to execute the technical solution of the first aspect of the embodiment of this application and any possible design of the first aspect.

[0031] Furthermore, the technical effects of any of the possible design methods in aspects two through seven can be found in the section on methods, which discusses the technical effects of different design methods; these will not be elaborated upon here. Attached Figure Description

[0032] Figure 1 This is a schematic diagram of a graphics processing procedure in existing technology.

[0033] Figure 2 This is a schematic diagram of the graphics processing process in the prior art (Article 2).

[0034] Figure 3A graphics processing apparatus provided in an embodiment of this application;

[0035] Figure 4 This is a schematic diagram illustrating the relationship between graphic elements and the display area;

[0036] Figure 5 This is a schematic diagram showing the relationship between the rectangular outline of a graphic element and its display area.

[0037] Figure 6 This is a schematic diagram of the structure of a rasterizer provided in an embodiment of this application;

[0038] Figure 7 This application provides a schematic diagram of the structure of a primitive processing pipeline.

[0039] Figure 8 This is a schematic diagram of another primitive processing pipeline provided in an embodiment of this application;

[0040] Figure 9 This is a schematic diagram of primitive vertices provided in an embodiment of this application;

[0041] Figure 10 This is a schematic diagram illustrating the relationship between graphic elements and the determination range;

[0042] Figure 11 A schematic diagram of the preset direction side of the straight line containing the outline of the graphic element;

[0043] Figure 12 A schematic diagram of the graphic processing process provided in the embodiments of this application;

[0044] Figure 13 A schematic flowchart illustrating a graphics processing method provided in an embodiment of this application;

[0045] Figure 14 A schematic flowchart illustrating another graphics processing method provided in an embodiment of this application;

[0046] Figure 15 This is a schematic diagram of the structure of a graphics processor provided in an embodiment of this application;

[0047] Figure 16 A chip provided in an embodiment of this application;

[0048] Figure 17 An electronic device provided in an embodiment of this application. Detailed Implementation

[0049] GPUs are widely used in graphics-related fields such as gaming, video, and modeling, serving as dedicated hardware acceleration processors for image rendering. GPUs can typically process various two-dimensional (2D) or three-dimensional (3D) models. These models are generally composed of simple geometric primitives such as points, lines, or triangles. For other complex primitives, the GPU can first convert them into simpler geometric primitives, and then perform rasterization, fragment shading, and other processing on these primitives through a fixed hardware pipeline. However, due to design complexity, hardware cost, and computational accuracy considerations, the GPU's fixed hardware pipeline cannot directly process extremely large primitives.

[0050] The 3D clipping method provided in Existing Technology 1 configures the screen range as the coordinate range for processing primitives, using the screen range as a reference to determine the positional relationship between the input primitives and the screen. Existing Technology 1's fixed hardware pipeline in the GPU can directly process primitives that are entirely within the screen range. For ultra-large primitives that the fixed hardware pipeline cannot directly process—that is, primitives where part is within the screen range and another part is outside the screen range—Existing Technology 1 clips these ultra-large primitives.

[0051] For example, Figure 1 The third primitive in the image is a primitive in which part of it is inside the screen and another part is outside the screen; it is a very large primitive. In existing technology, when processing the third primitive, the CPU typically first detects the edges of the third primitive △V0V1V2 with the four boundaries of the screen. Based on linear equations, the CPU determines the intersection points of the third primitive △V0V1V2 with the screen as points V3, V4, V5, and V6.

[0052] Then, the CPU constructs new primitives based on the intersections of the third primitive △V0V1V2 with the screen. For example, △V3V4V6 and △V3V5V6 are identified as the new primitives corresponding to the third primitive. The CPU inputs these new primitives to the GPU, so the GPU does not process the third primitive itself, but instead performs rasterization or fragment shading on the new primitives △V3V4V6 and △V3V5V6 identified by the CPU. To ensure rendering quality, the CPU also needs to use interpolation to calculate the attribute data corresponding to the intersections of the third primitive with the screen, based on the color, normal vector, and texture coordinates of the third primitive vertices.

[0053] In the existing technology, for very large primitives, the CPU needs to perform clipping processing on the primitives before they are input into the GPU. This increases the CPU load, making the CPU the system performance bottleneck. Furthermore, after clipping the very large primitives, the CPU needs to recalculate the attribute data of the intersection points between the very large primitives and the screen. If the number of attribute types in the attribute data is large, the processing speed will decrease significantly. Moreover, since the new primitive corresponding to a very large primitive may be multiple primitives, the GPU is actually processing multiple primitives during rendering, increasing the GPU load and causing a loss in GPU performance and power consumption.

[0054] In practical applications, a high proportion of primitives input to the GPU extend beyond the screen, meaning a significant proportion are oversized. Existing technology one involves frequent clipping of these oversized primitives, leading to low processing efficiency. To alleviate this problem, existing technology two provides a guard band clipping (GBC) method for processing oversized primitives. The GPU provided by existing technology two has a fixed hardware pipeline that can directly process primitives within the guard band, where the guard band's area is much larger than the screen area. Therefore, the GPU provided by existing technology two can directly process primitives with a larger coordinate range.

[0055] In the second prior art, the positional relationship between the input graphic elements and the protection zone is first determined based on the protection zone's range. For example... Figure 2 As shown, if a primitive is completely outside the screen (e.g., the fourth primitive), it means that the fourth primitive has no impact on the rendering result displayed on the screen, and no processing is required for the fourth primitive. In other words, the GPU discards the fourth primitive directly during primitive processing. If a primitive is completely inside the guard band (e.g., the fifth primitive), since the coordinate range of the fifth primitive is within the guard band, the GPU fixed hardware pipeline can use the primitive's coordinates to determine the fragments included in the primitive's outline.

[0056] Existing technology 2 performs clipping processing on ultra-large primitives that cannot be directly processed by the GPU's fixed hardware pipeline, that is, primitives in which part is within the protection band and another part is outside the protection band, such as the sixth primitive.

[0057] First, the GPU detects the edges of the sixth primitive △M0M1M2 and the four boundaries of the guard band. The GPU determines the intersection points of the sixth primitive △M0M1M2 with the screen as points M3, M4, M5, and M6. Then, the GPU constructs new primitives based on the intersection points of the sixth primitive △M0M1M2 with the screen, for example, determining △M3M4M6 and △M3M5M6 as the new primitives corresponding to the sixth primitive. The GPU inputs the new primitives corresponding to the sixth primitive into the GPU.

[0058] Therefore, it can be seen that in the second prior art, the GPU does not directly process the sixth primitive, but instead performs rasterization or fragment shading on the new primitives △M3M4M6 and △M3M5M6 generated after cropping the sixth primitive.

[0059] Compared to Existing Technology 1, Existing Technology 2, because the protective band is much larger than the screen area, allows for a greater number of primitives that can be directly processed by the fixed hardware pipeline, thus reducing the number of ultra-large primitives that need to be clipped. However, the process of clipping the sixth primitive in Existing Technology 2 is similar to that in Existing Technology 1. The GPU still needs to use the attribute data of the sixth primitive's vertices, such as color, normal vector, and texture coordinates, to calculate the attribute data corresponding to the intersection point between the sixth primitive and the screen using interpolation methods. Because it is necessary to determine the attribute data of the new vertices generated after primitive clipping, the GPU's primitive processing speed will decrease significantly.

[0060] After introducing the aforementioned guard band mechanism in Existing Technology 2, the pruning function is typically implemented using a GPU. Implementing the pruning function using shaders within the GPU would complicate the GPU hardware pipeline and programming model. Implementing it using dedicated hardware circuitry within the GPU would introduce significant hardware overhead for pruning and attribute interpolation. Furthermore, pruning primitives like the sixth primitive might generate multiple primitives, increasing the workload on subsequent GPU pipelines such as rasterization, leading to decreased GPU performance and a surge in power consumption.

[0061] It is evident that the GPUs and pruning methods provided in Existing Technologies 1 and 2 cause a decrease in GPU processing speed when handling extremely large primitives. Furthermore, processing extremely large primitives leads to a decrease in GPU performance and an increase in power consumption.

[0062] In view of this, this application provides a graphics processing method, apparatus, device, and medium that can improve the processing speed of primitives, enhance the performance of processing ultra-large primitives, and eliminate the need for primitive clipping. The graphics processing apparatus includes a circuit with a rasterization fixed rendering pipeline, capable of processing any primitive without any limitation on the primitive's coordinate range. The method and apparatus are based on the same technical concept; since the methods and apparatus solve problems based on similar principles, their implementations can be mutually referenced, and repeated details will not be elaborated further. The following explanations of some terms used in this application are provided to facilitate understanding by those skilled in the art.

[0063] 1) Data representation

[0064] Typically, data in a computer can be expressed in floating-point or fixed-point formats. For example, a numerical value can be expressed in either floating-point or fixed-point format, and neither format affects the value.

[0065] 2) Floating-point number format

[0066] The mathematical form of the numerical value N can be written as M×R E In this system, M is the mantissa, R is the base, and E is the exponent. In a computer, the value N can be represented by a combination of the mantissa, base, and exponent. In a computer, the base is generally a fixed value.

[0067] Floating-point formats can represent a wide range of values; for example, IEEE FP32 floating-point numbers can represent 10^60^65. 38 The range of magnitudes is limited. However, mathematical operations on floating-point data (such as addition, subtraction, multiplication, and division) are complex. Compared to fixed-point arithmetic, floating-point arithmetic has lower precision and is non-linear.

[0068] 3) Fixed-point number format

[0069] In fixed-point number formats, the position of the decimal point is fixed. The decimal point can be placed in any position. Fixed-point number formats typically represent pure decimals or pure integers. When storing numerical values ​​in a computer, the decimal point is not stored; when storing data in fixed-point number format, the decimal point's position is fixed.

[0070] Fixed-point number formats have a limited range of values ​​that can be represented. For example, a 32-bit fixed-point number format can only represent 10^60. 9 The range of magnitude is much smaller than that of floating-point numbers of the same bit width. However, mathematical operations in fixed-point format (such as addition, subtraction, multiplication, and division) are simple, highly precise, and linear in precision throughout the entire representation range.

[0071] 4) Expression of straight lines

[0072] A straight line can be described in many ways. For example, a straight line can be described using an equation. From a mathematical perspective, there are several forms of straight line equations, such as parametric equations, point-slope form equations, and general form equations. In computers, the general form equation is usually used to describe straight lines, denoted as Ax + By + C = 0. Here, A, B, and C are the coefficients in the equation, where A is the x-coordinate coefficient, B is the y-coordinate coefficient, and C is the constant term.

[0073] In computers, straight lines are represented by recording the coefficients in their equations. In the field of graphics processing, the equation of the line containing the outline of a primitive is also called the edge equation, which is the equation of the line containing any two adjacent vertices of the primitive.

[0074] It should be noted that the term "and / or" in this application describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. The term "multiple" in this application refers to two or more objects.

[0075] In addition, it should be understood that in the description of this application, the words "first" and "second" are used only for the purpose of distinguishing descriptions and should not be construed as indicating or implying relative importance or order.

[0076] The embodiments of this application will now be described in detail with reference to the accompanying drawings. The embodiments of this application provide a graphics processing apparatus capable of processing any primitive whose vertex coordinates are represented in floating-point format. For example, primitives whose vertex coordinates are represented in FP32 floating-point format. Figure 3 As shown, the graphics processing device may include a rasterizer 30 and a fragment shader 31.

[0077] The graphics processing apparatus may also include a vertex shader 32. The vertex shader 32 can perform vertex transformations on primitives before they are input to the rasterizer 30. Vertex transformation typically refers to performing translation, rotation, scaling, or other processing on the primitives according to graphics processing configuration parameters. These graphics processing configuration parameters can be carried by user-triggered graphics processing commands. For example, if the translation distance in the primitive processing configuration parameters is x, the graphics processing apparatus determines the coordinates of the translated primitive based on the translation distance and the primitive's coordinates. The graphics processing apparatus may also include a drawing layer unit 33, which can generate a layer containing the shaded fragments.

[0078] Vertex shader 32 can input the transformed coordinates of the primitive's vertices into rasterizer 30. Rasterizer 30 can then filter the primitive. For example, rasterizer 30 can detect all vertices of the primitive to determine whether each vertex is within the display area. The display area can be the display range of a display device connected to the graphics processing device, such as the screen area or the projection area.

[0079] In this embodiment, the primitives input to the rasterizer 30 can be lines or triangles. Furthermore, the vertex coordinates of the primitives input to the rasterizer 30 are in floating-point format.

[0080] In practical applications, based on the positional relationship between the input graphic elements and the display area, the rasterizer 30 can divide the graphic elements into those outside the display area (such as...). Figure 4 The graphic element 1 shown in the figure and the graphic elements within the display range (such as...) Figure 4The diagram shows two types of graphic elements (2, 3, and 4). Here, "graphic elements within the display area" can be understood as all or part of the graphic element being within the display area, such as... Figure 4 All of the graphic elements 2 shown are within the display area; graphic element 2 belongs to the graphic element type that is within the display area. For example... Figure 4 The graphic element 3 shown is partially within the display area, and graphic element 3 belongs to the graphic element type within the display area.

[0081] The rasterizer 30 can determine the vertex coordinates of the rectangular outline of a primitive based on the coordinates of all its vertices. The rasterizer 30 compares the coordinates of all vertices of the rectangular outline of the primitive with a first coordinate threshold. The first coordinate threshold can be determined based on the vertex coordinates of the display area. The first coordinate threshold may include a first horizontal coordinate threshold and a first vertical coordinate threshold. Figure 5 As shown, the vertex coordinates of the display range are (x1, y1), (x1, y2), (x2, y1), and (x2, y2), where x2 > x1 and y2 > y1. The first horizontal coordinate threshold is x1, x2, and the first vertical coordinate threshold is y1, y2. Figure 5 The primitive shown in the figure and its rectangular outline are defined by the vertex coordinates of the rectangular outline as (v1, w1), (v1, w2), (v2, w1), and (v2, w2), where v2 > v1 and w2 > w1. The coordinates of the i-th vertex Pi among all vertices of the rectangular outline can be denoted as (mi, ni).

[0082] Rasterizer 30 can determine the x-coordinate m of the vertices of the rectangular outline. i Compare with x1 and x2 respectively, and set the ordinate n of the vertices of the rectangle outline. i Compare with y1 and y2 respectively.

[0083] The rasterizer 30 compares the coordinates of the rectangular outline of the primitive with a first coordinate threshold. The first coordinate threshold can be determined based on the vertex coordinates of the display area. The vertex coordinates of the display area are (x1, y1), (x1, y2), (x2, y1), and (x2, y2), where x2 > x1 and y2 > y1. If any vertex Pj(m) of the rectangular outline... j n j The x-coordinate of any vertex Pj is mj≤x1, or mj≥x2, or the y-coordinate of any vertex Pj is n. j ≤y1, or n j If y2 ≥ 2, the rasterizer 30 can determine that the primitive is outside the display range. For example, Figure 5 The primitive 1 shown in the figure has a rectangular outline in which the ordinate of any vertex Pj satisfies n j≥y2, the primitive 1 is a primitive outside the display range. Since the primitive is completely outside the display range and has no impact on the display within the display range, the rasterizer 30 can discard this primitive.

[0084] If the rasterizer 30 determines that the primitive is not a primitive outside the display range, it can determine that the primitive is within the display range.

[0085] To shorten the process of comparing the coordinates of the rectangular contour of the primitive with the first coordinate threshold, the rasterizer 30 can also determine that the primitive is a primitive outside the display range if the maximum abscissa v2 of all vertices of the rectangular contour of the primitive ≤ x1, or the minimum abscissa v1 ≥ x2, or the maximum ordinate v2 ≤ y1, or the minimum ordinate v1 ≥ y2. Conversely, if the rasterizer 30 determines that the maximum abscissa v2 of all vertices of the rectangular contour of the primitive > x1, the minimum abscissa v1 < x2, the maximum ordinate v2 > y1, and the minimum ordinate v1 < y2, it can determine that the primitive is a primitive within the display range.

[0086] In the embodiments of the present application, the rectangular contour of the primitive includes all the covered areas of the primitive. Therefore, the actual covered area of the primitive is a subset of the rectangular contour of the primitive. If there is no intersection between the rectangular contour of the primitive and the display range, there is also no intersection between the actual covered area of the primitive and the display range, and it can be determined that the primitive is completely outside the display range. The rasterizer 30 does not process this primitive and has no impact on the display of the display range. Therefore, the rasterizer 30 can discard the primitive outside the display range.

[0087] In a possible implementation, such as Figure 6 The rasterizer 30 may include a vertex detection circuit 60, a primitive processing pipeline 61, and a rasterization circuit 62 connected in sequence. Among them, the input end of the vertex detection circuit 60 is also the input end of the rasterizer 30. The output end of the rasterization circuit 62 is also the output end of the rasterizer 30. It should be understood that the functions or capabilities implemented by the vertex detection circuit 60, the primitive processing pipeline 61, and the rasterization circuit 62 are also the functions or capabilities that the rasterizer 30 can implement. The functions or capabilities that the vertex detection circuit 60, the primitive processing pipeline 61, and the rasterization circuit 62 can implement are introduced below.

[0088] The vertex detection circuit 60 in the embodiments of the present application can perform the aforementioned process of filtering the primitive, and then input the vertex coordinates in floating-point format of the primitive within the display range into the primitive processing pipeline 61. The primitive processing pipeline 61 can perform graphic processing on any primitive within the display range. For example, it can determine the edge equation of the primitive.

[0089] The primitive processing pipeline 61 provided in this embodiment can be a first primitive processing pipeline 6110. For example... Figure 7 As shown, the first primitive processing pipeline 6110 may include a first coefficient determination circuit 6111 and a first format conversion circuit 6112 connected in sequence. The input terminal of the first coefficient determination circuit 6111 can be connected to the output terminal of the vertex detection circuit 60 to receive the vertex coordinates of the primitives provided by the vertex detection circuit 60, wherein the vertex coordinates are in floating-point format. The output terminal of the first format conversion circuit 6112 can be connected to the input terminal of the rasterization circuit 62 to input the coefficients of the fixed-point format of the line equation (edge ​​equation) corresponding to the primitive into the rasterization circuit 62.

[0090] The first coefficient determination circuit 6111 can also be called a floating-point-based linear equation calculation circuit. The first coefficient determination circuit 6111 is used to determine the linear equation of the line containing any two adjacent vertices of a primitive, that is, to determine the linear equation of each line that makes up the contour of the primitive, where the vertex coordinates are in floating-point format. Typically, the general linear equation Ax + By + C = 0 is used to describe each line. The adjacent vertices Pi(m) in the primitive... i n i ) and Pi+1(m i+1 n i+1 The coefficients of a straight line equation can be determined using the following formula:

[0091] A = n i -n i+1

[0092] B = m i+1 -m i

[0093] C = m i n i+1 -m i+1 n i

[0094] Since the coordinates of any vertex Pj(m) of the primitive are... j n j The coefficients of the determined straight line equation are also in floating-point format. Floating-point format can represent a large range of values; therefore, this embodiment can directly process any primitive without needing to trim or set a guard band. In other words, the primitive processing pipeline 61 provided in this embodiment does not limit the coordinate range of primitives and can process primitives with very large vertex coordinates.

[0095] The first coefficient determination circuit 6111 uses floating-point format in the process of determining the coefficients of the linear equation, which can prevent the calculation results from overflowing. Furthermore, it maintains precision during mathematical operations (such as addition, subtraction, multiplication, and division) in the process of determining the coefficients of the linear equation.

[0096] In one possible implementation, the first coefficient determination circuit 6111 can represent the result of the multiplication operation of the vertex coordinates of the primitive in floating-point format FP32 using floating-point format FP64.

[0097] The first format conversion circuit 6112 can also be called a normalizer circuit. The first format conversion circuit 6112 is used to convert the coefficients of the linear equation in floating-point format output by the first coefficient determination circuit 6111 into fixed-point format.

[0098] Because fixed-point number format has a limited bit width, the range of values ​​it can represent is relatively small. However, the floating-point number output by the first coefficient determination circuit 6111 may exceed the maximum range of values ​​that the fixed-point number format can represent. This application provides a method for converting floating-point number format to fixed-point number format, applicable to scenarios involving the conversion of coefficients in linear equations.

[0099] First, let's introduce a property of linear equations. A line L can be represented by the linear equation A1x + B1y + C1 = 0. At the same time, a line L can also be represented by the linear equation... For an equation, dividing each term on the left-hand side by the value q, and then dividing each term on the right-hand side by the value q, does not change the equality relationship between the two sides. Since the right-hand side of the equation of a straight line is 0, it remains 0 after being divided by the value q. Therefore, the straight line L can be represented by different straight line equations. If the coefficients of the equation are both divided by the value q or both multiplied by the value q, the straight line L will not change; only the coefficients of the straight line equation representing L will change.

[0100] Based on the aforementioned characteristics of the linear equation, when the first format conversion circuit 6112 converts the floating-point format coefficients output by the first coefficient determination circuit 6111 into a fixed-point format, it can scale the floating-point format coefficients. The floating-point format coefficients are scaled to a value range that the fixed-point format can represent. Then, the scaled linear coefficients are recorded in fixed-point format.

[0101] In one example, the first coefficient determination circuit 6111 outputs the floating-point format coefficients A, B, and C of the linear equation Ax + By + C = 0. The first format conversion circuit 6112 determines the scaling factor S based on the floating-point format coefficients A, B, and C and the maximum value N in the range (-N, N) that the fixed-point format can represent. For example, S is the maximum value among the coefficients in the floating-point format of the linear equation, i.e. In practical applications, the value N can be determined based on the number of bits in the fixed-point number format. The value N can be the maximum value that the fixed-point number format can represent.

[0102] The first format conversion circuit 6112 scales the coefficients A, B, and C of the floating-point format of the linear equation according to the determined scaling factor S. The scaled coefficients are respectively... The scaled coefficients are within the range of values ​​that can be represented in the fixed-point format. The first format conversion circuit 6112 records the scaled coefficients A′, B′, and C′ of the linear equation in fixed-point format.

[0103] In one example, the first format conversion circuit 6112 can determine the coefficients of the linear equation in fixed-point format by right-shifting the mantissa of the coefficients in the floating-point format.

[0104] The coefficients A, B, and C of the floating-point equation of a straight line can be denoted by their corresponding floating-point exponents as E. A E B E C The mantissas of the floating-point numbers corresponding to coefficients A, B, and C can be denoted as M. A M B M C .

[0105] Since the mantissa of a floating-point number can be represented in a fixed-point number format, the first format conversion unit 6112 can scale the coefficients of the linear equation by right-shifting the mantissa of the coefficients. The coefficients in the fixed-point number format are A′=M. A >>(E max -E A ), B′=M B >>(E max -E B ), C′=M C >>(E max -E C ), where E max =max(E A E B E C ).

[0106] In this embodiment of the application, the primitive processing pipeline 61 can be a second primitive processing pipeline 6120. For example... Figure 8As shown, the second primitive processing pipeline 6120 may include a second format conversion circuit 6121 and a second coefficient determination circuit 6122 connected in sequence. The input terminal of the second format conversion circuit 6121 can be connected to the output terminal of the vertex detection circuit 60 to receive the vertex coordinates of the primitives provided by the vertex detection circuit 60, wherein the vertex coordinates are in floating-point format. The output terminal of the second coefficient determination circuit 6122 can be connected to the input terminal of the rasterization circuit 62 to input the coefficients of the fixed-point format of the linear equation corresponding to the primitive into the rasterization circuit 62.

[0107] The second format conversion circuit 6121 can also be called a floating-point to fixed-point circuit. The second format conversion circuit 6121 is used to convert the floating-point format coordinates of primitive vertices into fixed-point format coordinates, wherein the coordinates of primitive vertices are within the numerical range that can be represented by the fixed-point format.

[0108] Vertex detection circuit 60 will detect the floating-point format coordinates (m) of any vertex Pj of the primitive. j n j The input is to the second format conversion circuit 6121, which converts the floating-point format coordinates (m) of any vertex Pj into... j n j Convert to fixed-point coordinate format (m) j ',n j '). Among them, m j and m j They are all the same value, only the form in which the value is represented is different.

[0109] The second coefficient determination circuit 6122 can also be called a fixed-point number-based linear equation calculation circuit. The second coefficient determination circuit 6122 is used to determine the linear equation of the line containing any two adjacent vertices of a primitive, where the coordinates of the vertices are fixed-point number format coordinates output by the second format conversion circuit 6121. The equations are calculated based on the adjacent vertices Pi(m) in the primitive. i ',n i ') and Pi+1(m i+1 ',n i+1 The coefficients of a straight line equation can be determined using the following formula:

[0110] A'=n i '-n i+1 '

[0111] B' = m i+1 '-m i '

[0112] C'=m i 'n i+1 '-m' i+1 n i '

[0113] Because the coefficients of the linear equation are determined using coordinates in a fixed-point format, the calculation process for determining the coefficients of the linear equation can maintain accuracy and is faster.

[0114] Furthermore, in the process of determining the equation of the line containing any two adjacent vertices of a primitive in the embodiments of this application, the adjacent vertices Pi and Pi+1 in the primitive are ordered in a certain order. For example... Figure 9 As shown, assume the primitive has 3 vertices, P0, P1, and P2. Using point O as the reference point, define the direction as x. Using the reference point O as the vertex of a ray, determine the angles between rays OP0, OP1, and OP2 and the defined direction x. Based on these angles, determine the order of all vertices in the pattern. The angle between ray OP0 and the defined direction is θ0, the angle between ray OP1 and the defined direction is θ1, and the angle between ray OP2 and the defined direction is θ2.

[0115] If the included angles are in the order θ0 < θ1 < θ2, the vertex order can be the same as the angle order, resulting in vertices P0, P1, P2. Alternatively, with point O as the reference point, the vertices can be ordered counter-clockwise. Adjacent vertices Pi and Pi+1 can be P0 and P1, P1 and P2, or P0 and P2 respectively. Therefore, when determining the coefficients of the line equation, the coefficients of adjacent vertices Pi(m)... i n i ) and Pi+1(m i+1 n i+1 The coefficients of a straight line equation can be determined using the following formula:

[0116] A = n i -n i+1

[0117] B = m i+1 -m i

[0118] C = m i n i+1 -m i+1 n i

[0119] If the angles are θ0 < θ1 < θ2, the vertex order can be the reverse of the angle order, resulting in vertices P2, P1, P0. In other words, with point O as the reference point, the vertices are ordered clockwise. Adjacent vertices Pi and Pi+1 can be P2 and P1, P1 and P0, or P2 and P0 respectively. The coefficients of the line equation can also be determined using the aforementioned formula.

[0120] In one possible implementation, the primitive processing pipeline 61 in the graphics processing device is a first primitive processing pipeline 6110. The first primitive processing pipeline 6110 calculates the coefficients of the linear equation of the primitive's outline in floating-point format based on the floating-point coordinates of the primitive's vertices. Then, it converts the coefficients of the linear equation in floating-point format to fixed-point format coefficients by scaling. The floating-point format can represent a large range of values, enabling the determination of the coefficients of the linear equation of the outline of primitives of arbitrary size. This allows the image processing device to directly process very large primitives without requiring cropping operations or attribute data determination, thereby accelerating the processing speed of very large primitives.

[0121] In another possible implementation, the primitive processing pipeline 61 in the graphics processing device is a second primitive processing pipeline 6120. The second primitive processing pipeline 6120 converts the floating-point coordinates of the primitive vertices into fixed-point coordinates, and then calculates the coefficients of the fixed-point format of the linear equation of the primitive's outline. Since the graphics processing device in this embodiment uses fixed-point coordinates in the process of determining the coefficients of the linear equation, the data processing speed of the fixed-point format is faster, which can improve the primitive processing speed.

[0122] In another possible implementation, the primitive processing pipeline 61 in the graphics processing device includes at least one first primitive processing pipeline 6110 and at least one second primitive processing pipeline 6120.

[0123] The vertex detection circuit 60 can filter the input primitives. If the vertex detection circuit 60 determines that the input primitive is within the display range, it can also classify the primitives within the display range into two types: normal primitives and oversized primitives.

[0124] The vertex detection circuit 60 can determine that the input primitive is a normal primitive if all vertices of the primitive are within the preset judgment range. If at least one vertex of the primitive is not within the judgment range, the rasterizer 30 can determine that the input primitive is an oversized primitive. Figure 10 As shown, all vertices of primitives 5 and 6 are outside the judgment range. Primitive 5 has one vertex outside the judgment range, making it a super-large primitive. All vertices of primitive 6 are outside the judgment range, making it a super-large primitive.

[0125] In one example, the decision range can be determined based on the representation range of the floating-point number format. Any value within the decision range is within the representation range of the floating-point number format.

[0126] In another example, the judgment range may be determined based on simulation experiment results or set based on empirical values, and the judgment range is larger than the protection zone range in the prior art 2.

[0127] After determining that a primitive is within the display range, the vertex detection circuit 60 determines whether the primitive is an oversized primitive. The vertex detection circuit 60 can determine whether all vertices of the primitive are within the judgment range by comparing the coordinates of all vertices of the primitive with a second coordinate threshold. The second coordinate threshold can be determined based on the vertex coordinates within the judgment range. The second coordinate threshold may include a second horizontal coordinate threshold and a second vertical coordinate threshold. For example, as... Figure 10 As shown, the vertex coordinates within the judgment range are (r1, t1), (r1, t2), (r2, t1), and (r2, t2), where r2 > r1 and t2 > t1. The second horizontal coordinate thresholds are r1 and r2, and the second vertical coordinate thresholds are t1 and t2. The coordinates of the i-th vertex Pi among all vertices of the primitive can be denoted as (m... i n i The vertex detection circuit 60 can detect the x-coordinate m of a primitive vertex. i Compare with r1 and r2 respectively, and set the ordinate n of the primitive vertex. i Compare with t1 and t2 respectively.

[0128] If, among all the vertices in a primitive, there exists a vertex whose x-coordinate is less than r1 or greater than r2, then the primitive is determined to be outside the judgment range, and thus the input primitive is identified as an oversized primitive. Alternatively, if, among all the vertices in a primitive, there exists a vertex whose y-coordinate is less than t1 or greater than t2, the vertex detection circuit 60 can also determine that the primitive is outside the judgment range and is also an oversized primitive.

[0129] When determining whether a primitive is an oversized primitive, the vertex detection circuit 60 determines that the primitive is a normal primitive if it determines that the primitive is not an oversized primitive.

[0130] Vertex detection circuit 60 can input the vertex coordinates of input primitives identified as oversized primitives to the first primitive processing pipeline 6110, which determines the coefficients of the fixed-point number format of the edge equation of the input primitive. Rasterizer 30 can also input the vertex coordinates of input primitives identified as normal primitives to the second primitive processing pipeline 6120, which determines the coefficients of the fixed-point number format of the edge equation of the input primitive.

[0131] In this embodiment, the graphics processing device processes ultra-large and normal primitive types of primitives through the first primitive processing pipeline 6110 and the second primitive processing pipeline 6120, respectively, which can improve the primitive processing speed and performance. Especially in scenarios involving a large number of primitives, the graphics processing device provided in this embodiment has a faster processing speed compared to the prior art. Furthermore, the graphics processing device provided in this embodiment processes polygonal primitives without needing to split polygonal primitives into multiple triangular primitives, thereby improving processing speed and reducing computational load.

[0132] In the graphics processing apparatus provided in the above embodiments, the rasterization circuit 62 can determine the fragments covered by the primitive based on the coefficients of the fixed-point format of the edge equation of the primitive. Since the mathematical operations of the fixed-point format are simple and highly accurate, the rasterization circuit 62, based on the coefficients of the fixed-point format of the edge equation provided by the primitive processing pipeline 61, can improve the accuracy of determining the fragments covered by the primitive, avoid calculation errors, and thus improve the display or rendering effect of the primitive. Typically, the fixed-point format of the edge equation of the primitive can be a 6-bit or 8-bit decimal fixed-point format.

[0133] In one possible implementation, for any pixel in the screen, the rasterization circuit 62 determines whether the pixel satisfies the preset positional relationship corresponding to the i-th straight line based on the equation corresponding to the i-th straight line, wherein the preset positional relationship of the i-th straight line is that the pixel is on the preset direction side of the i-th straight line, i = {1,2,3...N}, and N is the number of the multiple straight lines.

[0134] The rasterization circuit 62 can determine whether any pixel PYj (j={1,2,3……M}) in the display range is on the side closer to the interior of the pixel on each straight line. For example... Figure 11 As shown, the outline of element 7 corresponds to three straight lines, namely L1, L2, and L3. Figure 11 The dashed arrows indicate the side of each line closest to the interior of the element.

[0135] When the rasterization circuit 62 determines whether the fragment satisfies the preset positional relationship corresponding to the i-th straight line based on the equation corresponding to the i-th straight line, it can determine whether any fragment PYj satisfies the condition of pointing to the inside of the primitive on the i-th straight line.

[0136] In one example, the rasterization circuit 62 can calculate the value num = A'xj' + B'yj' + C' based on the equation Ai'x + Bi'y + Ci' = 0 (Ai', Bi', and Ci' are in fixed-point format) corresponding to the i-th straight line. If num > 0, it can be determined that the fragment PYj points to one side inside the primitive on the i-th straight line, which also satisfies the preset positional relationship corresponding to the i-th straight line.

[0137] If fragment PYj satisfies a preset positional relationship with all straight lines, then fragment PYj can be determined to be inside the primitive. The rasterization circuit 62 can determine all fragments (which are also target fragments) covered by the primitive by traversing all fragments in the display range and identifying the fragments that satisfy the preset positional relationship with all straight lines as target fragments.

[0138] In this embodiment, the rasterization circuit 62 uses the coefficients of the edge equation of the primitive in a fixed-point format to cover the fragments. Because the fixed-point format has higher calculation accuracy, it can more accurately determine whether any fragment in the display range is in the primitive.

[0139] After the rasterization circuit 62 determines the target fragment, it can send the coordinates of the target fragment to the fragment shader 31. The fragment shader 31 can perform shading processing on the target fragment. The fragment shader 31 can also perform rendering processing on the target fragment.

[0140] The drawing layer unit 33 can fill pixels in the layer to be drawn within the display area based on the result of coloring the target fragment. The drawing layer unit 33 can also generate layers, which include the target fragment after coloring or rendering. The graphics processing device may also include a display controller and a display screen assembly. The display controller can output and display the target fragment on the display screen assembly.

[0141] Figure 12 The diagram illustrates the primitive processing process of the graphics processing apparatus provided in this application. The primitive processing includes two processes: rasterization and fragment shading. Prior art graphics processing apparatuses, before the rasterization process, need to determine the vertices where the primitive intersects with the guard band, and then trim the primitive into one or more new primitives composed of these intersection point groups based on these vertices. However, the graphics processing apparatus provided in this application does not perform primitive trimming before rasterization and does not generate new primitive vertices. Unlike the prior art, the graphics processing apparatus provided in this application can utilize the first primitive processing pipeline 6110 and / or the second primitive processing pipeline 6120 to determine the coefficients of the fixed-point format of the edge equations of the primitives. Then, the rasterization circuit 62 determines the fragments covered by the primitives based on the coefficients of the fixed-point format of each line equation, completing the rasterization process.

[0142] Therefore, the graphics processing device provided in this application embodiment can directly process the original primitives. If the graphics processing device has a vertex transformation function, the original primitives are the primitives after the vertex transformation process. The coordinate range of the original primitive vertices is not limited by the screen or guard band, and the graphics processing device does not need to redefine the primitives through clipping, which can improve the processing speed of primitives and has better graphics processing performance.

[0143] In a test environment, under conditions where the graphics processing device provided in this application embodiment processes millions of primitives, it exhibits faster processing speed, significant performance improvement, and lower power consumption compared to existing graphics processing devices (such as GPUs). Furthermore, the graphics processing device provided in this application embodiment can quickly process complex primitives, and its processing performance for complex primitives is superior to that of existing graphics processing devices.

[0144] Based on the above embodiments, this application provides a graphics processing method that can be executed by an electronic device. See also... Figure 13 This is a flowchart illustrating the graphics processing method provided in an embodiment of this application. The method can be... Figure 3 The graphics processing device shown performs the operation. For example... Figure 13 As shown, the process of this method includes:

[0145] S1301 receives the coordinates of all vertices of the original primitive.

[0146] The electronic device can receive graphics processing instructions, which contain the coordinates of all vertices of the original primitive. The graphics processing instructions may also include attribute data such as the primitive's color, normal vector, and texture coordinates. The graphics processing instructions received by the electronic device may be sent by an external device. The input primitive can be a line, triangle, or polygon. In this embodiment, the vertex coordinates of the original primitive can be represented in floating-point format.

[0147] When displaying graphics, lines have a certain width. During the primitive processing, electronic devices can decompose primitives belonging to lines into two sides or four sides.

[0148] S1302, determine whether to discard graphic elements. If yes, proceed to step S1303. If no, proceed to step S1304.

[0149] The electronic device can employ the process described in the above embodiment, where the rasterizer 30 determines whether a graphic element is outside the display range. If the graphic element is determined to be outside the display range, it can be determined to discard the graphic element, and then step S1303 is executed. If the graphic element is determined to be within the display range, it can be determined not to discard the graphic element, and then step S1304 is executed.

[0150] S1303, Discard primitives.

[0151] S1304, determine whether the graphic element is a normal graphic element. If yes, proceed to step S1305. If no, proceed to step S1307.

[0152] The electronic device can employ the process described in the above embodiment where the rasterizer 30 classifies the graphic elements within the display range. If the graphic element is determined to be a normal graphic element, the next step is to execute step S1305; if the graphic element is determined to be an oversized graphic element, the next step is to execute step S1307.

[0153] S1305 converts the floating-point coordinates of a graphic element to a fixed-point coordinate format.

[0154] Electronic devices can convert the floating-point coordinates of primitive vertices into fixed-point coordinates, where the coordinates of the primitive vertices are within the range of values ​​that can be represented by the fixed-point format.

[0155] S1306, Based on the coordinates of the fixed-point format of the primitive, determine the fixed-point format coefficients of the linear equations corresponding to each side of the primitive.

[0156] The electronic device can use the second coefficient determination circuit 6122 in the above embodiment to determine the fixed-point format coefficients of the linear equation, and determine the fixed-point format coefficients of the linear equation corresponding to each side of the primitive.

[0157] S1307, based on the coordinates of the primitive in floating-point format, determine the floating-point format coefficients of the linear equations corresponding to each side of the primitive.

[0158] The electronic device can use the first coefficient determination circuit 6111 in the above embodiment to determine the floating-point format coefficients of the linear equation, and determine the floating-point format coefficients of the linear equation corresponding to each side of the primitive.

[0159] S1308 converts the floating-point format coefficients of the line equation corresponding to each edge into fixed-point format coefficients.

[0160] The electronic device can use the first format conversion circuit 6112 in the above embodiment to convert the floating-point format coefficients of the linear equation into fixed-point format coefficients to determine the fixed-point format coefficients of the linear equation.

[0161] Electronic devices can also determine the target fragments covered by the primitives based on the fixed-point format coefficients of the line equations corresponding to each side of the primitives, and then perform coloring or rendering processing on the target fragments covered by the primitives.

[0162] The electronic device can also generate layers, which include target fragments after shading or rendering. The electronic device may include a display controller and a display screen assembly. The display controller can output and display the target fragments onto the display screen assembly.

[0163] This application also provides a graphics processing method that can be executed by an electronic device. For example... Figure 14 As shown, the graphics processing method may include the following steps:

[0164] S1401, Obtain the primitive to be processed, where the vertex coordinates of the primitive are in floating-point format.

[0165] S1402, for any two adjacent vertices of a primitive, determines the coefficients of the equation in the fixed-point number format corresponding to the line containing the two vertices based on the coordinates of the two vertices.

[0166] The equation coefficients can include abscissa coefficients, ordinate coefficients, and constant terms. The abscissa coefficients are determined based on the difference between the ordinate values ​​of the first and second vertices.

[0167] The coefficients of the vertical variable are determined based on the difference between the x-coordinate values ​​of the second vertex and the x-coordinate values ​​of the first vertex;

[0168] The constant term is determined based on the difference between the first value and the second value. The first value is the product of the x-coordinate of the first vertex and the y-coordinate of the second vertex, and the second value is the product of the x-coordinate of the second vertex and the y-coordinate of the first vertex.

[0169] In this process, the vertices of the primitives are sorted in a preset order, with the first vertex preceding the second vertex.

[0170] In one possible implementation, the x-coordinate or y-coordinate value of at least one vertex of a primitive is greater than a preset value, and the x-coordinate or y-coordinate value of at least one vertex of the rectangular outline of the primitive is within the coordinate range of the screen. When the electronic device determines the equation coefficients of the fixed-point format corresponding to the line containing the two vertices based on the coordinates of the two vertices, it can also determine the equation coefficients of the floating-point format corresponding to the line containing the two vertices based on the coordinates of the two vertices. The electronic device determines a scaling factor based on the equation coefficients of the floating-point format and a target threshold, wherein the target threshold is the maximum value that the fixed-point format can represent. Then, the equation coefficients of the fixed-point format are determined based on the equation coefficients of the floating-point format and the scaling factor.

[0171] In one possible implementation, the x-coordinate and y-coordinate values ​​of all vertices of the primitive are less than preset values. When the electronic device determines the equation coefficients in the fixed-point format corresponding to the line containing the two vertices based on their coordinates, it can convert the coordinates of the two vertices into a fixed-point format. Then, the electronic device determines the equation coefficients in the fixed-point format based on the converted coordinates of the two vertices.

[0172] S1403, determine the target fragment in the screen based on the equation coefficients corresponding to multiple straight lines, including the straight line containing every two adjacent vertices of the fragment.

[0173] For any pixel on the screen, the electronic device determines whether the pixel satisfies the preset positional relationship corresponding to the i-th line based on the equation corresponding to the i-th line. Here, the preset positional relationship of the i-th line is that the pixel is on the preset direction side of the i-th line, where i = {1, 2, 3, ..., N}, and N is the number of lines. If the pixel satisfies the preset positional relationships corresponding to the multiple lines, the electronic device determines the pixel as the target pixel.

[0174] S1404, color the target fragment.

[0175] The electronic device performs color processing on the target fragment.

[0176] Figure 13 and Figure 14 The graphic processing method shown is Figure 3 The illustrated graphics processing device provides a specific example of primitive processing. Figure 13 and Figure 14 For details regarding the implementation methods and technical effects of the graphics processing methods shown, please refer to [link to relevant documentation]. Figure 3 The relevant description of the graphics processing device shown.

[0177] This application also provides a GPU1500. For example... Figure 15 As shown, GPU1500 may include rasterizer 1501 and shader 1502.

[0178] In one example, the rasterizer 1501 of the GPU1500 can be used with... Figure 3 The rasterizer 30 of the image processing device corresponds to the shader 1502. Figure 3 The fragment shader 31 of the image processing device corresponds to this.

[0179] In another example, rasterizer 1501 and shader 1502 are... Figure 3 The components in the corresponding image processing device are similar, but not limited to these. The GPU1500 may include, in addition to Figure 3 Components other than those in the corresponding image processing device, or may include Figure 3 Additional similar components in the corresponding image processing device.

[0180] In this embodiment, the rasterizer 1501 can acquire the primitive to be processed, specifically any two adjacent vertices of the primitive. It then determines the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices based on their coordinates. Finally, it determines the target fragment on the screen based on the equation coefficients corresponding to multiple straight lines, where the multiple straight lines include the straight lines containing every two adjacent vertices of the primitive, and the vertex coordinates of the primitive are in floating-point format.

[0181] Shader 1502 can color the target fragment.

[0182] In one possible implementation, the x-coordinate or y-coordinate of at least one vertex of the graphic element is greater than a preset value; the maximum y-coordinate of all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate of the coordinate range of the screen; the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range; the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range; and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range.

[0183] When the rasterizer 1501 determines the equation coefficients of the fixed-point format corresponding to the line containing the two vertices based on their coordinates, it can specifically determine the equation coefficients of the floating-point format corresponding to the line containing the two vertices based on their coordinates. A scaling factor is determined based on the floating-point format equation coefficients and a target threshold, where the target threshold is the maximum value that the fixed-point format can represent. The equation coefficients of the fixed-point format are then determined based on the floating-point format equation coefficients and the scaling factor.

[0184] In another possible implementation, the x-coordinate and y-coordinate values ​​of all vertices of the primitive are both less than preset values, the maximum y-coordinate value among all vertices of the rectangular outline of the primitive is greater than the minimum y-coordinate value in the coordinate range of the screen, and the minimum y-coordinate value among all vertices is less than the maximum y-coordinate value in the coordinate range, and the maximum x-coordinate value among all vertices is greater than the minimum x-coordinate value in the coordinate range, and the minimum x-coordinate value among all vertices is less than the maximum x-coordinate value in the coordinate range.

[0185] When the rasterizer 1501 determines the equation coefficients in a fixed-point format corresponding to the lines containing the two vertices based on their coordinates, it can specifically convert the coordinates of the two vertices into a fixed-point format. Then, based on the converted coordinates of the two vertices, it determines the equation coefficients in the fixed-point format.

[0186] In one possible implementation, the equation coefficients in this embodiment may include abscissa coefficients, ordinate coefficients, and a constant term. The abscissa coefficients are determined based on the difference between the ordinate values ​​of the first and second vertices. The ordinate coefficients are determined based on the difference between the abscissa values ​​of the second and first vertices. The constant term is determined based on the difference between a first value and a second value, where the first value is the product of the abscissa of the first vertex and the ordinate of the second vertex, and the second value is the product of the abscissa of the second vertex and the ordinate of the first vertex. The vertices of the primitives are sorted according to a preset order, with the first vertex preceding the second vertex.

[0187] When the rasterizer 1501 determines the target fragment in the screen based on the equation coefficients corresponding to multiple straight lines, it can specifically determine, for any fragment in the screen, whether the fragment satisfies the preset positional relationship corresponding to the i-th straight line based on the equation coefficients corresponding to the i-th straight line. The preset positional relationship of the i-th straight line is that the fragment is on the preset direction side of the i-th straight line, where i = {1, 2, 3... N}, and N is the number of the multiple straight lines. If the fragment satisfies the preset positional relationships corresponding to the multiple straight lines, then the fragment is determined to be the target fragment.

[0188] In one possible implementation, GPU 1500 may further include memory 1503. Memory 1503 may store data required during primitive processing, such as vertex attribute data and display range information of primitives. Memory 1503 may also store data generated during primitive processing, such as coefficients of edge equations of primitives and target fragment information. The memory in this embodiment may be volatile memory or non-volatile memory, or may include both. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), and synchronous link dynamic random access memory (SLDRAM). It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memory.

[0189] In one possible implementation, the GPU1500 in this embodiment can be an integrated circuit chip with primitive processing capabilities. The GPU1500 may include at least one first primitive processing pipeline, which can determine the fixed-point format coefficients of the edge equations for very large primitives. The GPU1500 may include at least one second primitive processing pipeline, which can determine the fixed-point format coefficients of the edge equations for normal primitives. The GPU1500 may also include at least one first primitive processing pipeline and at least one second primitive processing pipeline.

[0190] Accordingly, embodiments of this application also provide a chip. For example... Figure 16As shown, the chip may include a GPU 1600 and an input / output circuit 1601. The input / output circuit 1601 and the GPU 1600 can be connected via a bus 1602. The input / output circuit 1601 in the chip can receive primitive processing instructions or receive vertex coordinates and attribute data of primitives. The GPU 1600 may be as follows: Figure 3 The image processing device in the image processing device can also be as follows: Figure 15 The GPU1500 and GPU1600 can perform operations on primitives based on their vertex coordinates, such as... Figure 13 , Figure 14 The method described in the embodiments above.

[0191] In one possible implementation, the chip further includes a memory 1603, which may be as follows: Figure 15 The memory 1503 is used in the GPU. Memory 1603 can store data required by the graphics processing process, or data generated during the graphics processing process. Memory 1603 can also store instructions. The GPU 1600 can request the required data from memory 1603.

[0192] This application also provides an electronic device. The electronic device can be implemented as a computer, portable computer, handheld device (e.g., mobile phone, tablet computer), server, virtual reality device, augmented reality device, mixed reality device, wearable electronic device with a display screen, projection device, holographic device, or other device with display functionality.

[0193] like Figure 17 As shown, the electronic device may include a GPU 1700, a processor 1701, and a display screen assembly 1702. The GPU 1700 can be any of the graphics processing devices or GPUs provided in the above embodiments. The GPU 1700, processor 1701, and display screen assembly 1702 can be connected via a bus 1703, enabling the hardware within the electronic device to send and receive data. Figure 17 The bus is represented by only one thick line, but this does not mean that there is only one bus or one type of bus. The bus can be divided into address bus, data bus, control bus, etc.

[0194] Processor 1701 can be hardware used to control the overall operation and functions of an electronic device. For example, processor 1701 can be a central processing unit (CPU) or a display controller. Processor 1701 can control display screen component 1702 to display target fragments or layers provided by GPU 1700.

[0195] Display screen assembly 1702 may include various types of display screens, such as liquid crystal display (LCD), cathode ray tube (CRT) display, light-emitting diode (LED) display, organic light-emitting diode (OLED) display, combined LCD-LED display, plasma display panel (PDP), digital light processing (DLP) display, or other types of devices or apparatuses that can display chips.

[0196] The electronic device may also include a memory 1704, which is connected to other hardware in the electronic device via a bus 1703. The memory 1704 can store various types of data processed within the electronic device. For example, the memory 1704 stores programs that the processor 1701 needs to execute.

[0197] This application also provides a computer-readable storage medium for storing computer software instructions required to execute the processor, including a program required to execute the processor.

[0198] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

Claims

1. A graphics processing method, characterized in that, The method includes: Obtain the primitive to be processed, wherein the vertex coordinates of the primitive are in floating-point format; For any two adjacent vertices of the given primitive, determine the equation coefficients of the fixed-point number format corresponding to the line containing the two vertices based on the coordinates of the two vertices; The target fragment in the screen is determined based on the equation coefficients corresponding to multiple straight lines, wherein the multiple straight lines include the straight line containing every two adjacent vertices of the fragment; The target fragment is colored.

2. The method as described in claim 1, characterized in that, The x-coordinate or y-coordinate of at least one vertex of the graphic element is greater than a preset value; the maximum y-coordinate of all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate of the coordinate range of the screen; the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range; the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range; and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range. The step of determining the coefficients of the fixed-point number equation corresponding to the line containing the two vertices based on their coordinates includes: Based on the coordinates of the two vertices, determine the equation coefficients in floating-point format corresponding to the lines containing the two vertices; Based on the equation coefficients of the floating-point number format and the target threshold, a scaling factor is determined, wherein the target threshold is the maximum value that the fixed-point number format can represent; The equation coefficients of the fixed-point number format are determined based on the equation coefficients of the floating-point number format and the scaling factor.

3. The method as described in claim 1, characterized in that, The x-coordinate and y-coordinate values ​​of all vertices of the graphic element are all less than preset values. The maximum y-coordinate value of all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate value of the coordinate range of the screen. The minimum y-coordinate value of all vertices is less than the maximum y-coordinate value of the coordinate range. The maximum x-coordinate value of all vertices is greater than the minimum x-coordinate value of the coordinate range. The minimum x-coordinate value of all vertices is less than the maximum x-coordinate value of the coordinate range. The step of determining the coefficients of the fixed-point number equation corresponding to the line containing the two vertices based on their coordinates includes: Convert the coordinates of the two vertices into a fixed-point number format; The equation coefficients of the fixed-point number format are determined based on the coordinates of the two vertices converted to a fixed-point number format.

4. The method according to any one of claims 1-3, characterized in that, The equation coefficients include abscissa coefficients, ordinate coefficients, and a constant term, wherein the abscissa coefficients are determined based on the difference between the ordinate values ​​of the first vertex and the ordinate values ​​of the second vertex. The ordinate coefficient is determined based on the difference between the x-coordinate value of the second vertex and the x-coordinate value of the first vertex. The constant term is determined based on the difference between the first value and the second value. The first value is the product of the x-coordinate of the first vertex and the y-coordinate of the second vertex, and the second value is the product of the x-coordinate of the second vertex and the y-coordinate of the first vertex. The fixed points of the graphic elements are sorted in a preset order, with the first vertex preceding the second vertex.

5. The method according to any one of claims 1-3, characterized in that, The step of determining the target fragment in the screen based on the equation coefficients corresponding to all straight lines includes: For any piece of data in the screen, determine whether the piece of data satisfies the preset positional relationship corresponding to the i-th line based on the equation coefficients corresponding to the i-th line, wherein the preset positional relationship of the i-th line is that the piece of data is on the preset direction side of the i-th line, i = {1,2,3...N}, and N is the number of the multiple lines; If the fragment satisfies the preset positional relationship corresponding to the multiple straight lines, then the fragment is determined to be the target fragment.

6. A graphics processing device, characterized in that, The device includes: A rasterizer is used to acquire primitives to be processed, wherein the vertex coordinates of the primitives are in floating-point format; and for any two adjacent vertices of the primitive, to determine the equation coefficients in fixed-point format corresponding to the straight lines containing the two vertices based on the coordinates of the two vertices; and to determine the target fragments in the screen based on the equation coefficients corresponding to multiple straight lines, wherein the multiple straight lines include the straight lines containing every two adjacent vertices of the primitive. A shader is used to color the target fragment.

7. The apparatus as claimed in claim 6, characterized in that, The x-coordinate or y-coordinate of at least one vertex of the graphic element is greater than a preset value; the maximum y-coordinate of all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate of the coordinate range of the screen; the minimum y-coordinate of all vertices is less than the maximum y-coordinate of the coordinate range; the maximum x-coordinate of all vertices is greater than the minimum x-coordinate of the coordinate range; and the minimum x-coordinate of all vertices is less than the maximum x-coordinate of the coordinate range. When the rasterizer determines the coefficients of the fixed-point number equation corresponding to the line containing the two vertices based on their coordinates, it is specifically used for: Based on the coordinates of the two vertices, determine the equation coefficients in floating-point format corresponding to the lines containing the two vertices; Based on the equation coefficients of the floating-point number format and the target threshold, a scaling factor is determined, wherein the target threshold is the maximum value that the fixed-point number format can represent; The equation coefficients of the fixed-point number format are determined based on the equation coefficients of the floating-point number format and the scaling factor.

8. The apparatus as claimed in claim 6, characterized in that, The x-coordinate and y-coordinate values ​​of all vertices of the graphic element are all less than preset values. The maximum y-coordinate value of all vertices of the rectangular outline of the graphic element is greater than the minimum y-coordinate value of the coordinate range of the screen. The minimum y-coordinate value of all vertices is less than the maximum y-coordinate value of the coordinate range. The maximum x-coordinate value of all vertices is greater than the minimum x-coordinate value of the coordinate range. The minimum x-coordinate value of all vertices is less than the maximum x-coordinate value of the coordinate range. When the rasterizer determines the coefficients of the fixed-point number equation corresponding to the line containing the two vertices based on their coordinates, it is specifically used for: Convert the coordinates of the two vertices into a fixed-point number format; The equation coefficients of the fixed-point number format are determined based on the coordinates of the two vertices converted to a fixed-point number format.

9. The apparatus as described in any one of claims 6-8, characterized in that, The equation coefficients include abscissa coefficients, ordinate coefficients, and a constant term, wherein the abscissa coefficients are determined based on the difference between the ordinate values ​​of the first vertex and the ordinate values ​​of the second vertex. The ordinate coefficient is determined based on the difference between the x-coordinate value of the second vertex and the x-coordinate value of the first vertex. The constant term is determined based on the difference between the first value and the second value. The first value is the product of the x-coordinate of the first vertex and the y-coordinate of the second vertex, and the second value is the product of the x-coordinate of the second vertex and the y-coordinate of the first vertex. The fixed points of the graphic elements are sorted in a preset order, with the first vertex preceding the second vertex.

10. The apparatus according to any one of claims 6-8, characterized in that, When the rasterizer determines the target fragment in the screen based on the equation coefficients corresponding to multiple straight lines, it is specifically used for: For any piece of data in the screen, determine whether the piece of data satisfies the preset positional relationship corresponding to the i-th line based on the equation corresponding to the i-th line, wherein the preset positional relationship of the i-th line is that the piece of data is on the preset direction side of the i-th line, i = {1,2,3...N}, and N is the number of the multiple lines; If the fragment satisfies the preset positional relationship corresponding to the multiple straight lines, then the fragment is determined to be the target fragment.

11. An electronic device, characterized in that, Includes a processor, a display screen assembly, and a graphics processing device as described in any one of claims 6-10; The processor is used to output the target fragment obtained by the graphics processing device and display it on the display screen assembly.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 5.

13. A chip, characterized in that, Includes a graphics processor, which, when executing instructions, performs the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Screen-based three-dimensional linear symbol rendering method

    CN107564087A

  • GPU line primitive rasterization translation coordinate system scanning method

    CN110969567A