Pixel cutting method and device, equipment, storage medium and computer program product

By dynamically updating the crop parameters, the cropped primitives are determined based on the positional relationship between the crop surface and the primitives, the invalid cropping problem caused by changes in the primitive shape is solved, and the efficiency and performance of the primitive cropping are improved.

CN119151953AActive Publication Date: 2024-12-17MOORE THREADS TECHNOLOGY (SHANGHAI) CO LTD

Patent Information

Application Number
CN202411342370.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-17
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

During the element cropping process, changes in element shape lead to unnecessary cropping, resulting in wasted time and power consumption.

Method used

By obtaining the primitive and its corresponding cropping surface, dynamically update the cropping parameters according to the positional relationship between the cropping surface and the primitive, avoiding invalid cropping and reducing the cropping process.

Benefits of technology

Improves the efficiency of element cropping, reduces time and power consumption, and avoids ineffective cropping.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119151953A_ABST
    Figure CN119151953A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a primitive cutting method and device, equipment, a storage medium and a computer program product. The primitive clipping method comprises the following steps: acquiring a primitive and at least one clipping surface corresponding to the primitive; in the process of executing the cutting corresponding to each cutting surface according to the preset sequence, determining cutting parameters based on the position relationship between at least one cutting surface and the current primitive; the current primitive is a primitive or a result obtained after the primitive is cut at least once; and determining the current primitive as a clipped primitive under the condition that the clipping parameter represents that the clipping surface needing to clip the current primitive does not exist. According to the embodiment of the invention, the clipping parameter is updated according to the updated current primitive in the process of clipping the current primitive, and whether clipping is ended or not is judged according to the updated clipping parameter, so that invalid primitive clipping is avoided, time and power consumption required by primitive clipping are reduced, and the efficiency of primitive clipping is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computer image processing, and in particular to a primitive clipping method, device, equipment, storage medium and computer program product. Background Art

[0002] In a graphics processor (GPU), the invisible or unnecessary parts of the image rendering process can be removed by primitive clipping to improve rendering efficiency and reduce unnecessary calculations. In the related art, the specific clipping plane that needs to be clipped for the primitive is determined according to the primitive clipping mask of the primitive, so as to clip the primitive according to the specific clipping plane. During the primitive clipping process, the shape of the primitive may change, so that the primitive no longer needs to be clipped for some specific clipping planes. If the original clipping mask is continued to be used to clip the primitive for each specific clipping plane, it may cause a waste of time and power consumption required for primitive clipping. Summary of the invention

[0003] In view of this, embodiments of the present application provide a primitive clipping method, apparatus, device, storage medium and computer program product, which improve the efficiency of primitive clipping.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a method for clipping a primitive, comprising: obtaining a primitive and at least one clipping plane corresponding to the primitive; in the clipping process corresponding to each clipping plane executed in a preset order, determining clipping parameters based on a positional relationship between at least one clipping plane and a current primitive; the current primitive is the primitive or the result of clipping the primitive at least once; when the clipping parameters indicate that there is no clipping plane that needs to be clipped for the current primitive, determining the current primitive as the clipped primitive.

[0006] In a second aspect, an embodiment of the present application also provides a primitive clipping device, comprising: a data acquisition module, used to acquire a primitive and at least one clipping surface corresponding to the primitive; a parameter determination module, used to determine clipping parameters based on a positional relationship between at least one clipping surface and a current primitive in a clipping process corresponding to each clipping surface executed in a preset order; the current primitive is the primitive or the result of at least one clipping of the primitive; and a result determination module, used to determine the current primitive as a clipped primitive when the clipping parameters indicate that there is no clipping surface that requires clipping the current primitive.

[0007] In a third aspect, an embodiment of the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements any of the above primitive clipping methods when executing the computer program.

[0008] In a fourth aspect, an embodiment of the present application further provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, any of the above primitive clipping methods is implemented.

[0009] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above primitive clipping cache allocation methods.

[0010] In summary, in the primitive clipping method provided in the embodiment of the present application, a primitive and at least one clipping plane corresponding to the primitive are obtained; in the clipping process corresponding to each clipping plane is executed in a preset order, clipping parameters are determined based on the positional relationship between at least one clipping plane and the current primitive; when the clipping parameters indicate that there is no clipping plane that needs to be clipped for the current primitive, the current primitive is determined as the clipped primitive. In the process of clipping the current primitive, the embodiment of the present application updates the clipping parameters based on the current primitive updated after clipping, and ends the clipping when the updated clipping parameters indicate that no further clipping is required, thereby avoiding invalid primitive clipping, reducing the time and power consumption required for primitive clipping, and improving the efficiency of primitive clipping. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings are embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0012] Figure 1 A schematic diagram of the system architecture of the primitive clipping method provided in an embodiment of the present application;

[0013] Figure 2 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 1 ;

[0014] Figure 3 A schematic diagram of a scene of a graphic element and a clipping surface provided in an embodiment of the present application;

[0015] Figure 4 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 2 ;

[0016] Figure 5 A schematic diagram of another scene of a primitive and a clipping plane provided in an embodiment of the present application;

[0017] Figure 6 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 3 ;

[0018] Figure 7A schematic diagram of a vertex clipping mask of a vertex provided in an embodiment of the present application;

[0019] Figure 8 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 4 ;

[0020] Fig. 9 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 5 ;

[0021] Fig.10 A schematic diagram of a count value of a cutting surface provided in an embodiment of the present application;

[0022] Fig.11 A schematic diagram of another counting value of a cutting surface provided in an embodiment of the present application;

[0023] Fig.12 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 6 ;

[0024] Fig.13 A schematic diagram of a primitive clipping device provided in an embodiment of the present application;

[0025] Fig.14 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0027] It should be understood that the "embodiment of the present application" or "the aforementioned embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in the embodiment of the present application" or "in the aforementioned embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0028] In addition, the accompanying drawings are only schematic diagrams of the embodiments of the present application and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and thus their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices. The terms used in this application are only for the purpose of describing specific embodiments, and are not intended to limit the present disclosure. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0029] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this application and are not intended to limit this application.

[0031] In the related art, the GPU determines the specific clipping planes that need to be clipped for the primitives according to the primitive clipping mask of the primitives, so as to clip the primitives according to the specific clipping planes. During the primitive clipping process, the primitive may no longer need to be clipped for some specific clipping planes due to the change of the primitive shape. If the original clipping mask is continued to be used to clip the primitives for each specific clipping plane, it may cause a waste of time and power consumption required for primitive clipping.

[0032] Based on the above problems, an embodiment of the present application proposes a primitive cropping method. During the process of cropping the current primitive, the cropping parameters are updated based on the current primitive updated after cropping, and the cropping is terminated when the updated cropping parameters indicate that no further cropping is needed, thereby avoiding invalid primitive cropping, reducing the time and power consumption required for primitive cropping, and improving the efficiency of primitive cropping.

[0033] Figure 1Schematic diagram of the system architecture of the primitive clipping method provided in the embodiment of the present application. Figure 1 As shown, the system architecture 100 includes a primitive assembly module 101, a clipping module 102 and a vertex buffer 103. The primitive assembly module 101 is used to generate vertex coordinates, primitive information and protection band parameters. The primitive information includes the vertex coordinates of the primitive. The primitive assembly module 101 is also used to remove primitives whose vertices are outside each clipping surface of at least one clipping surface and do not need to be clipped, remove primitives whose vertices are within the protection area determined by the protection band parameters and the area within each clipping surface of at least one clipping surface, and send the vertex coordinates of the primitives whose vertices are partly within the protection area to the clipping module 102. The clipping module 102 is used to clip the primitives according to the received primitive information. The vertex buffer 103 is used to cache the clipping results obtained by clipping the primitives.

[0034] The clipping module 102 includes a clipping parameter generation unit 1021, a clipping decision unit 1022 and a clipping execution unit 1023. The clipping parameter generation unit 1021 is used to generate clipping parameters required in the process of clipping the primitive according to the positional relationship between the primitive and the clipping window, and to update the clipping parameters according to the clipped primitive; the clipping decision unit 1022 is used to determine the current clipping surface currently used for clipping the current primitive according to the current clipping parameters; the clipping execution unit 1023 can clip the current primitive using the current clipping surface, and send the clipping result to the vertex buffer 103, and the clipping execution unit 1023 can also send the clipping result to the clipping parameter generation unit 1021, so that the clipping parameter generation unit 1021 can update the clipping parameters according to the positional relationship between the new vertex and the clipping window.

[0035] Figure 2 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 1 .like Figure 2 As shown, the primitive clipping method at least includes steps S201 to S203.

[0036] Step S201: Obtain a graphic element and at least one clipping surface corresponding to the graphic element.

[0037] Here, primitives are basic elements constituting a three-dimensional image, such as points, lines, triangles, etc. In some embodiments, primitive information may also be obtained, and the primitive information may include the position and direction of the primitive in space, such as the coordinates of the vertices of the primitive, the normal vector, etc.; the primitive information may also include the attribute information of the primitive, such as the color, transparency, texture coordinates, etc. of the primitive, and the above attributes determine the appearance of the primitive when rendered. Here, at least one clipping plane corresponding to the primitive is a clipping plane for clipping the primitive. In the process of obtaining the clipping plane, relevant information of the clipping plane may be obtained. For example, the plane equation of the clipping plane may be included, and the plane equation is a mathematical equation defining the position and direction of the clipping plane. The clipping plane is usually composed of four parameterized coordinate axes (u, v, w, t) and a distance value, which are used to determine the position and direction of the clipping plane; the clipping boundary of the clipping plane may also be included, which is used to define the boundary range of the clipping plane to limit the range of rendering. It is understandable that the clipping plane information corresponding to each primitive may be the same or different.

[0038] In some embodiments, the clipping planes provided in the present application may include clipping planes corresponding to the viewing cone, or may include user-defined clipping planes. Generally speaking, the clipping planes corresponding to the viewing cone may include four different clipping planes: top, bottom, left, and right.

[0039] In the above step S201, by obtaining the primitive and at least one clipping surface corresponding to the primitive, the clipping process for the primitive can be completed in the subsequent steps to obtain the clipped primitive.

[0040] Step S202: in the cropping process corresponding to each cropping plane executed in a preset order, determine the cropping parameters based on the positional relationship between the at least one cropping plane and the current primitive; the current primitive is the primitive or the result of at least one cropping of the primitive.

[0041] In some embodiments, whether a clipping plane in the at least one clipping plane needs to clip a primitive may be determined in a preset order.

[0042] The preset order is the arrangement order of the clipping planes in the at least one clipping plane. Taking the at least one clipping plane including the upper clipping plane, the lower clipping plane, the left clipping plane, and the right clipping plane as an example, the preset order can be the arrangement order of the upper clipping plane, the lower clipping plane, the right clipping plane, and the left clipping plane, or can be other arrangement orders determined based on experience. It can be understood that in the process of clipping a primitive through at least one clipping plane, the preset order remains unchanged.

[0043] In the above-mentioned cutting process corresponding to each cutting surface is executed in the preset order, taking the cutting process executed to the current cutting surface in the at least one cutting surface as an example, the current cutting surface is the cutting surface used in the current cutting process. Taking the arrangement order of the preset order of the upper cutting surface, the lower cutting surface, the right cutting surface, and the left cutting surface as an example, the current cutting surface used in the first round of cutting process is the upper cutting surface, and the current cutting surface used in the second round of cutting process is the lower cutting surface. It can be understood that in different rounds of cutting processes, the current cutting surface should correspond to different cutting surfaces in the at least one cutting surface.

[0044] In the above step S202, the current clipping plane is determined from at least one clipping plane in a preset order, so that in the subsequent steps, clipping is only performed on one current clipping plane in a round of clipping, instead of directly traversing each clipping plane in at least one clipping plane in a round of clipping to clip the primitive through all clipping planes. This not only improves the accuracy of primitive clipping, but also reduces the situation of invalid clipping.

[0045] In some embodiments, during the process of clipping the current primitive using the current clipping plane, the vertices and shape of the current primitive may change due to clipping, thereby causing the positional relationship between the current primitive and at least one clipping plane to change. Before clipping the current primitive using the current clipping plane, a new clipping parameter may be determined based on the changed positional relationship between the current primitive and at least one clipping plane, so as to determine whether the changed current primitive needs to be clipped based on the new clipping parameter.

[0046] Here, the current primitive is the primitive to be cropped in this round of cropping, corresponding to the current cropping plane. That is, the current primitive is the primitive (uncropped primitive) or the result of the primitive after at least one cropping. It should be noted that the result of the primitive after at least one cropping here refers to the primitive after at least one round of cropping. The above-mentioned uncropped primitive refers to the primitive that has not undergone any round of cropping, that is, the original primitive.

[0047] For example, in the first round of clipping, the current primitive may be an unclipped primitive, and the corresponding current clipping plane may be a first clipping plane, which will be used to clip the unclipped primitive; in the second round of clipping, the current primitive may be a primitive clipped by the first clipping plane, and the corresponding current clipping plane may be a second clipping plane, which will be used to clip the primitive clipped by the first clipping plane. It is understandable that the shape of the current primitive may be different in different rounds of clipping.

[0048] The cropping parameters represent whether there is a cropping surface that needs to be cropped for the current primitive in at least one cropping surface. In the related art, if there are N cropping surfaces, N rounds of cropping processes are required. The present application updates the cropping parameters according to the current primitive updated during the cropping process to determine whether there is a cropping surface that needs to be cropped for the current primitive according to the updated cropping parameters. In the case where there are N cropping surfaces, if in the N-1th round of cropping process, the cropping parameters represent that there is no cropping surface that needs to be cropped for the current primitive, then there is no need to continue cropping the current primitive, and only N-1 rounds of cropping processes are required.

[0049] In some embodiments, a counter may be set for each cutting surface according to the number of cutting surfaces in at least one cutting surface. The cutting parameter may be a count value in the counter corresponding to each cutting surface. The count value may be represented by a first value and a second value, or may be represented by a specific value.

[0050] Exemplarily, taking the example of representing the count value by a first numerical value and a second numerical value, the first numerical value can be used to represent that there are no vertices outside the corresponding clipping plane. When the count value is the first numerical value, the clipping plane corresponding to the count value does not need to clip the current primitive. The second numerical value can be used to represent that there are vertices outside the corresponding clipping plane. When the count value is the second numerical value, the clipping plane corresponding to the count value needs to clip the current primitive.

[0051] In some embodiments, the first numerical value may be a binary number 0, and the second numerical value may be a binary number 1. Taking the use of binary numbers 0 and 1 to represent count values ​​as an example, the binary number 0 may be used to represent that there are no vertices outside the corresponding clipping plane. When the count value is 0, the clipping plane corresponding to the count value does not need to clip the current primitive. The binary number 1 may be used to represent that there are vertices outside the corresponding clipping plane. When the count value is 1, the clipping plane corresponding to the count value needs to clip the current primitive.

[0052] Exemplarily, taking the count value represented by a specific numerical value as an example, when the count value is 0, the number of vertices outside the clipping plane corresponding to the count value is 0, and the clipping plane does not need to clip the current primitive; when the count value is not 0, for example, when the count value is 2, the number of vertices outside the clipping plane corresponding to the count value is 2, and the clipping plane needs to clip the current primitive.

[0053] In some embodiments, the clipping parameter may be a primitive clipping mask composed of a first parameter and a second parameter. A primitive clipping mask bit may be set for each clipping plane according to the number of clipping planes in at least one clipping plane, a primitive clipping mask may be composed according to each primitive clipping mask bit, and whether the current primitive is located outside each clipping plane may be determined according to each primitive clipping mask bit. The primitive clipping mask bit may be a first parameter or a second parameter. When the current primitive is located within a clipping plane, the primitive clipping mask bit corresponding to the clipping plane is the first parameter, indicating that the clipping plane corresponding to the primitive clipping mask bit does not need to clip the current primitive; when the current primitive is located outside a clipping plane, the primitive clipping mask bit corresponding to the clipping plane is the second parameter, indicating that the clipping plane corresponding to the primitive clipping mask bit needs to clip the current primitive.

[0054] In some embodiments, the vertex clipping mask corresponding to each vertex in the current primitive may be determined first, and then a bitwise OR operation may be performed on the vertex clipping masks corresponding to each vertex to determine the primitive clipping mask.

[0055] In some embodiments, when the vertex is within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is the first parameter; when the vertex is outside a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is the second parameter.

[0056] In some embodiments, the first parameter may be a binary number 0, and the second parameter may be a binary number 1. When the vertex is within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is a binary number 0; when the vertex is outside a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is a binary number 1.

[0057] Taking the example that the number of clipping planes in at least one clipping plane is 4, the corresponding vertex clipping mask should consist of 4 vertex clipping mask bits corresponding to the 4 clipping planes. For example, the vertex clipping mask of vertex A in primitive ABC is 0b0000 (0b is the prefix of binary expression, indicating that a binary number follows), the vertex clipping mask of vertex B is 0b0101, and the vertex clipping mask of vertex C is 0b0010. The vertex clipping masks of vertices A, B, and C are bitwise ORed to obtain the primitive clipping mask of primitive ABC, which is 0b0111.

[0058] In the process of determining the clipping parameters, it is necessary to determine whether each vertex is located inside or outside each clipping plane in at least one clipping plane. For example, the distance between each vertex and each clipping plane can be determined by the coordinates of each vertex in the current primitive and the plane coefficient of each clipping plane in at least one clipping plane, and it is determined whether each vertex is located inside or outside each clipping plane according to the distance between each vertex and each clipping plane.

[0059] like Figure 3 As shown, Figure 3 The triangle ABC in the figure represents the primitive to be cropped, and 301, 302, 303 and 304 are four clipping planes corresponding to the primitive to be cropped. The following is explained by taking 301 as the upper clipping plane, 302 as the lower clipping plane, 303 as the right clipping plane, and 304 as the left clipping plane as an example.

[0060] Taking determining the clipping parameters of primitive ABC for the lower clipping plane as an example, the coordinates of vertex A, vertex B, vertex C and the plane coefficient of the lower clipping plane can be determined, and the distances between vertices A, B and C and the lower clipping plane are determined by taking the dot product of the coordinates of vertex A, vertex B and vertex C with the plane coefficient of the lower clipping plane respectively, so as to determine whether vertices A, B and C are inside or outside the lower clipping plane based on the distances between vertices A, B and C and the lower clipping plane.

[0061] Taking the normal vector of the lower clipping plane as (a, b, c) and the coordinates of a point on the lower clipping plane as (x0, y0, z0) as an example, the plane coefficient of the lower clipping plane can be determined by formula (1) and formula (2):

[0062] a(x-x0)+b(y-y0)+c(z-z0)=0 (1);

[0063] Among them, (x0, y0, z0) represent the coordinates of a point on the lower clipping plane, (a, b, c) represent the normal vector of the lower clipping plane, and x, y, and z represent unknowns in the equation.

[0064] By rearranging formula (1), we can obtain formula (2):

[0065] ax+by+cz+d=0 (2);

[0066] Among them, (a, b, c) represents the normal vector of the lower clipping plane, x, y, z represent the unknowns in the equation, d represents the constant in the equation, and (a, b, c, d) is the plane coefficient of the lower clipping plane.

[0067] The coordinates of vertex A are (x A ,y A , z A ) as an example, the distance between vertex A and the lower clipping plane can be determined by formula (3):

[0068]

[0069] Where D0 represents the distance between vertex A and the lower clipping plane, (a, b, c, d) represents the plane coefficient of the lower clipping plane, (x A ,y A , zA ) represents the coordinates of vertex A.

[0070] After determining the distance between vertex A and the lower clipping plane, it can be determined whether vertex A is inside or outside the lower clipping plane according to the distance between vertex A and the lower clipping plane. When the distance between vertex A and the lower clipping plane is a positive number, vertex A is inside the lower clipping plane; when the distance between vertex A and the lower clipping plane is a negative number, vertex A is outside the lower clipping plane. The positional relationship between other vertices and other clipping planes can be determined according to the calculation method in formula (1) to formula (3), so as to determine the clipping parameters according to the positional relationship between each vertex and each clipping plane.

[0071] In the above step S202, in each round of clipping, before clipping begins, new clipping parameters are determined based on the positional relationship between at least one clipping plane and the updated current primitive, so as to determine whether clipping is required based on the new clipping parameters. This reduces the situation of invalid clipping and improves the efficiency of primitive clipping.

[0072] Step S203: When the clipping parameters indicate that there is no clipping plane that needs to clip the current primitive, determine the current primitive as a clipped primitive.

[0073] In some embodiments, it can be determined by the clipping parameters whether there is a clipping plane that needs to clip the current primitive. In the case where there is no clipping plane that needs to clip the current primitive, the clipping of the current primitive is completed. Here, the clipped primitive is the primitive obtained after the clipping of the primitive is completed according to at least one clipping plane.

[0074] Taking the clipping parameter as an example, which is the count value corresponding to each clipping surface in at least one clipping surface, when the count values ​​corresponding to each clipping surface are 0, the number of vertices outside each clipping surface is 0, and there is no clipping surface that needs to be clipped for the current primitive, the clipping is terminated, and the current primitive is determined to be the primitive obtained by clipping the primitive according to at least one clipping surface.

[0075] Taking the clipping parameter as an example, when the primitive clipping mask bits in the primitive clipping mask corresponding to the current primitive are all 0, the current primitive is located within each clipping plane, and there is no clipping plane that needs to clip the current primitive, then clipping is terminated and the current primitive is determined to be the primitive obtained by clipping the primitive according to at least one clipping plane.

[0076] In some embodiments, when the clipping parameters indicate that there is a planned clipping plane that needs to clip the current primitive, the planned clipping plane is used to clip the current primitive.

[0077] Here, the planned clipping plane is the clipping plane that needs to clip the current primitive. It is understandable that the planned clipping plane may be the current clipping plane used in the current round of clipping process, or may be the clipping plane used in the next round or the next round after the next round of clipping process.

[0078] Taking the clipping parameter as an example, which is the count value corresponding to each clipping surface in at least one clipping surface, when there is a planned clipping surface with a count value greater than 0, the number of vertices outside the planned clipping surface is the number greater than 0, and the planned clipping surface needs to clip the current primitive, then the planned clipping surface is used to clip the current primitive.

[0079] Taking the clipping parameter as an example, if the primitive clipping mask bit is 1 in the primitive clipping mask corresponding to the current primitive, and the current primitive is outside the planned clipping plane corresponding to the primitive clipping mask, and the planned clipping plane needs to clip the current primitive, the planned clipping plane is used to clip the current primitive.

[0080] In some embodiments, after determining that there is a clipping plane that needs to clip the current primitive according to the clipping parameters, the primitive can be clipped according to the coordinates of each vertex and the plane coefficient of the clipping plane.

[0081] like Figure 3 As shown, taking the current primitive as primitive ABC and the planned clipping plane as the lower clipping plane as an example, when the clipping parameters indicate that there is a lower clipping plane that needs to clip primitive ABC, primitive ABC is clipped through the lower clipping plane.

[0082] For example, after determining the plane coefficient of the lower clipping plane, the distance between the vertex A located inside the lower clipping plane and the lower clipping plane, and the distance between the vertex B located outside the lower clipping plane and the lower clipping plane according to formulas (1) to (3), the interpolation coefficient can be determined according to the distance between the vertex A and the lower clipping plane and the distance between the vertex B and the lower clipping plane, and the primitive ABC is clipped according to the interpolation coefficient. Figure 3 As shown, when vertex A is located inside the lower clipping plane, the distance from vertex A to the lower clipping plane can be represented by a positive number; when vertex B is located outside the lower clipping plane, the distance from vertex B to the lower clipping plane can be represented by a negative number, and the interpolation coefficient can be determined by formula (4):

[0083]

[0084] Wherein, f represents the interpolation coefficient, D1 represents the distance between vertex B and the lower clipping plane, and D0 represents the distance between vertex A and the lower clipping plane.

[0085] In some embodiments, the coordinates of the new vertex D obtained after the primitive ABC is clipped with the lower clipping plane can be determined by formula (5):

[0086] C D =C A *f+C B *(1-f) (5);

[0087] Among them, C D represents the coordinates of vertex D, C A represents the coordinates of vertex A, f represents the interpolation coefficient, C B Represents the coordinates of vertex B.

[0088] Formula (4) and formula (5) can be used to determine the position of the new vertex D interpolated between vertex A and vertex B in the process of clipping the lower clipping surface of primitive ABC. The position of vertex B outside the lower clipping surface is replaced by the new vertex D. The position of the new vertex E is determined according to the calculation method of formula (1) to formula (5), thereby determining the positions of the vertices in the polygon ADEC obtained after clipping the lower clipping surface of primitive ABC. Primitive ABC is replaced by polygon ADEC to complete the clipping of primitive ABC by the lower clipping surface.

[0089] After the current primitive is clipped using the planned clipping plane, the clipping parameters corresponding to the target primitive can be determined according to the positional relationship between the target primitive obtained after clipping and each clipping plane in at least one clipping plane, so as to determine whether there is a clipping plane that needs to clip the target primitive according to the clipping parameters. If there is no clipping plane that needs to clip the target primitive, the clipping is terminated and the target primitive is used as the clipped primitive; if there is a clipping plane that needs to clip the target primitive, the target primitive is clipped according to the clipping parameters, and new clipping parameters are determined after clipping, so as to perform the next round of judgment on the updated primitive according to the new clipping parameters.

[0090] In the process of cropping the current primitive, the embodiment of the present application updates the cropping parameters based on the current primitive updated after cropping, and ends the cropping when the updated cropping parameters indicate that no further cropping is needed, thereby avoiding invalid primitive cropping, reducing the time and power consumption required for primitive cropping, and improving the efficiency of primitive cropping.

[0091] Figure 4 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 2 .like Figure 4 As shown, based on Figure 2 , Figure 2 Step S202 in the method can be updated to steps S401 to S402, and step S203 can be updated to step S403.

[0092] Step S401: Determine a vertex clipping mask for each vertex in the current primitive based on a positional relationship between the at least one clipping plane and each vertex in the current primitive.

[0093] In some embodiments, when the current primitive is cropped according to a cropping window, the vertex cropping mask can be determined based on the positional relationship between the cropping window and each vertex in the current primitive, so as to determine the primitive cropping mask corresponding to the current primitive based on the vertex cropping mask, and determine whether the current primitive is within the cropping window based on the primitive cropping mask, thereby determining whether the current primitive needs to continue to be cropped with respect to the cropping window.

[0094] Here, at least one clipping plane corresponding to the primitive is a clipping plane used to clip the primitive. The current primitive is the primitive to be clipped in this round of clipping. When the current primitive is to be clipped in the first round, the current primitive may be an unclipped primitive; when the current primitive is to be clipped in the second round, the current primitive may be a primitive obtained after the first round of clipping. It is understandable that the shape of the current primitive may be different in different rounds of clipping.

[0095] In one round of clipping, the vertex clipping mask of a vertex of the current primitive represents whether the vertex is outside each clipping surface of at least one clipping surface.

[0096] In some embodiments, the vertex clipping mask may be determined through steps S4011 to S4012.

[0097] Step S4011, determining the vertex clipping mask bit corresponding to each clipping plane according to the positional relationship between each clipping plane and the vertex; the vertex clipping mask bit indicates whether the vertex is outside the clipping plane.

[0098] In some embodiments, the vertex clipping mask may include multiple vertex clipping mask bits. The number of vertex clipping mask bits may be determined according to the number of clipping planes in at least one clipping plane. For example, if there are 4 clipping planes in at least one clipping plane, the number of corresponding vertex clipping mask bits is 4. Each vertex clipping mask bit corresponds to a clipping plane, and may indicate whether the vertex is outside the corresponding clipping plane.

[0099] Here, the count sub-value may include a first parameter and a second value. The first value may be used to indicate that the vertex is within the corresponding clipping plane, and the second value may be used to indicate that the vertex is outside the corresponding clipping plane.

[0100] In some embodiments, the vertex clipping mask bit can be a first parameter or a second parameter. When the vertex is within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is the first parameter, indicating that the vertex is within the clipping plane; when the vertex is within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is the second parameter, indicating that the vertex is outside the clipping plane. The first parameter and the second parameter can be Boolean values ​​or numbers, etc.

[0101] In some embodiments, the first parameter and the second parameter can be binary numbers 0 and 1. When the vertex is located within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is a binary number 0, indicating that the vertex is located within the clipping plane; when the vertex is located within a clipping plane, the vertex clipping mask bit corresponding to the clipping plane is a binary number 1, indicating that the vertex is located outside the clipping plane.

[0102] In some embodiments, the positional relationship between each vertex and each clipping plane can be determined based on the coordinates of each vertex and the plane coefficient of each clipping plane. For example, the distance from each vertex to each clipping plane can be determined by the calculation method in formula (1) to formula (3). When the distance from the vertex to the clipping plane is a positive number, the vertex is located within the clipping plane; when the distance from the vertex to the clipping plane is a negative number, the vertex is located outside the clipping plane.

[0103] In some embodiments, when the vertex is a new vertex and the new vertex meets the preset requirements, the vertex clipping mask bit of the clipping plane corresponding to the new vertex is set to the third parameter representing that the new vertex is within the clipping plane. The new vertex is a vertex obtained by clipping the primitive based on the historical clipping plane that has undergone the clipping process.

[0104] In some embodiments, the current primitive in this round of clipping may have a different shape from that in the previous round of clipping, and the vertices in the current primitive in this round of clipping that are different from those in the previous round of clipping can be used as new vertices.

[0105] like Figure 3 As shown, in the second round of clipping, the corresponding current primitive is primitive ABC. Primitive ABC can be clipped through the lower clipping plane to obtain primitive ADEC. The corresponding current primitive in the third round of clipping is primitive ADEC. The vertices different from primitive ABC in the previous round of clipping are vertex D and vertex E. The new vertices in the current primitive ADEC corresponding to the third round of clipping are vertex D and vertex E.

[0106] In some embodiments, taking the vertex clipping mask bit as a binary number 0 or 1 as an example, the third parameter may be a binary number 0 representing that the new vertex is within the clipping plane.

[0107] In some embodiments, the preset requirement may be that the clipping plane corresponding to the new vertex is a historical clipping plane. Here, the historical clipping plane is the clipping plane used in the previous round of clipping before the current primitive is clipped in this round. It can be understood that when the clipping plane corresponding to the new vertex is a historical clipping plane, the new vertex is generated after the primitive is clipped by the corresponding clipping plane, so the new vertex is not outside the corresponding clipping plane, and the vertex clipping mask bit of the clipping plane corresponding to the new vertex can be set to 0.

[0108] like Figure 3 As shown in the figure, taking the new vertex as vertex E as an example, the lower clipping plane is the historical clipping plane used in the previous clipping process. Vertex E is obtained by clipping primitive ABC with the lower clipping plane in the previous clipping process. Therefore, vertex E is not outside the lower clipping plane, and the vertex clipping mask bit corresponding to the lower clipping plane of vertex E can be set to 0.

[0109] In some embodiments, if the clipping surfaces corresponding to the multiple vertex clipping mask bits in vertex E are all clipping surfaces used in the previous round of clipping or before the previous round of clipping, the multiple vertex clipping mask bits are all set to 0. Figure 3 As shown, taking the new vertex as vertex E as an example, the lower clipping plane is the clipping plane used in the previous round of clipping, and the upper clipping plane is the clipping plane used before the previous round of clipping. Vertex E is obtained by clipping primitive ABC with the lower clipping plane in the previous round of clipping. The vertex clipping mask bits of vertex E corresponding to the lower clipping plane used in the previous round of clipping and the upper clipping plane used before the previous round of clipping are both set to 0.

[0110] In some embodiments, the preset requirement may be that the vertex clipping mask bit of the edge vertex of the primitive edge corresponding to the new vertex is set to the third parameter; wherein the primitive edge is the edge in the primitive before the primitive is clipped based on the historical clipping plane.

[0111] Taking the generation of new vertices based on the historical clipping surface in the previous round of clipping as an example, the primitive edges are the edges in the primitives before the previous round of clipping. The primitive edge corresponding to the new vertex is the primitive edge where the new vertex is located. The edge vertices are the vertices other than the new vertex on the primitive edge corresponding to the new vertex. It can be understood that when the vertex clipping mask bits of all edge vertices on the primitive edge are 0 for a clipping surface, all edge vertices on the primitive edge are within the clipping surface, so the new vertex generated on the primitive edge should also be within the clipping surface, and the vertex clipping mask bit of the new vertex corresponding to the clipping surface can be set to 0. Figure 3As shown in the figure, taking the vertex D as an example, vertex D is generated based on the lower clipping plane in the previous clipping process, the primitive edge is the edge in the primitive ABC before clipping by the lower clipping plane, and the primitive edge corresponding to vertex D is edge AB, and the edge vertices on edge AB include vertex A and vertex B. When it is known that the vertex clipping mask bits of vertex A and vertex B corresponding to the right clipping plane are both 0, vertex A and vertex B are both within the right clipping plane, so edge AB is also within the right clipping plane, and vertex D on edge AB should also be within the right clipping plane, and the vertex clipping mask bit of vertex D corresponding to the right clipping plane is set to 0.

[0112] In some embodiments, taking the current round of clipping as the i-th round of clipping as an example, there may be a long historical primitive edge in the historical primitives used in the previous round of clipping (i-3th round). If the new vertex is located on the historical primitive edge, and the vertex clipping mask bits of the vertices at both ends of the historical primitive edge are not all 0 for the lower clipping surface, it is inferred according to the above method that the vertex clipping mask bit of the new vertex for the lower clipping surface is not 0, and the result may be incorrect.

[0113] In the clipping process of the previous round (i-2 round), the historical primitive was clipped through the lower clipping plane, and each vertex in the obtained primitive was located within the lower clipping plane, and the vertex clipping mask bits for the lower clipping plane were all 0, so that the new vertices generated by other clipping planes in the clipping process of the previous round (i-1 round) or after the previous round were all located within the lower clipping plane, and the vertex clipping mask bits for the lower clipping plane were all 0. Therefore, according to the above method, by determining the new vertex through the vertex clipping mask bits of each vertex on the edge of the primitive in the primitive before the previous round of clipping process, it can be inferred that the vertex clipping mask bit of the new vertex for the lower clipping plane is 0, and the result is correct.

[0114] For example, Figure 5 A schematic diagram of another scene of graphic elements and clipping planes provided in an embodiment of the present application. Figure 5 The triangle A1B1C1 in the figure represents the primitive to be cropped, and 501, 502, 503 and 504 are four clipping planes corresponding to the primitive to be cropped. The following is explained by taking 501 as the upper clipping plane, 502 as the lower clipping plane, 503 as the right clipping plane, and 504 as the left clipping plane as an example.

[0115] like Figure 5 As shown, when the first round of clipping is about to be performed, the current primitive is primitive A1B1C1, and the three vertices of primitive A1B1C1 are vertex A1, vertex B1, and vertex C1. In the first round of clipping, primitive A1B1C1 is clipped by the lower clipping plane to obtain primitive A1D1E1C1, and in the second round of clipping, primitive A1D1E1C1 is clipped by the right clipping plane to obtain primitive F1D1G1.

[0116] The third round of clipping is used as the current round of clipping. Before the current round of clipping, the vertex clipping mask bits of vertex F1, vertex D1 and vertex G1 need to be determined respectively. Element A1B1C1 is a historical element. If the vertex clipping mask bit of the new vertex F1 for the lower clipping surface is determined by edge A1B1 in element A1B1C1 according to the above method, the vertex clipping mask bit of vertex A1 for the lower clipping surface is 0, and the vertex clipping mask bit of vertex B1 for the lower clipping surface is 1, then the vertex clipping mask bit of the new vertex F1 for the lower clipping surface is not 0, which is not the correct result.

[0117] If the vertex clipping mask bit of the new vertex F1 with respect to the lower clipping plane is judged by the edge A1D1 in the primitive A1D1E1C1 before the previous round (second round) of clipping process, the vertex clipping mask bit of vertex A1 with respect to the lower clipping plane is 0, and the vertex clipping mask bit of vertex D1 with respect to the lower clipping plane is 1, then the vertex clipping mask bit of the new vertex F1 with respect to the lower clipping plane is 0, which is the correct result.

[0118] Therefore, when determining the vertex clipping mask bit of a new vertex for a certain clipping surface by the above method, the primitive edge should be the edge in the primitive before the previous round of clipping process.

[0119] In some embodiments, when the vertex is a new vertex and the new vertex does not meet preset requirements, the vertex clipping mask bit corresponding to the clipping plane is determined based on the distance from the new vertex to the clipping plane corresponding to the new vertex.

[0120] In the above embodiment, when the new vertex meets the preset requirements, the vertex clipping mask bits of the clipping surface corresponding to the new vertex are directly determined, which improves the efficiency of determining the vertex clipping mask and thus improves the efficiency of primitive clipping.

[0121] like Figure 3 As shown, taking the new vertex as vertex D as an example, when it is necessary to determine the vertex clipping mask bit of vertex D corresponding to the left clipping plane, the left clipping plane is not the clipping plane used in the previous clipping process or before the previous clipping process. The vertex clipping mask bits of the vertices on the edge AB corresponding to vertex D corresponding to the left clipping plane are not all 0, which cannot meet the above preset requirements. Therefore, it is necessary to determine the distance from vertex D to the left clipping plane according to formulas (1) to (3), and then determine the vertex clipping mask bit of vertex D corresponding to the left clipping plane according to the distance from vertex D to the left clipping plane.

[0122] Step S4012: Determine the vertex clipping mask of the vertex according to the vertex clipping mask bit corresponding to each clipping plane.

[0123] In some embodiments, after determining the vertex clipping mask bits corresponding to each clipping surface, the vertex clipping mask bits may be arranged in a preset order to obtain a vertex clipping mask.

[0124] like Figure 3 As shown, after determining the vertex clipping mask bits of vertex A, vertex B and vertex C corresponding to the upper clipping plane, lower clipping plane, right clipping plane and left clipping plane respectively, the vertex clipping mask bits of the vertices can be arranged from high to low in the order of the upper clipping plane, the lower clipping plane, the right clipping plane and the left clipping plane. The vertex clipping mask of vertex A is 0b0000, the vertex clipping mask of vertex B is 0b0101, and the vertex clipping mask of vertex C is 0b0010. In some embodiments, the clipping planes corresponding to each vertex clipping mask bit in the vertex clipping mask can also be arranged in other orders, which is not limited in this application.

[0125] Step S402: Determine the primitive clipping mask according to the vertex clipping masks of each vertex in the current primitive.

[0126] In some embodiments, after determining the vertex clipping masks of each vertex in the current primitive, the primitive clipping mask of the current primitive can be determined based on each vertex clipping mask to determine whether the current primitive is within each clipping plane based on the primitive clipping mask, thereby determining whether the current primitive needs to be clipped for each clipping plane.

[0127] In some embodiments, the primitive clipping mask may be determined through steps S4021 to S4022.

[0128] Step S4021: Determine the primitive clipping mask bit corresponding to each clipping plane according to the vertex clipping mask bit corresponding to each clipping plane.

[0129] In some embodiments, when only one vertex is included in the current primitive, the primitive clipping mask bits of the current primitive corresponding to each clipping surface are the same as the vertex clipping mask bits of the vertex corresponding to each clipping surface. When multiple vertices are included in the current primitive, the primitive clipping mask bits of the current primitive corresponding to each clipping surface can be determined according to the vertex clipping mask bits of the multiple vertices corresponding to each clipping surface.

[0130] In some embodiments, when there are vertex clipping mask bits representing that the vertices are outside the clipping plane, the primitive clipping mask bits are set to the first parameter representing that the clipping plane needs to clip the current primitive; when there are no vertex clipping mask bits representing that the vertices are outside the clipping plane, the primitive clipping mask bits are set to the second parameter representing that the clipping plane does not need to clip the current primitive.

[0131] Taking the primitive clipping mask bit as a binary number 0 or 1 as an example, the first parameter is a binary number 1 representing that the clipping plane needs to clip the current primitive, and the second parameter is a binary number 0 representing that the clipping plane does not need to clip the current primitive.

[0132] like Figure 3 As shown, primitive ABC includes vertex A, vertex B and vertex C. Taking the primitive clipping mask bit of primitive ABC corresponding to the lower clipping plane as an example, the vertex clipping mask bit of vertex A corresponding to the lower clipping plane is 0, indicating that vertex A is located within the lower clipping plane; the vertex clipping mask bit of vertex B corresponding to the lower clipping plane is 1, indicating that vertex B is located outside the lower clipping plane; the vertex clipping mask bit of vertex C corresponding to the lower clipping plane is 0, indicating that vertex C is located within the lower clipping plane; there is a vertex clipping mask bit indicating that vertex B is located outside the lower clipping plane, so the primitive clipping mask bit of primitive ABC corresponding to the lower clipping plane is a binary number 1 indicating that the lower clipping plane needs to clip primitive ABC.

[0133] Taking the primitive clipping mask bit of primitive ABC corresponding to the upper clipping plane as an example, the vertex clipping mask bit of vertex A corresponding to the upper clipping plane is 0, indicating that vertex A is located within the upper clipping plane; the vertex clipping mask bit of vertex B corresponding to the upper clipping plane is 0, indicating that vertex B is located within the upper clipping plane; the vertex clipping mask bit of vertex C corresponding to the upper clipping plane is 0, indicating that vertex C is located within the upper clipping plane; there is no vertex clipping mask bit representing that the vertex is outside the upper clipping plane, so the primitive clipping mask bit of primitive ABC corresponding to the upper clipping plane is a binary number 0, indicating that the upper clipping plane does not need to clip primitive ABC.

[0134] Step S4022: Determine the primitive clipping mask according to the primitive clipping mask bits corresponding to each of the clipping planes.

[0135] In some embodiments, after determining the primitive clipping mask bits corresponding to each clipping plane, the primitive clipping mask bits may be arranged in a preset order to obtain a primitive clipping mask.

[0136] like Figure 3 As shown, after determining the primitive clipping mask bits of the upper clipping plane, the lower clipping plane, the right clipping plane and the left clipping plane of the primitive ABC respectively, the primitive clipping mask bits can be arranged from high to low in the order of the upper clipping plane, the lower clipping plane, the right clipping plane and the left clipping plane. The primitive clipping mask of the primitive ABC is obtained as 0b0111. In some embodiments, the clipping planes corresponding to the primitive clipping mask bits in the primitive clipping mask can also be arranged in other orders, which is not limited in this application.

[0137] In the above embodiment, a new primitive clipping mask is determined based on the positional relationship between at least one clipping plane and the updated current primitive in each clipping process, so as to determine whether clipping is required according to the new primitive clipping mask, thereby reducing invalid clipping and improving the efficiency of primitive clipping.

[0138] Step S403: When each of the primitive clipping mask bits indicates that the corresponding clipping plane does not need to clip the current primitive, determine the current primitive as the clipped primitive.

[0139] Here, the cropped primitive is a primitive obtained after the primitive is cropped according to at least one cropping plane. In some embodiments, the cropping parameters include a primitive cropping mask; the primitive cropping mask includes a primitive cropping mask bit corresponding to each of the cropping planes. When each primitive cropping mask bit in the primitive cropping mask corresponding to the current primitive is 0, the current primitive is within each cropping plane, so there is no cropping plane that needs to be cropped for the current primitive, and the cropping is terminated, and the current primitive is determined to be the primitive obtained after the primitive is cropped according to at least one cropping plane.

[0140] In the above-mentioned embodiment, during the process of cropping the current primitive, the primitive cropping mask is updated based on the current primitive updated after cropping, and the cropping is ended when the continuously updated primitive cropping mask indicates that cropping is not necessary, thereby avoiding invalid primitive cropping, reducing the time and power consumption required for primitive cropping, and improving the efficiency of primitive cropping.

[0141] Figure 6 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 3 .like Figure 6 As shown, based on Figure 2 , Figure 2 Step S202 in can be updated to step S601, Figure 2 Step S203 in can be updated to step S602.

[0142] Step S601: determine a count value of each clipping surface based on a positional relationship between each clipping surface in the at least one clipping surface and each vertex in the current primitive; the count value indicates whether the vertex exists outside the clipping surface.

[0143] In some embodiments, a counter may be set for each cutting surface according to the number of cutting surfaces in at least one cutting surface, and each counter is used to record the count value of the corresponding cutting surface. The count value may be represented by binary digits 0 and 1, or by a specific numerical value.

[0144] In some embodiments, the distance from each vertex to each clipping plane can be determined by the calculation method in formula (1) to formula (3). When the distance from the vertex to the clipping plane is a positive number, the vertex is located inside the clipping plane; when the distance from the vertex to the clipping plane is a negative number, the vertex is located outside the clipping plane. After determining the positional relationship between each vertex and each clipping plane, the number of vertices outside each clipping plane can be determined based on the positional relationship between each vertex and each clipping plane, thereby determining the count value corresponding to each clipping plane.

[0145] Taking the binary numbers 0 and 1 as an example to represent the count value, the binary number 0 may represent that there is no vertex outside the corresponding clipping surface, and the binary number 1 may represent that there is a vertex outside the corresponding clipping surface.

[0146] Taking the count value represented by a specific numerical value as an example, when the count value is 0, the number of vertices outside the clipping surface corresponding to the count value is 0, that is, there are no vertices outside the clipping surface corresponding to the count value; when the count value is not 0, for example, when the count value is 2, the number of vertices outside the clipping surface corresponding to the count value is 2, that is, there are two vertices outside the clipping surface corresponding to the count value.

[0147] In some embodiments, the count value of each clipping surface may be determined through steps S6011 to S6012.

[0148] Step S6011: determining a count sub-value corresponding to each vertex according to a positional relationship between each vertex and the clipping plane; the count sub-value represents whether the vertex is located outside the clipping plane or inside the clipping plane.

[0149] Taking the counting sub-value as a binary number 0 or 1 as an example, the binary number 0 may be used to represent that the vertex is within the corresponding clipping plane, and the binary number 1 may be used to represent that the vertex is outside the corresponding clipping plane.

[0150] like Figure 3 As shown, taking the determination of the count sub-values ​​of the upper clipping plane, the lower clipping plane, the right clipping plane and the left clipping plane corresponding to the vertex B as an example, vertex B is located inside the upper clipping plane, and the count sub-value of the upper clipping plane corresponding to vertex B is 0; vertex B is located outside the lower clipping plane, and the count sub-value of the lower clipping plane corresponding to vertex B is 1; vertex B is located inside the right clipping plane, and the count sub-value of the right clipping plane corresponding to vertex B is 0; vertex B is located outside the left clipping plane, and the count sub-value of the left clipping plane corresponding to vertex B is 1.

[0151] Step S6012: Determine the count value of the clipping surface according to the count sub-value corresponding to each of the vertices.

[0152] In some embodiments, after determining the count sub-values ​​corresponding to a clipping surface for each vertex, the count value of the clipping surface may be determined according to each count sub-value.

[0153] Taking the binary digits 0 and 1 as an example to represent the count value, when there is a count sub-value representing that the vertex is outside the clipping plane among the count sub-values ​​corresponding to the clipping plane, the count value of the clipping plane is set to 1; when there is no count sub-value representing that the vertex is outside the clipping plane among the count sub-values ​​corresponding to the clipping plane, the count value of the clipping plane is set to 0.

[0154] like Figure 3 As shown, the count sub-values ​​of the lower clipping plane corresponding to vertex A, vertex B, and vertex C are 0, 1, and 0 respectively, among which there is a count sub-value 1 representing that vertex B is outside the lower clipping plane. Therefore, the count value of the lower clipping plane for primitive ABC is set to 1, representing that there is a vertex outside the lower clipping plane.

[0155] Taking the counting value represented by a specific numerical value as an example, the counting sub-values ​​corresponding to a clipping surface may be added to determine the counting value of the clipping surface.

[0156] like Figure 3 As shown, the counting sub-values ​​of the right clipping surface for vertex A, vertex D, vertex E, and vertex C in the primitive ADEC are 0, 0, 1, and 1 respectively. After adding the counting sub-values ​​corresponding to the right clipping surface, the counting value of the right clipping surface for the primitive ADEC is 2, indicating that there are two vertices outside the right clipping surface.

[0157] In the above embodiment, a new count value is determined based on the positional relationship between at least one clipping surface and the updated current primitive in each clipping process, so as to determine whether clipping is required according to the new count value, thereby reducing invalid clipping and improving the efficiency of primitive clipping.

[0158] Step S602: When the count value of each clipping plane indicates that the vertex does not exist outside the corresponding clipping plane, determine the current primitive as the clipped primitive.

[0159] Here, the clipped primitive is a primitive obtained after the primitive is clipped according to at least one clipping plane. In some embodiments, when the count value of each clipping plane corresponding to the current primitive is 0, each vertex in the current primitive is located within each clipping plane, and therefore there is no clipping plane that needs to clip the current primitive, then the clipping is terminated, and the current primitive is determined to be a primitive obtained after the primitive is clipped according to at least one clipping plane.

[0160] In the process of cropping the current primitive, the above-mentioned embodiment updates the count value corresponding to each cropping surface based on the continuously updated current primitive, and ends the cropping when the continuously updated count values ​​all indicate that cropping is not needed, thereby avoiding invalid primitive cropping, reducing the time and power consumption required for primitive cropping, and improving the efficiency of primitive cropping.

[0161] The following describes the application of the primitive clipping method provided in the embodiment of the present application in actual scenarios.

[0162] The GPU can be used to render 2D or 3D images. A 3D image is a geometric body composed of multiple primitives, which may include thousands of primitives. Therefore, the GPU may need to perform a lot of processing and calculations in the process of 3D image rendering. Primitive clipping can be used to remove invisible or unnecessary parts of the primitives in the image rendering process to improve image rendering efficiency and reduce unnecessary calculations.

[0163] In the process of implementing primitive clipping in related technologies, the following problems exist:

[0164] In the process of implementing primitive clipping in the GPU, the primitive clipping mask of the primitive must first be determined, so as to determine which specific clipping planes the primitive needs to be clipped according to the clipping mask, and each edge of the primitive is traversed by the clipping unit, and each edge and the corresponding clipping plane are intersected in turn. If the edge and the clipping plane intersect, a new vertex is clipped, added to the primitive, and the primitive is reorganized. In the process of implementing primitive clipping by the above method, the primitive clipping mask of the primitive will not change.

[0165] In the process of primitive clipping, the shape of the primitive will change when new vertices are clipped. After the shape of the primitive changes, it may no longer be necessary to clip some specific clipping surfaces. If the above process is continued and the initial clipping mask is used to clip primitives on specific clipping surfaces, it may cause a waste of time and power consumption required for primitive clipping. Based on the above problems, in the process of clipping the current primitive, the embodiment of the present application updates the clipping parameters based on the current primitive updated after clipping, and ends the clipping when the updated clipping parameters indicate that no further clipping is needed, thereby avoiding invalid primitive clipping, reducing the time and power consumption required for primitive clipping, and improving the efficiency of primitive clipping.

[0166] The primitive clipping method in the embodiment of the present application can be applied to a primitive clipping apparatus and a primitive clipping device, or to a hardware system or device equipped with a primitive clipping apparatus or a primitive clipping device.

[0167] like Figure 1As shown, the system architecture 100 of the primitive clipping method provided in the embodiment of the present application includes a primitive assembly module 101, a clipping module 102 and a vertex buffer 103. Among them, the primitive assembly module 101 is used to generate vertex coordinates, primitive information and protection band parameters. The primitive information includes the vertex coordinates of the primitives. The primitive assembly module 101 can remove primitives whose vertices are outside each clipping surface of at least one clipping surface and do not need to be clipped, remove primitives whose vertices are within the protection area determined by the protection band parameters and the area within each clipping surface of at least one clipping surface, and send the vertex coordinates of the primitives whose vertices are partly within the protection area to the clipping module 102. The clipping module 102 is used to clip the primitives according to the received primitive information. The vertex buffer 103 is used to cache the clipping results obtained by clipping the primitives.

[0168] The clipping module 102 includes a clipping parameter generation unit 1021, a clipping decision unit 1022 and a clipping execution unit 1023. The clipping parameter generation unit 1021 is used to generate clipping parameters required in the process of clipping the primitive according to the positional relationship between the primitive and the clipping window, and to update the clipping parameters according to the clipped primitive; the clipping decision unit 1022 is used to determine the current clipping surface currently used for clipping the current primitive according to the current clipping parameters; the clipping execution unit 1023 can clip the current primitive using the current clipping surface, and send the clipping result to the vertex buffer 103, and the clipping execution unit 1023 can also send the clipping result to the clipping parameter generation unit 1021, so that the clipping parameter generation unit 1021 can update the clipping parameters according to the positional relationship between the new vertex and the clipping window.

[0169] The following is an example of using the primitive clipping mask as a clipping parameter.

[0170] For example, Figure 3 A schematic diagram of a scene of a graphic element and a clipping plane provided in an embodiment of the present application. Figure 3 The triangle ABC in the figure represents the primitive to be cropped, and 301, 302, 303 and 304 are four clipping planes corresponding to the primitive to be cropped. The following is explained by taking 301 as the upper clipping plane, 302 as the lower clipping plane, 303 as the right clipping plane, and 304 as the left clipping plane as an example.

[0171] like Figure 3 As shown, when the first round of clipping is about to be performed, the current primitive is primitive ABC, which has three vertices, namely, vertex A, vertex B, and vertex C. Among them, vertex A is within all clipping planes. Vertex B is outside the lower clipping plane and the left clipping plane, and within the other two clipping planes. Vertex C is outside the right clipping plane and within the other three clipping planes.

[0172] Corresponding to the four clipping planes, the vertex clipping masks of vertex A, vertex B and vertex C for the four clipping planes can be encoded respectively through four vertex clipping mask bits. Among them, the vertex clipping mask of the vertex is a binary number. If a vertex clipping mask bit is 1, it indicates that the vertex is outside the corresponding clipping plane; if a vertex clipping mask bit is 0, it indicates that the vertex is inside the corresponding clipping plane. The vertex clipping mask bits of the vertices can be arranged from high to low in the order of upper clipping plane, lower clipping plane, right clipping plane and left clipping plane. The vertex clipping mask of vertex A is 0b0000, the vertex clipping mask of vertex B is 0b0101, and the vertex clipping mask of vertex C is 0b0010.

[0173] In some embodiments, the vertex clipping masks of vertices A, B and C may be bitwise ORed to obtain a primitive clipping mask P(ABC) of primitive ABC as 0b0111, indicating that the lower clipping plane, the right clipping plane and the left clipping plane need to clip primitive ABC.

[0174] In some embodiments, after the primitive clipping mask is determined by the clipping parameter generation unit 1021, the primitive clipping mask can be sent to the clipping decision unit 1022. After the clipping decision unit 1022 determines that the primitive clipping mask is 0b0111, the current clipping planes are determined to be the upper clipping plane, the lower clipping plane, the right clipping plane and the left clipping plane in a preset order. Since the upper clipping plane does not need to clip the primitive ABC, the clipping decision unit 1022 decides to clip the primitive ABC in sequence through the lower clipping plane, the right clipping plane and the left clipping plane. Since the clipping execution unit can only clip primitives for one clipping plane at a time, before executing the clipping of the primitive, the current clipping plane used to clip the current primitive in this round of clipping can be decided by the clipping decision unit 1022. According to the preset order of the clipping planes, the clipping decision unit 1022 can first decide to clip the primitives on the lower clipping plane, so that the clipping execution unit 1023 clips the primitive ABC on the lower clipping plane to obtain the polygon ADEC. Next, the vertex clipping masks of the newly generated vertices D and E can be determined. The vertex clipping mask of vertex D is 0b0000, and the vertex clipping mask of vertex E is 0b0010.

[0175] Next, the clipping execution unit 1023 sends the vertex clipping masks of vertices D and E to the clipping parameter generation unit 1021, and the clipping parameter generation unit 1021 updates the corresponding primitive clipping mask P (ADEC) to 0b0010 according to the vertex clipping masks of each vertex of polygon ADEC. After the clipping decision unit 1022 determines that the primitive clipping mask is 0b0010, it decides that the polygon ADEC is clipped with respect to the right clipping plane. The clipping execution unit 1023 clips the polygon ADEC with respect to the right clipping plane to obtain the polygon ADFG. It is determined that the vertex clipping masks of the newly generated vertices F and G are both 0b0000.

[0176] Next, the clipping execution unit 1023 sends the vertex clipping masks of vertices F and G to the clipping parameter generation unit 1021, and the clipping parameter generation unit 1021 updates the corresponding primitive clipping mask P(ADFG) to 0b0000 according to the vertex clipping masks of each vertex of polygon ADFG. Since all the primitive clipping mask bits in the primitive clipping mask are 0, it means that the polygon ADFG does not need to be clipped for any clipping surface, so the clipping is completed.

[0177] Figure 7 A schematic diagram of a vertex clipping mask of a vertex provided in an embodiment of the present application. Figure 7 It can be seen that vertices A, B, C, D, E, F, and G correspond to the vertex clipping mask bits of the upper clipping plane, the lower clipping plane, the right clipping plane, and the left clipping plane, respectively. Figure 7 As shown, the vertex clipping mask bits of vertex A for the upper clipping plane, lower clipping plane, right clipping plane and left clipping plane are all 0, and the vertex clipping mask of vertex A is 0b0000; the vertex clipping mask bits of vertex B for the upper clipping plane, lower clipping plane, right clipping plane and left clipping plane are 0, 1, 0 and 1 respectively, and the vertex clipping mask of vertex B is 0b0101; the vertex clipping mask bits of vertex C for the upper clipping plane, lower clipping plane, right clipping plane and left clipping plane are 0, 0, 1 and 0 respectively, and the vertex clipping mask of vertex C is 0b0010.

[0178] like Figure 7 As shown, for the newly generated vertices D, E, F, and G, only specific parts of the vertex clipping mask that do not meet the preset requirements can be calculated, and the parts of the vertex clipping mask that meet the preset requirements can be directly set to 0.

[0179] In some embodiments, the following algorithm can be used to confirm the vertex clipping mask that meets the preset requirements in the new vertex: for the new vertex, the clipping mask bits for the previously clipped faces and the currently clipped clipping faces are directly set to 0, that is, no intersection will occur. For example, Figure 3The middle vertex E is a new vertex obtained by clipping the primitive with respect to the lower clipping plane 302. For the previously clipped upper clipping plane 301 and the currently clipped lower clipping plane 302, the vertex clipping mask bits of vertex E with respect to the upper clipping plane 301 and the lower clipping plane 302 are directly set to 0. For a new vertex, if the vertex clipping mask bits of the vertices on the edge where the vertex is located with respect to the corresponding clipping plane are all 0, the vertex clipping mask bit of the vertex with respect to the corresponding clipping plane can be directly set to 0. For example, Figure 3 The middle vertex D is obtained by clipping the AB edge of the primitive ABC with respect to the lower clipping plane 302. Since the vertex clipping mask bits of vertices A and B on the AB edge where vertex D is located with respect to the right clipping plane 303 are both 0, the vertex clipping mask bit of vertex D obtained by clipping the AB edge with respect to the right clipping plane 303 can be directly set to 0.

[0180] The above embodiment optimizes the part of the clipping decision in the primitive clipping process. On the one hand, the newly generated vertices are also involved in the clipping decision, which can avoid useless clipping. On the other hand, the primitive clipping is terminated when all the primitive clipping mask bits in the primitive clipping mask are 0, and there is no need to loop through the last clipping surface, which saves the time and power consumption required for clipping and improves the efficiency of the clipping process.

[0181] Figure 8 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 4 .like Figure 8 As shown, the primitive clipping method of the embodiment of the present application may include steps S801 to S808.

[0182] Step S801, determine the primitive clipping mask, wherein the vertex clipping mask corresponding to each vertex of the primitive (corresponding to the current primitive in the above embodiment) is determined according to the preset order of the clipping planes, and the vertex clipping mask of each vertex is bitwise ORed to obtain the primitive clipping mask of the primitive.

[0183] Step S802: Determine the clipping plane with a mask of 1. The clipping plane corresponding to the clipping mask bit of the primitive clipping mask being 1 is determined.

[0184] Step S803, traverse each edge of the primitive, wherein each edge of the primitive is traversed to determine whether each edge intersects with the clipping plane (corresponding to the current clipping plane in the above embodiment).

[0185] Step S804: Determine whether the edge intersects with the clipping plane. If the edge intersects with the clipping plane, execute step S805; if the edge does not intersect with the clipping plane, execute step S803.

[0186] Step S805, calculating the clipping mask of the intersection point. In the case where the edge intersects the clipping plane, the vertex clipping mask bits of the intersection point for each clipping plane are calculated respectively, and the vertex clipping mask of the intersection point is determined according to each vertex clipping mask bit.

[0187] Step S806, determine whether all edges have been looped over. If all edges of the primitive have been looped over, execute step S807; if all edges of the primitive have not been looped over, execute step S802.

[0188] Step S807: Update the primitive clipping mask, wherein a new vertex is determined according to each intersection point, and the primitive clipping mask is updated according to the vertex clipping mask of the new vertex.

[0189] Step S808, determine whether each primitive clipping mask bit is 0. If all primitive clipping mask bits in the primitive clipping mask are 0, it means that the updated primitive does not need to be clipped to any clipping surface, so clipping ends; if all primitive clipping mask bits in the primitive clipping mask are not 0, return to step S802.

[0190] The above-mentioned embodiment updates the primitive clipping mask according to the vertex clipping mask of the new vertices generated in the process of primitive clipping, implements primitive clipping according to the continuously updated primitive clipping mask, and ends primitive clipping when all primitive clipping mask bits in the primitive clipping mask are 0. There is no need to loop through the last clipping surface, thereby reducing the situation of useless primitive clipping for some clipping surfaces according to the original primitive clipping mask, thereby reducing the time and power consumption required for primitive clipping and improving the efficiency of primitive clipping.

[0191] Fig. 9 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 5 .like Fig. 9 As shown, the primitive clipping method of the embodiment of the present application may include steps S901 to S905.

[0192] Step S901, determine whether to clip the clipping surface. Determine whether the new vertex generated in the process of primitive clipping is clipped with the corresponding clipping surface. If the new vertex is not clipped with the corresponding clipping surface, execute step S902; if the new vertex has been clipped with the corresponding clipping surface, execute step S904.

[0193] Step S902: Determine the vertex clipping mask bits of other vertices on the edge where the new vertex is located with respect to the clipping surface. Determine the vertex clipping mask bits of other vertices on the edge where the new vertex is located with respect to the clipping surface.

[0194] Step S903, determine whether the clipping mask bits of other vertices are all 0. Determine whether the vertex clipping mask bits of other vertices on the edge where the new vertex is located for the clipping plane are all 0. If the vertex clipping mask bits of other vertices for the clipping plane are all 0, execute step S904; if the vertex clipping mask bits of other vertices for the clipping plane are not all 0, execute step S905.

[0195] Step S904: Set the vertex clipping mask bit of the new vertex to 0 for the clipping plane. Set the vertex clipping mask bit of the new vertex to 0 for the clipping plane.

[0196] Step S905: Calculate the vertex clipping mask bit of the new vertex with respect to the clipping plane. Determine the vertex clipping mask bit of the new vertex with respect to the clipping plane according to the positional relationship between the new vertex and the clipping plane.

[0197] In the above embodiment, the vertex clipping mask bits of the new vertex can be directly determined for the clipping surface that has been clipped, and the clipping mask bits of the new vertex with respect to the clipping surface can also be determined based on the clipping mask bits of other vertices on the edge where the new vertex is located with respect to the clipping surface, thereby improving the efficiency of determining the vertex clipping mask of the new vertex.

[0198] In some embodiments, the clipping of the primitives can also be accomplished by setting a counter for each of the at least one clipping plane. For example, a counter can be set for each clipping plane, and each counter can be used to record the number of vertices outside the corresponding clipping plane. Figure 3 For example, the upper clipping plane 301, the lower clipping plane 302, the right clipping plane 303 and the left clipping plane 304 are clipped by the primitive ABC in FIG. Fig.10 As shown. Before the primitive ABC starts clipping, there are 0 vertices outside the upper clipping plane, so the number recorded in the counter corresponding to the upper clipping plane is 0; there is 1 vertex outside the lower clipping plane, so the number recorded in the counter corresponding to the lower clipping plane is 1; there is 1 vertex outside the right clipping plane, so the number recorded in the counter corresponding to the right clipping plane is 1; there is 1 vertex outside the left clipping plane, so the number recorded in the counter corresponding to the left clipping plane is 1.

[0199] In some embodiments, the preset order may be the order of arrangement of the upper clipping plane, the lower clipping plane, the right clipping plane, and the left clipping plane, and whether the primitive ABC needs to clip each clipping plane in at least one clipping plane may be determined in the preset order. When the number in the counter corresponding to the upper clipping plane is 0, the primitive ABC does not need to clip the upper clipping plane. When the number in the counter corresponding to the lower clipping plane is 1, the primitive ABC needs to clip the lower clipping plane. After the primitive ABC clips the lower clipping plane, the polygon ADEC may be obtained.

[0200] Compared with primitive ABC, polygon ADEC has added vertices D and E, and reduced vertex B. Therefore, the counter of the clipping surface after clipping needs to be updated according to the positions of the vertices of polygon ADEC. Fig.11 As shown, after obtaining the polygon ADEC, there are 0 vertices outside the upper clipping plane, so the number recorded in the counter corresponding to the upper clipping plane is 0; there are 0 vertices outside the lower clipping plane, so the number recorded in the counter corresponding to the lower clipping plane is 0; there are 2 vertices outside the right clipping plane, so the number recorded in the counter corresponding to the right clipping plane is 2; there are 0 vertices outside the left clipping plane, so the number recorded in the counter corresponding to the left clipping plane is 0.

[0201] In some embodiments, the count value corresponding to each clipping plane may be represented by a binary number 0 or 1. The binary number 0 may represent that there are no vertices outside the corresponding clipping plane, and when the count value is 0, the clipping plane corresponding to the count value does not need to clip the current primitive; the binary number 1 may represent that there are vertices outside the corresponding clipping plane, and when the count value is 1, the clipping plane corresponding to the count value needs to clip the current primitive.

[0202] In some embodiments, after primitive ABC clips the upper clipping plane and the lower clipping plane, the numbers recorded in the counters corresponding to the upper clipping plane and the lower clipping plane may be directly set to 0.

[0203] When the number in the counter corresponding to the right clipping plane is 2, polygon ADEC needs to be clipped with respect to the right clipping plane, and polygon ADFG can be obtained after clipping. Next, the counters of the clipping planes can be updated according to the positions of the vertices of polygon ADFG. Since vertex A, vertex D, vertex F, and vertex G are not outside the upper clipping plane, the lower clipping plane, the right clipping plane, and the left clipping plane, the numbers in the counters corresponding to the upper clipping plane, the lower clipping plane, the right clipping plane, and the left clipping plane are all updated to 0. When the numbers in the counters corresponding to all clipping planes are 0, the primitive clipping is ended.

[0204] In some embodiments, the counter corresponding to each of the at least one clipping surface can be used to record whether there is a vertex outside the clipping surface. For example, the number 0 can be used to indicate that there is no vertex outside the clipping surface, and the number 1 can be used to indicate that there is a vertex outside the clipping surface.

[0205] Fig.12 A schematic diagram of the implementation process of a primitive clipping method provided in an embodiment of the present application Figure 6 .like Fig.12 As shown, the primitive clipping method of the embodiment of the present application may include steps S1201 to S1208.

[0206] Step S1201: Set a counter for a clipping surface. Set a counter for each clipping surface in at least one clipping surface, and the counter is used to record the number of vertices outside each clipping surface.

[0207] Step S1202, determine the clipping planes that are not 0. Determine the clipping planes whose counters are not 0. When the counters are not 0, there are vertices outside the clipping planes, which means that the clipping planes need to clip the primitives.

[0208] Step S1203: traverse each edge of the primitive. Traverse each edge of the primitive (corresponding to the current primitive in the above embodiment) to determine whether each edge intersects with the clipping plane.

[0209] Step S1204: Determine whether the edge intersects with the clipping plane. Determine whether the edge of the primitive intersects with the clipping plane. If the edge intersects with the clipping plane, execute step S1205; if the edge does not intersect with the clipping plane, execute step S1203.

[0210] Step S1205: Use the intersection point as a new vertex. When the edge of a primitive intersects with the clipping plane, use the intersection point as a new vertex of the primitive, and use the new vertex to replace the vertex on the edge that is outside the clipping plane.

[0211] Step S1206, judging whether all edges have been looped over. Judge whether all edges of the primitive have been looped over. If all edges of the primitive have been looped over, execute step S1207; if all edges of the primitive have not been looped over, execute step S1202.

[0212] Step S1207: Update the counter of the clipping plane. After replacing the vertices outside the clipping plane according to all the intersection points on the clipping plane, if there are no vertices outside the clipping plane, the counter of the clipping plane can be updated to 0.

[0213] Step S1208, determine whether all clipping surfaces are 0. Determine whether the counters of all clipping surfaces are 0. If the counters of all clipping surfaces are 0, it means that all vertices of the updated primitive are not outside the clipping surface, so the primitive does not need to be clipped for any clipping surface, and the clipping is completed; if the counters of all clipping surfaces are not all 0, return to execute step S1202.

[0214] In the above embodiment, a counter is set for each clipping surface to record the number of vertices outside the corresponding clipping surface. For clipping surfaces that have been clipped, the numbers in the counter can be set to 0. When the numbers in the counters corresponding to all clipping surfaces are 0, the primitive clipping is terminated, thereby avoiding invalid primitive clipping and improving the efficiency of primitive clipping.

[0215] Fig.13Schematic diagram of a primitive clipping device provided in an embodiment of the present application. Fig.13 As shown, the primitive clipping device 1300 includes a data acquisition module 1301, a parameter determination module 1302 and a result determination module 1303, wherein:

[0216] A data acquisition module 1301 is used to acquire a graphic element and at least one clipping surface corresponding to the graphic element;

[0217] A parameter determination module 1302 is used to determine a cropping parameter based on a positional relationship between the at least one cropping plane and the current primitive before cropping the current primitive using the current cropping plane; the current primitive is the primitive or a result of at least one cropping of the primitive;

[0218] The result determination module 1303 is configured to determine the current primitive as a clipped primitive when the clipping parameter indicates that there is no clipping plane that needs to clip the current primitive.

[0219] In some embodiments, the clipping parameters include a primitive clipping mask; the parameter determination module 1302 is also used to determine the vertex clipping mask of each vertex in the current primitive based on the positional relationship between the at least one clipping plane and each vertex in the current primitive; and determine the primitive clipping mask according to the vertex clipping mask of each vertex in the current primitive.

[0220] In some embodiments, the vertex clipping mask includes vertex clipping mask bits corresponding to each of the clipping planes; the parameter determination module 1302 is also used to determine the vertex clipping mask bits corresponding to each of the clipping planes according to the positional relationship between each of the clipping planes and the vertex; the vertex clipping mask bits represent whether the vertex is located outside the clipping plane; and the vertex clipping mask of the vertex is determined according to the vertex clipping mask bits corresponding to each of the clipping planes.

[0221] In some embodiments, the primitive clipping mask includes primitive clipping mask bits; the parameter determination module 1302 is also used to determine the primitive clipping mask bits corresponding to each of the clipping planes according to the vertex clipping mask bits corresponding to each of the clipping planes; and determine the primitive clipping mask according to the primitive clipping mask bits corresponding to each of the clipping planes.

