Pixel cutting method and device, electronic equipment and storage medium

By adaptively determining the configuration information of the crop protection belt, a crop mask is generated based on the size of the rendering target and the data accuracy of the rasterization stage, the problem of insufficient GPU cropping performance in the prior art is solved, and more efficient element cropping is achieved and rendering efficiency.

CN119251355AActive Publication Date: 2025-01-03MOORE THREADS TECHNOLOGY (CHENGDU) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411341389.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-01-03
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

In the prior art, the cutting performance of the GPU has not been fully improved, and the configuration of the cutting protection belt is not flexible enough, resulting in a long time to cut and an increase in the number of primitives after cutting.

Method used

According to the size of the rendering target and the preset data accuracy of the rasterization stage, the configuration information of the crop protection band is adaptively determined, so that the rendering target is located in the crop protection band, generating the crop mask of the primitives and the cropped primitive vertex coordinate accuracy Less than or equal to the preset data accuracy.

Benefits of technology

It improves the configuration flexibility of the crop protection belt, reduces the number of crops and the number of primitives, improves the rendering efficiency of the GPU, and ensures the accuracy of the rasterization function.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119251355A_ABST
    Figure CN119251355A_ABST
Patent Text Reader

Abstract

The invention relates to the field of graphic data processing, and provides a primitive cutting method and device, electronic equipment and a storage medium. The method comprises the steps of determining configuration information of a cutting protection band according to the size of a rendering target and preset data precision of a rasterization stage, enabling the rendering target to be located in the cutting protection band, generating a cutting mask of a primitive according to vertex coordinates of the primitive and the configuration information, cutting the primitive according to a cutting mode indicated by the cutting mask of the primitive, and obtaining the target rendering target. The precision of the vertex coordinates of the cut primitives is smaller than or equal to the preset data precision. According to the method, the configuration information of the cutting protection band is adaptively determined according to the size of the rendering target and the preset data precision of the rasterization stage, so that when the size of the rendering target changes, the cutting protection band is flexibly configured, and the GPU performance is improved without affecting the rasterization function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of graphics data processing, and in particular to a primitive clipping method, device, electronic device and storage medium. Background Art

[0002] The graphics processing unit (GPU) pipeline consists of a series of processing stages that convert graphics data into pixels that are ultimately displayed on the screen. These stages process the graphics data in sequence, with each stage performing a specific task to ultimately generate the final image. Rasterization is a key stage in the GPU pipeline. Before the rasterization stage, the GPU typically clips primitives to ensure that only the primitives that are partially within the frustum are rasterized, thereby improving rendering efficiency.

[0003] Clipping is a time-consuming operation in the GPU pipeline, and a single primitive may be clipped into multiple primitives, resulting in an increase in the number of clipped primitives. To reduce the clipping time and the number of clipped primitives, you can add a clipping guardband around the viewport. Primitives that intersect the viewport boundary will not be clipped as long as they do not exceed the clipping guardband.

[0004] In the existing technical solutions, the configuration of the cutting protection band is not flexible enough, and the cutting performance of the GPU still has room for improvement. Summary of the invention

[0005] In view of this, the present disclosure proposes a primitive clipping method, device, electronic device and storage medium. The method adaptively determines the configuration information of the clipping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage, so that when the size of the rendering target changes, the clipping protection band can be flexibly configured, thereby improving the GPU performance without affecting the early stage of the rasterization function.

[0006] According to one aspect of the present disclosure, a primitive clipping method is provided, the method comprising: determining configuration information of a clipping protection band according to the size of a rendering target and preset data precision of a rasterization stage, so that the rendering target is located in the clipping protection band, the size of the rendering target comprising the size of the rendering target in one or more clipping directions of a rendering target space, the configuration information comprising configuration information of the clipping protection band in each clipping direction; generating a clipping mask of the primitive according to vertex coordinates of the primitive and the configuration information, the clipping mask of the primitive indicating whether to clip the primitive, and when the clipping mask of the primitive indicates clipping the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive; when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive according to the clipping method indicated by the clipping mask of the primitive, and the precision of the vertex coordinates of the clipped primitive is less than or equal to the preset data precision.

[0007] In a possible implementation, the configuration information of the cropping protection band in any cropping direction includes scale information and offset information, wherein the scale information represents a ratio of a first difference to a size of the rendering target in the cropping direction, and the first difference is equal to a difference between an actual size of the cropping protection band in the cropping direction and a size of the rendering target in the cropping direction; and the offset information represents a difference between a minimum coordinate of the rendering target in the cropping direction and a minimum coordinate of the rendering target space in the cropping direction.

[0008] In a possible implementation, the determining of the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage includes: for any cropping direction corresponding to the size of the rendering target, determining the maximum size and maximum coordinate of the rendering target space in the cropping direction according to the preset data precision of the rasterization stage; determining the scale information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction and the maximum size and maximum coordinate of the rendering target space in the cropping direction; determining the offset information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction, the scale information and the maximum size and maximum coordinate of the rendering target space in the cropping direction, so that the actual size of the cropping protection band in the cropping direction is smaller than the maximum size of the rendering target space in the cropping direction, the minimum coordinate of the cropping protection band in the cropping direction is greater than 0, and the maximum coordinate of the cropping protection band in the cropping direction is smaller than the maximum coordinate of the rendering target space in the cropping direction.

[0009] In a possible implementation, when the size of the rendering target corresponds to a cropping direction, the size of the rendering target in the cropping direction is greater than or equal to the size in other cropping directions; the configuration information of the cropping protection band in the cropping direction also serves as the configuration information of the cropping protection band in other cropping directions.

[0010] In a possible implementation, for any cropping direction corresponding to the size of the rendering target, the minimum coordinate of the cropping protection band in the cropping direction is bm×R / 2, and the maximum coordinate is b+(R+m×R / 2), wherein R represents the size of the rendering target in the cropping direction, and R is a positive integer; m represents the scale information of the cropping protection band in the cropping direction, and m is a positive number; b represents the offset information of the cropping protection band in the cropping direction, and b is a positive number.

[0011] In a possible implementation, when there are multiple numerical combinations available for the scale information and offset information of the cropping protection band in any cropping direction, a numerical combination is selected that makes the actual size of the cropping protection band in the cropping direction closest to the maximum size of the rendering target space in the cropping direction.

[0012] In a possible implementation, the generating of the clipping mask of the primitive based on the vertex coordinates of the primitive and the configuration information includes: determining the coordinates of the clipping surface of the clipping protection band in each clipping direction based on the configuration information of the clipping protection band; determining the positional relationship between the primitive and each clipping surface based on the vertex coordinates of the primitive and the coordinates of each clipping surface; and generating the clipping mask of the primitive based on the positional relationship.

[0013] In one possible implementation, when the primitive intersects with at least one clipping plane and intersects with the rendering target, the clipping mask of the primitive indicates that the primitive is to be clipped, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane or does not intersect with the rendering target, the clipping mask of the primitive indicates that the primitive is not to be clipped.

[0014] In one possible implementation, when the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates clipping of the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane, the clipping mask of the primitive indicates not clipping the primitive.

[0015] In one possible implementation, when the clipping mask of the primitive indicates clipping of the primitive, clipping the primitive according to the clipping method indicated by the clipping mask of the primitive includes: when the clipping mask of the primitive indicates clipping of the primitive, selecting any one clipping plane from the clipping planes intersecting with the primitive; clipping the primitive using the selected clipping plane; the method also includes: updating the clipping mask of the primitive according to the vertex coordinates of new vertices obtained by clipping.

[0016] According to another aspect of the present disclosure, a primitive clipping device is provided, the device comprising: a first determination module, for determining configuration information of a clipping protection band according to the size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the clipping protection band, the size of the rendering target comprising the size of the rendering target in one or more clipping directions of a rendering target space, and the configuration information comprising configuration information of the clipping protection band in each clipping direction; a first generation module, for generating a clipping mask of the primitive according to vertex coordinates of the primitive and the configuration information, the clipping mask of the primitive indicating whether to clip the primitive, and when the clipping mask of the primitive indicates clipping the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive; a first clipping module, for clipping the primitive according to the clipping method indicated by the clipping mask of the primitive when the clipping mask of the primitive indicates clipping the primitive, and the precision of the vertex coordinates of the clipped primitive is less than or equal to the preset data precision.

[0017] In a possible implementation, the configuration information of the cropping protection band in any cropping direction includes scale information and offset information, wherein the scale information represents a ratio of a first difference to a size of the rendering target in the cropping direction, and the first difference is equal to a difference between an actual size of the cropping protection band in the cropping direction and a size of the rendering target in the cropping direction; and the offset information represents a difference between a minimum coordinate of the rendering target in the cropping direction and a minimum coordinate of the rendering target space in the cropping direction.

[0018] In a possible implementation, the determining of the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage includes: for any cropping direction corresponding to the size of the rendering target, determining the maximum size and maximum coordinate of the rendering target space in the cropping direction according to the preset data precision of the rasterization stage; determining the scale information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction and the maximum size and maximum coordinate of the rendering target space in the cropping direction; determining the offset information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction, the scale information and the maximum size and maximum coordinate of the rendering target space in the cropping direction, so that the actual size of the cropping protection band in the cropping direction is smaller than the maximum size of the rendering target space in the cropping direction, the minimum coordinate of the cropping protection band in the cropping direction is greater than 0, and the maximum coordinate of the cropping protection band in the cropping direction is smaller than the maximum coordinate of the rendering target space in the cropping direction.

[0019] In a possible implementation, when the size of the rendering target corresponds to a cropping direction, the size of the rendering target in the cropping direction is greater than or equal to the size in other cropping directions; the configuration information of the cropping protection band in the cropping direction also serves as the configuration information of the cropping protection band in other cropping directions.

[0020] In a possible implementation, for any cropping direction corresponding to the size of the rendering target, the minimum coordinate of the cropping protection band in the cropping direction is bm×R / 2, and the maximum coordinate is b+(R+m×R / 2), wherein R represents the size of the rendering target in the cropping direction, and R is a positive integer; m represents the scale information of the cropping protection band in the cropping direction, and m is a positive number; b represents the offset information of the cropping protection band in the cropping direction, and b is a positive number.

[0021] In a possible implementation, when there are multiple numerical combinations available for the scale information and offset information of the cropping protection band in any cropping direction, a numerical combination is selected that makes the actual size of the cropping protection band in the cropping direction closest to the maximum size of the rendering target space in the cropping direction.

[0022] In a possible implementation, the generating of the clipping mask of the primitive based on the vertex coordinates of the primitive and the configuration information includes: determining the coordinates of the clipping surface of the clipping protection band in each clipping direction based on the configuration information of the clipping protection band; determining the positional relationship between the primitive and each clipping surface based on the vertex coordinates of the primitive and the coordinates of each clipping surface; and generating the clipping mask of the primitive based on the positional relationship.

[0023] In one possible implementation, when the primitive intersects with at least one clipping plane and intersects with the rendering target, the clipping mask of the primitive indicates that the primitive is to be clipped, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane or does not intersect with the rendering target, the clipping mask of the primitive indicates that the primitive is not to be clipped.

[0024] In one possible implementation, when the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates clipping of the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane, the clipping mask of the primitive indicates not clipping the primitive.

[0025] In a possible implementation, when the clipping mask of the primitive indicates clipping of the primitive, clipping the primitive according to the clipping method indicated by the clipping mask of the primitive includes: when the clipping mask of the primitive indicates clipping of the primitive, selecting any one clipping surface from the clipping surfaces intersecting with the primitive; clipping the primitive using the selected clipping surface; the device also includes: an updating module, used to update the clipping mask of the primitive according to the vertex coordinates of new vertices obtained by clipping.

[0026] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0027] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.

[0028] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0029] According to the primitive clipping method of the embodiment of the present disclosure, according to the size of the rendering target and the preset data accuracy of the rasterization stage, the configuration information of the clipping protection zone can be adaptively determined, and the rendering target is located in the clipping protection zone, thereby improving the configuration flexibility of the clipping protection zone; according to the vertex coordinates and configuration information of the primitive, a clipping mask of the primitive is generated, and the clipping mask of the primitive indicates whether to clip the primitive. When the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates the clipping method of the primitive, so according to the primitive The clipping mask of the primitive can determine whether to clip the primitive and how to clip the primitive; when the clipping mask of the primitive indicates clipping the primitive, the primitive is clipped according to the clipping method indicated by the clipping mask of the primitive. Since the configuration information of the clipping protection band is determined based on the preset data accuracy of the rasterization stage, and the configuration information is used to generate the clipping mask of the primitive, the accuracy of the vertex coordinates of the primitive clipped according to the clipping method indicated by the clipping mask of the primitive can be less than or equal to the preset data accuracy to ensure that the rasterization function is not affected. In summary, the primitive clipping method disclosed in the present invention can adaptively determine the configuration information of the clipping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage, so that when the size of the rendering target changes, the clipping protection band can be flexibly configured, thereby improving the GPU performance without affecting the rasterization function in the early stage.

[0030] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0032] Figure 1 The effect of different sizes of cutting protection tape on the cutting times is shown.

[0033] Figure 2 An exemplary application scenario of the primitive clipping method according to an embodiment of the present disclosure is shown.

[0034] Figure 3 A schematic diagram showing the process of a primitive clipping method according to an embodiment of the present disclosure.

[0035] Figure 4 The figure shows the positional relationship between the cropping protection band and the rendering target in the first cropping direction X according to an embodiment of the present disclosure.

[0036] Figure 5 An example of the positional relationship between a primitive and a cropping protection band according to an embodiment of the present disclosure is shown.

[0037] Figure 6 A schematic diagram showing the structure of a primitive clipping device according to an embodiment of the present disclosure.

[0038] Figure 7 A schematic diagram showing that a configuration information generating unit outputs configuration information to a crop mask generating unit according to an embodiment of the present disclosure.

[0039] Figure 8 A schematic diagram showing the structure of a primitive clipping device according to an embodiment of the present disclosure.

[0040] Fig. 9 A block diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0041] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0042] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0043] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0044] The Graphics Processing Unit (GPU) pipeline consists of a series of processing stages that convert graphics data into pixels that are ultimately displayed on the screen. These stages process the graphics data in turn, with each stage performing a specific task to ultimately produce the final image. The typical GPU pipeline includes the following processing stages:

[0045] 1. Vertex Shader stage: The vertex shading stage is the first stage of the GPU pipeline, which is used to receive vertex data input, such as vertex coordinates, colors, and texture coordinates, and perform vertex-level calculations and transformations, such as model transformation, view transformation, and projection transformation. The vertex shading stage can process vertex attributes, such as color interpolation, normal transformation, etc., and output the processed vertex data.

[0046] 2. Primitive Assembly: In this stage, the GPU assembles the shaded vertices into primitives and outputs primitive metadata. Primitives can be points, line segments, or triangles. Primitive metadata can include the correspondence between primitives and vertices.

[0047] 3. Geometry Shader stage: The geometry shading stage is an optional stage that does not require GPU support. In this stage, the GPU performs geometry-related operations on the primitives, such as geometric transformation, normal calculation, clipping, etc., and outputs the processed primitive data.

[0048] 4. Rasterization stage: In the rasterization stage, primitives are converted into pixels on the screen. This stage determines which pixels are covered by primitives and generates fragments for each pixel.

[0049] 5. Fragment Shader stage: The fragment shading stage is an important stage of the GPU pipeline. This stage takes the fragments generated by the rasterization stage as input, calculates the color and other properties of the fragments, such as texture sampling, lighting model, shadow calculation, etc., and outputs the pixel color.

[0050] 6. Per-Fragment Operations stage: In the per-fragment operations stage, some operations are performed on each fragment, such as depth test, template test, blending, etc., and the final pixel is output. These operations can affect whether the fragment is finally written to the frame buffer and how to blend with existing pixels.

[0051] 7. Framebuffer Write stage: Framebuffer Write is the last stage of the GPU pipeline, which is used to write the final pixels into the frame buffer for display.

[0052] Among them, rasterization is a key stage in the GPU pipeline. The rasterization stage mainly includes the following steps:

[0053] 1. Geometric primitive assembly: Assemble primitives according to the vertex data output by the vertex shader and the primitive data output by the primitive assembly stage (or geometric shading stage), and establish the correspondence between primitives and vertex coordinates.

[0054] 2. Primitive clipping: Before starting rasterization, the GPU usually clips primitives to ensure that only some triangles within the frustum are rasterized, thereby improving rendering efficiency.

[0055] 3. Projection transformation: After clipping, the vertices of the primitives are projected and mapped to the normalized device space coordinate system (Normalized Device Coordinate, NDC).

[0056] 4. Viewport transformation: After the projection transformation, the vertices of the primitives are mapped to the rendering target space, thereby determining the positions of the vertices of the primitives on the screen.

[0057] 5. Primitive setup: The GPU determines the pixels to be rasterized and the position of the pixels relative to the primitives based on the projected vertex coordinates.

[0058] 6. Scan conversion: During the rasterization stage, the GPU performs scan conversion on each primitive. During this process, the GPU determines the pixel coverage of the primitive on the screen and the position of each pixel relative to the primitive.

[0059] 7. Pixel interpolation: During rasterization, the GPU also interpolates the vertex attributes (such as color, texture coordinates, etc.) on the primitives to determine the final attribute value of each pixel. This ensures a smooth transition of the rendering results within the primitives.

[0060] 8. Fragment generation: After scan conversion, the GPU generates pixel fragments covering the primitives. Each fragment contains the pixel position, color, depth value, and other possible attributes.

[0061] In the primitive clipping step, when clipping primitives, it is desired to retain the primitives that are entirely within the rendering target and the primitives that intersect with the rendering target and are partially within the rendering target. If the rendering target is used directly as the basis for clipping primitives, all primitives that intersect with the rendering target will be clipped.

[0062] Cropping is a time-consuming operation in the GPU pipeline, and a single primitive will be cropped into multiple primitives, resulting in an increase in the number of primitives after cropping. In order to reduce the time spent on cropping and the number of primitives after cropping, a guardband can be used and set outside the render target. When cropping primitives, only primitives that intersect with the guardband are cropped. In this case, any primitive that intersects with the render target but does not intersect with the guardband needs to be cropped when the guardband is not used, but does not need to be cropped when the guardband is used, thereby reducing the number of cropping times and the time spent on cropping, which helps to improve rendering efficiency. The primitives within the guardband can be expressed with the precision required by the Application Programming Interface (API) and the hardware, so not cropping the primitives within the guardband will not have any impact on the accuracy of the rendering result.

[0063] The number of cuts is related to the size of the cutting protection tape. Figure 1 The effect of different sizes of cutting protection tape on the cutting times is shown.

[0064] like Figure 1 As shown, the size of the cutting protection band 2 is smaller than that of the cutting protection band 1. When the cutting protection band 2 is used, the primitives 1, 2, 3, and 4 all intersect with the cutting protection band 2, so the primitives 1, 2, 3, and 4 need to be cut. When the cutting protection band 1 is used, only the primitives 2 and 4 intersect with the cutting protection band 1, so only the primitives 2 and 4 need to be cut. It can be seen that compared with the cutting protection band with a smaller size, the larger protection band can further reduce the number of the cut primitives.

[0065] However, the clipping protection band cannot be set to be infinitely large. The reason is that the vertex coordinates of the clipped primitives need to be used in the rasterization stage, and the data precision supported by the rasterization stage is preset. If the clipping protection band is too large, the precision of the vertex coordinates of the clipped primitives may be greater than the preset data precision. The data precision of the rasterization stage needs to be additionally modified to make the rasterization proceed normally, which increases the complexity of the GPU.

[0066] In the prior art, the cropping guard band is usually manually configured so that the rendering target is located in the cropping guard band and the vertex coordinate precision of the primitives cropped based on the cropping guard band is less than or equal to the preset data precision. However, if the size of the rendering target changes, the configuration information of the cropping guard band needs to be manually adjusted, and the configuration of the cropping guard band is not flexible enough.

[0067] In view of this, the present disclosure proposes a primitive clipping method, device, electronic device and storage medium. The method adaptively determines the configuration information of the clipping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage, so that when the size of the rendering target changes, the clipping protection band can be flexibly configured, thereby improving the GPU performance without affecting the early stage of the rasterization function.

[0068] Furthermore, the configuration information determined by the method can make the size of the cropping protection zone larger, so that fewer primitives are cropped, the cropping of primitives is less time-consuming, and the rendering efficiency is higher.

[0069] Figure 2 An exemplary application scenario of the primitive clipping method according to an embodiment of the present disclosure is shown.

[0070] like Figure 2As shown, the primitive clipping method disclosed in the present invention can be applied to the primitive clipping device in the GPU, and is used to complete the clipping of primitives. The primitive clipping device can store information of the preset data accuracy of the rasterization stage. After the primitive clipping device receives the size of the rendering target, it can first determine the configuration information of the clipping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage. The primitive clipping device can also receive the vertex coordinates of the primitive and the primitive information (such as the texture of the primitive), and can determine whether the primitive needs to be clipped according to the configuration information of the clipping protection band and the vertex coordinates of the primitive, and use the clipping protection band to clip the primitives that need to be clipped to remove invalid primitive information. The primitive clipping results can be placed in the vertex buffer for use by other functional modules of the subsequent stage, such as the triangle parameter setting module and the depth and gradient setting module. The triangle parameter setting module and the depth and gradient setting module are both existing modules in the prior art, and the functions of the triangle parameter setting module and the depth and gradient setting module will not be repeated here.

[0071] Figure 3 A schematic diagram showing the process of a primitive clipping method according to an embodiment of the present disclosure.

[0072] like Figure 3 As shown, in a possible implementation, the present disclosure proposes a primitive clipping method, the method comprising:

[0073] Step 31, determining configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage, so that the rendering target is located in the cropping protection band, the size of the rendering target includes the size of the rendering target in one or more cropping directions of the rendering target space, and the configuration information includes configuration information of the cropping protection band in each cropping direction;

[0074] Step 32, generating a clipping mask of the primitive according to the vertex coordinates and configuration information of the primitive, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive;

[0075] Step 33, when the clipping mask of the primitive indicates clipping of the primitive, clipping the primitive according to the clipping method indicated by the clipping mask of the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.

[0076] For example, a render target refers to a buffer for drawing textures, which is usually rectangular in shape. A render target space refers to a coordinate space that can express the actual size of a render target, and the render target space may include a first clipping direction X and a second clipping direction Y, and the first clipping direction and the second clipping direction are perpendicular. The size W of the render target in the first clipping direction X may represent the width of the render target. The size H in the second clipping direction Y may represent the height of the render target. X and Y may be positive integers. The size of the render target may include the size of the render target in one or more clipping directions of the render target space, that is, including at least one of X and Y.

[0077] The preset data precision of the rasterization stage may be, for example, a fixed-point number in 16.8 format, in which case the maximum coordinates that can be expressed in each clipping direction of the rendering target space are 64k (the maximum expression range of a 16-bit integer). Those skilled in the art should understand that the preset data precision of the rasterization stage may also be a fixed-point number in 18.8 format, in which case the maximum coordinates that can be expressed in each clipping direction of the rendering target space are 256k (the maximum expression range of an 18-bit integer). The disclosed embodiment does not impose any restrictions on the preset data precision of the rasterization stage.

[0078] After determining the size of the rendering target and the preset data accuracy of the rasterization stage, step S31 can be executed to determine the configuration information of the cropping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage. Among them, the configuration information of the cropping protection band may include the configuration information of the cropping protection band in each cropping direction, and the configuration information of the cropping protection band in different cropping directions may be the same or different. The configuration information of the cropping protection band may indicate the position and shape of the cropping protection band in the rendering target space, and the rendering target may be located in the cropping protection band. Examples of the configuration information of the cropping protection band are given later. The present disclosure does not limit the specific implementation method of step S31, and an exemplary implementation method is given later.

[0079] The rendering target space may include multiple primitives. As described above, not all primitives need to be cropped. Therefore, it is possible to determine whether each primitive needs to be cropped, and only the primitives that need to be cropped can be cropped. It is possible to determine whether multiple primitives need to be cropped in sequence, or it is possible to determine whether multiple primitives need to be cropped in parallel, and the present disclosure does not limit this. For the sake of clarity, the following takes determining whether multiple primitives need to be cropped in sequence as an example.

[0080] Exemplarily, for any primitive, step S32 may be executed first, and whether the primitive needs to be cropped is determined based on the vertex coordinates and configuration information of the primitive, and a cropping mask for the primitive is generated. The present disclosure does not limit the specific implementation method of step S32, and an exemplary implementation method is given later. The cropping mask of the primitive may indicate whether the primitive is to be cropped. When the cropping mask of the primitive indicates cropping the primitive, the cropping mask of the primitive also indicates the cropping method of the primitive. Furthermore, when determining whether a primitive needs to be cropped, it may be determined first whether the primitive needs to be culled. For primitives that need to be culled, it may be determined directly that the primitive does not need to be cropped; for primitives that do not need to be culled, it may be further determined whether the primitive is to be cropped. In this way, the number of primitives to be cropped may be reduced, so as to further reduce the number of primitive cropping times.

[0081] When the clipping mask of the current primitive indicates that the primitive is not to be clipped, the clipping step of the current primitive can be skipped, and it is continued to determine whether the next primitive needs to be clipped, that is, step S32 is re-executed for the next primitive.

[0082] When the clipping mask of the current primitive indicates clipping of the primitive, the clipping step of the current primitive can be continued, that is, step S33 is executed to clip the primitive according to the clipping method indicated by the clipping mask of the primitive. The present disclosure does not limit the specific execution method of step S33, and an exemplary execution method is given later. Since the configuration information of the clipping protection band is determined based on the preset data accuracy of the rasterization stage, the configuration information is used to determine the positional relationship between the primitive and the clipping protection band, and the positional relationship is used to determine the clipping mask of the primitive. Therefore, after clipping according to the clipping method indicated by the clipping mask of the primitive, the accuracy of the vertex coordinates of the primitive can be less than or equal to the preset data accuracy to ensure that the rasterization function is not affected.

[0083] According to the primitive clipping method of the embodiment of the present disclosure, according to the size of the rendering target and the preset data accuracy of the rasterization stage, the configuration information of the clipping protection zone can be adaptively determined, and the rendering target is located in the clipping protection zone, thereby improving the configuration flexibility of the clipping protection zone; according to the vertex coordinates and configuration information of the primitive, a clipping mask of the primitive is generated, and the clipping mask of the primitive indicates whether to clip the primitive. When the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates the clipping method of the primitive, so according to the primitive The clipping mask of the primitive can determine whether to clip the primitive and how to clip the primitive; when the clipping mask of the primitive indicates clipping the primitive, the primitive is clipped according to the clipping method indicated by the clipping mask of the primitive. Since the configuration information of the clipping protection band is determined based on the preset data accuracy of the rasterization stage, and the configuration information is used to generate the clipping mask of the primitive, the accuracy of the vertex coordinates of the primitive clipped according to the clipping method indicated by the clipping mask of the primitive can be less than or equal to the preset data accuracy to ensure that the rasterization function is not affected. In summary, the primitive clipping method disclosed in the present invention can adaptively determine the configuration information of the clipping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage, so that when the size of the rendering target changes, the clipping protection band can be flexibly configured, thereby improving the GPU performance without affecting the rasterization function in the early stage.

[0084] The following describes exemplary contents included in the configuration information of the cropping protection band.

[0085] In a possible implementation, the configuration information of the cropping protection band in any cropping direction includes scale information and offset information, wherein:

[0086] The ratio information indicates a ratio of the first difference value to the size of the rendering target in the clipping direction, and the first difference value is equal to a difference between an actual size of the clipping protection band in the clipping direction and a size of the rendering target in the clipping direction;

[0087] The offset information indicates the difference between the minimum coordinate of the rendering target in the clipping direction and the minimum coordinate of the rendering target space in the clipping direction.

[0088] Taking the first cutting direction X as an example, the following describes the contents included in the configuration information of the cutting protection belt in the first cutting direction X.

[0089] Figure 4 The figure shows the positional relationship between the cropping protection band and the rendering target in the first cropping direction X according to an embodiment of the present disclosure.

[0090] like Figure 4As shown, it is assumed that the minimum coordinate of the rendering target space in the first clipping direction X is 0 and the maximum coordinate is MAX_RESOLUTION_X. In the first clipping direction X, the minimum coordinate x2 of the rendering target is greater than the minimum coordinate x1 of the clipping protection band, the maximum coordinate x3 of the rendering target is less than the maximum coordinate x4 of the clipping protection band, and the rendering target is located at the center of the clipping protection band, that is, x2-x1=x4-x3. In the first clipping direction X, the minimum coordinate x1 of the clipping protection band is greater than the minimum coordinate of the rendering target space, that is, x1>0; the maximum coordinate x4 of the clipping protection band is less than the maximum coordinate of the rendering target space, that is, x4 <MAX_RESOLUTION_X。

[0091] The configuration information of the cropping protection band in the first cropping direction X includes scale information Kx and offset information Bx. The definitions of scale information Kx and offset information Bx are given below.

[0092] exist Figure 4 In the example, the size W of the rendering target in the first cropping direction X is W=x3-x2. The actual size W' of the cropping protection band in the first cropping direction X is equal to the difference between the maximum coordinate x4 and the minimum coordinate x1 of the cropping protection band, that is, W'=x4-x1. The difference (W'-W) between the actual size W' of the cropping protection band in the first cropping direction X and the size W of the rendering target in the first cropping direction X is also referred to as the first difference in the first cropping direction X in the present disclosure. At this time, W'-W=(x4-x1)-(x3-x2)=x4-x3+x2-x1=2(x4-x3)=2(x2-x1).

[0093] In the present disclosure, in the first cropping direction X, the first difference (W'-W) and the size (W) of the rendering target may be proportional, and the ratio information Kx may indicate the proportional relationship between the two. That is, the ratio information Kx of the cropping protection band in the first cropping direction X represents the ratio of the first difference (W'-W) to the size W of the rendering target in the first cropping direction X, and the first difference is equal to the difference between the actual size W' of the cropping protection band in the first cropping direction X and the size W of the rendering target in the first cropping direction X. In this case, in the first cropping direction X, the actual size W' of the cropping protection band is equal to Kx×W+W.

[0094] In any clipping direction, the position of the rendering target in the rendering target space is not fixed, and may be at the center of the rendering target space, or may be to the left or right of the center. In the configuration information of the clipping protection band in the first clipping direction X, the offset information Bx may indicate the position of the rendering target relative to the rendering target space in the first clipping direction X. For example, the offset information Bx may indicate the difference between the minimum coordinate x2 of the rendering target in the first clipping direction X and the minimum coordinate 0 of the rendering target space in the first clipping direction X. That is, Bx=x2-0=x2.

[0095] In this case, if the size W and offset information Bx of the rendering target in the first clipping direction X are known, it can be determined that the minimum coordinate of the rendering target in the rendering target space in the first clipping direction X is Bx, and the maximum coordinate is Bx+W; if the minimum coordinate Bx and maximum coordinate Bx+W of the rendering target in the rendering target space in the first clipping direction X are known, as well as the size W and scale information Kx of the rendering target in the first clipping direction X, it can be determined that the minimum coordinate of the clipping protection band in the rendering target space in the first clipping direction X is Bx-Kx×W / 2, and the maximum coordinate is Bx+(W+Kx×W / 2).

[0096] Similarly, if the size H and offset information By of the rendering target in the second clipping direction Y are known, it can be determined that the minimum coordinate of the rendering target in the rendering target space in the second clipping direction Y is By, and the maximum coordinate is By+H; if the minimum coordinate By and maximum coordinate By+H of the rendering target in the rendering target space in the second clipping direction Y are known, as well as the size H and scale information Ky of the rendering target in the second clipping direction Y, it can be determined that the minimum coordinate of the clipping protection band in the rendering target space in the second clipping direction Y is By-Ky×H / 2, and the maximum coordinate is By+(H+Ky×H / 2).

[0097] That is, in a possible implementation, for any clipping direction corresponding to the size of the rendering target, the minimum coordinate of the clipping protection band in the clipping direction is bm×R / 2, and the maximum coordinate is b+(R+m×R / 2), where:

[0098] R represents the size of the rendering target in the clipping direction, and R is a positive integer;

[0099] m represents the ratio information of the cropping protection band in the cropping direction, and m is a positive number;

[0100] b represents the offset information of the cropping protection band in the cropping direction, and b is a positive number.

[0101] For the first cropping direction X, R may be equal to W, m may be equal to Kx, and b may be equal to Bx. For the second cropping direction Y, R may be equal to H, m may be equal to Ky, and b may be equal to By.

[0102] Before rasterization, the coordinates of the rendering target must first be transformed to the normalized device space NDC coordinate system, so Figure 4 The coordinates of the rendering target and the clipping protection zone in the NDC coordinate system are also shown. Figure 4 As shown, if the maximum coordinate x3 of the rendering target in the first clipping direction X is transformed to 1 in the NDC coordinate system, and the minimum coordinate x2 of the rendering target in the first clipping direction X is transformed to -1 in the NDC coordinate system, then in the NDC coordinate system, the maximum coordinate x4 of the clipping protection band in the first clipping direction X can be 1+m, and the minimum coordinate x1 of the clipping protection band in the first clipping direction X can be -(1+m).

[0103] An exemplary method for determining the ratio information and the offset information of the cropping protection band in the first cropping direction X is described below.

[0104] In a possible implementation, determining the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage (step S31) includes:

[0105] For any clipping direction corresponding to the size of the render target,

[0106] According to the preset data precision of the rasterization stage, the maximum size and maximum coordinates of the rendering target space in the clipping direction are determined;

[0107] According to the size of the rendering target in the cropping direction and the maximum size and maximum coordinates of the rendering target space in the cropping direction, the scale information of the cropping protection band in the cropping direction is determined, and according to the size and scale information of the rendering target in the cropping direction and the maximum size and maximum coordinates of the rendering target space in the cropping direction, the offset information of the cropping protection band in the cropping direction is determined, so that the actual size of the cropping protection band in the cropping direction is smaller than the maximum size of the rendering target space in the cropping direction, the minimum coordinate of the cropping protection band in the cropping direction is greater than 0, and the maximum coordinate of the cropping protection band in the cropping direction is smaller than the maximum coordinate of the rendering target space in the cropping direction.

[0108] For example, when determining the configuration information, you may use only the size of the rendering target in one cropping direction, or you may use the sizes of the rendering target in multiple cropping directions. If you use the sizes of the rendering target in multiple cropping directions, you need to determine the configuration information of the cropping protection band in each cropping direction. In this case, the configuration information of the cropping protection band in different cropping directions may be different.

[0109] For example, for any clipping direction corresponding to the size of the rendering target, the maximum size and maximum coordinates of the rendering target space in the clipping direction may be determined according to the preset data precision of the rasterization stage.

[0110] The minimum coordinates of the rendering target space in different clipping directions may be the same and equal to 0. The maximum coordinates of the rendering target space in different clipping directions may be the same or different, as long as the precision of the maximum coordinates of the rendering target space in each clipping direction is less than or equal to the preset data precision.

[0111] Taking the default data precision of the rasterization stage as a fixed-point number in 16.8 format, the maximum coordinate that can be expressed by the render target space in each clipping direction is 64k (the maximum expression range of 16-bit integers). The minimum coordinates of the render target space in different clipping directions can be the same and equal to 0. When the render target space is the largest, the maximum size and maximum coordinates of the render target space in different clipping directions are equal and equal to 64k.

[0112] For example, the user can also reduce the rendering target space according to the application scenario requirements, and the maximum size and maximum coordinates of the rendering target space in different clipping directions can be different. As long as the accuracy of the maximum coordinates of the rendering target space in each clipping direction is less than or equal to the preset data accuracy. The present disclosure does not limit the specific method for determining the maximum size and maximum coordinates of the rendering target space in each clipping direction.

[0113] The entire cropping protection band is located in the rendering target space, that is, in any cropping direction, the coordinates of the cropping protection band must meet the following conditions: the actual size of the cropping protection band in the cropping direction is smaller than the maximum size of the rendering target space in the cropping direction; the minimum coordinate of the cropping protection band in the cropping direction is greater than 0; the maximum coordinate of the cropping protection band in the cropping direction is smaller than the maximum coordinate of the rendering target space in the cropping direction.

[0114] According to the above conditions, formulas (1)-(6) can be obtained:

[0115] Kx×W+W <MAX_RESOLUTION_X (1)

[0116] Bx-Kx×W / 2>0 (2)

[0117] Bx+Kx×W / 2+W <MAX_RESOLUTION_X (3)

[0118] Ky×H+H <MAX_RESOLUTION_Y (4)

[0119] By-Ky×H / 2>0 (5)

[0120] By+Ky×H / 2+H <MAX_RESOLUTION_Y (6)

[0121] In formulas (1)-(3), Kx×W+W represents the actual size of the cropping protection zone in the first cropping direction X; MAX_RESOLUTION_X represents the maximum size and maximum coordinate of the rendering target space in the first cropping direction X; Bx-Kx×W / 2 represents the minimum coordinate of the cropping protection zone in the first cropping direction X; and Bx+Kx×W / 2+W represents the maximum coordinate of the cropping protection zone in the first cropping direction X.

[0122] In formulas (4)-(6), Ky represents the scale information of the cropping protection band in the second cropping direction Y, By represents the offset information of the cropping protection band in the second cropping direction Y, H represents the size of the rendering target in the second cropping direction Y, Ky×H+H represents the actual size of the cropping protection band in the second cropping direction Y, MAX_RESOLUTION_Y represents the maximum size of the rendering target space in the second cropping direction Y, By-Ky×H / 2 represents the minimum coordinate of the cropping protection band in the second cropping direction Y, and By+Ky×H / 2+H represents the maximum coordinate of the cropping protection band in the second cropping direction Y.

[0123] Formulas (1)-(6) can be further simplified to obtain the value ranges of Kx, Bx, Ky, and By as follows:

[0124] Kx <MAX_RESOLUTION_X / X-1;

[0125] Kx×W / 2 <Bx<MAX_RESOLUTION_X-(W / 2+1)W;

[0126] Ky <MAX_RESOLUTION_Y / Y-1;

[0127] Ky×H / 2 <By<MAX_RESOLUTION_Y-(H / 2+1)H;

[0128] Any numerical combination of Kx and Bx that satisfies the above value range can be set as the proportion information and offset information of the cutting protection band in the first cutting direction X; any numerical combination of Ky and By that satisfies the above value range can be set as the proportion information and offset information of the cutting protection band in the second cutting direction Y.

[0129] Only two clipping directions are shown above. Those skilled in the art should understand that the rendering target space may have more clipping directions, and the embodiments of the present disclosure do not limit the specific number of clipping directions of the rendering target space.

[0130] When the sizes of the render target in multiple clipping directions are used to determine the configuration information of the clipping guard band, the size settings of the clipping guard band in different clipping directions are more flexible.

[0131] In a possible implementation, when the size of the rendering target corresponds to a clipping direction, the size of the rendering target in the clipping direction is greater than or equal to the size in other clipping directions;

[0132] The configuration information of the cutting protection band in the cutting direction also serves as the configuration information of the cutting protection band in other cutting directions.

[0133] For example, if only the size of the rendering target in one cropping direction is used to determine the configuration information of the cropping protection band, the method for determining the configuration information of the cropping protection band in this cropping direction can be the same as when the size of the rendering target in multiple cropping directions is used to determine the configuration information of the cropping protection band. That is, if only the size of the rendering target in the first cropping direction X is used to determine the configuration information of the cropping protection band, the configuration information of the cropping protection band in the first cropping direction X can be determined according to formulas (1)-(3). If only the size of the rendering target in the second cropping direction Y is used to determine the configuration information of the cropping protection band, the configuration information of the cropping protection band in the second cropping direction Y can be determined according to formulas (4)-(6). The specific determination method has been described above and will not be repeated here.

[0134] The configuration information of the cutting protection band in the cutting direction is also used as the configuration information of the cutting protection band in other cutting directions. At this time, the configuration information of the cutting protection band in different cutting directions is the same, that is, Kx=ky, Bx=By.

[0135] In order to make the cropping protection band satisfy the conditions that the actual size is smaller than the maximum size of the rendering target space in the cropping direction, the minimum coordinate is greater than 0, and the maximum coordinate is smaller than the maximum coordinate of the rendering target space in the cropping direction in each cropping direction, when only the size of the rendering target in one cropping direction is used to determine the configuration information of the cropping protection band, the cropping direction with a larger size of the rendering target can be selected, that is, when the size of the rendering target corresponds to one cropping direction, the size of the rendering target in the cropping direction is greater than or equal to the size in other cropping directions. For example, when the size of the rendering target in the first cropping direction X is greater than the size in the second cropping direction Y, the size of the rendering target in the first cropping direction X can be selected to determine the configuration information of the cropping protection band. When the size of the rendering target in the first cropping direction X is smaller than the size in the second cropping direction Y, the size of the rendering target in the second cropping direction Y can be selected to determine the configuration information of the cropping protection band. When the size of the rendering target in the first cropping direction X is equal to the size in the second cropping direction Y, the size of the rendering target in the second cropping direction Y or the first cropping direction X can be selected to determine the configuration information of the cropping protection band.

[0136] In this case, the method of determining the configuration information of the cropping protection band is simpler.

[0137] An exemplary method of determining specific values ​​of the ratio information and the offset information in the present disclosure is described below.

[0138] In a possible implementation, when there are multiple numerical combinations available for the scale information and offset information of the cropping protection band in any cropping direction, a numerical combination is selected that makes the actual size of the cropping protection band in the cropping direction closest to the maximum size of the rendering target space in the cropping direction.

[0139] As described above, since the value range of the ratio information and the offset information can be derived according to formulas (1)-(6), any value that meets the value range can be selected. Therefore, in any cutting direction, there may be multiple value combinations for the ratio information and the offset information. As described above, the larger the cutting protection band, the fewer the cutting times. In this case, in any cutting direction, a value combination that makes the actual size of the cutting protection band closest to the maximum size of the cutting protection band can be selected, so that the actual size of the cutting protection band is larger, further reducing the cutting times.

[0140] In practical applications, in any clipping direction, the size of the rendering target is usually an exponential power of 2 (unit: bit), such as 1k, 2k, 4k, 8k, 16k, 32k, etc. (1k equals 1024 bits). Since the selection of the size of the rendering target is limited, a lookup table of the configuration information of the clipping protection band can be predetermined. The lookup table can record the correspondence between the size of the rendering target and the scale information and the offset information. Different lookup tables can be set for different data precisions in the rasterization stage. Table 1 shows an example of a lookup table of the configuration information of the clipping protection band when the data precision of the rasterization is 16.8.

[0141] Table 1

[0142] The size of the render target m b Clipping guard band coordinates R m b bm×R / 2, b+(R+m×R / 2) 32k 0.5 20k 14k, 60k 16k 2 20k 4k, 52k 8k 6 30k 6k, 62k 4k(4096) 14 30k 2k, 62k 2k(2048) 30 31k 1k, 63k 1k(1024) 60 31k 1k, 62k

[0143] In this case, the lookup table to be searched can be found first according to the preset data accuracy of the rasterization stage, and then the configuration information of the cropping protection band can be directly searched in the lookup table according to the size of the rendering target required to determine the configuration information of the cropping protection band. There is no need to calculate and determine the configuration information of the cropping protection band, thereby improving the efficiency of determining the configuration information.

[0144] In the embodiments of the present disclosure, determining the configuration information of the cropping protection band may be completed by a hardware module or a software algorithm, and the present disclosure does not impose any limitation on this.

[0145] The following describes an exemplary method of the present disclosure for determining the positional relationship between a primitive and a cropping protection band.

[0146] In a possible implementation, step S32 includes:

[0147] Determine the coordinates of the cutting surface of the cutting protection band in each cutting direction according to the configuration information of the cutting protection band;

[0148] Determine the positional relationship between the primitive and each clipping surface according to the vertex coordinates of the primitive and the coordinates of each clipping surface;

[0149] Generate a clipping mask for the primitives based on their positional relationships.

[0150] For example, the space where the primitives are located is three-dimensional space, so Figure 1 and Figure 4 The cross section of the cutting protection band is shown. The cutting protection band may have two cutting surfaces in each cutting direction. The minimum coordinate of the cutting protection band in the cutting direction corresponds to the first cutting surface, and the maximum coordinate corresponds to the second cutting surface.

[0151] According to the configuration information of the cropping protection band, the coordinates of the cropping surface of the cropping protection band in each cropping direction can be determined. According to the vertex coordinates of the primitive and the coordinates of each cropping surface, the positional relationship between the primitive and each cropping surface can be determined.

[0152] Figure 5 An example of the positional relationship between a primitive and a cropping protection band according to an embodiment of the present disclosure is shown.

[0153] like Figure 5 As shown, the cutting protection band may correspond to the cutting surface 1 and the cutting surface 2 in the first cutting direction X, the coordinates of all points on the cutting surface 1 in the first cutting direction X are equal to the minimum coordinates of the cutting protection band in the first cutting direction X, and the coordinates of all points on the cutting surface 3 in the first cutting direction X are equal to the maximum coordinates of the cutting protection band in the first cutting direction X. The cutting protection band may correspond to the cutting surface 3 and the cutting surface 4 in the second cutting direction Y. The coordinates of all points on the cutting surface 3 in the second cutting direction Y are equal to the minimum coordinates of the cutting protection band in the second cutting direction Y, and the coordinates of all points on the cutting surface 4 in the second cutting direction Y are equal to the maximum coordinates of the cutting protection band in the second cutting direction Y.

[0154] In this case, the positional relationship between primitive 1 and the cutting protection band can be: primitive 1 does not intersect with cutting planes 1, 2, 3, and 4, that is, primitive 1 does not intersect with the cutting protection band; the positional relationship between primitive 2 and the cutting protection band can be: primitive 2 does not intersect with cutting planes 1, 2, and 3, but intersects with cutting plane 4, that is, primitive 2 intersects with the cutting protection band; the positional relationship between primitive 3 and the cutting protection band can be: primitive 3 does not intersect with cutting planes 1, 2, 3, and 4, that is, primitive 3 does not intersect with the cutting protection band; the positional relationship between primitive 4 and the cutting protection band can be: primitive 4 does not intersect with cutting planes 1, 2, and 4, but intersects with cutting plane 3, that is, primitive 4 intersects with the cutting protection band.

[0155] An exemplary method of the present disclosure for determining whether a primitive needs to be cropped is described below.

[0156] In one possible implementation, when a primitive intersects with at least one clipping plane and intersects with a rendering target, a clipping mask of the primitive indicates clipping the primitive, and a clipping method of the primitive includes clipping the primitive using a clipping plane that intersects with the primitive;

[0157] When a primitive does not intersect any clipping planes or does not intersect the render target, the primitive's clipping mask indicates that the primitive is not clipped.

[0158] For example, in actual applications, there may be a culling step before rendering to remove non-visible primitives outside the screen to improve rendering performance. If a primitive intersects the clipping protection band but does not intersect the render target, then the primitive is actually a culled primitive, and not clipping the primitive will not affect the rasterization result. In other words, only primitives that intersect with at least one clipping plane and the render target actually need to be clipped.

[0159] Thus, when a primitive intersects at least one clipping plane and intersects a render target, the clipping mask of the primitive may indicate that the primitive is clipped, including clipping the primitive using the clipping planes that intersect the primitive. Figure 5 In the example, only primitive 4 intersects with at least one clipping plane and intersects with the rendering target, so only the clipping mask of primitive 4 can indicate the clipping of primitive 4. The clipping mask of primitive 4 can also indicate that the clipping method of primitive 4 is to clip primitive 4 using clipping plane 3.

[0160] When a primitive does not intersect any clipping planes, or when a primitive does not intersect a render target, the primitive does not need to be clipped, and the primitive's clipping mask can indicate that the primitive is not to be clipped. Figure 5 In the example of , primitive 1 does not intersect any clipping plane and does not intersect the render target, so the clipping mask of primitive 1 can indicate that primitive 1 is not clipped. Primitive 2 does not intersect the render target, so the clipping mask of primitive 2 can indicate that primitive 2 is not clipped. Primitive 3 does not intersect any clipping plane, so the clipping mask of primitive 3 can indicate that primitive 3 is not clipped.

[0161] By enabling the clipping guard band to play a role in the culling process, it helps to reduce the overhead of unnecessary processing of invisible primitives, resulting in fewer clipped primitives and improved rendering efficiency.

[0162] Another exemplary method of the present disclosure for determining whether a primitive needs to be cropped is introduced below.

[0163] In a possible implementation, when a primitive intersects with at least one clipping plane, a clipping mask of the primitive indicates clipping the primitive, and a clipping method of the primitive includes clipping the primitive using the clipping plane intersecting with the primitive;

[0164] When a primitive and each clipping plane do not intersect, the primitive's clipping mask indicates that the primitive is not clipped.

[0165] In one example, when determining whether a primitive needs to be clipped, it is also possible not to consider whether the primitive needs to be culled, that is, determining whether the primitive needs to be clipped is performed only based on the intersection between the primitive and the clipping plane.

[0166] In this case, when a primitive intersects at least one clipping plane and intersects the rendering target, it can be determined that the primitive needs to be clipped, and the clipping mask of the primitive can indicate clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects the primitive. Figure 5 In the example, primitive 2 and clipping plane 4 intersect, and primitive 4 and clipping plane 3 intersect, so the clipping mask of primitive 4 can indicate that primitive 4 is clipped, and can further indicate that the clipping method of primitive 4 is to use clipping plane 3 to clip primitive 4; the clipping mask of primitive 2 can indicate that primitive 2 is clipped, and can further indicate that the clipping method of primitive 4 is to use clipping plane 4 to clip primitive 2.

[0167] When a primitive does not intersect any clipping plane, the primitive's clipping mask indicates that the primitive is not clipped. Figure 5 In the example of , primitive 1 and primitive 3 do not intersect any clipping plane, so the clipping mask of primitive 1 may indicate that primitive 1 is not clipped, and the clipping mask of primitive 3 may indicate that primitive 3 is not clipped.

[0168] In this way, it is easier to determine whether a primitive needs to be clipped.

[0169] An example of clipping primitives disclosed herein is described below.

[0170] In a possible implementation, step S33 includes:

[0171] When the clipping mask of a primitive indicates clipping of the primitive, the primitive is clipped in sequence according to the clipping planes that intersect the primitive, using one clipping plane at a time.

[0172] For example, since the clipping planes that intersect with the primitive have been determined when the clipping mask of the primitive is generated, the clipping method of the primitive can indicate all clipping planes that intersect with the primitive. Assume that only one clipping plane can be used to clip the primitive at a time. In this case, when the clipping mask of the primitive indicates to clip the primitive, the primitive can be clipped in sequence according to the clipping planes that intersect with the primitive, using one clipping plane at a time. After the last clipping plane is used, the primitive is clipped.

[0173] In this way, the clipping process of the primitives is made simpler.

[0174] Another example of clipping primitives disclosed in the present invention is described below.

[0175] In a possible implementation, step S33 includes:

[0176] When the clipping mask of the primitive indicates clipping the primitive, any clipping plane is selected from the clipping planes intersecting with the primitive, and the primitive is clipped using the selected clipping plane;

[0177] The method further comprises: updating the clipping mask of the primitive according to the vertex coordinates of the new vertex obtained by clipping.

[0178] For example, suppose that only one clipping plane can be used to clip a primitive at a time. After each clipping, the shape of the primitive will change, so the unused clipping planes may become invalid. For example, a primitive intersects with three clipping planes before clipping. If it is clipped according to the clipping method indicated by the clipping mask determined before clipping, it needs to be clipped three times. After the first clipping, it may only intersect with one clipping plane, so two clippings are actually enough to clip the primitive, and one clipping plane is invalid.

[0179] In this case, when the clipping mask of the primitive indicates clipping the primitive, any clipping plane can be selected from the clipping planes intersecting the primitive as the clipping plane used for this clipping. When there is only one clipping plane intersecting the primitive, the clipping plane can be directly selected. When there are multiple clipping planes intersecting the primitive, a clipping plane can be randomly selected. The selected clipping plane can be used to clip the primitive.

[0180] After clipping the primitive, at least one new vertex can be obtained. The clipping mask of the primitive can be updated according to the vertex coordinates of the new vertex obtained by clipping. Exemplarily, the updating method can be to redetermine the positional relationship between the primitive and each clipping surface according to the vertex coordinates of the new vertex and the vertex coordinates of the valid old vertex and the coordinates of each clipping surface, and generate the clipping mask of the primitive according to the determined positional relationship, that is, the updated clipping mask of the primitive. Determining the positional relationship between the primitive and the clipping surface and generating the clipping mask of the primitive according to the determined positional relationship have been described above and will not be repeated here.

[0181] Step S33 may be re-executed according to the updated clipping mask of the primitive until the clipping mask of the primitive no longer indicates clipping the primitive.

[0182] In this way, the number of primitive clipping can be further reduced.

[0183] The following introduces an exemplary structure of a primitive clipping device implemented by hardware modules in an embodiment of the present disclosure and the functions of each hardware module.

[0184] Figure 6 A schematic diagram showing the structure of a primitive clipping device according to an embodiment of the present disclosure.

[0185] like Figure 6 As shown, the primitive clipping device may include a configuration information generating unit and a clipping module. The clipping module may include a clipping mask generating unit, a clipping resolution unit and a clipping execution unit.

[0186] The configuration information generation unit may store information of preset data precision in the rasterization stage. The configuration information generation unit may receive the size of the rendering target and execute step S31 to determine the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision in the rasterization stage, so that the rendering target is located in the cropping protection band. The configuration information generation unit may obtain the configuration information of the cropping protection band in each cropping direction and output it to the cropping mask generation unit.

[0187] Figure 7 A schematic diagram showing that a configuration information generating unit outputs configuration information to a crop mask generating unit according to an embodiment of the present disclosure.

[0188] like Figure 7 As shown, assuming that the rendering target space has a first cropping direction X and a second cropping direction Y, the configuration information generating unit can transmit the configuration information of the cropping protection band in the first cropping direction X and the configuration information of the second cropping direction Y to the cropping mask generating unit respectively.

[0189] The clipping mask generating unit also receives vertex coordinates and executes steps S32 and S33 to generate a clipping mask of the primitive according to the vertex coordinates and configuration information of the primitive. Exemplarily, the clipping mask generating unit may first generate a clipping mask of the vertex for the vertex, the clipping mask of the vertex indicating the positional relationship between the vertex and the clipping plane, and then generate a clipping mask of the primitive according to the clipping mask of the vertex, so that the clipping mask of the primitive indicates the positional relationship between the primitive and the clipping plane, and further indicates the clipping method of the primitive. The clipping mask generating unit may output the clipping mask of the primitive to the clipping resolution unit.

[0190] The cropping resolution unit also receives primitive information. According to the primitive's cropping mask and primitive information, the cropping resolution unit can determine whether to crop the primitive, and when determining to crop the primitive, further determine which cropping plane to use for this cropping. The cropping resolution unit can output information about the cropping plane used when cropping the primitive to the cropping execution unit.

[0191] The clipping execution unit also receives vertex coordinates and primitive information, and can clip the primitive according to the information of the clipping surface used when clipping the primitive, remove invalid vertex coordinates and primitive information during clipping, and generate new vertex coordinates. The clipping execution unit can output the new vertex coordinates to the clipping mask generation unit. After receiving the new vertex coordinates, the clipping mask generation unit can generate a new vertex clipping mask for the new vertex coordinates, and update the clipping mask of the primitive according to the new vertex clipping mask.

[0192] The cropping resolution unit continues to determine whether to crop the primitive based on the updated primitive cropping mask. When determining to crop the primitive, it repeats the above process with the cropping execution unit until the cropping resolution unit determines that the cropping unit is not needed based on the cropping mask. In this case, the cropping execution unit can be driven to output the cropping result of the primitive to the vertex buffer (not shown) of the next stage.

[0193] The present disclosure also proposes a primitive clipping device, Figure 8 A schematic diagram showing the structure of a primitive clipping device according to an embodiment of the present disclosure.

[0194] like Figure 8 As shown, in a possible implementation, the device includes:

[0195] A first determining module 81 is used to determine configuration information of a cropping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the cropping protection band, the size of the rendering target includes the size of the rendering target in one or more cropping directions of a rendering target space, and the configuration information includes configuration information of the cropping protection band in each cropping direction;

[0196] A first generating module 82, configured to generate a clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive;

[0197] The first clipping module 83 is used to clip the primitive according to the clipping method indicated by the clipping mask of the primitive when the clipping mask of the primitive indicates clipping the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.

[0198] The first determination module, the first generation module, and the first cropping module can be either hardware modules or software modules. When used as hardware modules, the first determination module is equivalent to the configuration information generation unit described above, the first generation module is equivalent to the cropping mask generation unit described above, and the first cropping module is equivalent to the cropping resolution unit and the cropping execution unit described above.

[0199] In a possible implementation, the configuration information of the cropping protection band in any cropping direction includes scale information and offset information, wherein the scale information represents a ratio of a first difference to a size of the rendering target in the cropping direction, and the first difference is equal to a difference between an actual size of the cropping protection band in the cropping direction and a size of the rendering target in the cropping direction; and the offset information represents a difference between a minimum coordinate of the rendering target in the cropping direction and a minimum coordinate of the rendering target space in the cropping direction.

[0200] In a possible implementation, the determining of the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage includes: for any cropping direction corresponding to the size of the rendering target, determining the maximum size and maximum coordinate of the rendering target space in the cropping direction according to the preset data precision of the rasterization stage; determining the scale information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction and the maximum size and maximum coordinate of the rendering target space in the cropping direction; determining the offset information of the cropping protection band in the cropping direction according to the size of the rendering target in the cropping direction, the scale information and the maximum size and maximum coordinate of the rendering target space in the cropping direction, so that the actual size of the cropping protection band in the cropping direction is smaller than the maximum size of the rendering target space in the cropping direction, the minimum coordinate of the cropping protection band in the cropping direction is greater than 0, and the maximum coordinate of the cropping protection band in the cropping direction is smaller than the maximum coordinate of the rendering target space in the cropping direction.

[0201] In a possible implementation, when the size of the rendering target corresponds to a cropping direction, the size of the rendering target in the cropping direction is greater than or equal to the size in other cropping directions; the configuration information of the cropping protection band in the cropping direction also serves as the configuration information of the cropping protection band in other cropping directions.

[0202] In a possible implementation, for any cropping direction corresponding to the size of the rendering target, the minimum coordinate of the cropping protection band in the cropping direction is bm×R / 2, and the maximum coordinate is b+(Rm×R / 2), wherein R represents the size of the rendering target in the cropping direction, and R is a positive integer; m represents the scale information of the cropping protection band in the cropping direction, and m is a positive number; b represents the offset information of the cropping protection band in the cropping direction, and b is a positive number.

[0203] In a possible implementation, when there are multiple numerical combinations available for the scale information and offset information of the cropping protection band in any cropping direction, a numerical combination is selected that makes the actual size of the cropping protection band in the cropping direction closest to the maximum size of the rendering target space in the cropping direction.

[0204] In a possible implementation, the generating of the clipping mask of the primitive based on the vertex coordinates of the primitive and the configuration information includes: determining the coordinates of the clipping surface of the clipping protection band in each clipping direction based on the configuration information of the clipping protection band; determining the positional relationship between the primitive and each clipping surface based on the vertex coordinates of the primitive and the coordinates of each clipping surface; and generating the clipping mask of the primitive based on the positional relationship.

[0205] In one possible implementation, when the primitive intersects with at least one clipping plane and intersects with the rendering target, the clipping mask of the primitive indicates that the primitive is to be clipped, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane or does not intersect with the rendering target, the clipping mask of the primitive indicates that the primitive is not to be clipped.

[0206] In one possible implementation, when a primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane that intersects with the primitive; when the primitive does not intersect with each clipping plane, the clipping mask of the primitive indicates not clipping the primitive.

[0207] In a possible implementation, when the clipping mask of the primitive indicates clipping of the primitive, clipping the primitive according to the clipping method indicated by the clipping mask of the primitive includes: when the clipping mask of the primitive indicates clipping of the primitive, selecting any one clipping surface from the clipping surfaces intersecting with the primitive; clipping the primitive using the selected clipping surface; the device also includes: an updating module, used to update the clipping mask of the primitive according to the vertex coordinates of new vertices obtained by clipping.

[0208] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0209] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.

[0210] An embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0211] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0212] Fig. 9 1 is a block diagram of an electronic device 1900 according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal device. Fig. 9 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0213] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.

[0214] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.

[0215] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0216] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0217] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0218] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0219] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0220] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0221] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0222] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0223] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A primitive clipping method, characterized in that: The method comprises: Determining configuration information of a clipping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the clipping protection band, the size of the rendering target including a size of the rendering target in one or more clipping directions of a rendering target space, and the configuration information including configuration information of the clipping protection band in each clipping direction; Generate a clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive; When the clipping mask of the primitive indicates clipping of the primitive, the primitive is clipped according to the clipping method indicated by the clipping mask of the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.

2. The method according to claim 1, characterized in that The configuration information of the cutting protection band in any cutting direction includes ratio information and offset information, wherein: The ratio information represents a ratio of a first difference value to a size of the rendering target in the cropping direction, wherein the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and a size of the rendering target in the cropping direction; The offset information indicates a difference between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of the rendering target space in the clipping direction.

3. The method according to claim 2, characterized in that The step of determining the configuration information of the cropping protection band according to the size of the rendering target and the preset data precision of the rasterization stage includes: For any clipping direction corresponding to the size of the render target, According to the preset data precision of the rasterization stage, the maximum size and maximum coordinates of the rendering target space in the clipping direction are determined; According to the size of the rendering target in the clipping direction and the maximum size and maximum coordinates of the rendering target space in the clipping direction, the scale information of the clipping protection band in the clipping direction is determined; according to the size of the rendering target in the clipping direction, the scale information and the maximum size and maximum coordinates of the rendering target space in the clipping direction, the offset information of the clipping protection band in the clipping direction is determined, so that the actual size of the clipping protection band in the clipping direction is smaller than the maximum size of the rendering target space in the clipping direction, the minimum coordinate of the clipping protection band in the clipping direction is greater than 0, and the maximum coordinate of the clipping protection band in the clipping direction is smaller than the maximum coordinate of the rendering target space in the clipping direction.

4. The method according to claim 2, characterized in that: When the size of the rendering target corresponds to a clipping direction, the size of the rendering target in the clipping direction is greater than or equal to the size in other clipping directions; The configuration information of the cutting protection band in the cutting direction also serves as the configuration information of the cutting protection band in other cutting directions.

5. The method according to claim 3 or 4, characterized in that: For any clipping direction corresponding to the size of the rendering target, the minimum coordinate of the clipping protection band in the clipping direction is bm×R / 2, and the maximum coordinate is b+(R+m×R / 2), where: R represents the size of the rendering target in the clipping direction, and R is a positive integer; m represents the ratio information of the cutting protection band in the cutting direction, and m is a positive number; b represents the offset information of the cutting protection band in the cutting direction, and b is a positive number.

6. The method according to claim 3 or 4, characterized in that: When there are multiple numerical combinations available for the proportion information and offset information of the cropping protection band in any cropping direction, a numerical combination that makes the actual size of the cropping protection band in the cropping direction closest to the maximum size of the rendering target space in the cropping direction is selected.

7. The method according to claim 1, characterized in that The step of generating a clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information includes: Determining the coordinates of the cutting surface of the cutting protection band in each cutting direction according to the configuration information of the cutting protection band; Determine the positional relationship between the graphic primitive and each clipping surface according to the vertex coordinates of the graphic primitive and the coordinates of each clipping surface; A clipping mask of the primitive is generated according to the positional relationship.

8. The method according to claim 7, characterized in that When the primitive intersects with at least one clipping plane and intersects with the rendering target, the clipping mask of the primitive indicates clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane intersecting with the primitive; When the primitive does not intersect any clipping plane or does not intersect the rendering target, the clipping mask of the primitive indicates that the primitive is not clipped.

9. The method according to claim 7, characterized in that: When the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane intersecting with the primitive; When the primitive and each clipping plane do not intersect, the clipping mask of the primitive indicates that the primitive is not clipped.

10. The method according to claim 1, characterized in that When the clipping mask of the primitive indicates clipping the primitive, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive includes: When the clipping mask of the primitive indicates clipping the primitive, selecting any one clipping plane from clipping planes intersecting with the primitive; Clipping the primitive using the selected clipping plane; The method further includes: updating the clipping mask of the primitive according to the vertex coordinates of the new vertex obtained by clipping.

11. A primitive cutting device, characterized in that: The device comprises: A first determining module is used to determine configuration information of a cropping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the cropping protection band, the size of the rendering target includes a size of the rendering target in one or more cropping directions of a rendering target space, and the configuration information includes configuration information of the cropping protection band in each cropping direction; A first generating module, configured to generate a clipping mask of the primitive according to vertex coordinates of the primitive and the configuration information, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive further indicates a clipping method of the primitive; The first clipping module is used to clip the primitive according to the clipping method indicated by the clipping mask of the primitive when the clipping mask of the primitive indicates clipping the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.

12. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 10 when executing the instructions stored in the memory.

13. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Clipping of graphics primitives

    CN104933749A

  • Graph processing method and device, equipment and medium

    CN116601662A

  • Rendering marking method and device in GPU (Graphics Processing Unit) graphic rendering and electronic equipment

    CN117830485A

  • Cutting method and device, equipment, storage medium and program product

    CN118823277A

  • Block-based fragment filtration with feasible multi-GPU acceleration for real-time volume rendering on conventional personal computer

    US20050231503A1