Method, device, electronic device and storage medium for primitive clipping
By adaptively determining the configuration information of the crop protection belt and generating the crop mask, the problem of inflexible configuration of the crop protection belt is solved, and the cropping performance and rendering efficiency of the GPU are improved.
Patent Information
- Application Number
- CN202411341389.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2044-09-24
AI Technical Summary
In the prior art, the configuration of the crop protection belt is not flexible enough, resulting in room for improvement in the crop performance of the GPU, and the cropping time is long, which increases the number of cropping elements.
According to the size of the rendering target and the preset data accuracy of the rasterization stage, the configuration information of the crop protection belt is adaptively determined, and a crop mask is generated to indicate whether and how to crop the primitive vertex coordinate accuracy to ensure that the cropped primitive vertex coordinate accuracy meets the preset data accuracy.
It improves the configuration flexibility of the crop protection belt, reduces the number of cropping times and time-consuming, improves the rendering efficiency of the GPU, and ensures the normal progress of the rasterization function.
Smart Images

Figure CN119251355B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of graphics data processing, and in particular to a method, device, electronic device, and storage medium for clipping graphics primitives. 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, each performing a specific task to ultimately produce the final image. Rasterization is a key stage in the GPU pipeline. Before rasterization, the GPU typically clips primitives to ensure that only those within the viewing 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 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 light of this, the present disclosure proposes a primitive clipping method, apparatus, electronic device, and storage medium. This method adaptively determines the configuration information of the clipping guard band based on the size of the render target and the preset data accuracy of the rasterization stage. This allows for flexible configuration of the clipping guard band when the render target size changes, improving GPU performance without affecting the initial 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 based on 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, and the configuration information comprising configuration information of the clipping protection band in each clipping direction; generating a clipping mask of the primitive based on 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 further 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 one 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 value to a size of the rendering target in the cropping direction, and the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and the 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, determining configuration information of the cropping protection band based on the size of the rendering target and preset data precision of the rasterization stage includes: determining, for any cropping direction corresponding to the size of the rendering target, the maximum size and maximum coordinates of the rendering target space in the cropping direction based on the preset data precision of the rasterization stage; determining scale information of the cropping protection band in the cropping direction based on 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; determining offset information of the cropping protection band in the cropping direction based on the size of the rendering target in the cropping direction, the scale information, and the maximum size and maximum coordinates 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 one 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 one 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 R represents the size of the rendering target in the clipping direction, and R is a positive integer; m represents the scale information of the clipping protection band in the clipping direction, and m is a positive number; b represents the offset information of the clipping protection band in the clipping direction, and b is a positive number.
[0011] In one 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 one 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 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 clipped.
[0014] In one possible implementation, when the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates that the primitive is 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, the clipping mask of the primitive indicates that the primitive is not clipped.
[0015] In one possible implementation, 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, including: when the clipping mask of the primitive indicates clipping of the primitive, any one clipping surface is selected from the clipping surfaces intersecting with the primitive; clipping the primitive using the selected clipping surface; the method also includes: updating the clipping mask of the primitive according to the vertex coordinates of the new vertex 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 based on 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 based on the 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 one 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 value to a size of the rendering target in the cropping direction, and the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and the 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, determining configuration information of the cropping protection band based on the size of the rendering target and preset data precision of the rasterization stage includes: determining, for any cropping direction corresponding to the size of the rendering target, the maximum size and maximum coordinates of the rendering target space in the cropping direction based on the preset data precision of the rasterization stage; determining scale information of the cropping protection band in the cropping direction based on 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; determining offset information of the cropping protection band in the cropping direction based on the size of the rendering target in the cropping direction, the scale information, and the maximum size and maximum coordinates 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 one 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 one 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 R represents the size of the rendering target in the clipping direction, and R is a positive integer; m represents the scale information of the clipping protection band in the clipping direction, and m is a positive number; b represents the offset information of the clipping protection band in the clipping direction, and b is a positive number.
[0021] In one 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 one 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 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 clipped.
[0024] In one possible implementation, when the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates that the primitive is 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, the clipping mask of the primitive indicates that the primitive is not clipped.
[0025] 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 surface from the clipping surfaces intersecting with the primitive; clipping the primitive using the selected clipping surface; the device also includes: an updating module for updating the clipping mask of the primitive according to the vertex coordinates of the new vertex 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, the configuration information of the clipping protection zone can be adaptively determined according to the size of the rendering target and the preset data accuracy of the rasterization stage, 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, the clipping mask of the primitive is generated, and the clipping mask of the primitive indicates whether the primitive is clipped. When the clipping mask of the primitive indicates clipping 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 number of 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 FIG. 4 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 illustrating a configuration information generating unit outputting configuration information to a cropping 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] Figure 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 indicated.
[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, numerous specific details are provided in the following detailed description to better illustrate the present disclosure. Those skilled in the art will appreciate that the present disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art are not described in detail in order to highlight the main points 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 sequence, each performing a specific task to ultimately produce the final image. A 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. It receives vertex data input, such as vertex coordinates, colors, and texture coordinates, and performs 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 and normal transformation, 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 Shader stage is an optional stage that does not require GPU support. In this stage, the GPU performs geometry-related operations on primitives, such as geometric transformations, normal calculations, and clipping, and outputs the processed primitive data.
[0048] 4. Rasterization stage: In the rasterization stage, primitive data is 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 it is blended 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 the primitives to ensure that only the triangles that are partially 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 (NDC).
[0056] 4. Viewport transformation: After the projection transformation, the vertices of the primitives are mapped to the rendering target space, thereby determining the position of the vertices of the primitives on the screen.
[0057] 5. Primitive setup: The GPU determines the pixels to be rasterized based on the projected vertex coordinates and the position of the pixels relative to the primitives.
[0058] 6. Scan conversion: During the rasterization phase, 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 primitive to determine the final attribute value of each pixel. This ensures a smooth transition of the rendering results within the primitive.
[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] During the primitive clipping step, when clipping primitives, we want to keep the primitives that are entirely within the render target, as well as the portion of the primitives that intersect the render target that is within the render target. If we clip primitives directly based on the render target, all primitives that intersect the render 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 cropping guardband can be used and set on the periphery of the rendering target. When cropping primitives, only primitives that intersect with the cropping guardband are cropped. In this case, for any primitive that intersects with the rendering target but does not intersect with the cropping guardband, it needs to be cropped when the cropping guardband is not used, but it does not need to be cropped when the cropping 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 cropping guardband can be expressed with the precision required by the Application Programming Interface (API) and the hardware, so not cropping the primitives within the cropping guardband will not have any impact on the accuracy of the rendering results.
[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 number of cutting times is shown.
[0064] like Figure 1 As shown, the size of cropping guard band 2 is smaller than that of cropping guard band 1. When cropping guard band 2 is used, primitives 1, 2, 3, and 4 all intersect with cropping guard band 2, so primitives 1, 2, 3, and 4 need to be cropped. However, when cropping guard band 1 is used, only primitives 2 and 4 intersect with cropping guard band 1, so only primitives 2 and 4 need to be cropped. This shows that compared to a smaller cropping guard band, a larger guard band can further reduce the number of cropped primitives.
[0065] However, the clipping protection band cannot be set to infinite size. 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] Conventional solutions typically manually configure a clipping guardband, ensuring that the render target is within the guardband and that the vertex coordinate precision of primitives clipped within the guardband is less than or equal to a preset data precision. However, if the render target size changes, the guardband configuration must be manually adjusted, making it inflexible.
[0067] In light of this, the present disclosure proposes a primitive clipping method, apparatus, electronic device, and storage medium. This method adaptively determines the configuration information of the clipping guard band based on the size of the render target and the preset data accuracy of the rasterization stage. This allows for flexible configuration of the clipping guard band when the render target size changes, improving GPU performance without affecting the initial rasterization function.
[0068] Furthermore, the configuration information determined by the method can make the size of the cropping protection zone larger, resulting in less cropping of primitives, less time-consuming cropping of primitives, and higher rendering efficiency.
[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 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, etc.), 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 put into 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 modules already available 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: Determine configuration information of a clipping guard band based on the size of the render target and a preset data precision of the rasterization stage, so that the render target is located within the clipping guard band. The size of the render target includes the size of the render target in one or more clipping directions of the render target space, and the configuration information includes configuration information of the clipping guard band in each clipping direction.
[0074] Step 32: Generate a clipping mask for the primitive based on the vertex coordinates and configuration information of the primitive. The clipping mask for the primitive indicates whether to clip the primitive. When the clipping mask for the primitive indicates to clip the primitive, the clipping mask for the primitive also indicates a clipping method for the primitive.
[0075] Step 33 : When the clipping mask of the primitive indicates clipping of the primitive, clip 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 used to draw textures, typically in a rectangular shape. A render target space refers to a coordinate space that can express the actual size of a render target. The render target space may include a first clipping direction X and a second clipping direction Y, with the first clipping direction and the second clipping direction being perpendicular. The dimension W of the render target in the first clipping direction X may represent the width of the render target. The dimension 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 a render target may include the size of the render target in one or more clipping directions of the render target space, i.e., at least one of X and Y.
[0077] The preset data precision of the rasterization stage can be, for example, a fixed-point number in 16.8 format. In this case, the maximum coordinate that can be expressed in the render target space in each clipping direction is 64k (the maximum expression range of a 16-bit integer). Those skilled in the art will appreciate that the preset data precision of the rasterization stage can also be a fixed-point number in 18.8 format. In this case, the maximum coordinate that can be expressed in the render target space in each clipping direction is 256k (the maximum expression range of an 18-bit integer). The presently disclosed embodiments do 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 based on the size of the rendering target and the preset data accuracy of the rasterization stage. 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 execution method of step S31, and an exemplary execution method is given later.
[0079] The render target space can include multiple primitives. As mentioned above, not all primitives must be clipped. Therefore, it is possible to determine whether each primitive requires clipping and only perform clipping on those primitives that require clipping. This determination can be performed sequentially or concurrently for multiple primitives, and this is not a limitation in this disclosure. For clarity, the following example uses the sequential determination of whether multiple primitives require clipping as an example.
[0080] Exemplarily, for any primitive, step S32 may be executed first, and based on the vertex coordinates and configuration information of the primitive, it may be determined whether the primitive needs to be cropped, and a cropping mask for the primitive may be generated. The present disclosure does not limit the specific execution method of step S32, and an exemplary execution 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 to crop 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, thereby further reducing 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 the determination of whether the next primitive needs to be clipped is continued, that is, step S32 is re-executed for the next primitive.
[0082] When the clipping mask of the current primitive indicates clipping the primitive, the clipping step of the current primitive can be continued, that is, step S33 is executed, and the primitive is clipped 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, the configuration information of the clipping protection zone can be adaptively determined according to the size of the rendering target and the preset data accuracy of the rasterization stage, 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, the clipping mask of the primitive is generated, and the clipping mask of the primitive indicates whether the primitive is clipped. When the clipping mask of the primitive indicates clipping 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 content 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 represents a ratio of the first difference value to the size of the rendering target in the cropping direction, where the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and the size of the rendering target in the cropping direction;
[0087] The offset information represents 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] The following takes the first cutting direction X as an example to introduce the configuration information of the cutting protection tape in the first cutting direction X.
[0089] Figure 4 FIG. 4 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] Configuration information of the cropping protection band in the first cropping direction X includes scale information Kx and offset information Bx. 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 this disclosure. In this case, 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 scale information Kx may indicate the proportional relationship between the two. That is, the scale 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, where 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 render target in the render target space is not fixed; it may be at the center of the render target space, to the left, or to the right of the center. In the configuration information for the clipping guard band in the first clipping direction X, the offset information Bx may indicate the position of the render target relative to the render target space in the first clipping direction X. For example, the offset information Bx may represent the difference between the minimum coordinate x2 of the render target in the first clipping direction X and the minimum coordinate 0 of the render 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, the minimum coordinate of the rendering target in the rendering target space in the second clipping direction Y can be determined to be 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, the minimum coordinate of the clipping guard band in the rendering target space in the second clipping direction Y can be determined to be By-Ky×H / 2, and the maximum coordinate is By+(H+Ky×H / 2).
[0097] That is, in one possible implementation, for any clipping direction corresponding to the size of the rendering target, the minimum coordinate of the clipping guard 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 proportion 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 into 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 one possible implementation, determining 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 (step S31) includes:
[0105] For any clipping direction corresponding to the size of the render target,
[0106] Determine the maximum size and maximum coordinates of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage;
[0107] 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 and scale information 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 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.
[0108] For example, when determining the configuration information, you can use only the size of the render target in one cropping direction, or you can use the sizes of the render target in multiple cropping directions. If you use the sizes of the render target in multiple cropping directions, you need to determine the configuration information of the cropping guard band in each cropping direction separately. In this case, the configuration information of the cropping guard 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 based on the preset data precision of the rasterization stage.
[0110] The minimum coordinates of the render target space in different clipping directions can be the same and equal to 0. The maximum coordinates of the render target space in different clipping directions can be the same or different, as long as the precision of the maximum coordinates of the render target space in each clipping direction is less than or equal to the preset data precision.
[0111] For example, using a fixed-point number in 16.8-bit format during the rasterization phase, the maximum coordinate that can be expressed in the render target space in each clipping direction is 64k (the maximum range of a 16-bit integer). The minimum coordinates of the render target space in different clipping directions can be the same and equal to 0. Therefore, when the render target space is at its maximum size, the maximum size and maximum coordinates of the render target space in different clipping directions are equal and equal to 64k.
[0112] For example, users can also reduce the size of the render target space based on application scenario requirements. The maximum size and maximum coordinates of the render target space in different clipping directions can be different. This is sufficient as long as the precision of the maximum coordinates of the render target space in each clipping direction is less than or equal to the preset data precision. This disclosure does not limit the specific method for determining the maximum size and maximum coordinates of the render target space in each clipping direction.
[0113] The entire clipping guard is located within the render target space. That is, in any clipping direction, the coordinates of the clipping guard must meet the following conditions: the actual size of the clipping guard in that clipping direction is smaller than the maximum size of the render target space in that clipping direction; the minimum coordinate of the clipping guard in that clipping direction is greater than 0; the maximum coordinate of the clipping guard in that clipping direction is smaller than the maximum coordinate of the render target space in that clipping 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 meets 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 meets 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 will appreciate that the rendering target space may have more clipping directions. The embodiments of the present disclosure do not limit the specific number of clipping directions in 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 is also used 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, then the method for determining the configuration information of the cropping protection band in that 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, then 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, then 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. In this case, the configuration information of the cutting protection band in different cutting directions is the same, that is, Kx=ky, Bx=By.
[0135] To ensure that the cropping guard band in each cropping direction satisfies the following conditions: its actual size is smaller than the maximum size of the render target space in that cropping direction, its minimum coordinate is greater than 0, and its maximum coordinate is smaller than the maximum coordinate of the render target space in that cropping direction, when only the size of the render target in one cropping direction is used to determine the cropping guard band configuration information, the cropping direction with the larger size of the render target can be selected. That is, when the size of the render target corresponds to a cropping direction, the size of the render target in that cropping direction is greater than or equal to the size in the other cropping directions. For example, if the size of the render target in the first cropping direction X is larger than the size in the second cropping direction Y, the size of the render target in the first cropping direction X can be used to determine the cropping guard band configuration information. If the size of the render target in the first cropping direction X is smaller than the size in the second cropping direction Y, the size of the render target in the second cropping direction Y can be used to determine the cropping guard band configuration information. If the size of the render target in the first cropping direction X is equal to the size in the second cropping direction Y, the size of the render target in either the second cropping direction Y or the first cropping direction X can be used to determine the cropping guard band configuration information.
[0136] In this case, the method of determining the configuration information of the cropping protection band is simpler.
[0137] An exemplary method for determining specific values of the scale information and the offset information according to the present disclosure is described below.
[0138] In one 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, the 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.
[0139] As described above, since the range of values for the scale information and the offset information can be derived from formulas (1)-(6), any value that fits within the range can be selected. Therefore, in any cutting direction, there may be multiple combinations of values for the scale information and the offset information. Also, as described above, the larger the cutting protection band, the fewer the number of cuts. In this case, in any cutting direction, a combination of values can be selected that makes the actual size of the cutting protection band closest to the maximum size of the cutting protection band, thereby making the actual size of the cutting protection band larger and further reducing the number of cuts.
[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 is equal to 1024 bits). Since the selection of the size of the rendering target is limited, a lookup table for the configuration information of the clipping protection band can be determined in advance. The lookup table can record the correspondence between the size of the rendering target and the scale information and 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 for the configuration information of the clipping protection band when the data precision of the rasterization is 16.8.
[0141] Table 1
[0142] Render target size 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 embodiment of the present disclosure, determining the configuration information of the cropping protection band can be completed by a hardware module or by 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] 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;
[0148] Determine 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;
[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 strip is shown. The cutting protection strip can have two cutting surfaces in each cutting direction. The minimum coordinate of the cutting protection strip 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 tape may correspond to cutting surface 1 and cutting surface 2 in the first cutting direction X. The coordinates of all points on cutting surface 1 in the first cutting direction X are equal to the minimum coordinates of the cutting protection tape in the first cutting direction X. The coordinates of all points on cutting surface 3 in the first cutting direction X are equal to the maximum coordinates of the cutting protection tape in the first cutting direction X. The cutting protection tape may correspond to cutting surface 3 and cutting surface 4 in the second cutting direction Y. The coordinates of all points on cutting surface 3 in the second cutting direction Y are equal to the minimum coordinates of the cutting protection tape in the second cutting direction Y. The coordinates of all points on cutting surface 4 in the second cutting direction Y are equal to the maximum coordinates of the cutting protection tape 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 surfaces 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 surfaces 1, 2, and 3, but intersects with cutting surface 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 surfaces 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 surfaces 1, 2, and 4, but intersects with cutting surface 3, that is, primitive 4 intersects with the cutting protection band.
[0155] The following describes an exemplary method of the present disclosure for determining whether a graphic element needs to be cropped.
[0156] In one possible implementation, when a primitive intersects at least one clipping plane and intersects 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 the primitive;
[0157] When a primitive does not intersect any clipping plane or the render target, the primitive's clipping mask indicates that the primitive is not clipped.
[0158] For example, in real applications, a culling step might be performed before rendering to remove off-screen primitives that are not visible, thereby improving rendering performance. If a primitive intersects the clipping guard but not the render target, then the primitive is effectively culled, and not clipping it will not affect the rasterization results. In other words, only primitives that intersect at least one clipping plane and the render target are actually clipped.
[0159] Thus, when a primitive intersects at least one clipping plane and intersects a render target, the primitive's clipping mask 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 at least one clipping plane and intersects the rendering target, so only the clipping mask of primitive 4 can indicate that primitive 4 is clipped, and 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 the primitive does not intersect any clipping plane, or the primitive does not intersect the render target, the primitive does not need to be clipped, and the primitive's clipping mask can indicate that the primitive is not clipped. Figure 5 In the example shown in , primitive 1 does not intersect any clipping planes and does not intersect the render target, so the clipping mask for primitive 1 can indicate that primitive 1 is not clipped. Primitive 2 does not intersect the render target, so the clipping mask for primitive 2 can indicate that primitive 2 is not clipped. Primitive 3 does not intersect any clipping planes, so the clipping mask for 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 described below.
[0163] In one possible implementation, when a primitive intersects 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 that intersects 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 to not consider whether the primitive needs to be culled. That is, whether the primitive needs to be clipped is determined 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 render target, it can be determined that the primitive needs to be clipped, and the clipping mask of the primitive can indicate that the primitive should be clipped, 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 intersects with clipping plane 4, and primitive 4 intersects with clipping plane 3. Therefore, 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, primitive 1 and primitive 3 do not intersect any clipping plane, so the clipping mask of primitive 1 can indicate that primitive 1 is not clipped, and the clipping mask of primitive 3 can indicate that primitive 3 is not clipped.
[0168] In this way, it is easier to determine whether the primitive needs to be clipped.
[0169] An example of the clipping primitive disclosed herein is described below.
[0170] In a possible implementation, step S33 includes:
[0171] When the primitive's clipping mask indicates that the primitive is clipped, the primitive is clipped sequentially based on the clipping planes that intersect the primitive, using one clipping plane at a time.
[0172] For example, because the clipping planes that intersect the primitive are already determined when the primitive's clipping mask is generated, the primitive's clipping method can indicate all clipping planes that intersect the primitive. Assume that only one clipping plane can be used to clip the primitive at a time. In this case, when the primitive's clipping mask indicates that the primitive should be clipped, the primitive can be clipped sequentially based on the clipping planes that intersect the primitive, using one clipping plane at a time. Once the last clipping plane has been used, the primitive is clipped.
[0173] In this way, the clipping process of the primitives is made simpler.
[0174] Another example of the clipping primitive disclosed herein is described below.
[0175] In a possible implementation, step S33 includes:
[0176] When the clipping mask of the primitive indicates clipping the primitive, any one 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 includes: updating a clipping mask of the primitive according to vertex coordinates of new vertices obtained by clipping.
[0178] For example, suppose only one clipping plane can be used to clip a primitive at a time. Each clipping change causes the primitive's shape to change, so unused clipping planes may become invalid. For example, if a primitive intersects three clipping planes before clipping, clipping according to the clipping mask determined before clipping would require three clipping passes. After the first clipping pass, it may only intersect one clipping plane, so two clipping passes are actually sufficient to clip the primitive, leaving one clipping plane invalid.
[0179] In this case, if the primitive's clipping mask indicates clipping of the primitive, you can select any one of the clipping planes intersecting the primitive as the clipping plane for this clipping. If there is only one clipping plane intersecting the primitive, you can directly select that clipping plane. If there are multiple clipping planes intersecting the primitive, you can randomly select a clipping plane. The selected clipping plane can then be used to clip the primitive.
[0180] After clipping a primitive, at least one new vertex can be obtained. The clipping mask of the primitive can be updated based on 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 based on the vertex coordinates of the new vertex, the vertex coordinates of the valid old vertex, and the coordinates of each clipping surface, and generate the clipping mask of the primitive based on 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 based on 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 that the primitive is clipped.
[0182] In this way, the number of primitive clipping times can be further reduced.
[0183] The following describes 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 apparatus 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 about the preset data precision for the rasterization stage. The configuration information generation unit may receive the size of the render target and, in step S31, determine the configuration information for the cropping guard band based on the size of the render target and the preset data precision for the rasterization stage, so that the render target is located within the cropping guard band. The configuration information generation unit may obtain the configuration information for the cropping guard band in each cropping direction and output it to the cropping mask generation unit.
[0187] Figure 7 A schematic diagram illustrating a configuration information generating unit outputting configuration information to a cropping 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 in the second cropping direction Y to the cropping mask generating unit respectively.
[0189] The clipping mask generation unit also receives vertex coordinates and executes steps S32 and S33 to generate a clipping mask for the primitive based on the vertex coordinates and configuration information of the primitive. For example, the clipping mask generation unit may first generate a vertex clipping mask for the vertex, where the vertex clipping mask indicates the positional relationship between the vertex and the clipping plane, and then generate a clipping mask for the primitive based on the vertex clipping mask, so that the primitive clipping mask indicates the positional relationship between the primitive and the clipping plane, and further indicates the clipping method of the primitive. The clipping mask generation unit may output the primitive clipping mask to the clipping resolution unit.
[0190] The cropping resolution unit also receives primitive information. Based on the primitive's cropping mask and primitive information, the cropping resolution unit determines whether to crop the primitive and, when deciding to crop the primitive, further determines which cropping plane to use. 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 based on the clipping plane information 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 based on 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 it is determined 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. It can then drive the cropping execution unit to output the cropping result of the primitive to the vertex buffer (not shown) of the subsequent 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 configured to determine configuration information of a clipping guard band based on a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located within the clipping guard band, wherein the size of the rendering target includes the size of the rendering target in one or more clipping directions of a rendering target space, and the configuration information includes configuration information of the clipping guard band in each clipping direction;
[0196] A first generating module 82 is 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 the primitive is to be clipped, and when the clipping mask of the primitive indicates that the primitive is to be clipped, the clipping mask of the primitive further indicates a clipping method of the primitive;
[0197] The first clipping module 83 is configured 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. 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 cropping execution unit described above.
[0199] In one 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 value to a size of the rendering target in the cropping direction, and the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and the 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, determining configuration information of the cropping protection band based on the size of the rendering target and preset data precision of the rasterization stage includes: determining, for any cropping direction corresponding to the size of the rendering target, the maximum size and maximum coordinates of the rendering target space in the cropping direction based on the preset data precision of the rasterization stage; determining scale information of the cropping protection band in the cropping direction based on 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; determining offset information of the cropping protection band in the cropping direction based on the size of the rendering target in the cropping direction, the scale information, and the maximum size and maximum coordinates 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 one 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 one 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+(Rm×R / 2), where R represents the size of the rendering target in the clipping direction, and R is a positive integer; m represents the scale information of the clipping protection band in the clipping direction, and m is a positive number; b represents the offset information of the clipping protection band in the clipping direction, and b is a positive number.
[0203] In one 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 one 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 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 clipped.
[0206] In one possible implementation, when a primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates that the primitive is 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, the clipping mask of the primitive indicates that the primitive is not clipped.
[0207] 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 surface from the clipping surfaces intersecting with the primitive; clipping the primitive using the selected clipping surface; the device also includes: an updating module for updating the clipping mask of the primitive according to the vertex coordinates of the new vertex 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. For the sake of brevity, it will not be repeated here.
[0209] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium may 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] An embodiment of the present disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying 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] Figure 9 FIG1 shows 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. Figure 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 the instructions to perform the above-described method.
[0213] The electronic device 1900 may further 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 that 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, method and / or 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 can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can 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 thereof. More specific examples (a non-exhaustive list) of computer-readable storage media 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 disc 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 thereof. As used herein, a computer-readable storage medium is not to be construed 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 an electrical 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, fiber optic transmission, wireless transmission, 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 to be stored in the computer-readable storage medium in each computing / processing device.
[0218] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent 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++, and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely 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 entirely 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., utilizing 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 personalized by utilizing the state information of the computer-readable program instructions. 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 flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, 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 is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks 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 operational 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 blocks in the flowchart and / or block diagram.
[0222] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and the part of the module, program segment or instruction contains one or more executable instructions for realizing the prescribed logical function. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the prescribed function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0223] While various embodiments of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or technological improvements in the marketplace, or to enable others skilled 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 guard band based on a size of a render target and a preset data precision of a rasterization stage, so that the render target is located within the clipping guard band, wherein the size of the render target includes the size of the render target in one or more clipping directions of a render target space, and the configuration information includes configuration information of the clipping guard band in each clipping direction; generating 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; 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; The rendering target space refers to a coordinate space that can express the actual size of the rendering target, the precision of the maximum coordinate of the rendering target space in each clipping direction is less than or equal to the preset data precision, and the clipping protection zone is entirely located within the rendering target space.
2. The method according to claim 1, characterized in that The configuration information of the cutting protection band in any cutting direction includes scale 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, the first difference value being equal to a difference between an actual size of the cropping protection band in the cropping direction and the size of the rendering target in the cropping direction; The offset information represents a 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.
3. The method according to claim 2, characterized in that The step of determining 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 includes: For any clipping direction corresponding to the size of the render target, Determine the maximum size and maximum coordinates of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage; Determine 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 coordinates of the rendering target space in the cropping direction; determine 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 coordinates 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.
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 guard 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 proportion 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 scale information and offset information of the cropping guard band in any cropping direction, the numerical combination that makes the actual size of the cropping guard 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 Generating a clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information includes: Determining the coordinates of a cutting surface of the cutting protection band in each cutting direction according to the configuration information of the cutting protection band; Determining a 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 at least one clipping plane and intersects the render 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 the primitive; When the primitive does not intersect any clipping plane or does not intersect the render 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 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 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 manner 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 clipping planes intersecting with the primitive; Clipping the primitive using the selected clipping plane; The method further includes: updating a clipping mask of the primitive according to vertex coordinates of new vertices obtained by clipping.
11. A primitive clipping device, characterized in that: The device comprises: a first determining module, configured to determine configuration information of a clipping guard band based on a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located within the clipping guard band, wherein the size of the rendering target includes the size of the rendering target in one or more clipping directions of a rendering target space, and the configuration information includes configuration information of the clipping guard band in each clipping 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 the primitive is to be clipped, and when the clipping mask of the primitive indicates that the primitive is to be clipped, the clipping mask of the primitive further indicates a clipping method of the primitive; A first clipping module is configured 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; The rendering target space refers to a coordinate space that can express the actual size of the rendering target, the precision of the maximum coordinate of the rendering target space in each clipping direction is less than or equal to the preset data precision, and the clipping protection zone is entirely located within the rendering target space.
12. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method according to 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
Cutting method and device, equipment, storage medium and program product
CN118823277A