[0222] In some embodiments, the parameter determination module 1302 is further used to, in the case where there is a vertex clipping mask bit representing that the vertex is outside the clipping plane, set the primitive clipping mask bit to a first parameter representing that the clipping plane needs to clip the current primitive; in the case where there is no vertex clipping mask bit representing that the vertex is outside the clipping plane, set the primitive clipping mask bit to a second parameter representing that the clipping plane does not need to clip the current primitive.

[0223] In some embodiments, the cropping parameters include a primitive cropping mask; the primitive cropping mask includes primitive cropping mask bits corresponding to each of the cropping planes; the result determination module 1303 is also used to determine the current primitive as the cropped primitive when each of the primitive cropping mask bits indicates that the corresponding cropping plane does not need to crop the current primitive.

[0224] In some embodiments, the parameter determination module 1302 is also used to set the vertex clipping mask bit of the clipping plane corresponding to the new vertex to a third parameter characterizing that the new vertex is within the clipping plane when the vertex is a new vertex and the new vertex meets preset requirements; when the vertex is a new vertex and the new vertex does not meet the preset requirements, determine the vertex clipping mask bit corresponding to the clipping plane based on the distance from the new vertex to the clipping plane corresponding to the new vertex; wherein the new vertex is a vertex obtained after clipping the primitive based on a historical clipping plane that has undergone a clipping process.

[0225] In some embodiments, the preset requirements include any one of the following: the clipping plane corresponding to the new vertex is the historical clipping plane; the vertex clipping mask bit of the edge vertex of the primitive edge corresponding to the new vertex is set to the third parameter; the primitive edge is the edge in the primitive before the primitive is clipped based on the historical clipping plane.

[0226] In some embodiments, the clipping parameters include a count value of each of the clipping planes; the parameter determination module 1302 is further used to determine the count value of each of the clipping planes based on the positional relationship between each of the at least one clipping planes and each vertex in the current primitive; the count value represents whether the vertex exists outside the clipping plane.

[0227] In some embodiments, the count value includes a count sub-value; the parameter determination module 1302 is also used to determine the count sub-value corresponding to each vertex based on the positional relationship between each vertex and the clipping plane; the count sub-value represents whether the vertex is outside the clipping plane or inside the clipping plane; the count value of the clipping plane is determined based on the count sub-value corresponding to each vertex.

[0228] In some embodiments, the result determination module 1303 is further configured to determine the current primitive as the clipped primitive when the count value of each clipping plane indicates that the vertex does not exist outside the corresponding clipping plane.

[0229] In some embodiments, the parameter determination module 1302 is further configured to, when the clipping parameters indicate that there is a planned clipping plane that needs to clip the current primitive, clip the current primitive using the planned clipping plane.

[0230] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0231] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0232] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0233] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0234] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0235] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0236] Fig.14 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Fig.14 As shown, the hardware entity of the computer device 1400 includes: a processor 1401 and a memory 1402, wherein the memory 1402 stores a computer program that can be run on the processor 1401, and the processor 1401 implements the steps in the method of any of the above embodiments when executing the program.

[0237] The memory 1402 stores computer programs that can be run on the processor. The memory 1402 is configured to store instructions and applications executable by the processor 1401. It can also cache data to be processed or processed by the processor 1401 and various modules in the computer device 1400 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0238] When the processor 1401 executes the program, the steps of any of the above primitive clipping methods can be implemented. The processor 1401 generally controls the overall operation of the computer device 1400.

[0239] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the primitive clipping method of any of the above embodiments.

[0240] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For the technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding. The above processor can be at least one of a target application integrated circuit (Application Specific Integrated Circuit, ASIC), a digital signal processor (Digital Signal Processor, DSP), a digital signal processing device (Digital Signal Processing Device, DSPD), a programmable logic device (Programmable Logic Device, PLD), a field programmable gate array (Field Programmable Gate Array, FPGA), a central processing unit, a controller, a microcontroller, and a microprocessor. It can be understood that the electronic device that realizes the above processor function can also be other, and the embodiments of the present application are not specifically limited.

[0241] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0242] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0243] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0244] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0245] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0246] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0247] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.

[0248] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0249] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A primitive clipping method, characterized in that: include: Obtaining a primitive and at least one clipping surface corresponding to the primitive; In the clipping process corresponding to each clipping plane executed in a preset order, a clipping parameter is determined based on a positional relationship between the at least one clipping plane and the current primitive; The current primitive is the primitive or a result of at least one clipping of the primitive; When the clipping parameters indicate that there is no clipping plane that needs to clip the current primitive, the current primitive is determined as a clipped primitive.

2. The primitive clipping method according to claim 1, characterized in that: The clipping parameters include a primitive clipping mask; and determining the clipping parameters based on a positional relationship between the at least one clipping plane and the current primitive includes: Determine a vertex clipping mask for each vertex in the current primitive based on a positional relationship between the at least one clipping plane and each vertex in the current primitive; The primitive clipping mask is determined according to the vertex clipping masks of each vertex in the current primitive.

3. The primitive clipping method according to claim 2, characterized in that: The vertex clipping mask includes a vertex clipping mask bit corresponding to each clipping surface; The determining of the vertex clipping mask of each vertex in the current primitive based on the positional relationship between the at least one clipping plane and each vertex in the current primitive comprises: Determine the vertex clipping mask bit corresponding to each clipping surface according to the positional relationship between each clipping surface and the vertex; the vertex clipping mask bit indicates whether the vertex is outside the clipping surface; The vertex clipping mask of the vertex is determined according to the vertex clipping mask bit corresponding to each of the clipping planes.

4. The primitive clipping method according to claim 3, characterized in that: The primitive clipping mask includes primitive clipping mask bits; The determining the primitive clipping mask according to the vertex clipping mask of each vertex in the current primitive comprises: Determine the primitive clipping mask bit corresponding to each clipping surface according to the vertex clipping mask bit corresponding to each clipping surface; The primitive clipping mask is determined according to the primitive clipping mask bit corresponding to each of the clipping planes.

5. The primitive clipping method according to claim 4, characterized in that: Determining the primitive clipping mask bit corresponding to each clipping surface according to the vertex clipping mask bit corresponding to each clipping surface includes: In the case where there is a vertex clipping mask bit indicating that the vertex is outside the clipping plane, setting the primitive clipping mask bit to a first parameter indicating that the clipping plane needs to clip the current primitive; In the absence of a vertex clipping mask bit indicating that the vertex is outside the clipping plane, the primitive clipping mask bit is set to a second parameter indicating that the clipping plane does not need to clip the current primitive.

6. The primitive clipping method according to claim 1, characterized in that: The clipping parameters include a primitive clipping mask; the primitive clipping mask includes a primitive clipping mask bit corresponding to each clipping plane; when the clipping parameters indicate that there is no clipping plane that needs to clip the current primitive, determining the current primitive as a clipped primitive includes: When each of the primitive clipping mask bits indicates that the corresponding clipping plane does not need to clip the current primitive, the current primitive is determined as the clipped primitive.

7. The primitive clipping method according to claim 3, characterized in that: The step of determining the vertex clipping mask bit corresponding to each clipping surface according to the positional relationship between each clipping surface and the vertex comprises: When the vertex is a new vertex and the new vertex meets a preset requirement, setting the vertex clipping mask bit of the clipping plane corresponding to the new vertex to a third parameter representing that the new vertex is within the clipping plane; When the vertex is a new vertex and the new vertex does not meet the preset requirements, based on the distance from the new vertex to the clipping plane corresponding to the new vertex, determine the vertex clipping mask bit corresponding to the clipping plane; The new vertex is a vertex obtained by clipping the primitive based on a historical clipping plane that has undergone a clipping process.

8. The primitive clipping method according to claim 7, characterized in that: The preset requirements include any one of the following: The clipping surface corresponding to the new vertex is the historical clipping surface; The vertex clipping mask bit of the edge vertex of the primitive edge corresponding to the new vertex is set to the third parameter; the primitive edge is the edge in the primitive before the primitive is clipped based on the historical clipping plane.

9. The primitive clipping method according to any one of claims 1 to 8, characterized in that: The clipping parameters include a count value of each clipping surface; The determining of the clipping parameters based on the positional relationship between the at least one clipping plane and the current primitive includes: A count value of each of the at least one clipping planes is determined based on a positional relationship between each of the clipping planes and each vertex in the current primitive; the count value indicates whether the vertex exists outside the clipping plane.

10. The primitive clipping method according to claim 9, characterized in that: The count value includes a count sub-value; and determining the count value of each clipping surface based on the positional relationship between each clipping surface in the at least one clipping surface and each vertex in the current primitive includes: Determine a count sub-value corresponding to each vertex according to a positional relationship between each vertex and the clipping plane; the count sub-value indicates whether the vertex is located outside the clipping plane or inside the clipping plane; The count value of the clipping surface is determined according to the count sub-values ​​corresponding to the vertices.

11. The primitive clipping method according to claim 9, characterized in that: The step of determining the current primitive as a clipped primitive when the clipping parameter indicates that there is no clipping plane that needs to clip the current primitive comprises: When the count value of each clipping surface indicates that the vertex does not exist outside the corresponding clipping surface, the current primitive is determined as the clipped primitive.

12. The primitive clipping method according to any one of claims 1 to 8, characterized in that: The method further comprises: In a case where the clipping parameters indicate that there is a planned clipping plane that needs to clip the current primitive, the current primitive is clipped using the planned clipping plane.

13. A primitive cutting device, characterized in that: include: A data acquisition module, used to acquire a graphic element and at least one clipping surface corresponding to the graphic element; A parameter determination module, configured to determine a clipping parameter based on a positional relationship between the at least one clipping plane and a current primitive during a clipping process corresponding to each clipping plane executed in a preset order; The current primitive is the primitive or a result of at least one clipping of the primitive; A result determination module is configured to determine the current primitive as a clipped primitive when the clipping parameter indicates that there is no clipping plane that needs to clip the current primitive.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the primitive clipping method according to any one of claims 1 to 12 is implemented.

15. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the primitive clipping method according to any one of claims 1 to 12 is implemented.

16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the primitive clipping method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

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

    CN103400338A

  • Device and method for entity clipping during graphic processing unit (GPU) graphic processing

    CN104200425A

  • Clipping of graphics primitives

    CN104933749A

  • Device and method for achieving user defined cutting function in GPU

    CN108447015A

  • 3-d clipping in a graphics processing unit

    US20080094412A1

Cited By

  • Image data storage, write-out and read methods and devices, equipment and storage medium

    CN121000983A

  • Image data storage, writing, reading method, device, equipment, storage medium

    CN121000983B