Movatterモバイル変換


[0]ホーム

URL:


CN119251355A - Method, device, electronic device and storage medium for clipping primitives - Google Patents

Method, device, electronic device and storage medium for clipping primitives
Download PDF

Info

Publication number
CN119251355A
CN119251355ACN202411341389.6ACN202411341389ACN119251355ACN 119251355 ACN119251355 ACN 119251355ACN 202411341389 ACN202411341389 ACN 202411341389ACN 119251355 ACN119251355 ACN 119251355A
Authority
CN
China
Prior art keywords
clipping
primitive
rendering target
size
mask
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202411341389.6A
Other languages
Chinese (zh)
Other versions
CN119251355B (en
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Moore Thread Intelligent Technology Chengdu Co ltd
Original Assignee
Moore Thread Intelligent Technology Chengdu Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Moore Thread Intelligent Technology Chengdu Co ltdfiledCriticalMoore Thread Intelligent Technology Chengdu Co ltd
Priority to CN202411341389.6ApriorityCriticalpatent/CN119251355B/en
Publication of CN119251355ApublicationCriticalpatent/CN119251355A/en
Application grantedgrantedCritical
Publication of CN119251355BpublicationCriticalpatent/CN119251355B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

The disclosure relates to the field of graphic data processing, and provides a primitive clipping method, a device, electronic equipment and a storage medium. Determining configuration information of a clipping protection band according to the size of a rendering target and the preset data precision of a rasterization stage, enabling the rendering target to be located in the clipping protection band, generating a clipping mask of the primitive according to the vertex coordinates and the configuration information of the primitive, clipping the primitive according to a clipping mode indicated by the clipping mask of the primitive, and enabling the precision of the vertex coordinates of the clipped primitive to be smaller than or equal to the preset data precision. According to the method, configuration information of the clipping protection band is determined in a self-adaptive mode according to the size of the rendering target and the preset data precision of the rasterization stage, so that the clipping protection band is configured flexibly when the size of the rendering target changes, and the GPU performance is improved under the condition that the early stage of the rasterization function is not affected.

Description

Primitive clipping method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the field of graphic data processing, and in particular relates to a primitive clipping method, a primitive clipping device, electronic equipment and a storage medium.
Background
A graphics processing unit (Graphics Processing Unit, GPU) pipeline includes a series of processing stages for converting graphics data into pixels that are ultimately displayed on a screen. These stages in turn process the graphics data, each stage performing a specific task, ultimately producing a final image. Rasterization is a critical stage in the GPU pipeline, and prior to the rasterization stage, the GPU typically clips (clips) primitives to ensure that only a portion of the primitives within the view cone are rasterized, thereby improving rendering efficiency.
Clipping is a time consuming operation in the GPU pipeline and a single primitive may be clipped into multiple primitives, resulting in an increased number of primitives after clipping. In order to reduce clipping time consumption and reduce the number of the clipped primitives, clipping protection bands (guardband) can be added around the viewport, and the primitives intersected with the viewport boundary can not be clipped as long as the clipping protection bands are not exceeded.
In the scheme of the prior art, the configuration of the clipping protection belt is not flexible enough, and the clipping performance of the GPU is still provided with a room for improvement.
Disclosure of Invention
In view of this, the disclosure provides a primitive clipping method, a device, an electronic device and a storage medium. According to the method, configuration information of the clipping protection band is determined in a self-adaptive mode according to the size of the rendering target and the preset data precision of the rasterization stage, so that the clipping protection band is configured flexibly when the size of the rendering target changes, and the GPU performance is improved under the condition that the early stage of the rasterization function is not affected.
According to one aspect of the disclosure, a primitive clipping method is provided, the method comprises the steps of determining configuration information of clipping protection bands according to the size of a rendering target and preset data precision of a rasterization stage, enabling the rendering target to be located in the clipping protection bands, enabling the size of the rendering target to comprise the size of the rendering target in one or more clipping directions of a rendering target space, enabling the configuration information to comprise the configuration information of the clipping protection bands in each clipping direction, generating clipping masks of the primitives according to vertex coordinates of the primitives and the configuration information, enabling the clipping masks of the primitives to indicate whether to clip the primitives, enabling the clipping masks of the primitives to also indicate clipping modes of the primitives when the clipping masks of the primitives indicate clipping modes of the primitives, and enabling the vertex coordinates of the primitives after clipping to be less than or equal to the preset data precision when the clipping masks of the primitives indicate clipping modes of the primitives.
In one possible implementation manner, the configuration information of the clipping protection band in any clipping direction includes proportion information and offset information, wherein the proportion information represents a ratio of a first difference value to a size of the rendering target in the clipping direction, the first difference value is equal to a difference value between an actual size of the clipping protection band in the clipping direction and a size of the rendering target in the clipping direction, and the offset information represents a difference value between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of a rendering target space in the clipping direction.
In one possible implementation manner, the configuration information of the clipping protection belt is determined according to the size of the rendering target and the preset data precision of the rasterization stage, and the configuration information comprises determining the maximum size and the maximum coordinate of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage for any clipping direction corresponding to the size of the rendering target, determining the proportion information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, and determining the offset information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction, the proportion information and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, so that the actual size of the clipping protection belt 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 belt in the clipping direction is larger than 0, and the maximum coordinate of the clipping protection belt in the clipping direction is smaller than the maximum coordinate of the target space in the clipping direction.
In one possible implementation manner, when the size of the rendering target corresponds to one clipping direction, the size of the rendering target in the clipping direction is larger than or equal to the size of the rendering target in other clipping directions, and the configuration information of the clipping protection belt in the clipping direction is also used as the configuration information of the clipping protection belt in other clipping directions.
In one possible implementation manner, 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 b-m×r/2, the maximum coordinate is b+ (r+m×r/2), wherein R represents the size of the rendering target in the clipping direction, R is a positive integer, m represents the proportion information of the clipping protection band in the clipping direction, 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.
In one possible implementation, when there are a plurality of numerical combinations of the scale information and the offset information of the clipping protection band in any one clipping direction, a numerical combination is selected such that the actual size of the clipping protection band in the clipping direction is closest to the maximum size of the rendering target space in the clipping direction.
In one possible implementation manner, the generating the clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information comprises determining coordinates of clipping surfaces of the clipping protection belt in each clipping direction according to the configuration information of the clipping protection belt, determining a position relation between the primitive and each clipping surface according to the vertex coordinates of the primitive and the coordinates of each clipping surface, and generating the clipping mask of the primitive according to the position relation.
In one possible implementation, when the primitive intersects at least one clipping plane and intersects the rendering target, the clipping mask of the primitive indicates clipping the primitive, the clipping mode of the primitive includes clipping the primitive using the clipping plane intersecting the primitive, and when the primitive does not intersect each clipping plane or does not intersect the rendering target, the clipping mask of the primitive indicates not clipping the primitive.
In one possible implementation, the clipping mask of the primitive indicates clipping the primitive when the primitive intersects at least one clipping plane, the clipping mode of the primitive includes clipping the primitive using the clipping plane intersecting the primitive, and the clipping mask of the primitive indicates not clipping the primitive when the primitive does not intersect each clipping plane.
In one possible implementation manner, when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive comprises selecting any clipping surface from clipping surfaces intersected with the primitive when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive by using the selected clipping surface, and updating the clipping mask of the primitive according to the vertex coordinates of a new vertex obtained by clipping.
According to another aspect of the disclosure, a primitive clipping device is provided, which comprises a first determining module, a first generating module and a second generating module, wherein the first determining module is used for determining configuration information of a clipping protection band according to the size of a rendering target and the 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 comprises the size of the rendering target in one or more clipping directions of a rendering target space, the configuration information comprises the configuration information of the clipping protection band in each clipping direction, the first generating module is used for generating a clipping mask of a primitive according to the vertex coordinates of the primitive and the configuration information, the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates the clipping mode of the primitive, and the first generating module is used for when the clipping mask of the primitive indicates to clip the primitive, the vertex coordinates of the clipped primitive are smaller than the preset data precision or equal to the preset data precision.
In one possible implementation manner, the configuration information of the clipping protection band in any clipping direction includes proportion information and offset information, wherein the proportion information represents a ratio of a first difference value to a size of the rendering target in the clipping direction, the first difference value is equal to a difference value between an actual size of the clipping protection band in the clipping direction and a size of the rendering target in the clipping direction, and the offset information represents a difference value between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of a rendering target space in the clipping direction.
In one possible implementation manner, the configuration information of the clipping protection belt is determined according to the size of the rendering target and the preset data precision of the rasterization stage, and the configuration information comprises determining the maximum size and the maximum coordinate of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage for any clipping direction corresponding to the size of the rendering target, determining the proportion information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, and determining the offset information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction, the proportion information and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, so that the actual size of the clipping protection belt 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 belt in the clipping direction is larger than 0, and the maximum coordinate of the clipping protection belt in the clipping direction is smaller than the maximum coordinate of the target space in the clipping direction.
In one possible implementation manner, when the size of the rendering target corresponds to one clipping direction, the size of the rendering target in the clipping direction is larger than or equal to the size of the rendering target in other clipping directions, and the configuration information of the clipping protection belt in the clipping direction is also used as the configuration information of the clipping protection belt in other clipping directions.
In one possible implementation manner, 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 b-m×r/2, the maximum coordinate is b+ (r+m×r/2), wherein R represents the size of the rendering target in the clipping direction, R is a positive integer, m represents the proportion information of the clipping protection band in the clipping direction, 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.
In one possible implementation, when there are a plurality of numerical combinations of the scale information and the offset information of the clipping protection band in any one clipping direction, a numerical combination is selected such that the actual size of the clipping protection band in the clipping direction is closest to the maximum size of the rendering target space in the clipping direction.
In one possible implementation manner, the generating the clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information comprises determining coordinates of clipping surfaces of the clipping protection belt in each clipping direction according to the configuration information of the clipping protection belt, determining a position relation between the primitive and each clipping surface according to the vertex coordinates of the primitive and the coordinates of each clipping surface, and generating the clipping mask of the primitive according to the position relation.
In one possible implementation, when the primitive intersects at least one clipping plane and intersects the rendering target, the clipping mask of the primitive indicates clipping the primitive, the clipping mode of the primitive includes clipping the primitive using the clipping plane intersecting the primitive, and when the primitive does not intersect each clipping plane or does not intersect the rendering target, the clipping mask of the primitive indicates not clipping the primitive.
In one possible implementation, the clipping mask of the primitive indicates clipping the primitive when the primitive intersects at least one clipping plane, the clipping mode of the primitive includes clipping the primitive using the clipping plane intersecting the primitive, and the clipping mask of the primitive indicates not clipping the primitive when the primitive does not intersect each clipping plane.
In one possible implementation manner, when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive comprises selecting any clipping surface from clipping surfaces intersected with the primitive when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive by using the selected clipping surface, and updating the clipping mask of the primitive according to the vertex coordinates of a new vertex obtained by clipping.
According to another aspect of the disclosure, there is provided an electronic device comprising a processor, a memory for storing processor-executable instructions, wherein the processor is configured to implement the above-described method when executing the instructions stored in the memory.
According to another aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer program instructions, wherein the computer program instructions, when executed by a processor, implement the above-described method.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer readable code, or a non-transitory computer readable storage medium carrying computer readable code, which when run in a processor of an electronic device, performs the above method.
According to the primitive clipping method, configuration information of clipping protection bands can be determined in a self-adaptive mode according to the size of a rendering target and preset data precision of a rasterization stage, the rendering target is located in the clipping protection bands, configuration flexibility of the clipping protection bands is improved, a clipping mask of the primitive is generated according to vertex coordinates and the configuration information of the primitive, the clipping mask of the primitive indicates whether the primitive is clipped, the clipping mask of the primitive also indicates the clipping mode of the primitive when the clipping mask of the primitive indicates the clipping primitive, whether the primitive is to be clipped or not and how the primitive is to be clipped can be determined according to the clipping mask of the primitive, and when the clipping mask of the primitive indicates the clipping primitive, the clipping mode of the clipping protection bands is clipped according to the clipping mode of the primitive, because the configuration information of the clipping protection bands is determined based on the preset data precision of the rasterization stage, the precision of the vertex coordinates of the primitive after clipping mode according to the clipping mask of the primitive can be smaller than or equal to the preset data precision, and therefore the rasterization function is not influenced. In summary, the primitive clipping method disclosed by the disclosure can adaptively determine configuration information of clipping protection bands according to the size of a rendering target and the preset data precision of a rasterization stage, so that the clipping protection bands are flexibly configured when the size of the rendering target changes, and the performance of the GPU is improved under the earlier stage of not affecting the rasterization function.
Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments, features and aspects of the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 shows the effect of different sizes of cut guard bands on the number of cuts.
Fig. 2 illustrates an exemplary application scenario of a primitive clipping method according to an embodiment of the present disclosure.
Fig. 3 shows a schematic diagram of a flow of a primitive clipping method according to an embodiment of the present disclosure.
Fig. 4 illustrates a positional relationship of clipping guard bands and rendering targets in a first clipping direction X according to an embodiment of the disclosure.
Fig. 5 illustrates an example of a positional relationship of primitives and clipping guard bands according to an embodiment of the present disclosure.
Fig. 6 shows a schematic diagram of the structure of a primitive clipping device according to an embodiment of the present disclosure.
Fig. 7 illustrates a schematic diagram in which a configuration information generating unit outputs configuration information to a clipping mask generating unit according to an embodiment of the present disclosure.
Fig. 8 shows a schematic diagram of the structure of a primitive clipping device according to an embodiment of the present disclosure.
Fig. 9 shows a block diagram of an electronic device 1900 according to an embodiment of the disclosure.
Detailed Description
Various exemplary embodiments, features and aspects of the disclosure will be described in detail below with reference to the drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
In addition, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art have not been described in detail in order not to obscure the present disclosure.
A graphics processing unit (Graphics Processing Unit, GPU) pipeline includes a series of processing stages for converting graphics data into pixels that are ultimately displayed on a screen. These stages in turn process the graphics data, each stage performing a specific task, ultimately producing a final image. A typical GPU pipeline includes the following stages of processing:
1. vertex shading (Vertex loader) phase, the first phase of the GPU pipeline, is used for receiving Vertex data input such as Vertex coordinates, color and texture coordinates, and performing Vertex-level computation and transformation such as model transformation, view transformation and projection transformation. The vertex shading stage may process vertex attributes, such as color interpolation, normal transformation, etc., and output processed vertex data.
2. Primitive assembly (PRIMITIVE ASSEMBLY) stage, at which the GPU assembles the colored vertices into primitives and outputs primitive data. The primitive may be a point, a line segment, or a triangle. The primitive data may include a correspondence of primitives to vertices.
3. Geometry Shader (Geometry Shader) stage the Geometry Shader stage is an optional stage that does not require the GPU to support. At this stage, the GPU performs geometry-dependent operations on the primitives, such as geometric transformations, normal calculations, clipping, etc., and outputs the processed primitive data.
4. A rasterization (Rasterization) stage in which the primitive data is converted into pixels on the screen. This stage determines which pixels are covered by the primitive and generates a Fragment (Fragment) for each pixel.
5. Fragment shading (FRAGMENT SHADER) stage, which is an important stage of the GPU pipeline, takes as input fragments generated by the rasterization stage, calculates the color and other properties of the fragments, such as texture sampling, illumination model, shadow calculation, etc., and outputs pixel colors.
6. Segment-by-segment operation (Per-Fragment Operations) phase in which some operations are performed on each segment, such as depth testing, stencil testing, blending, etc., and the final pixel is output. These operations can affect whether the fragment is ultimately written to the frame buffer and how it is mixed with existing pixels.
7. Frame buffer write (Framebuffer Write) stage-frame buffer write is the last stage of the GPU pipeline to write the final pixels to the frame buffer for display by the display.
Wherein, the rasterization is a key stage in the GPU pipeline, and the rasterization stage mainly comprises the following steps:
1. And assembling the graphics primitives according to the vertex data output by the vertex shader and the graphics primitive data output by the graphics primitive assembling stage (or the geometry shading stage), and establishing the corresponding relation between the graphics primitives and the vertex coordinates.
2. Primitive clipping-prior to starting rasterization, the GPU will typically clip primitives to ensure that only a portion of the triangles within the view cone will be rasterized, thereby improving rendering efficiency.
3. Projective transformation-after clipping, the vertices of the primitives are projectively transformed and mapped to a normalized device space coordinate system (Normalized Device Coordinate, NDC).
4. Viewport transformation-after projective transformation, the vertices of the primitives are mapped to rendering target space, thereby determining the locations of the vertices of the primitives on the screen.
5. The graphic element setting, wherein the GPU determines the pixel to be rasterized according to the projected vertex coordinates and the position of the pixel relative to the graphic element.
6. Scan conversion-in the rasterization phase, the GPU will scan convert each primitive. In this process, the GPU determines the pixel coverage of the primitive on the screen, and the position of each pixel relative to the primitive.
7. Pixel interpolation-during rasterization, the GPU will also interpolate vertex attributes (e.g., color, texture coordinates, etc.) on the primitives to determine the final attribute value for each pixel. This ensures a smooth transition of the rendering results inside the primitives.
8. Fragment generation-after scan conversion, the GPU generates pixel fragments that cover the primitives. Each segment contains the pixel's location, color, depth value, and possibly other attributes.
In the primitive clipping step, when clipping the primitive, it is desirable to keep the primitive wholly located within the rendering target and the part of the primitive located within the rendering target in the primitive intersecting with the rendering target. If the rendering target is directly taken as the basis for clipping the primitives, the primitives intersected with the rendering target are clipped.
Clipping is a time consuming operation in the GPU pipeline and a single primitive may be clipped into multiple primitives, resulting in an increased number of primitives after clipping. To reduce clipping time and reduce the number of primitives after clipping, a clipping guard band (guardband) may be used and placed around the rendering target, where only primitives that intersect the clipping guard band are clipped. In this case, for any one of the primitives intersecting the rendering target but not intersecting the clipping guard band, clipping is required when the clipping guard band is not used, but not when the clipping guard band is used, so that the clipping times and clipping time are reduced, and the rendering efficiency is improved. The primitives within the clipping guard band can be expressed with the precision required by the application programming interface (Application Programming Interface, API) and hardware, so that the primitives within the clipping guard band are not clipped and have no effect on the precision of the rendering results.
The number of cuts is related to the size of the cut guard band. Fig. 1 shows the effect of different sizes of cut guard bands on the number of cuts.
As shown in fig. 1, the size of the clipping guard band 2 is smaller than that of the clipping guard band 1, and when the clipping guard band 2 is used, all of the primitives 1, 2,3, and 4 intersect with the clipping guard band 2, so that all of the primitives 1, 2,3, and 4 need clipping. When the clipping guard band 1 is used, only the primitives 2, 4 intersect the clipping guard band 1, so that only the primitives 2, 4 need be clipped. It follows that a guard band of larger size can further reduce the number of primitives that are clipped compared to a smaller size clipping guard band.
However, clipping the guard band is not unlimited, because the vertex coordinates of the clipped primitive need to be used in the rasterization stage, and the data precision supported in the rasterization stage is preset, if the clipping guard band is oversized, the precision of the vertex coordinates of the clipped primitive may be greater than the preset data precision, and the data precision of the rasterization stage needs to be additionally modified to make rasterization normally performed, thereby increasing the complexity of the GPU.
In the prior art solutions, clipping protection bands are typically manually configured such that a rendering target is located in the clipping protection band, and vertex coordinate accuracy of primitives clipped based on the clipping protection band is less than or equal to a preset data accuracy. However, if the size of the rendering target is changed, it is necessary to manually adjust configuration information of the cut guard band, and the configuration of the cut guard band is not flexible enough.
In view of this, the disclosure provides a primitive clipping method, a device, an electronic device and a storage medium. According to the method, configuration information of the clipping protection band is determined in a self-adaptive mode according to the size of the rendering target and the preset data precision of the rasterization stage, so that the clipping protection band is configured flexibly when the size of the rendering target changes, and the GPU performance is improved under the condition that the early stage of the rasterization function is not affected.
Further, the configuration information determined by the method can enable the size of the clipping protection band to be larger, so that the clipping of the graphic primitive is fewer, the clipping time consumption of the graphic primitive is smaller, and the rendering efficiency is higher.
Fig. 2 illustrates an exemplary application scenario of a primitive clipping method according to an embodiment of the present disclosure.
As shown in fig. 2, the primitive clipping method of the present disclosure may be applied to a primitive clipping device in a GPU and used to complete clipping of primitives. The primitive clipping device can store the information of the preset data precision of the rasterization stage, and after receiving the size of the rendering target, the primitive clipping device can firstly determine the configuration information of clipping the protection belt according to the size of the rendering target and the preset data precision of the rasterization stage. The primitive clipping device can also receive the vertex coordinates of the primitives and primitive information (such as textures of the primitives, etc.), determine whether the primitives need clipping according to the configuration information of clipping protection bands and the vertex coordinates of the primitives, clip the primitives needing clipping by using the clipping protection bands, and remove invalid primitive information. The primitive clipping result can be put into a vertex buffer area for other functional modules of the later stage, such as a triangle parameter setting module, a depth and gradient setting module and the like. The triangle parameter setting module and the depth and gradient setting module are all existing modules in the prior art, and the functions of the triangle parameter setting module and the depth and gradient setting module are not repeated here.
Fig. 3 shows a schematic diagram of a flow of a primitive clipping method according to an embodiment of the present disclosure.
As shown in fig. 3, in one possible implementation, the present disclosure proposes a primitive clipping method, which includes:
Step 31, determining configuration information of the clipping guard band according to the size of the rendering target and the preset data precision of the rasterization stage, so that the rendering target is positioned in the clipping guard band, the size of the rendering target comprises the size of the rendering target in one or more clipping directions of the rendering target space, and the configuration information comprises the configuration information of the clipping guard band in each clipping direction;
Step 32, generating a clipping mask of the primitive according to the vertex coordinates and configuration information of the primitive, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates the clipping mode of the primitive;
And step 33, when the clipping mask of the primitive indicates to clip the primitive, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive, wherein the precision of the vertex coordinates of the clipped primitive is smaller than or equal to the preset data precision.
For example, a render target refers to a buffer for drawing textures, typically rectangular in shape. The rendering target space refers to a coordinate space that may express a real size of a rendering target, and may include a first clipping direction X and a second clipping direction Y, which are perpendicular. The dimension W of the rendering object in the first clipping direction X may represent the width of the rendering object. The dimension H of Y in the second clipping direction may represent the height of the rendering target. X and Y may be positive integers. The size of the render target may include the size of the render target in one or more clipping directions of the render target space, i.e., including at least one of X and Y.
The preset data precision of the rasterization stage may be, for example, a fixed point number in 16.8 format, where the maximum coordinate in which the rendering target space can be expressed in each clipping direction is 64k (the maximum expression range of 16-bit integer). It will be appreciated by those skilled in the art that the preset data precision of the rasterization stage may also be a fixed point number in 18.8 format, where the maximum coordinate that the rendering target space can express in each clipping direction is 256k (the maximum expression range of an 18-bit integer). The embodiments of the present disclosure do not limit the preset data precision of the rasterization stage.
After determining the size of the rendering object and the preset data precision of the rasterization stage, step S31 may be executed to determine configuration information of the clipping guard band according to the size of the rendering object and the preset data precision of the rasterization stage. The configuration information of the clipping protection band may include configuration information of the clipping protection band in each clipping direction, and the configuration information of the clipping protection band in different clipping directions may be the same or different. The configuration information of the clipping guard band may indicate a position and a shape of the clipping guard band in a rendering target space, and the rendering target may be located in the clipping guard band. Examples of configuration information of the cut guard band are given later. The present disclosure is not limited to the specific implementation of step S31, and exemplary implementations are given below.
Multiple primitives may be included in the render target space. As described above, not all primitives need to be cropped. Therefore, whether each primitive needs to be cut or not can be judged, and only the primitive needing to be cut is cut. The method can sequentially judge whether the plurality of primitives need to be cut or not, and can judge whether the plurality of primitives need to be cut or not in parallel, and the method is not limited in this disclosure. For clarity of description, the following takes as an example a determination as to whether or not a plurality of primitives need clipping in turn.
For any primitive, step S32 may be executed first, to determine whether the primitive needs clipping according to the vertex coordinates and configuration information of the primitive, and to generate a clipping mask of the primitive. The present disclosure is not limited to the specific implementation of step S32, and exemplary implementations are given below. The clipping mask of the primitive may indicate whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates the clipping manner of the primitive. Further, judging whether the primitive needs to be cut or not can firstly judge whether the primitive needs to be cut or not, directly determining that the primitive does not need to be cut for the primitive needing to be cut, and further judging whether the primitive needs to be cut or not for the primitive which does not need to be cut. In this way, the number of primitives to be clipped can be reduced to further reduce the number of primitive clipping times.
When the clipping mask of the current primitive indicates that the primitive is not clipped, the clipping step of the current primitive may be skipped, and the determination of whether the next primitive needs clipping is continued, that is, step S32 is re-executed for the next primitive.
When the clipping mask of the current primitive indicates clipping the primitive, the clipping step of the current primitive may be continued, that is, step S33 is performed, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive. The present disclosure is not limited to the specific implementation of step S33, and exemplary implementations are given below. Because the configuration information of the clipping protection belt is determined based on the preset data precision of the rasterization stage, the configuration information is used for determining the position relation between the graphic primitive and the clipping protection belt, and the position relation is used for determining the clipping mask of the graphic primitive, the precision of the vertex coordinates of the graphic primitive can be smaller than or equal to the preset data precision after clipping according to the clipping mode indicated by the clipping mask of the graphic primitive, so that the rasterization function is not influenced.
According to the primitive clipping method, configuration information of clipping protection bands can be determined in a self-adaptive mode according to the size of a rendering target and preset data precision of a rasterization stage, the rendering target is located in the clipping protection bands, configuration flexibility of the clipping protection bands is improved, a clipping mask of the primitive is generated according to vertex coordinates and the configuration information of the primitive, the clipping mask of the primitive indicates whether the primitive is clipped, the clipping mask of the primitive also indicates the clipping mode of the primitive when the clipping mask of the primitive indicates the clipping primitive, whether the primitive is to be clipped or not and how the primitive is to be clipped can be determined according to the clipping mask of the primitive, and when the clipping mask of the primitive indicates the clipping primitive, the clipping mode of the clipping protection bands is clipped according to the clipping mode of the primitive, because the configuration information of the clipping protection bands is determined based on the preset data precision of the rasterization stage, the precision of the vertex coordinates of the primitive after clipping mode according to the clipping mask of the primitive can be smaller than or equal to the preset data precision, and therefore the rasterization function is not influenced. In summary, the primitive clipping method disclosed by the disclosure can adaptively determine configuration information of clipping protection bands according to the size of a rendering target and the preset data precision of a rasterization stage, so that the clipping protection bands are flexibly configured when the size of the rendering target changes, and the performance of the GPU is improved under the earlier stage of not affecting the rasterization function.
Exemplary contents included in the configuration information of the cut guard band are described below.
In one possible implementation, the configuration information of the clip guard band in any one of the clip directions 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 clipping direction, the first difference value being equal to a difference value between an actual size of the clipping protection band in the clipping direction and a size of the rendering target in the clipping direction;
The offset information indicates a difference between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of the rendering target space in the clipping direction.
Taking the first cutting direction X as an example, the contents included in the configuration information of the cutting protection tape in the first cutting direction X will be described.
Fig. 4 illustrates a positional relationship of clipping guard bands and rendering targets in a first clipping direction X according to an embodiment of the disclosure.
As shown in fig. 4, 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 larger than the minimum coordinate X1 of the clipping guard band, the maximum coordinate X3 of the rendering target is smaller than the maximum coordinate X4 of the clipping guard band, and the rendering target is located at the center of the clipping guard band, that is, x2—x1=x4—x3. In the first clipping direction X, the minimum coordinate X1 of the clipping guard band is larger than the minimum coordinate of the rendering target space, i.e., X1>0, and the maximum coordinate X4 of the clipping guard band is smaller than the maximum coordinate of the rendering target space, i.e., x4< max_resolution_x.
The configuration information of the cut guard band in the first cutting direction X includes scale information Kx and offset information Bx. The definition of the scale information Kx and the offset information Bx is given below.
In the example of fig. 4, the dimension w=x3-X2 of the rendering target in the first clipping direction X. The actual dimension W 'of the clipping guard band in the first clipping direction X is equal to the difference between the maximum coordinate X4 and the minimum coordinate X1 of the clipping guard band, i.e., W' =x4-X1. The difference (W ' -W) of the actual size W ' of the clipping protection band in the first clipping direction X and the size W of the rendering target in the first clipping direction X, also referred to as the first difference in the first clipping direction X in this disclosure, is W ' -w= (X4-X1) - (X3-X2) =x4-x3+x2-x1=2 (X4-X3) =2 (X2-X1).
In the present disclosure, in the first clipping direction X, the first difference value (W' -W) may be proportional to the size (W) of the rendering target, and the scale information Kx may indicate a proportional relationship of the two. That is, the ratio information Kx of the clipping protection tape in the first clipping direction X represents a ratio of a first difference value (W '-W) to the size W of the rendering target in the first clipping direction X, the first difference value being equal to a difference value of an actual size W' of the clipping protection tape in the first clipping direction X and the size W of the rendering target in the first clipping direction X. In this case, in the first clipping direction X, the actual size W' =kx×w+w of the clipping protection tape.
In any one of the clipping directions, the position of the rendering target in the rendering target space is not fixed, and may be at the center of the rendering target space, and may be left or right of the center. In the configuration information of the clipping guard band in the first clipping direction X, the offset information Bx may indicate a position of the rendering target with respect to the rendering target space in the first clipping direction X, for example, the offset information Bx may represent a difference between a minimum coordinate X2 of the rendering target in the first clipping direction X and a minimum coordinate 0 of the rendering target space in the first clipping direction X. That is, bx=x2-0=x2.
In this case, if the size W of the rendering target in the first clipping direction X and the offset information Bx are known, it is possible to determine that the minimum coordinate of the rendering target in the rendering target space is Bx and the maximum coordinate is Bx+W in the first clipping direction X, and if the minimum coordinate Bx, the maximum coordinate Bx+W of the rendering target in the rendering target space in the first clipping direction X, and the size W and the scale information Kx of the rendering target in the first clipping direction X are known, it is possible to determine that the minimum coordinate of the clipping guard band in the rendering target space in the first clipping direction X is Bx-Kx X W/2 and the maximum coordinate is Bx+ (W+Kx X W/2).
Similarly, if the size H and the offset information By of the rendering target in the second cropping direction Y are known, the minimum coordinate of the rendering target in the rendering target space is By and the maximum coordinate is by+H, and if the minimum coordinate By and the maximum coordinate by+H of the rendering target in the rendering target space in the second cropping direction Y, the size H and the proportion information Ky of the rendering target in the second cropping direction Y are known, the minimum coordinate of the cropping guard band in the rendering target space is By-Ky×H/2 and the maximum coordinate is by+ (H+Ky×H/2) in the second cropping direction Y can be determined.
That is, in one possible implementation, for any one clipping direction corresponding to the size of the rendering target, the clipping guard band has a minimum coordinate of b-mxr/2 and a maximum coordinate of b+ (r+mxr/2) in that clipping direction, wherein,
R represents the size of the rendering target in the clipping direction, R is a positive integer;
m represents the proportion information of the clipping protection band in the clipping direction, and m is a positive number;
b represents offset information of the clipping guard band in the clipping direction, and b is a positive number.
For the first clipping direction X, R may be equal to W, m may be equal to Kx, and b may be equal to Bx. For the second clipping direction Y, R may be equal to H, m may be equal to Ky, and b may be equal to By.
Before rasterization, the coordinates of the render target first need to be transformed to the normalized device space NDC coordinate system, so fig. 4 also shows the coordinates of the render target in the NDC coordinate system and the coordinates of the clipping guard band. As shown in fig. 4, 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, the maximum coordinate X4 of the clipping guard band in the first clipping direction X may be 1+m and the minimum coordinate X1 of the clipping guard band in the first clipping direction X may be- (1+m) in the NDC coordinate system.
An exemplary determination of the scale information and the offset information of the cut guard band in the first cutting direction X is described below.
In one possible implementation, determining configuration information of clipping guard bands according to a size of a rendering target and a preset data precision of a rasterization stage (step S31) includes:
For any one of the clipping directions corresponding to the size of the rendering target,
Determining the maximum size and the maximum coordinate of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage;
Determining proportion information of a cutting protection belt in the cutting direction according to the size of a rendering target in the cutting direction and the maximum size and the maximum coordinate of a rendering target space in the cutting direction, and determining offset information of the cutting protection belt in the cutting direction according to the size and the proportion information of the rendering target in the cutting direction and the maximum size and the maximum coordinate of the rendering target space in the cutting direction, so that the actual size of the cutting protection belt in the cutting direction is smaller than the maximum size of the rendering target space in the cutting direction, the minimum coordinate of the cutting protection belt in the cutting direction is larger than 0, and the maximum coordinate of the cutting protection belt in the cutting direction is smaller than the maximum coordinate of the rendering target space in the cutting direction.
For example, when determining the configuration information, only the size of the rendering target in one clipping direction may be used, or the sizes of the rendering targets in a plurality of clipping directions may be used. If the size of the rendering object in a plurality of clipping directions is used, it is necessary to determine the configuration information of the clipping protection tape in the clipping direction for each clipping direction separately, in which case the configuration information of the clipping protection tape in different clipping directions may be different.
For example, for any clipping direction corresponding to the size of the rendering target, the maximum size and the maximum coordinate of the rendering target space in the clipping direction may be determined according to the preset data precision of the rasterization stage.
The minimum coordinates of the rendering target space in different clipping directions may be the same and equal to 0. The maximum coordinates of the rendering target space in different clipping directions may be the same or different as long as the accuracy of the maximum coordinates of the rendering target space in each clipping direction is made smaller than or equal to the preset data accuracy.
Taking the example that the preset data precision of the rasterization stage is a fixed point number in a 16.8 format, the maximum coordinate of the expressible rendering target space in each clipping direction is 64k (the maximum expression range of 16-bit integer). The minimum coordinates of the rendering target space in different clipping directions may be the same and equal to 0, and when the rendering target space is maximum, the maximum size of the rendering target space in different clipping directions and the maximum coordinates are equal to and equal to 64k.
For example, the user may reduce the rendering target space according to the application scene requirement, and the maximum size and the maximum coordinate of the rendering target space in different clipping directions may be different. As long as the accuracy of the maximum coordinates of the rendering target space in each clipping direction is less than or equal to the preset data accuracy. The present disclosure is not limited to a specific determination manner of the maximum size, maximum coordinates of the rendering target space in each clipping direction.
The coordinate of the clipping guard band is set in the rendering target space entirely, that is, in any clipping direction, the actual size of the clipping guard 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 guard band in the clipping direction is larger than 0, and the maximum coordinate of the clipping guard band in the clipping direction is smaller than the maximum coordinate of the rendering target space in the clipping direction.
From the above conditions, formulas (1) to (6) can be obtained:
Kx×W+W<MAX_RESOLUTION_X (1)
Bx-Kx×W/2>0 (2)
Bx+Kx×W/2+W<MAX_RESOLUTION_X (3)
Ky×H+H<MAX_RESOLUTION_Y (4)
By-Ky×H/2>0 (5)
By+Ky×H/2+H<MAX_RESOLUTION_Y (6)
in the formulas (1) - (3), kx×W+W represents the actual size of the cut-out protection tape in the first cut-out direction X, MAX_RESOLUTION_X represents the maximum size and the maximum coordinate of the rendering target space in the first cut-out direction X, bx-Kx×W/2 represents the minimum coordinate of the cut-out protection tape in the first cut-out direction X, and Bx+Kx×W/2+W represents the maximum coordinate of the cut-out protection tape in the first cut-out direction X.
In the formulas (4) - (6), ky represents the proportion information of the cut-out protection tape in the second cutting direction Y, by represents the offset information of the cut-out protection tape in the second cutting direction Y, H represents the size of the rendering target in the second cutting direction Y, ky×h+h represents the actual size of the cut-out protection tape in the second cutting direction Y, max_resolution_y represents the maximum size of the rendering target space in the second cutting direction Y, by-ky×h/2 represents the minimum coordinate of the cut-out protection tape in the second cutting direction Y, by+ky×h/2+H represents the maximum coordinate of the cut-out protection tape in the second cutting direction Y.
The formulas (1) - (6) can be further simplified, and the value range of Kx, bx, ky, by is obtained as follows:
Kx<MAX_RESOLUTION_X/X-1;
Kx×W/2<Bx<MAX_RESOLUTION_X-(W/2+1)W;
Ky<MAX_RESOLUTION_Y/Y-1;
Ky×H/2<By<MAX_RESOLUTION_Y-(H/2+1)H;
Any numerical combination of Kx and Bx which satisfies the above-mentioned value range can be set as the proportion information and the offset information of the clipping protection band in the first clipping direction X, and any numerical combination of Ky and By which satisfies the above-mentioned value range can be set as the proportion information and the offset information of the clipping protection band in the second clipping direction Y.
Only two clipping directions are shown above, and those skilled in the art will understand that there may be more clipping directions for the rendering target space, and the embodiments of the present disclosure do not limit how many clipping directions the rendering target space has in particular.
When configuration information of the clipping protection band is determined by using the sizes of the rendering targets in a plurality of clipping directions, the size setting of the clipping protection band in different clipping directions is more flexible.
In one possible implementation, when the size of the rendering target corresponds to one clipping direction, the size of the rendering target in that clipping direction is greater than or equal to the size in the other clipping directions;
The configuration information of the cut guard band in the cut direction is also used as the configuration information of the cut guard band in other cut directions.
For example, if the configuration information of the clip protection tape is determined using only the size of the rendering target in one clipping direction, the configuration information of the clip protection tape in that clipping direction may be determined in the same manner as when the configuration information of the clip protection tape is determined using the sizes of the rendering target in a plurality of clipping directions. That is, if the configuration information of the clip protection tape is determined using only the size of the rendering target in the first clipping direction X, the configuration information of the clip protection tape in the first clipping direction X may be determined according to formulas (1) - (3). If the configuration information of the clip protection tape is determined using only the size of the rendering target in the second clipping direction Y, the configuration information of the clip protection tape in the second clipping direction Y may be determined according to formulas (4) - (6). The specific determination manner is already described above and will not be described here again.
The configuration information of the cut guard band in the cut direction is also used as the configuration information of the cut guard band in other cut directions. The configuration information of the cut guard bands in the different cut directions is the same, i.e., kx=ky, bx=by.
In order for the clip protection tape to satisfy the condition that the actual size is smaller than the maximum size of the rendering target space in the clipping direction, the minimum coordinate is larger than 0, and the maximum coordinate is smaller than the maximum coordinate of the rendering target space in the clipping direction in each clipping direction, when configuration information of the clip protection tape is determined using only the size of the rendering target in one clipping direction, a clipping direction in which the size of the rendering target is larger, that is, when the size of the rendering target corresponds to one clipping direction, the size of the rendering target in the clipping direction is larger than or equal to the sizes in other clipping directions may be selected. For example, when the size of the rendering object in the first clipping direction X is larger than the size in the second clipping direction Y, the configuration information of the clipping protection tape may be determined by selecting the size of the rendering object in the first clipping direction X. When the size of the rendering object in the first clipping direction X is smaller than the size in the second clipping direction Y, the configuration information of the clipping protection tape may be determined by selecting the size of the rendering object in the second clipping direction Y. When the size of the rendering object in the first clipping direction X is equal to the size in the second clipping direction Y, the configuration information of the clipping protection tape is determined by selecting the size of the rendering object in the second clipping direction Y or the first clipping direction X.
In this case, the manner of determining the configuration information of the cut guard band is simpler.
One exemplary manner in which the present disclosure determines specific values for the scale information and the offset information is described below.
In one possible implementation, when there are a plurality of numerical combinations of the scale information and the offset information of the clipping protection tape in any one clipping direction, a numerical combination is selected such that the actual size of the clipping protection tape in that clipping direction is closest to the maximum size of the rendering target space in that clipping direction.
As described above, since the scale information and the offset information can be derived from the formulas (1) to (6), the values conforming to the scale information and the offset information can be selected, and thus, in any one cutting direction, the scale information and the offset information can be selected by a plurality of combinations of values. And as described above, the larger the cut guard band, the fewer the number of cuts, in which case, in any one cutting direction, the numerical combination that makes the actual size of the cut guard band closest to the maximum size of the cut guard band may be selected so that the actual size of the cut guard band is larger, further reducing the number of cuts.
In practical applications, in any clipping direction, the size of the rendering object is typically an exponential power of 2 (unit bit), such as 1k, 2k, 4k, 8k, 16k, 32k, etc. (1 k equals 1024 bits). Since the selection of the size of the rendering target is limited, a lookup table of configuration information of the clipping guard band may be predetermined. The lookup table may record a correspondence of the size of the render target to the scale information and the offset information. Different look-up tables may be set for different data accuracies of the rasterization phase. Table 1 shows an example of a lookup table of configuration information of a clip guard band when the rasterized data precision is 16.8.
TABLE 1
Size of rendering targetmbCoordinates of cutting protecting band
Rmbb-m×R/2,b+(R+m×R/2)
32k0.520k14k,60k
16k220k4k,52k
8k630k6k,62k
4k(4096)1430k2k,62k
2k(2048)3031k1k,63k
1k(1024)6031k1k,62k
In this case, the lookup table to be searched can be found according to the preset data precision of the rasterization stage, and then the configuration information of the clipping protection belt is directly searched in the lookup table according to the size of the rendering target to be used for determining the configuration information of the clipping protection belt, so that the configuration information of the clipping protection belt is not required to be calculated and determined, and the determination efficiency of the configuration information is improved.
In the embodiment of the present disclosure, determining the configuration information of the clipping guard band may be performed by a module of hardware or may be performed by a software algorithm, which is not limited in this disclosure.
An exemplary method of determining the positional relationship of primitives and clipping guard bands of the present disclosure is described below.
In one possible implementation, step S32 includes:
determining coordinates of a cutting face of the cutting protection belt in each cutting direction according to configuration information of the cutting protection belt;
Determining the position relationship between the primitive and each clipping surface according to the vertex coordinates of the primitive and the coordinates of each clipping surface;
And generating clipping masks of the primitives according to the position relation.
For example, the space in which the primitives are located is a three-dimensional space, and thus fig. 1 and 4 show cross-sections of the cut guard bands. The clipping protection belt can have two clipping surfaces in each clipping direction. Wherein the minimum coordinates of the clipping guard band in the clipping direction correspond to the first clipping plane and the maximum coordinates correspond to the second clipping plane.
From the configuration information of the cut protection tape, coordinates of the cut surface of the cut protection tape in each cut direction can be determined. The position relationship between the primitive and each clipping plane can be determined according to the vertex coordinates of the primitive and the coordinates of each clipping plane.
Fig. 5 illustrates an example of a positional relationship of primitives and clipping guard bands according to an embodiment of the present disclosure.
As shown in fig. 5, the clipping protection tape may correspond to the clipping surface 1 and the clipping surface 2 in the first clipping direction X, and the coordinates of all points on the clipping surface 1 in the first clipping direction X are equal to the minimum coordinates of the clipping protection tape in the first clipping direction X, and the coordinates of all points on the clipping surface 3 in the first clipping direction X are equal to the maximum coordinates of the clipping protection tape in the first clipping direction X. The clipping protection band may correspond to the clipping plane 3 and the clipping plane 4 in the second clipping direction Y. The coordinates of all points on the clipping plane 3 in the second clipping direction Y are equal to the minimum coordinates of the clipping protection tape in the second clipping direction Y, and the coordinates of all points on the clipping plane 4 in the second clipping direction Y are equal to the maximum coordinates of the clipping protection tape in the second clipping direction Y.
In this case the positional relationship of the primitive 1 and the clipping guard band may be such that the primitive 1 does not intersect with the clipping surfaces 1,2, 3, 4, i.e. the primitive 1 does not intersect with the clipping guard band, the positional relationship of the primitive 2 and the clipping guard band may be such that the primitive 2 does not intersect with the clipping surfaces 1,2, 3, i.e. the primitive 2 intersects with the clipping guard band, the positional relationship of the primitive 3 and the clipping guard band may be such that the primitive 3 does not intersect with the clipping surfaces 1,2, 3, 4, i.e. the primitive 3 does not intersect with the clipping guard band, and the positional relationship of the primitive 4 and the clipping guard band may be such that the primitive 4 does not intersect with the clipping surfaces 1,2, 4, i.e. the primitive 4 intersects with the clipping guard band.
An exemplary manner in which the present disclosure determines whether primitives require clipping is described below.
In one possible implementation, when the primitive intersects at least one clipping plane and intersects the render target, the clipping mask of the primitive indicates clipping the primitive, the clipping mode of the primitive includes clipping the primitive using the clipping plane that intersects the primitive;
when the primitive does not intersect each clipping plane or does not intersect a rendering target, the clipping mask of the primitive indicates that the primitive is not clipped.
For example, in practical applications, there may be a culling step before rendering to remove primitives that are not visible off-screen to improve rendering performance. If the primitive intersects the clipping guard band, but does not intersect the render target, then the primitive is effectively a cullable primitive, nor does the clipping primitive have an effect on the result of the rasterization. That is, only primitives that intersect at least one clipping plane and also intersect the render target need actually be clipped.
Thus, when a primitive intersects at least one clipping plane and intersects a render target, the clipping mask of the primitive may indicate clipping the primitive in a manner that includes clipping the primitive using the clipping plane that intersects the primitive. For example, in the example of FIG. 5, only primitive 4 intersects at least one clipping plane and intersects the render target, so that only the clipping mask for primitive 4 may indicate clipping primitive 4, and the clipping mask for primitive 4 may also indicate that primitive 4 is clipped using clipping plane 3.
When the primitive and each clipping plane do not intersect, or the primitive and rendering target do not intersect, the primitive does not need clipping, and the clipping mask of the primitive may indicate that the primitive is not clipped. For example, in the example of FIG. 5, primitive 1 and each clipping plane do not intersect, nor do rendering targets, so the clipping mask for primitive 1 may indicate that primitive 1 is not clipped. Primitive 2 and the render target do not intersect, so the clipping mask for primitive 2 may indicate that primitive 2 is not clipped. Primitive 3 and each clipping plane do not intersect, so the clipping mask for primitive 3 may indicate that primitive 3 is not clipped.
By enabling the clipping guard band to play a role in the process of eliminating, the method is beneficial to reducing the cost of unnecessary processing on invisible primitives, so that the number of the clipped primitives is smaller, and the rendering efficiency is improved.
Another exemplary manner in which the present disclosure determines whether primitives require clipping is described below.
In one possible implementation, when the primitive intersects at least one clipping plane, the clipping mask of the primitive indicates clipping the primitive, the clipping mode of the primitive includes clipping the primitive using the clipping plane that intersects 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.
In one example, when determining whether the primitive needs clipping, whether the primitive needs clipping may also be determined without considering whether the primitive needs clipping, that is, only according to the intersection condition of the primitive and the clipping plane.
In this case, when the primitive intersects at least one clipping plane and intersects the rendering target, it may be determined that the primitive needs to be clipped, and the clipping mask of the primitive may indicate clipping the primitive in a manner that includes clipping the primitive using the clipping plane that intersects the primitive. For example, in the example of FIG. 5, primitive 2 intersects clipping plane 4, primitive 4 intersects clipping plane 3, so that the clipping mask of primitive 4 may indicate clipping primitive 4 and may further indicate that primitive 4 is clipping primitive 4 using clipping plane 3, and the clipping mask of primitive 2 may indicate clipping primitive 2 and may further indicate that primitive 4 is clipping primitive 2 using clipping plane 4.
When the primitive and each clipping plane do not intersect, the clipping mask of the primitive indicates that the primitive is not clipped. For example, in the example of FIG. 5, primitive 1 and primitive 3 do not intersect any clipping plane, so the clipping mask for primitive 1 may indicate that primitive 1 is not clipped and the clipping mask for primitive 3 may indicate that primitive 3 is not clipped.
In this way, it is simpler to determine whether the primitive needs clipping.
One example of a clipping primitive of the present disclosure is described below.
In one possible implementation, step S33 includes:
when the clipping mask of the primitive indicates clipping the primitive, the primitive is clipped in turn according to clipping planes intersecting the primitive, one clipping plane at a time.
For example, since the clipping plane intersecting the primitive has already been determined when the clipping mask of the primitive is generated, the clipping manner of the primitive may indicate all clipping planes intersecting the primitive. It is assumed that only one clipping plane can be used at a time to clip a primitive, in which case, when the clipping mask of the primitive indicates clipping the primitive, the primitive may be clipped sequentially according to clipping planes intersecting the primitive, one clipping plane at a time. After the last clipping surface is used, the primitive clipping is finished.
In this way, the clipping flow of the primitive is simpler.
Another example of clipping primitives of the present disclosure is described below.
In one possible implementation, step S33 includes:
When the clipping mask of the primitive indicates to clip the primitive, selecting any clipping surface from clipping surfaces intersected with the primitive, and clipping the primitive by using the selected clipping surface;
The method further includes updating a clipping mask of the primitive according to the vertex coordinates of the clipped new vertex.
For example, assuming that only one clipping plane can be used at a time to clip a primitive, the shape of the primitive changes after each clipping, and thus an unused clipping plane may be invalid. For example, a certain primitive may intersect 3 clipping planes before clipping, and if clipping is performed in a clipping manner indicated by a clipping mask determined before clipping, clipping is required 3 times. After the 1 st clipping, it may intersect only 1 clipping plane, so in practice 2 clipping is enough to clip the primitive, 1 clipping plane is invalid.
In this case, when the clipping mask of the primitive indicates clipping the primitive, any clipping plane may be selected from clipping planes intersecting the primitive as the clipping plane used in the present clipping. When only one clipping surface is intersected with the graphic primitive, the clipping surface is directly selected. Where there are multiple clipping planes intersecting the primitive, one clipping plane may be randomly selected. The primitives may be cropped using the selected crop plane.
At least one new vertex can be obtained after clipping the primitive. The clipping mask of the primitive may be updated based on the vertex coordinates of the clipped new vertex. For example, the updating manner may be to redetermine the positional relationship between the primitive and each clipping plane according to the vertex coordinates of the new vertex and the vertex coordinates of the valid old vertex and the coordinates of each clipping plane, and generate a clipping mask of the primitive according to the determined positional relationship, that is, the clipping mask of the updated primitive. Determining the positional relationship between the primitive and the clipping plane, and generating the clipping mask of the primitive according to the determined positional relationship has been described above, and will not be described herein.
Step S33 may be re-executed according to the clipping mask of the updated primitive until the clipping mask of the primitive no longer indicates clipping the primitive.
In this way, the number of clipping times of the primitive can be further reduced.
The following describes an exemplary structure of a primitive clipping device implemented using hardware modules and functions of each hardware module according to embodiments of the present disclosure.
Fig. 6 shows a schematic diagram of the structure of a primitive clipping device according to an embodiment of the present disclosure.
As shown in fig. 6, the primitive clipping device may include a configuration information generation unit and a clipping module. The clipping module may include a clipping mask generating unit, a clipping resolution unit, and a clipping execution unit.
The configuration information generation unit may store information of a preset data precision of the rasterization stage. The configuration information generating unit may receive the size of the rendering target and perform step S31 of determining configuration information of the clipping guard band according to the size of the rendering target and the preset data precision of the rasterization stage so that the rendering target is located in the clipping guard band. The configuration information generating unit may obtain the configuration information of the clip tape in each clip direction and output to the clip mask generating unit.
Fig. 7 illustrates a schematic diagram in which a configuration information generating unit outputs configuration information to a clipping mask generating unit according to an embodiment of the present disclosure.
As shown in fig. 7, it is assumed that the rendering target space has a first clipping direction X and a second clipping direction Y. The configuration information generation unit may transmit the configuration information of the clip guard band in the first clip direction X and the configuration information in the second clip direction Y to the clip mask generation unit, respectively.
The clipping mask generating unit also receives the vertex coordinates and performs steps S32 and S33 to generate a clipping mask for the primitive based on the vertex coordinates of the primitive and the configuration information. For example, the clipping mask generating unit may generate a clipping mask of the vertex for the vertex, where the clipping mask of the vertex indicates a positional relationship between the vertex and the clipping surface, and generate a clipping mask of the primitive according to the clipping mask of the vertex, so that the clipping mask of the primitive indicates the positional relationship between the primitive and the clipping surface, and further indicates a clipping manner of the primitive. The clipping mask generating unit may output the clipping mask of the primitive to the clipping resolution unit.
The clipping resolution unit also receives the primitive information, and according to the clipping mask of the primitive and the primitive information, the clipping resolution unit can determine whether to clip the primitive, and further determine which clipping plane is used in the clipping when determining to clip the primitive. The clipping resolution unit may output information of clipping planes used when clipping the graphic element to the clipping execution unit.
The clipping execution unit also receives vertex coordinates and primitive information, clips the primitive according to the clipping plane information used when clipping the primitive, removes invalid vertex coordinates and primitive information when clipping, and generates new vertex coordinates. The clipping execution unit may output the new vertex coordinates to the clipping mask generation unit, and the clipping mask generation unit may generate a new vertex clipping mask for the new vertex coordinates and update the clipping mask of the primitive according to the new vertex clipping mask after receiving the new vertex coordinates.
The clipping resolution unit continues to determine whether to clip the primitive according to the updated primitive clipping mask, and when determining to clip the primitive, the clipping execution unit repeats the above-mentioned procedure until the clipping resolution unit determines that the clipping unit is not required according to the clipping mask, and may drive the clipping execution unit to output the clipping result of the primitive to a vertex buffer (not shown) at a later stage.
The disclosure also provides a primitive clipping device, and fig. 8 is a schematic diagram illustrating a structure of the primitive clipping device according to an embodiment of the disclosure.
As shown in fig. 8, in one possible implementation, the apparatus includes:
A first determining module 81, configured to determine configuration information of a clipping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the clipping protection band, where the size of the rendering target includes a 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 protection band in each clipping direction;
A first generating module 82, configured to generate a clipping mask of a primitive according to vertex coordinates of the primitive and the configuration information, where the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates a clipping manner of the primitive;
and the first clipping module 83 is configured to clip the primitive according to the clipping mode indicated by the clipping mask of the primitive when the clipping mask of the primitive indicates clipping the primitive, where the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.
The first determining module, the first generating module and the first clipping module can be hardware modules or software modules. When the first determining module is used as a hardware module, the first determining module corresponds to the configuration information generating unit, the first generating module corresponds to the clipping mask generating unit, and the first clipping module corresponds to the clipping resolution unit and the clipping execution unit.
In one possible implementation manner, the configuration information of the clipping protection band in any clipping direction includes proportion information and offset information, wherein the proportion information represents a ratio of a first difference value to a size of the rendering target in the clipping direction, the first difference value is equal to a difference value between an actual size of the clipping protection band in the clipping direction and a size of the rendering target in the clipping direction, and the offset information represents a difference value between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of a rendering target space in the clipping direction.
In one possible implementation manner, the configuration information of the clipping protection belt is determined according to the size of the rendering target and the preset data precision of the rasterization stage, and the configuration information comprises determining the maximum size and the maximum coordinate of the rendering target space in the clipping direction according to the preset data precision of the rasterization stage for any clipping direction corresponding to the size of the rendering target, determining the proportion information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, and determining the offset information of the clipping protection belt in the clipping direction according to the size of the rendering target in the clipping direction, the proportion information and the maximum size and the maximum coordinate of the rendering target space in the clipping direction, so that the actual size of the clipping protection belt 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 belt in the clipping direction is larger than 0, and the maximum coordinate of the clipping protection belt in the clipping direction is smaller than the maximum coordinate of the target space in the clipping direction.
In one possible implementation manner, when the size of the rendering target corresponds to one clipping direction, the size of the rendering target in the clipping direction is larger than or equal to the size of the rendering target in other clipping directions, and the configuration information of the clipping protection belt in the clipping direction is also used as the configuration information of the clipping protection belt in other clipping directions.
In one possible implementation manner, 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 b-m×r/2, the maximum coordinate is b+ (rm×r/2), wherein R represents the size of the rendering target in the clipping direction, R is a positive integer, m represents the proportion information of the clipping protection band in the clipping direction, 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.
In one possible implementation, when there are a plurality of numerical combinations of the scale information and the offset information of the clipping protection band in any one clipping direction, a numerical combination is selected such that the actual size of the clipping protection band in the clipping direction is closest to the maximum size of the rendering target space in the clipping direction.
In one possible implementation manner, the generating the clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information comprises determining coordinates of clipping surfaces of the clipping protection belt in each clipping direction according to the configuration information of the clipping protection belt, determining a position relation between the primitive and each clipping surface according to the vertex coordinates of the primitive and the coordinates of each clipping surface, and generating the clipping mask of the primitive according to the position relation.
In one possible implementation, when the primitive intersects at least one clipping plane and intersects the rendering target, the clipping mask of the primitive indicates clipping the primitive, the clipping mode of the primitive includes clipping the primitive using the clipping plane intersecting the primitive, and when the primitive does not intersect each clipping plane or does not intersect the rendering target, the clipping mask of the primitive indicates not clipping the primitive.
In one possible implementation, the clipping mask of the primitive indicates clipping the primitive when the primitive intersects at least one clipping plane, and the clipping mode of the primitive includes clipping the primitive using the clipping plane that intersects the primitive, and the clipping mask of the primitive indicates not clipping the primitive when the primitive does not intersect each clipping plane.
In one possible implementation manner, when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive according to the clipping mode indicated by the clipping mask of the primitive comprises selecting any clipping surface from clipping surfaces intersected with the primitive when the clipping mask of the primitive indicates clipping the primitive, clipping the primitive by using the selected clipping surface, and updating the clipping mask of the primitive according to the vertex coordinates of a new vertex obtained by clipping.
In some embodiments, functions or modules included in an apparatus provided by the embodiments of the present disclosure may be used to perform a method described in the foregoing method embodiments, and specific implementations thereof may refer to descriptions of the foregoing method embodiments, which are not repeated herein for brevity.
The disclosed embodiments also provide a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described method. The computer readable storage medium may be a volatile or nonvolatile computer readable storage medium.
The embodiment of the disclosure also provides electronic equipment, which comprises a processor and a memory for storing instructions executable by the processor, wherein the processor is configured to realize the method when the instructions stored by the memory are executed.
Embodiments of the present disclosure also provide a computer program product comprising computer readable code, or a non-transitory computer readable storage medium carrying computer readable code, which when run in a processor of an electronic device, performs the above method.
Fig. 9 shows a block diagram of an electronic device 1900 according to an embodiment of the disclosure. For example, electronic device 1900 may be provided as a server or terminal device. Referring to FIG. 9, electronic device 1900 includes a processing component 1922 that further includes one or more processors and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by processing component 1922. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. Further, processing component 1922 is configured to execute instructions to perform the methods described above.
The electronic device 1900 may also include a power 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 memory 1932, such as Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 1932, including computer program instructions executable by processing component 1922 of electronic device 1900 to perform the methods described above.
The present disclosure may be a system, method, and/or computer program product. The computer program product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include a portable computer diskette, 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 Disc (DVD), a memory stick, a floppy disk, a mechanical encoding device, punch cards or intra-groove protrusion structures such as those having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media, as used herein, are not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through fiber optic cables), or electrical signals transmitted through wires.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as SMALLTALK, C ++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present disclosure are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information of computer readable program instructions, which can execute the computer readable program instructions.
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The foregoing description of the embodiments of the present disclosure has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvements in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (13)

Translated fromChinese
1.一种图元裁剪方法,其特征在于,所述方法包括:1. A primitive clipping method, characterized in that the method comprises:根据渲染目标的尺寸和光栅化阶段的预设数据精度,确定裁剪保护带的配置信息,使得所述渲染目标位于所述裁剪保护带中,所述渲染目标的尺寸包括所述渲染目标在渲染目标空间的一个或多个裁剪方向上的尺寸,所述配置信息包括所述裁剪保护带在每个裁剪方向上的配置信息;Determining configuration information of a clipping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the clipping protection band, the size of the rendering target including a size of the rendering target in one or more clipping directions of a rendering target space, and the configuration information including configuration information of the clipping protection band in each clipping direction;根据图元的顶点坐标以及所述配置信息,生成所述图元的裁剪掩码,所述图元的裁剪掩码指示是否裁剪所述图元,在所述图元的裁剪掩码指示裁剪所述图元时,所述图元的裁剪掩码还指示所述图元的裁剪方式;Generate a clipping mask of the primitive according to the vertex coordinates of the primitive and the configuration information, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive also indicates a clipping method of the primitive;在所述图元的裁剪掩码指示裁剪所述图元时,根据所述图元的裁剪掩码指示的裁剪方式裁剪所述图元,裁剪后的图元的顶点坐标的精度小于或等于所述预设数据精度。When the clipping mask of the primitive indicates clipping of the primitive, the primitive is clipped according to the clipping method indicated by the clipping mask of the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.2.根据权利要求1所述的方法,其特征在于,所述裁剪保护带在任意一个裁剪方向上的配置信息包括比例信息和偏移信息,其中,2. The method according to claim 1, characterized in that the configuration information of the cutting protection band in any cutting direction includes ratio information and offset information, wherein:所述比例信息表示第一差值与所述渲染目标在该裁剪方向上的尺寸的比值,所述第一差值等于所述裁剪保护带在该裁剪方向上的实际尺寸与所述渲染目标在该裁剪方向上的尺寸的差值;The ratio information represents a ratio of a first difference value to a size of the rendering target in the cropping direction, wherein the first difference value is equal to a difference between an actual size of the cropping protection band in the cropping direction and a size of the rendering target in the cropping direction;所述偏移信息表示所述渲染目标在该裁剪方向上的最小坐标与渲染目标空间在该裁剪方向上的最小坐标的差值。The offset information indicates a difference between a minimum coordinate of the rendering target in the clipping direction and a minimum coordinate of the rendering target space in the clipping direction.3.根据权利要求2所述的方法,其特征在于,所述根据渲染目标的尺寸和光栅化阶段的预设数据精度,确定裁剪保护带的配置信息,包括:3. The method according to claim 2, wherein determining the configuration information of the cropping protection band according to the size of the rendering target and the preset data accuracy of the rasterization stage comprises:针对所述渲染目标的尺寸对应的任意一个裁剪方向,For any clipping direction corresponding to the size of the render target,根据光栅化阶段的预设数据精度,确定渲染目标空间在该裁剪方向上的最大尺寸和最大坐标;According to the preset data precision of the rasterization stage, the maximum size and maximum coordinates of the rendering target space in the clipping direction are determined;根据所述渲染目标在该裁剪方向上的尺寸和所述渲染目标空间在该裁剪方向上的最大尺寸、最大坐标,确定所述裁剪保护带在该裁剪方向上的比例信息,根据所述渲染目标在该裁剪方向上的尺寸、所述比例信息以及所述渲染目标空间在该裁剪方向上的最大尺寸、最大坐标,确定所述裁剪保护带在该裁剪方向上的偏移信息,使所述裁剪保护带在该裁剪方向上的实际尺寸小于所述渲染目标空间在该裁剪方向上的最大尺寸、所述裁剪保护带在该裁剪方向上的最小坐标大于0、所述裁剪保护带在该裁剪方向上的最大坐标小于渲染目标空间在该裁剪方向上的最大坐标。According to the size of the rendering target in the clipping direction and the maximum size and maximum coordinates of the rendering target space in the clipping direction, the scale information of the clipping protection band in the clipping direction is determined; according to the size of the rendering target in the clipping direction, the scale information and the maximum size and maximum coordinates of the rendering target space in the clipping direction, the offset information of the clipping protection band in the clipping direction is determined, so that the actual size of the clipping protection band in the clipping direction is smaller than the maximum size of the rendering target space in the clipping direction, the minimum coordinate of the clipping protection band in the clipping direction is greater than 0, and the maximum coordinate of the clipping protection band in the clipping direction is smaller than the maximum coordinate of the rendering target space in the clipping direction.4.根据权利要求2所述的方法,其特征在于,所述渲染目标的尺寸对应于一个裁剪方向时,所述渲染目标在该裁剪方向上的尺寸大于或等于在其他裁剪方向上的尺寸;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.根据权利要求3或4所述的方法,其特征在于,针对所述渲染目标的尺寸对应的任意一个裁剪方向,所述裁剪保护带在该裁剪方向上的最小坐标为b-m×R/2,最大坐标为b+(R+m×R/2),其中,5. The method according to claim 3 or 4, characterized in that, for any clipping direction corresponding to the size of the rendering target, the minimum coordinate of the clipping protection band in the clipping direction is b-m×R/2, and the maximum coordinate is b+(R+m×R/2), wherein,R表示所述渲染目标在该裁剪方向上的尺寸,R是正整数;R represents the size of the rendering target in the clipping direction, and R is a positive integer;m表示所述裁剪保护带在该裁剪方向上的比例信息,m是正数;m represents the ratio information of the cutting protection band in the cutting direction, and m is a positive number;b表示所述裁剪保护带在该裁剪方向上的偏移信息,b是正数。b represents the offset information of the cutting protection band in the cutting direction, and b is a positive number.6.根据权利要求3或4所述的方法,其特征在于,任意一个裁剪方向上,所述裁剪保护带的比例信息和偏移信息有多个数值组合可选时,选择使得所述裁剪保护带在该裁剪方向上的实际尺寸与所述渲染目标空间在该裁剪方向上的最大尺寸最接近的数值组合。6. The method according to claim 3 or 4 is characterized in that, in any cropping direction, when there are multiple numerical combinations to choose from for the proportion information and offset information of the cropping protection band, 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.7.根据权利要求1所述的方法,其特征在于,所述根据图元的顶点坐标以及所述配置信息,生成所述图元的裁剪掩码,包括:7. The method according to claim 1, wherein generating a clipping mask of the primitive according to vertex coordinates of the primitive and the configuration information comprises:根据所述裁剪保护带的配置信息,确定所述裁剪保护带在每个裁剪方向上的裁剪面的坐标;Determining the coordinates of the cutting surface of the cutting protection band in each cutting direction according to the configuration information of the cutting protection band;根据所述图元的顶点坐标和每一裁剪面的坐标,确定所述图元和每一裁剪面的位置关系;Determine the positional relationship between the graphic primitive and each clipping surface according to the vertex coordinates of the graphic primitive and the coordinates of each clipping surface;根据所述位置关系生成所述图元的裁剪掩码。A clipping mask of the primitive is generated according to the positional relationship.8.根据权利要求7所述的方法,其特征在于,8. The method according to claim 7, characterized in that所述图元和至少一个裁剪面相交且与所述渲染目标相交时,所述图元的裁剪掩码指示裁剪所述图元,所述图元的裁剪方式包括使用与所述图元相交的裁剪面裁剪所述图元;When the primitive intersects with at least one clipping plane and intersects with the rendering target, the clipping mask of the primitive indicates clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane intersecting with the primitive;所述图元和每个裁剪面均不相交或者和所述渲染目标不相交时,所述图元的裁剪掩码指示不裁剪所述图元。When the primitive does not intersect any clipping plane or does not intersect the rendering target, the clipping mask of the primitive indicates that the primitive is not clipped.9.根据权利要求7所述的方法,其特征在于,9. The method according to claim 7, characterized in that:所述图元和至少一个裁剪面相交时,所述图元的裁剪掩码指示裁剪所述图元,所述图元的裁剪方式包括使用与所述图元相交的裁剪面裁剪所述图元;When the primitive intersects with at least one clipping plane, the clipping mask of the primitive indicates clipping the primitive, and the clipping method of the primitive includes clipping the primitive using the clipping plane intersecting with the primitive;所述图元和每个裁剪面均不相交时,所述图元的裁剪掩码指示不裁剪所述图元。When the primitive and each clipping plane do not intersect, the clipping mask of the primitive indicates that the primitive is not clipped.10.根据权利要求1所述的方法,其特征在于,所述在所述图元的裁剪掩码指示裁剪所述图元时,根据所述图元的裁剪掩码指示的裁剪方式裁剪所述图元,包括:10. The method according to claim 1, wherein when the clipping mask of the primitive indicates clipping of the primitive, clipping the primitive according to the clipping manner indicated by the clipping mask of the primitive comprises:在所述图元的裁剪掩码指示裁剪所述图元时,从与所述图元相交的裁剪面中选择任意一个裁剪面;When the clipping mask of the primitive indicates clipping the primitive, selecting any one clipping plane from clipping planes intersecting with the primitive;使用选择的裁剪面裁剪所述图元;Clipping the primitive using the selected clipping plane;所述方法还包括:根据裁剪得到的新顶点的顶点坐标更新所述图元的裁剪掩码。The method further includes: updating the clipping mask of the primitive according to the vertex coordinates of the new vertex obtained by clipping.11.一种图元裁剪装置,其特征在于,所述装置包括:11. A primitive clipping device, characterized in that the device comprises:第一确定模块,用于根据渲染目标的尺寸和光栅化阶段的预设数据精度,确定裁剪保护带的配置信息,使得所述渲染目标位于所述裁剪保护带中,所述渲染目标的尺寸包括所述渲染目标在渲染目标空间的一个或多个裁剪方向上的尺寸,所述配置信息包括所述裁剪保护带在每个裁剪方向上的配置信息;A first determining module is used to determine configuration information of a cropping protection band according to a size of a rendering target and a preset data precision of a rasterization stage, so that the rendering target is located in the cropping protection band, the size of the rendering target includes the size of the rendering target in one or more cropping directions of a rendering target space, and the configuration information includes configuration information of the cropping protection band in each cropping direction;第一生成模块,用于根据图元的顶点坐标以及所述配置信息,生成所述图元的裁剪掩码,所述图元的裁剪掩码指示是否裁剪所述图元,在所述图元的裁剪掩码指示裁剪所述图元时,所述图元的裁剪掩码还指示所述图元的裁剪方式;A first generating module, configured to generate a clipping mask of the primitive according to vertex coordinates of the primitive and the configuration information, wherein the clipping mask of the primitive indicates whether to clip the primitive, and when the clipping mask of the primitive indicates to clip the primitive, the clipping mask of the primitive further indicates a clipping method of the primitive;第一裁剪模块,用于在所述图元的裁剪掩码指示裁剪所述图元时,根据所述图元的裁剪掩码指示的裁剪方式裁剪所述图元,裁剪后的图元的顶点坐标的精度小于或等于所述预设数据精度。The first clipping module is used to clip the primitive according to the clipping method indicated by the clipping mask of the primitive when the clipping mask of the primitive indicates clipping the primitive, and the accuracy of the vertex coordinates of the clipped primitive is less than or equal to the preset data accuracy.12.一种电子设备,其特征在于,包括:12. An electronic device, comprising:处理器;processor;用于存储处理器可执行指令的存储器;a memory for storing processor-executable instructions;其中,所述处理器被配置为在执行所述存储器存储的指令时,实现权利要求1至10中任意一项所述的方法。Wherein, the processor is configured to implement the method described in any one of claims 1 to 10 when executing the instructions stored in the memory.13.一种非易失性计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求1至10中任意一项所述的方法。13. A non-volatile computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions implement the method of any one of claims 1 to 10 when executed by a processor.
CN202411341389.6A2024-09-242024-09-24 Method, device, electronic device and storage medium for primitive clippingActiveCN119251355B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202411341389.6ACN119251355B (en)2024-09-242024-09-24 Method, device, electronic device and storage medium for primitive clipping

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202411341389.6ACN119251355B (en)2024-09-242024-09-24 Method, device, electronic device and storage medium for primitive clipping

Publications (2)

Publication NumberPublication Date
CN119251355Atrue CN119251355A (en)2025-01-03
CN119251355B CN119251355B (en)2025-09-02

Family

ID=94021152

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202411341389.6AActiveCN119251355B (en)2024-09-242024-09-24 Method, device, electronic device and storage medium for primitive clipping

Country Status (1)

CountryLink
CN (1)CN119251355B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20050231503A1 (en)*2004-04-202005-10-20The Chinese University Of Hong KongBlock-based fragment filtration with feasible multi-GPU acceleration for real-time volume rendering on conventional personal computer
CN104933749A (en)*2013-12-112015-09-23Arm有限公司Clipping of graphics primitives
US20180240268A1 (en)*2017-02-172018-08-23Microsoft Technology Licensing, LlcVariable rate shading
CN116601662A (en)*2020-12-112023-08-15华为技术有限公司Graphic processing method, device, equipment and medium
CN117830485A (en)*2023-12-292024-04-05摩尔线程智能科技(成都)有限责任公司Rendering marking method and device in GPU graphics rendering and electronic equipment
CN118823277A (en)*2024-06-172024-10-22摩尔线程智能科技(北京)有限责任公司 Tailoring method, device, equipment, storage medium and program product

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20050231503A1 (en)*2004-04-202005-10-20The Chinese University Of Hong KongBlock-based fragment filtration with feasible multi-GPU acceleration for real-time volume rendering on conventional personal computer
CN104933749A (en)*2013-12-112015-09-23Arm有限公司Clipping of graphics primitives
US20180240268A1 (en)*2017-02-172018-08-23Microsoft Technology Licensing, LlcVariable rate shading
CN116601662A (en)*2020-12-112023-08-15华为技术有限公司Graphic processing method, device, equipment and medium
CN117830485A (en)*2023-12-292024-04-05摩尔线程智能科技(成都)有限责任公司Rendering marking method and device in GPU graphics rendering and electronic equipment
CN118823277A (en)*2024-06-172024-10-22摩尔线程智能科技(北京)有限责任公司 Tailoring method, device, equipment, storage medium and program product

Also Published As

Publication numberPublication date
CN119251355B (en)2025-09-02

Similar Documents

PublicationPublication DateTitle
US8115767B2 (en)Computer graphics shadow volumes using hierarchical occlusion culling
JP5721358B2 (en) Graphics processing system
US8704830B2 (en)System and method for path rendering with multiple stencil samples per color sample
JP3840014B2 (en) Scan conversion execution apparatus for graphics display system
JP5232358B2 (en) Rendering outline fonts
CN115147579B (en)Block rendering mode graphic processing method and system for expanding block boundary
US4855938A (en)Hidden line removal method with modified depth buffer
CN111260750B (en)Processing method and device for openFL drawing vector graphics and electronic equipment
KR102701851B1 (en)Apparatus and method for determining LOD(level Of detail) for texturing cube map
JP6235123B2 (en) 2D curve tessellation using graphics pipeline
CN109544658B (en)Map rendering method and device, storage medium and electronic device
CN108765539B (en)OpenGLES-based image rendering method, device, equipment and storage medium
US10134171B2 (en)Graphics processing systems
JP2015515059A (en) Method for estimating opacity level in a scene and corresponding apparatus
KR102646818B1 (en) Compressing and Decompressing Indexes in the Graphics Pipeline
US10078911B2 (en)System, method, and computer program product for executing processes involving at least one primitive in a graphics processor, utilizing a data structure
CN113256764A (en)Rasterization device and method and computer storage medium
JP2006120158A (en)Method for hardware accelerated anti-aliasing in three-dimension
US7420557B1 (en)Vertex processing when w=0
CN119251355B (en) Method, device, electronic device and storage medium for primitive clipping
US11869123B2 (en)Anti-aliasing two-dimensional vector graphics using a compressed vertex buffer
US7256796B1 (en)Per-fragment control for writing an output buffer
KR20190013146A (en)Rendering optimization method for real-time mass processing of 3d objects in mobile environment
WO2022120800A1 (en)Graphics processing method and apparatus, and device and medium
JP4106719B2 (en) Image processing device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp