Rendering processing method and apparatus, electronic device, storage medium, program product

CN121685686BActive Publication Date: 2026-08-18MOORE THREADS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511959128.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-08-18
Estimated Expiration
2045-12-23

AI Technical Summary

Benefits of technology

[0009]本公开所提供的实施例,在对渲染对象进行渲染处理的插值阶段,能够从渲染对象的图元中,确定裁剪后的第一图元;对于第一图元中的任一像素点,在像素点的属性中存在片元着色器要求传递属性值且无需插值处理的第一属性的情况下,确定像素点相对于裁剪前的第二图元的第一重心坐标,并将第一重心坐标及第二图元的各顶点的第一属性的属性值,发送给片元着色器,以使第一重心坐标及第二图元的各顶点的第一属性的属性值参与片元着色器对该像素点的着色处理,从而能够在渲染处理的插值阶段,对于裁剪后的图元中的像素点,在将该像素点的信息传递给片元着色器时,对于片元着色器要求传递属性值且不进行插值处理的属性,能够将裁剪前的图元的各顶点的该属性的属性值和该像素点相对于裁剪前的图元的顶点的重心坐标,传递给片元着色器,使得片元着色器能够使用正确的属性值和重心坐标对该像素点进行着色处理,降低了片元着色器的处理偏差,进而提高了渲染效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121685686B_ABST
    Figure CN121685686B_ABST
Patent Text Reader

Abstract

The present disclosure provides a rendering processing method and device, electronic equipment, storage medium and program product. The method comprises: in an interpolation stage of rendering processing of a rendering object, determining a first clipped primitive from a primitive of the rendering object; in the case that there is a first attribute in the attributes of any pixel point in the first primitive, the attribute value of which is required to be delivered by a fragment shader and does not need to be interpolated, determining a first barycentric coordinate of the pixel point relative to a second primitive, the second primitive being a primitive before clipping corresponding to the first primitive; and sending the first barycentric coordinate and the attribute value of the first attribute of each vertex of the second primitive to the fragment shader, so that the first barycentric coordinate and the attribute value of the first attribute of each vertex of the second primitive participate in the shading processing of the pixel point by the fragment shader. According to the embodiments of the present disclosure, the processing deviation of the fragment shader can be reduced, and the rendering effect can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of graphics processing technology, and in particular to a rendering processing method and apparatus, electronic equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] Graphics processing technology refers to the techniques used to process two-dimensional or three-dimensional visuals and images using various hardware and software devices to achieve specific rendering effects. Graphics processing devices refer to devices used to perform graphics processing operations, such as Graphics Processing Units (GPUs) or other similar devices. During the graphics rendering process, graphics processing devices process input data in the order of the geometry pipeline and the fragment pipeline. The geometry pipeline includes operations such as vertex shading, primitive assembly, tessellation, geometry shading, clipping, and viewport transformation. The fragment pipeline includes operations such as rasterization and fragment shading. Summary of the Invention

[0003] This disclosure provides a rendering processing method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product.

[0004] In a first aspect, this disclosure provides a rendering processing method, which includes: in an interpolation stage for rendering a rendering object, determining a clipped first primitive from the primitives of the rendering object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute for which the fragment shader requires the transmission of attribute values ​​and no interpolation processing is required, determining the first centroid coordinates of the pixel relative to a second primitive, wherein the second primitive is the primitive before clipping corresponding to the first primitive; sending the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's shading processing of the pixel.

[0005] Secondly, this disclosure provides a rendering processing apparatus, comprising: a primitive determination module, configured to determine a clipped first primitive from the primitives of the rendering object during an interpolation stage of rendering processing of the rendering object; a centroid coordinate determination module, configured to determine, for any pixel in the first primitive, a first centroid coordinate relative to a second primitive if the pixel's attributes contain a first attribute for which the fragment shader requires the transmission of attribute values ​​and no interpolation processing is required, wherein the second primitive is the primitive before clipping corresponding to the first primitive; and a sending module, configured to send the first centroid coordinate and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader, so that the first centroid coordinate and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's shading processing of the pixel.

[0006] Thirdly, this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the rendering processing method described above.

[0007] Fourthly, this disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-described rendering processing method.

[0008] Fifthly, this disclosure provides a computer program product that includes computer-readable code or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the rendering processing method described above.

[0009] The embodiments provided in this disclosure, during the interpolation stage of rendering the rendered object, can determine the clipped first primitive from the primitives of the rendered object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute that the fragment shader requires to pass attribute values ​​and does not require interpolation processing, the first centroid coordinates of the pixel relative to the second primitive before clipping are determined, and the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in fragment shading. The fragment shader performs color processing on the pixel, enabling it to handle pixel information in the clipped primitive during the interpolation stage of the rendering process. For attributes that the fragment shader requires to be passed without interpolation, the fragment shader can pass the attribute values ​​of the corresponding vertices of the primitive before clipping and the centroid coordinates of the pixel relative to the vertices of the primitive before clipping. This allows the fragment shader to use the correct attribute values ​​and centroid coordinates to color the pixel, reducing processing bias and improving rendering quality.

[0010] Furthermore, according to the rendering processing method of this disclosure embodiment, for the clipped second primitive, during the interpolation stage, the centroid coordinates of the old vertex (first vertex) can be updated in real time based on the first primitive information of the first primitive before clipping, without having to independently store the centroid coordinates of the shared vertex in each primitive, thus reducing the waste of storage space.

[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0012] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the embodiments of the present disclosure to explain the disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed description of exemplary embodiments with reference to the accompanying drawings, in which:

[0013] Figure 1A This is a schematic diagram of a rendering process in related technologies.

[0014] Figure 1B This is a schematic diagram of another rendering process in related technologies.

[0015] Figure 2 This is a schematic diagram of a primitive clipping method.

[0016] Figure 3This is a flowchart of a rendering processing method provided in an embodiment of the present disclosure.

[0017] Figure 4 This is a schematic diagram of primitive clipping in a rendering processing method provided in an embodiment of the present disclosure.

[0018] Figure 5 This is a schematic diagram of primitive information in a rendering processing method provided in an embodiment of the present disclosure.

[0019] Figure 6 This is a schematic diagram of a rendering processing method provided in an embodiment of the present disclosure.

[0020] Figure 7 This is a block diagram of a rendering processing apparatus provided in an embodiment of the present disclosure.

[0021] Figure 8 This is a block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0022] To enable those skilled in the art to better understand the technical solutions of this disclosure, exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments of this disclosure to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0023] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.

[0024] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.

[0025] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Words such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.

[0026] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.

[0027] Before detailing the embodiments of this disclosure, some related concepts will be explained for clarity.

[0028] A render target can refer to an object to be rendered, which can be a part of a virtual scene to be rendered, or an image or video frame to be rendered.

[0029] A primitive can refer to the basic geometric shapes that make up a graphic, such as points, lines, and triangles. For example, a graphic drawn by an application can be represented in a computer by a combination of a large number of basic geometric shapes.

[0030] It should be noted that, for ease of understanding, the embodiments of this disclosure will be illustrated using a triangular primitive as an example. The processing of other primitives is similar and will not be repeated here.

[0031] During the graphics rendering process, the graphics processing device can receive vertex data of the rendering object through the Application Programming Interface (API), process it in the order of geometry pipeline and fragment pipeline, and finally display it on the screen.

[0032] Figure 1A This is a schematic diagram of a rendering process in related technologies. (Refer to...) Figure 1AThe rendering process includes the geometry pipeline 11 and the fragment pipeline 12. During rendering, the input vertex data first passes through the geometry pipeline 11. The vertex shader 111 in the geometry pipeline 11 performs coordinate transformations, attribute calculations, and vertex interpolation on the vertices; then, the vertices are converted into primitives through a primitive assembler (not shown in the figure); subsequently, the primitives are transformed into clip space for clipping processing 112; after clipping processing 112, viewport transformation (not shown in the figure) can be performed, specifically: the coordinates of the primitives in clip space are divided by the w component value (the fourth dimension of homogeneous coordinates), transforming them to the normalized device coordinate space (NDC space). The primitives in the normalized device coordinate space are further transformed to the viewport space.

[0033] Primitives transformed into viewport space are processed in fragment pipeline 12. Specifically, the primitives transformed into viewport space undergo triangle setting 121 and rasterization 122 (transferred via memory 13) processing. After processing by triangle setting 121, rasterization 122, early depth testing 123, interpolation processing 124, and fragment shader 125, the primitives are rendered and displayed on the screen. During interpolation processing 124, the necessary primitive data can be retrieved from memory 13.

[0034] It should be noted that surface subdivision and geometry shading in the geometry pipeline are optional processing methods. Figure 1A The early depth test 123 in the fragment pipeline can be implemented in different ways or omitted, and this disclosure does not limit it.

[0035] Figure 1A The rendering process shown is applicable to graphics systems based on direct rendering, where primitives, after being clipped and transformed by the viewport, are directly passed to triangle setup 121 and rasterizer 122 for processing.

[0036] Figure 1B This is a schematic diagram of another rendering process in related technologies. (Refer to...) Figure 1BThe rendering process includes the geometry pipeline 21, tileization 22, and fragmentation pipeline 23. During the rendering process, the input vertex data first passes through the geometry pipeline 21. The vertex shader 211 in the geometry pipeline 21 performs coordinate transformations, attribute calculations, and vertex interpolation on the vertices of primitives; then, the vertices are converted into primitives through a primitive assembler (not shown in the figure); subsequently, the primitives are transformed into clip space for clipping processing 212; after clipping processing 212, viewport transformation (not shown in the figure) can be performed, specifically: the coordinates of the primitives in clip space are divided by the w component value, transformed to the normalized device coordinate space, and the primitives in the normalized device coordinate space are further transformed to the viewport space.

[0037] For primitives transformed into viewport space, the process enters the tileization stage 22, where the primitives can be tiled 221, and the primitives can be assigned to the tiles that they can cover.

[0038] After being tiled (22), primitives enter the fragment pipeline (23). The fragment pipeline (23) processes each tile. Multiple processing hardware components can be used in the fragment pipeline (23) to process different tiles in parallel. Specifically, the processing of tiles in the fragment pipeline (23) involves: triangle setting (231) and rasterization (232, transferred via memory (24)) for each tile; after processing by triangle setting (231), rasterization (232), early depth testing (233), interpolation (234), and fragment shader (235), the tile is rendered and displayed on the screen. During interpolation (234), the required tile data can be retrieved from memory (24).

[0039] Figure 1B The rendering process shown is applicable to tile-based graphics systems. After passing through the geometry pipeline, primitives are tiled, which assigns them to tiles that they can cover. Then, each tile is processed through the fragment pipeline.

[0040] During the rendering process, the data carried by primitives (including attribute data and vertex-related data) is interpolated to the pixels. This interpolation is passed to the fragment shader in the form of a plane equation or sampled values, and participates in the pixel shading process in the fragment shader.

[0041] Since the visible space ultimately mapped to the screen is a finite visible range, primitives that exceed the set clipping plane will be clipped during the clipping process. During clipping, primitives completely outside the clipping plane are discarded, and vertices are regenerated for primitives partially within the clipping plane. In other words, new vertices are generated after clipping the primitives. The results of the interpolation of the various attributes of the new vertices can be determined using the barycentric coordinate interpolation method. The formula for calculating the barycentric coordinate interpolation of triangular primitives is shown in the following formula (1):

[0042] =

[0043] (1)

[0044] In formula (1), The attribute value representing an attribute of the new vertex. The attribute value represents the attribute described in the first vertex of the triangle primitive. The attribute value represents the attribute described in the second vertex of the triangle primitive. This represents the attribute value of the attribute described in the third vertex of the triangle primitive. , , ) represents the barycenter coordinates of the new vertex, and .

[0045] After clipping a primitive, the newly generated vertices will combine with the old vertices to form a new primitive. The fragment pipeline can treat the new primitive as an independent primitive for processing. During the interpolation stage, the attributes of pixels in the clipped primitive can be divided into three categories: attributes whose values ​​are obtained through interpolation, attributes whose attribute values ​​are not required by the fragment shader and are not interpolated, and attributes whose attribute values ​​are required by the fragment shader and are not interpolated.

[0046] When passing pixel information to the fragment shader, for attributes whose values ​​are obtained through interpolation, the interpolated attribute value can be directly passed to the fragment shader. For attributes that the fragment shader does not require passing attribute values ​​and does not perform interpolation, the attribute value of a pre-specified vertex from multiple vertices of the primitive can be passed to the fragment shader. However, for attributes that the fragment shader requires passing attribute values ​​and does not perform interpolation, according to API requirements, the attribute values ​​of the corresponding attribute for each vertex of the primitive before clipping, as well as the centroid coordinates of the pixel relative to the vertices of the primitive before clipping, need to be passed to the fragment shader. However, in related technologies, the attribute values ​​of the corresponding attribute for each vertex of the primitive before clipping and the centroid coordinates of the pixel relative to the vertices of the primitive before clipping are not passed to the fragment shader; or the attribute values ​​and centroid coordinates passed to the fragment shader are incorrect. Both of these will cause deviations in the fragment shader's processing, thus affecting the rendering effect.

[0047] For example, Figure 2 This is a schematic diagram of primitive clipping. (Refer to...) Figure 2 primitives before cropping Figure 2 The primitive in the upper middle section (a triangle primitive composed of vertices V0, V1, and V2) is clipped by the clipping plane represented by the dashed line, generating new vertices NV0, NV1, and NV2. After clipping, three new primitives are generated: a triangle primitive composed of vertices V0, NV0, and V2; a triangle primitive composed of vertices NV0, NV1, and V2; and a triangle primitive composed of vertices NV1, NV2, and V2. After clipping, the vertex data of the primitive before clipping (the triangle primitive composed of vertices V0, V1, and V2) and the three primitives generated after clipping are all passed to the interpolation stage for processing. Figure 2 The vertex data of the four primitives below will be passed to the interpolation stage for processing.

[0048] During the interpolation stage, the three primitives generated after clipping are treated as new primitives. For any vertex, its barycentric coordinates are determined by its order among all vertices of the primitive. For example, in a triangle primitive composed of vertices V0, NV0, and V2, vertex V0 is in the first order with barycentric coordinates (1, 0, 0), vertex NV0 is in the second order with barycentric coordinates (0, 1, 0), and vertex V2 is in the third order with barycentric coordinates (0, 0, 1), which are independent of the primitives before clipping.

[0049] For a pixel in a triangle primitive composed of vertices V0, NV0, and V2, when passing the information of the pixel to the fragment shader, for attributes that the fragment shader requires to be passed without interpolation, the attribute value of the attribute in each vertex of the triangle primitive composed of vertices V0, NV0, and V2 (i.e., the clipped primitive) and the centroid coordinates of the pixel relative to the vertices of the triangle primitive composed of vertices V0, NV0, and V2 (i.e., the clipped primitive) are passed to the fragment shader.

[0050] In other words, when passing the information of a pixel in a clipped primitive to the fragment shader, the fragment shader is required to pass attribute values ​​without interpolation. Instead, it is passing the attribute values ​​of the corresponding attribute at each vertex of the clipped primitive and the centroid coordinates of the pixel relative to the vertices of the clipped primitive. This means that incorrect attribute values ​​and centroid coordinates are being passed, which fails to meet the API requirements. This will cause deviations in the processing of the fragment shader, thus affecting the rendering effect.

[0051] To address the aforementioned technical problems, embodiments of this disclosure provide a rendering processing method. The method includes: in an interpolation stage for rendering an object, determining a clipped first primitive from the primitives of the rendering object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute for which the fragment shader requires the transmission of attribute values ​​and no interpolation processing is needed, determining the first centroid coordinates of the pixel relative to a second primitive, wherein the second primitive is the primitive before clipping corresponding to the first primitive; and sending the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's shading processing of the pixel.

[0052] According to the rendering processing method of this disclosure, in the interpolation stage of rendering the rendering object, the clipped first primitive can be determined from the primitives of the rendering object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute that the fragment shader requires to pass attribute values ​​and does not require interpolation processing, the first centroid coordinates of the pixel relative to the second primitive before clipping are determined, and the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragmentation process. The meta shader's coloring processing of the pixel enables the interpolation stage of the rendering process to pass the pixel information to the fragment shader when the pixel information is passed to the fragment shader. For attributes that the fragment shader requires to be passed without interpolation, the attribute values ​​of the corresponding attributes of each vertex of the primitive before clipping and the centroid coordinates of the pixel relative to the vertices of the primitive before clipping can be passed to the fragment shader. This allows the fragment shader to use the correct attribute values ​​and centroid coordinates to color the pixel, reducing the processing bias of the fragment shader and thus improving the rendering effect.

[0053] The rendering processing method according to embodiments of this disclosure can be executed by an electronic device such as a terminal device or a server. The terminal device can be an in-vehicle device, user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. The method can be implemented by a processor calling computer-readable program instructions stored in memory. Alternatively, the method can be executed by a server.

[0054] Figure 3 A flowchart illustrating a rendering process method provided in an embodiment of this disclosure. (Refer to...) Figure 3 The rendering process includes:

[0055] In step S31, during the interpolation stage of rendering the rendering object, the first clipped primitive is determined from the primitives of the rendering object.

[0056] In step S32, for any pixel in the first primitive, if the pixel has a first attribute in its attributes that the fragment shader requires to pass attribute values ​​and does not require interpolation, the first centroid coordinates of the pixel relative to the second primitive are determined, where the second primitive is the primitive before clipping corresponding to the first primitive.

[0057] In step S33, the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's coloring process for the pixel.

[0058] In some possible implementations, during the rendering process of the rendered object, in the clipping phase, the clipper compares primitives with the screen boundaries and discards portions outside the view frustum. During clipping, primitives entirely outside the view frustum are discarded directly; for primitives partially outside the view frustum, the portion outside the view frustum is clipped, resulting in one or more new primitives. After clipping, the vertex data of the primitives before clipping, the vertex data of the new primitives after clipping, and the vertex data of the unclipped primitives are passed to the interpolation phase.

[0059] In some possible implementations, during the interpolation stage of rendering the rendered object, in step S31, the first clipped primitive can be determined from the primitives of the rendered object based on information such as the primitive type or clipping mark marked during the clipping stage of the rendering process. For example, the primitive type may include unclipped primitives, primitives before clipping, and primitives after clipping. For any primitive of the rendered object, if the type of the primitive is a clipped primitive, then the primitive is determined as the first primitive.

[0060] In some possible implementations, pixels in the first primitive have multiple attributes. For any pixel in the first primitive, the information of that pixel includes the attribute values ​​of multiple attributes. In step S32, it can be determined whether there is a first attribute among the multiple attributes of the pixel that the fragment shader requires to pass attribute values ​​and does not require interpolation processing. If there is a first attribute among the multiple attributes of the pixel that the fragment shader requires to pass attribute values ​​and does not require interpolation processing, the first centroid coordinates of the pixel relative to the second primitive can be determined based on the vertex data of the first primitive and the vertex data of the second primitive passed during the interpolation stage. Here, the second primitive is the primitive before clipping corresponding to the first primitive.

[0061] Figure 4 This is a schematic diagram of primitive clipping in a rendering processing method provided in an embodiment of this disclosure. (Refer to...) Figure 4 The dashed line represents the clipping plane. Before clipping, the primitive consists of vertices 0, 1, and 2. After clipping the primitive according to the clipping plane shown by the dashed line, two new vertices, 3 and 4, are generated, resulting in two new primitives: one consisting of vertices 4, 2, and 0, and the other consisting of vertices 4, 3, and 2.

[0062] During the interpolation stage of rendering the rendered object, the primitive composed of vertex 4, vertex 2 and vertex 0, as well as the primitive composed of vertex 4, vertex 3 and vertex 2, can be identified as the first primitive after clipping; the primitive composed of vertex 0, vertex 1 and vertex 2 can be identified as the second primitive, that is, the primitive before clipping corresponding to the first primitive.

[0063] For any pixel A in the first primitive composed of vertices 4, 2, and 0, if the attributes of pixel A contain a first attribute that the fragment shader requires to pass attribute values ​​and does not require interpolation, the first centroid coordinates of pixel A relative to the second primitive (composed of vertices 0, 1, and 2) can be determined based on the vertex data of the first primitive (composed of vertices 4, 2, and 0) and the vertex data of the second primitive (composed of vertices 0, 1, and 2) passed during the clipping stage.

[0064] In some possible implementations, in step S33, the attribute value of the first attribute of each vertex of the second primitive can be determined, and the first centroid coordinates determined in step S32 and the attribute value of the first attribute of each vertex of the second primitive can be sent to the fragment shader so that the first centroid coordinates and the attribute value of the first attribute of each vertex of the second primitive can be used as references for the shading process of the pixel.

[0065] For example, in the above example, after determining the first centroid coordinates, the attribute values ​​B1, B2, and B3 of the first attribute of vertex 0, vertex 1, and vertex 2 of the second primitive (a primitive composed of vertices 0, 1, and 2) can be determined. Then, the first centroid coordinates, attribute values ​​B1, B2, and B3 are sent to the fragment shader so that they participate in the fragment shader's shading process for pixel A.

[0066] According to the rendering processing method of this disclosure, in the interpolation stage of rendering the rendering object, the clipped first primitive can be determined from the primitives of the rendering object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute that the fragment shader requires to pass attribute values ​​and does not require interpolation processing, the first centroid coordinates of the pixel relative to the second primitive before clipping are determined, and the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragmentation process. The meta shader's coloring processing of the pixel enables the interpolation stage of the rendering process to pass the pixel information to the fragment shader when the pixel information is passed to the fragment shader. For attributes that the fragment shader requires to be passed without interpolation, the attribute values ​​of the corresponding attributes of each vertex of the primitive before clipping and the centroid coordinates of the pixel relative to the vertices of the primitive before clipping can be passed to the fragment shader. This allows the fragment shader to use the correct attribute values ​​and centroid coordinates to color the pixel, reducing the processing bias of the fragment shader and thus improving the rendering effect.

[0067] It should be noted that the second attribute (the attribute whose value is obtained through interpolation) and the third attribute (the attribute whose value is not required to be passed by the fragment shader and is not subject to interpolation) of the pixels in the first primitive can be processed in the conventional way, and will not be elaborated here.

[0068] The rendering processing method according to the embodiments of this disclosure will now be described in detail.

[0069] In some possible implementations, to ensure the correct transfer of pixel attribute values ​​and centroid coordinates of clipped primitives during the interpolation stage of rendering processing, clipping flags and vertex flags can be added to the primitives of the rendering object during the clipping stage of rendering processing. Clipping flags can be used to indicate whether a primitive belongs to the first clipped primitive, the second primitive before clipping, or the third primitive without clipping. In one example, the clipping flag can be represented by two binary bits. For example, a clipping flag value of 00 indicates that the primitive belongs to the second primitive before clipping; a clipping flag value of 01 indicates that the primitive belongs to the first clipped primitive; and a clipping flag value of 10 indicates that the primitive belongs to the third primitive without clipping.

[0070] Vertex flags can be used to indicate whether a vertex belongs to the first vertex before pruning (i.e., an old vertex that already existed before pruning) or the second vertex after pruning (i.e., a new vertex generated after pruning). In one example, a vertex flag can be represented by a single binary bit. For example, a vertex flag value of 0 indicates that the vertex belongs to the first vertex before pruning; a vertex flag value of 1 indicates that the vertex belongs to the second vertex after pruning. It should be noted that the above is only an exemplary description of the implementation of pruning flags and vertex flags. In practical applications, those skilled in the art can determine the specific implementation of pruning flags and vertex flags according to the actual situation, and this disclosure does not impose any limitations on this.

[0071] In some possible implementations, the rendering processing method of this disclosure embodiment may include: in the clipping stage of the rendering processing of the rendering object, determining the clipping flags of the primitives of the rendering object; determining, based on the clipping flags, a second primitive before clipping and the vertex flags of each vertex of the second primitive from the primitives of the rendering object; performing clipping processing on the second primitive to obtain a first primitive after clipping corresponding to the second primitive and the centroid coordinates and attribute values ​​of the vertices in the first primitive resulting from clipping; and determining the clipping flag of the first primitive and the vertex flags of each vertex of the first primitive, respectively.

[0072] During the clipping phase of rendering an object, for any primitive of the rendered object, its positional relationship with the clipping plane is first determined, and then the value of its clipping flag is determined. If the primitive is entirely outside the clipping plane, it is discarded without further processing. If the primitive is entirely within the clipping plane, no clipping is needed, and its clipping flag value can be set to the value of the third primitive (e.g., 10). If the primitive is partially within the clipping plane, it needs to be clipped, and its clipping flag value can be set to the value of the second primitive before clipping (e.g., 00).

[0073] For any second primitive, the vertex flags of each vertex of the second primitive can be determined. Since the second primitive is the primitive before clipping, its vertices are all the first vertices before clipping. Therefore, the vertex flags of all vertices of the second primitive can be set to the values ​​representing the first vertex before clipping (e.g., a value of 0).

[0074] The second primitive can then be clipped to obtain the corresponding first primitive. That is, the first primitive is the new primitive generated after clipping the second primitive. For vertices in the first primitive resulting from clipping, the centroid coordinates and position coordinates of these vertices can be determined based on the clipping method. For example, if the clipping method involves calculating the intersection of an edge of the clipped second primitive with the clipping plane, then the position coordinates of the resulting vertex (i.e., the intersection) can be determined first, and then the centroid coordinates of that vertex can be obtained through centroid coordinate interpolation. These centroid coordinates are relative to the centroid coordinates of the second primitive before clipping. If the clipping method involves first determining the intersection of an edge of the clipped second primitive with the clipping plane, and then calculating the ratio of the intersection to the vertex of that edge, then the centroid coordinates of the resulting vertex can be determined first, and then the position coordinates of that vertex can be obtained through centroid coordinate interpolation. After obtaining the centroid coordinates of the vertices resulting from the clipping, the attribute values ​​of the vertices resulting from the clipping can be determined by centroid coordinate interpolation based on the attribute values ​​of each vertex of the second primitive and the centroid coordinates.

[0075] For any first primitive, its clipping flag can be set to the value representing the clipped first primitive (e.g., 01). For any vertex of the first primitive, if the vertex is the old vertex before clipping (i.e., a vertex in the second primitive), its vertex flag is set to the value representing the first vertex before clipping (e.g., 0); if the vertex is a new vertex generated after clipping, its vertex flag is set to the value representing the second vertex after clipping (e.g., 1). Based on the values ​​of the vertex flags of the vertices of the first primitive, the vertices in the first primitive can be divided into the first vertex before clipping and the second vertex after clipping.

[0076] In the embodiments of this disclosure, during the clipping stage of rendering the rendered object, the clipping flags of the primitives of the rendered object can be determined. Based on the clipping flags, the second primitive before clipping and the vertex flags of the vertices of the second primitive are determined from the primitives of the rendered object. Then, the second primitive is clipped to obtain the clipped first primitive corresponding to the second primitive and the centroid coordinates and attribute values ​​of the vertices in the first primitive caused by clipping. Then, the clipping flag of the first primitive and the vertex flags of each vertex of the first primitive are determined. Thus, during the clipping stage, the clipping flags of the primitives and the vertex flags of each vertex of the primitives can be determined while clipping the primitives of the rendered object. This facilitates the rapid determination of the primitives before and after clipping and the new and old vertices in the primitives during the interpolation stage, improving processing efficiency.

[0077] In some possible implementations, the method further includes: storing the primitive information of the first primitive and the primitive information of the second primitive in a preset storage area; wherein the primitive information of the first primitive includes the clipping flag of the first primitive, the vertex index and vertex flag of each vertex, the centroid coordinates and attribute values ​​of the vertices generated by clipping, and the primitive information of the second primitive includes the clipping flag of the second primitive, the vertex index, vertex flag and attribute values ​​of each vertex; wherein, before sending the attribute values ​​of the first attribute of each vertex of the second primitive to the fragment shader, the method further includes: obtaining the attribute values ​​of the first attribute of each vertex of the second primitive from the storage area.

[0078] After obtaining the first primitive, the primitive information of the first primitive and the primitive information of the second primitive can be determined. The primitive information of the first primitive may include the clipping flag of the first primitive, the vertex indices and vertex labels of each vertex of the first primitive, and the centroid coordinates and attribute values ​​of the vertices resulting from the clipping of the first primitive. The primitive information of the second primitive may include the clipping flag of the second primitive, the vertex indices, vertex labels, and attribute values ​​of each vertex of the second primitive. Then, the primitive information of the first primitive and the primitive information of the second primitive are stored in a preset storage area. The preset storage area can be on-chip cache or off-chip video memory; this disclosure does not impose any limitations on this.

[0079] During the interpolation stage of the rendering process, before sending pixel information to the fragment shader, the attribute values ​​of the first attribute of each vertex of the second primitive can be obtained from a preset storage area.

[0080] In the embodiments of this disclosure, the primitive information of the first primitive and the primitive information of the second primitive can be stored in a preset storage area for use in the interpolation stage.

[0081] In some possible implementations, when storing the primitive information of the second primitive in a preset storage area, storage space can be allocated for the centroid coordinates of each vertex of the second primitive, but invalid centroid coordinate values ​​can be stored therein. This method enables normalized management of vertex storage space, thereby improving processing efficiency during data access.

[0082] In some possible implementations, since the centroid coordinates of the second primitive are dynamically determined according to the order of the vertices during the interpolation stage, when storing the primitive information of the second primitive in the preset storage area, storage space may not be allocated for the centroid coordinates of the vertices of the second primitive, thereby saving storage space.

[0083] In some possible implementations, the rendering processing method of this disclosure embodiment further includes: determining an uncropped third primitive from the primitives of the rendering object according to the clipping flag; and for any third primitive, determining the vertex flags of each vertex of the third primitive.

[0084] The uncropped third primitive can be identified from the primitives of the rendered object based on the clipping flag. In other words, the third primitive is a primitive that lies entirely within the clipping plane and requires no clipping. For any third primitive, vertex flags can be set for its vertices. Since the third primitive is not clipped, the vertex flags of all its vertices can be set to the values ​​representing the first vertex before clipping (e.g., a value of 0).

[0085] The primitive information of the third primitive can also be determined, including the clipping flag of the third primitive, the attribute values ​​of each vertex of the third primitive, the vertex flag, the vertex index, and the centroid coordinates of the vertex, and the primitive information of the third primitive is stored in the preset storage area for use in the interpolation stage.

[0086] In the embodiments of this disclosure, an uncropped third primitive can be determined from the primitives of the rendered object based on a clipping flag; for any third primitive, the vertex flags of its vertices are determined. By setting vertex flags for the third primitive, the implementation of the vertex flags of the unclipped third primitive is kept consistent with that of the second primitive before clipping and the first primitive after clipping, which is beneficial for program implementation and less prone to errors.

[0087] In some possible implementations, the primitive information of the first primitive may further include the position coordinates of the vertices resulting from clipping; the primitive information of the second primitive may further include the position coordinates of each vertex; and the primitive information of the third primitive may further include the position coordinates of each vertex. In this way, the position coordinates of the vertices can be added to the primitive information, facilitating their use in subsequent processing.

[0088] Figure 5 This is a schematic diagram of primitive information in a rendering processing method provided in an embodiment of this disclosure. (Refer to...) Figure 5 The primitive information includes Figure 4 The diagram shows the primitive information of all primitives, and classifies the primitive information, including: the second primitive 510 before clipping, the first primitive 520 after clipping, the third primitive 530 without clipping, the vertex position coordinates 540, the vertex attribute values, and the centroid coordinates 550. The second primitive 510 before clipping, the first primitive 520 after clipping, and the third primitive 530 without clipping are classified according to the values ​​of the clipping flag.

[0089] The second primitive 510 before clipping consists of one primitive, composed of vertices 0, 1, and 2, and is determined by the vertex indices of vertices 0, 2, and 3. The first primitive 520 after clipping consists of two primitives. The first primitive is composed of vertices 4, 2, and 0, and is determined by the vertex indices of vertices 4, 2, and 0. The second primitive is composed of vertices 4, 3, and 2, and is determined by the vertex indices of vertices 4, 3, and 2. In this example, there are no unclipped primitives, and the unclipped third primitive 530 is empty.

[0090] The vertex position coordinates 540 include the position coordinates of vertex 0, vertex 1, vertex 2, vertex 3, and vertex 4. The position coordinates of each vertex can be determined in the primitive information through the vertex index of each vertex.

[0091] The attribute values ​​and centroid coordinates of vertices 550 include the 32 attribute values ​​of vertex 0 (i.e., the first attribute value of vertex 0, ..., the 32nd attribute value of vertex 0) and the centroid coordinates of vertex 0; the 32 attribute values ​​of vertex 1 (i.e., the first attribute value of vertex 1, ..., the 32nd attribute value of vertex 1) and the centroid coordinates of vertex 1; the 32 attribute values ​​of vertex 2 (i.e., the first attribute value of vertex 2, ..., the 32nd attribute value of vertex 2) and the centroid coordinates of vertex 2; the 32 attribute values ​​of vertex 3 (i.e., the first attribute value of vertex 3, ..., the 32nd attribute value of vertex 3) and the centroid coordinates of vertex 3; and the 32 attribute values ​​of vertex 4 (i.e., the first attribute value of vertex 4, ..., the 32nd attribute value of vertex 4) and the centroid coordinates of vertex 4.

[0092] When determining the primitive information of each primitive, the clipping flag of the primitive, the attribute values ​​of the primitive's vertices, the vertex flag, the centroid coordinates, position coordinates, and vertex index of the vertex can be obtained from the above categories.

[0093] The primitive information of the second primitive composed of vertex 0, vertex 1, and vertex 2 includes: the clipping flag of the second primitive (e.g., value 00), the vertex index and vertex flag of vertex 0 (e.g., value 0), the vertex index and vertex flag of vertex 1 (e.g., value 0), the vertex index and vertex flag of vertex 2 (e.g., value 0), the position coordinates of vertex 0, the position coordinates of vertex 1, the position coordinates of vertex 2, the 32 attribute values ​​of vertex 0 (i.e., the first attribute value of vertex 0, ..., the 32nd attribute value of vertex 0) and the centroid coordinates of vertex 0, the 32 attribute values ​​of vertex 1 (i.e., the first attribute value of vertex 1, ..., the 32nd attribute value of vertex 1) and the centroid coordinates of vertex 1, the 32 attribute values ​​of vertex 2 (i.e., the first attribute value of vertex 2, ..., the 32nd attribute value of vertex 2) and the centroid coordinates of vertex 2. Since this primitive is the second primitive before clipping, the centroid coordinates in its primitive information need to be determined according to the vertex order in subsequent processing. When storing, the centroid coordinates of vertex 0, vertex 1, and vertex 2 are all invalid centroid coordinate values.

[0094] The primitive information of the clipped first primitive, composed of vertices 4, 2, and 0, includes: the clipping flag of the first primitive (e.g., value 01), the vertex index and vertex flag of vertex 4 (e.g., value 1), the vertex index and vertex flag of vertex 2 (e.g., value 0), the vertex index and vertex flag of vertex 0 (e.g., value 0), the position coordinates of vertex 0, the position coordinates of vertex 2, the position coordinates of vertex 4, the 32 attribute values ​​of vertex 4 (i.e., the first attribute value of vertex 4, ..., the 32nd attribute value of vertex 4), and the centroid coordinates of vertex 4. The position coordinates and centroid coordinates of vertex 4 are obtained after clipping, and its attribute values ​​can then be obtained through centroid coordinate interpolation.

[0095] The primitive information of the first primitive composed of vertices 4, 3, and 2 includes: the clipping flag of the first primitive (e.g., value 01), the vertex index and vertex flag of vertex 4 (e.g., value 1), the vertex index and vertex flag of vertex 3 (e.g., value 1), the vertex index and vertex flag of vertex 2 (e.g., value 0), the position coordinates of vertex 2, the position coordinates of vertex 3, the position coordinates of vertex 4, the 32 attribute values ​​of vertex 3 (i.e., the first attribute value of vertex 3, ..., the 32nd attribute value of vertex 3), the centroid coordinates of vertex 3, the 32 attribute values ​​of vertex 4 (i.e., the first attribute value of vertex 4, ..., the 32nd attribute value of vertex 4), and the centroid coordinates of vertex 4. For vertices 3 and 4, their position coordinates and centroid coordinates can be obtained after clipping, and their attribute values ​​can then be obtained through centroid coordinate interpolation.

[0096] The correspondence between the second primitive before clipping and the first primitive after clipping can be determined using the vertex indices of shared vertices. For any vertex, its attribute values, centroid coordinates, position coordinates, and the primitive it belongs to can all be determined using its vertex index. Figure 5 The classification shown allows for the storage of primitive information, thereby saving storage space.

[0097] It should be noted that, Figure 5 Each vertex shown has 32 attribute values. In practical applications, those skilled in the art can set the specific number of attribute values ​​for each vertex according to the actual situation, and this disclosure does not impose any restrictions on this.

[0098] In some possible implementations, step S31 may include: determining a clipped first primitive from the primitives of the rendered object based on a clipping flag, wherein the clipping flag indicates that the primitive belongs to a clipped first primitive, a pre-clipping second primitive, or an unclipped third primitive.

[0099] During the clipping stage of rendering the rendered object, clipping flags for each primitive of the rendered object are determined. These clipping flags indicate whether a primitive belongs to the clipped first primitive, the un-clipped second primitive, or the unclipped third primitive. During the interpolation stage, the clipping flags for each primitive of the rendered object can be obtained. If the primitive information of the first, second, and third primitives is stored in a preset storage area during the clipping stage, the clipping flags for each primitive of the rendered object can be obtained from this storage area during the interpolation stage.

[0100] Then, based on the value of the clipping flag, the first primitive after clipping is determined. For example, for any primitive of the rendering object, if the value of the clipping flag is 00, the primitive can be determined to be the second primitive before clipping; if the value of the clipping flag is 01, the primitive can be determined to be the first primitive after clipping; if the value of the clipping flag is 10, the primitive can be determined to be the third primitive that has not been clipped.

[0101] In the embodiments of this disclosure, the first clipped primitive can be determined from the primitives of the rendered object during the interpolation stage based on the clipping flag of the primitive determined in the clipping stage. This is simple and fast, thereby improving processing efficiency.

[0102] In some possible implementations, step S32 may include: determining a first vertex that existed before clipping and a second vertex that was generated after clipping in the first primitive based on the vertex markers of the vertices of the first primitive; determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive; determining the third centroid coordinates of the pixel relative to the first primitive based on the position information of the pixel; and determining the first centroid coordinates of the pixel relative to the second primitive based on the second centroid coordinates and the third centroid coordinates.

[0103] During the clipping phase of rendering the rendered object, the vertex markers of each vertex of the primitive are determined. These vertex markers indicate whether a vertex belongs to the first vertex before clipping (i.e., an existing vertex before clipping) or the second vertex after clipping (i.e., a new vertex generated after clipping). During the interpolation phase, the vertex markers of each vertex of the first primitive can be obtained. If the primitive information of the first primitive is stored in a preset storage area during the clipping phase, the vertex markers of each vertex of the first primitive can be obtained from this storage area during the interpolation phase.

[0104] Then, based on the vertex flag values ​​of the vertices in the first primitive, the first vertex existing before clipping and the second vertex generated after clipping are determined. For example, for any vertex in the first primitive, if the vertex flag value is 0, then the vertex can be determined as the first vertex before clipping; if the vertex flag value is 1, then the vertex can be determined as the second vertex after clipping. After obtaining the first and second vertices, the second centroid coordinates of the first vertex relative to the second primitive (i.e., the primitive before clipping) and the second centroid coordinates of the second vertex relative to the second primitive can be determined respectively.

[0105] Based on the pixel's position information, such as its coordinates, the third centroid coordinates of the pixel relative to the first primitive (i.e., the cropped primitive) can be determined through centroid coordinate interpolation. Then, based on the second centroid coordinates of each vertex of the first primitive relative to the second primitive and the third centroid coordinates of the pixel relative to the first primitive, the first centroid coordinates of the pixel relative to the second primitive are determined. In other words, the calculation of the first centroid coordinates of the pixel relative to the second primitive is not a direct calculation, but rather a calculation using the vertices of the first primitive as a medium.

[0106] In the embodiments of this disclosure, the first vertex existing before clipping and the second vertex generated after clipping in the first primitive can be determined based on the vertex markers of the vertices of the first primitive, and the second centroid coordinates of the first vertex and the second vertex relative to the second primitive can be determined respectively; then, the third centroid coordinates of the pixel relative to the first primitive can be determined based on the position information of the pixel, and the first centroid coordinates of the pixel relative to the second primitive can be determined based on the second centroid coordinates and the third centroid coordinates. Thus, the first centroid coordinates of the pixel relative to the second primitive can be calculated using each vertex of the first primitive as a medium, which is easy to understand and implement and improves processing efficiency.

[0107] Furthermore, using the vertices of the first primitive as a medium to calculate the first centroid coordinates of the pixels of the first primitive relative to the second primitive is applicable not only to scenarios where the rotation order of the vertices of the first primitive (e.g., clockwise) is the same as that of the vertices of the second primitive (e.g., clockwise), but also to scenarios where the rotation order of the vertices of the first primitive (e.g., counterclockwise) is different from that of the vertices of the second primitive (e.g., clockwise). This allows for automatic handling of cases where the rotation order of the first primitive and the second primitive is different, improving both the accuracy of the first centroid coordinates and the processing efficiency when calculating them.

[0108] In some possible implementations, determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: determining the centroid coordinates of the second vertex determined in the clipping stage of the rendering process as the second centroid coordinates of the second vertex relative to the second primitive.

[0109] Since the second vertex is a new vertex created by clipping, the centroid coordinates determined during the clipping stage are the centroid coordinates of this vertex relative to the second primitive before clipping. These centroid coordinates are passed to the interpolation stage along with the primitive information of the first primitive. Therefore, for the second vertex, the centroid coordinates determined during the clipping stage of the rendering process can be directly used as the second centroid coordinates of the second vertex relative to the second primitive. In this way, the second centroid coordinates of the new vertex after clipping relative to the second primitive can be quickly determined during the interpolation stage, reducing the computational load of the interpolation stage and saving processor resources.

[0110] In some possible implementations, determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: determining the order of the first vertex in the vertices of the second primitive based on the vertex index of the first vertex in the first primitive and the vertex indices of each vertex in the second primitive; and determining the second centroid coordinates of the first vertex relative to the second primitive based on the order.

[0111] Vertex indices can be used to uniquely identify vertices. When determining the second centroid coordinates of the first vertex relative to the second primitive, the vertex index of the first vertex in the first primitive and the vertex indices of each vertex in the second primitive can be determined separately. Then, through methods such as searching and comparing, the order of the first vertex among the vertices of the second primitive can be determined. Here, the vertex order refers to the order of that vertex among all vertices of its own primitive.

[0112] For example, if the second primitive is composed of vertices 0, 1, and 2, then vertex 0 has the first order of vertices in this second primitive, vertex 1 has the second order, and vertex 2 has the third order. When the first primitive is composed of vertices 4, 2, and 0, the first vertex has two values: vertex 2 and vertex 0. If the first vertex is vertex 2, then vertex 2 has the third order of vertices in the second primitive. If the first vertex is vertex 0, then vertex 0 has the first order of vertices in the second primitive.

[0113] Then, based on the order of the first vertex among the vertices of the second primitive, the second centroid coordinates of the first vertex relative to the second primitive can be determined.

[0114] In the embodiments of this disclosure, for the old vertices (i.e., the first vertex) in the clipped first primitive, the order of the first vertex in the vertices of the second primitive before clipping can be quickly and accurately determined based on the vertex index, and the second centroid coordinates of the first vertex relative to the second primitive can be determined according to this order. In this way, the second centroid coordinates of the old vertices in the clipped first primitive in the old primitive before clipping can be determined in real time during use, thereby improving the accuracy of the second centroid coordinates.

[0115] Because the second centroid coordinates of the first vertex in the first primitive relative to the second primitive are determined in real time, it is unnecessary to independently store the centroid coordinates of the first vertex shared by multiple clipped first primitives in each primitive, thus saving storage space. For example, Figure 4 The first primitives in the diagram include two types: one composed of vertices 4, 2, and 0, and the other composed of vertices 4, 3, and 2. Both primitives share vertex 2 as their first vertex. Since vertex 2 is in the second order among the vertices of the primitive composed of vertices 4, 2, and 0, but in the third order among the vertices of the primitive composed of vertices 4, 3, and 2, its centroid coordinates differ between the two primitives. In related technologies, the centroid coordinates of vertex 2 in these two primitives need to be stored separately. However, in the embodiments of this disclosure, the centroid coordinates of vertex 2 can be calculated in real time without storage, thus saving storage space.

[0116] In some possible implementations, determining the second centroid coordinates of the first vertex relative to the second primitive according to the order includes any of the following: when the order is the first order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (1, 0, 0); when the order is the second order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 1, 0); when the order is the third order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 0, 1).

[0117] When the first vertex is in the first order of the vertices of the second primitive, its second centroid coordinates relative to the second primitive can be determined as (1, 0, 0). When the first vertex is in the second order of the vertices of the second primitive, its second centroid coordinates relative to the second primitive can be determined as (0, 1, 0). When the first vertex is in the third order of the vertices of the second primitive, its second centroid coordinates relative to the second primitive can be determined as (0, 0, 1). This method of mapping order to centroid coordinates is not only easy to implement but also fast to execute, thus improving processing efficiency.

[0118] In some possible implementations, during the interpolation stage of rendering the rendered object, the second primitive before clipping can be determined based on the primitive's clipping flag, and then the primitive information of the second primitive can be stored in a preset cache area for use when processing the first primitive after clipping the second primitive.

[0119] In some possible implementations, during the interpolation stage of rendering the rendered object, the uncropped third primitive can be determined based on the primitive's clipping flag. The pixels of the third primitive can be processed using conventional methods, which will not be elaborated upon in this disclosure.

[0120] Figure 6 This is a schematic diagram illustrating a rendering processing method provided in an embodiment of this disclosure. (Refer to...) Figure 6 The rendering process includes two stages: clipping and interpolation. The clipping stage includes steps S601 to S604, and the interpolation stage includes steps S601 to S611, as detailed below:

[0121] Step S601: In the clipping stage of rendering the rendered object, determine the clipping flags of the primitives of the rendered object.

[0122] Step S602: Based on the clipping flags, determine the second primitive before clipping and the vertex flags of each vertex of the second primitive from the primitives of the rendered object.

[0123] Step S603: Perform a clipping process on the second primitive to obtain the clipped first primitive corresponding to the second primitive and the centroid coordinates and attribute values ​​of the vertices in the first primitive caused by the clipping.

[0124] Step S604: Determine the clipping flag of the first primitive and the vertex flags of each vertex of the first primitive respectively;

[0125] Step S605: In the interpolation stage of rendering the rendering object, the first clipped primitive is determined from the primitives of the rendering object.

[0126] Step S606: For any pixel in the first primitive, if the pixel has a first attribute in its attributes that the fragment shader requires to pass attribute values ​​and does not require interpolation, determine the first vertex that existed before clipping and the second vertex that was generated after clipping in the first primitive based on the vertex flags of the first primitive's vertices.

[0127] Step S607: Determine the centroid coordinates of the second vertex, which are determined during the clipping stage of the rendering process, as the second centroid coordinates of the second vertex relative to the second primitive.

[0128] Step S608: Based on the vertex index of the first vertex in the first primitive and the vertex indices of each vertex of the second primitive, determine the order of the first vertex in the vertices of the second primitive, and based on this order, determine the second centroid coordinates of the first vertex relative to the second primitive.

[0129] Step S609: Determine the third centroid coordinates of the pixel relative to the first primitive based on the pixel's position information;

[0130] Step S610: Determine the first centroid coordinates of the pixel relative to the second primitive based on the second centroid coordinates and the third centroid coordinates.

[0131] Step S611: Send the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's shading process for the pixel.

[0132] The embodiments provided in this disclosure, during the interpolation stage of rendering the rendered object, can determine the clipped first primitive from the primitives of the rendered object; for any pixel in the first primitive, if the pixel's attributes contain a first attribute that the fragment shader requires to pass attribute values ​​and does not require interpolation processing, the first centroid coordinates of the pixel relative to the second primitive before clipping are determined, and the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in fragment shading. The fragment shader performs color processing on the pixel, enabling it to handle pixel information in the clipped primitive during the interpolation stage of the rendering process. For attributes that the fragment shader requires to be passed without interpolation, the fragment shader can pass the attribute values ​​of the corresponding vertices of the primitive before clipping and the centroid coordinates of the pixel relative to the vertices of the primitive before clipping. This allows the fragment shader to use the correct attribute values ​​and centroid coordinates to color the pixel, reducing processing bias and improving rendering quality.

[0133] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0134] In addition, this disclosure also provides rendering processing apparatus, electronic devices, and computer-readable storage media, all of which can be used to implement any of the rendering processing methods provided in this disclosure. The corresponding technical solutions and descriptions are described in the corresponding descriptions in the method section, and will not be repeated here.

[0135] Figure 7 This is a block diagram of a rendering processing apparatus provided in an embodiment of the present disclosure.

[0136] Reference Figure 7 This disclosure provides a rendering processing apparatus, which includes:

[0137] The primitive determination module 71 is used to determine the first clipped primitive from the primitives of the rendering object during the interpolation stage of rendering the rendering object.

[0138] The centroid coordinate determination module 72 determines the first centroid coordinates of any pixel in the first primitive if the pixel has a first attribute in its attributes that requires the fragment shader to pass attribute values ​​and does not require interpolation. The second primitive is the primitive before clipping corresponding to the first primitive.

[0139] The sending module 73 is used to send the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the shading process of the fragment shader on the pixel.

[0140] In some possible implementations, the centroid coordinate determination module 72 is configured to: determine a first vertex existing before clipping and a second vertex generated after clipping in the first primitive based on the vertex markers of the vertices of the first primitive; determine the second centroid coordinates of the first vertex and the second vertex relative to the second primitive, respectively; determine the third centroid coordinates of the pixel relative to the first primitive based on the position information of the pixel; and determine the first centroid coordinates of the pixel relative to the second primitive based on the second centroid coordinates and the third centroid coordinates.

[0141] In some possible implementations, determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: determining the order of the first vertex in the vertices of the second primitive based on the vertex index of the first vertex in the first primitive and the vertex indices of each vertex of the second primitive; and determining the second centroid coordinates of the first vertex relative to the second primitive based on the order.

[0142] In some possible implementations, determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: determining the centroid coordinates of the second vertex determined in the clipping stage of the rendering process as the second centroid coordinates of the second vertex relative to the second primitive.

[0143] In some possible implementations, the primitive determination module 71 is configured to: determine a first primitive after clipping from the primitives of the rendering object based on a clipping flag, wherein the clipping flag indicates that the primitive belongs to the first primitive after clipping, the second primitive before clipping, or the third primitive before clipping.

[0144] In some possible implementations, the apparatus further includes: a first flag determination module, configured to determine a clipping flag of the primitives of the rendering object during the clipping stage of the rendering process; a second flag determination module, configured to determine, based on the clipping flag, a second primitive before clipping and vertex flags of each vertex of the second primitive from the primitives of the rendering object; a clipping module, configured to perform clipping processing on the second primitive to obtain a clipped first primitive corresponding to the second primitive and the centroid coordinates and attribute values ​​of the vertices in the first primitive resulting from clipping; and a third flag determination module, configured to determine the clipping flag of the first primitive and the vertex flags of each vertex of the first primitive, respectively.

[0145] In some possible implementations, the device further includes: a storage module for storing the primitive information of the first primitive and the primitive information of the second primitive in a preset storage area; wherein the primitive information of the first primitive includes a clipping flag of the first primitive, vertex indexes and vertex markers of each vertex, centroid coordinates and attribute values ​​of vertices resulting from clipping, and the primitive information of the second primitive includes a clipping flag of the second primitive, vertex indexes, vertex markers and attribute values ​​of each vertex; wherein the device further includes: an acquisition module for acquiring attribute values ​​of the first attribute of each vertex of the second primitive from the storage area.

[0146] In some possible implementations, the module further includes: an uncropped primitive determination module, configured to determine an uncropped third primitive from the primitives of the rendered object based on the clipping flag; and a fourth flag determination module, configured to determine the vertex flags of each vertex of any third primitive.

[0147] In some possible implementations, determining the second centroid coordinates of the first vertex relative to the second primitive according to the order includes any of the following: when the order is the first order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (1, 0, 0); when the order is the second order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 1, 0); when the order is the third order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 0, 1).

[0148] Figure 8 This is a block diagram of an electronic device provided in an embodiment of the present disclosure.

[0149] Reference Figure 8This disclosure provides an electronic device, which includes: at least one processor 701; at least one memory 702; and one or more I / O interfaces 703 connected between the processor 701 and the memory 702; wherein the memory 702 stores one or more computer programs that can be executed by at least one processor 701, and the one or more computer programs are executed by at least one processor 701 to enable at least one processor 701 to perform the above-described rendering processing method.

[0150] This disclosure also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the rendering processing method described above. The computer-readable storage medium may be volatile or non-volatile.

[0151] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the above-described rendering processing method.

[0152] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).

[0153] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable program instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

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

[0155] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0156] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0157] Various aspects of this 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 this disclosure. It should 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.

[0158] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

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

[0160] The flowcharts and block diagrams in the accompanying drawings 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 a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0161] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.

Claims

1. A rendering processing method, characterized in that, include: In the interpolation stage of rendering the rendered object, the first clipped primitive is determined from the primitives of the rendered object; For any pixel in the first primitive, if the pixel has a first attribute in its attributes that the fragment shader requires to pass attribute values ​​and does not require interpolation, determine the first centroid coordinates of the pixel relative to the second primitive, where the second primitive is the primitive before clipping corresponding to the first primitive. The first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive are sent to the fragment shader so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the fragment shader's shading process for the pixel.

2. The method according to claim 1, characterized in that, Determining the first centroid coordinates of the pixel relative to the second primitive includes: Based on the vertex markers of the vertices of the first primitive, determine the first vertex that existed before clipping and the second vertex that was generated after clipping in the first primitive; Determine the second centroid coordinates of the first vertex and the second vertex relative to the second primitive; Based on the position information of the pixel, determine the third centroid coordinates of the pixel relative to the first graphic element; Based on the second centroid coordinates and the third centroid coordinates, the first centroid coordinates of the pixel relative to the second primitive are determined.

3. The method according to claim 2, characterized in that, Determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: The order of the first vertex in the vertices of the second primitive is determined based on the vertex index of the first vertex in the first primitive and the vertex indexes of each vertex of the second primitive. Based on the order, the second centroid coordinates of the first vertex relative to the second primitive are determined.

4. The method according to claim 2, characterized in that, Determining the second centroid coordinates of the first vertex and the second vertex relative to the second primitive includes: The centroid coordinates of the second vertex determined in the clipping stage of the rendering process are used as the second centroid coordinates of the second vertex relative to the second primitive.

5. The method according to claim 1, characterized in that, Determining the first clipped primitive from the primitives of the rendered object includes: Based on the clipping flag of the primitive, the first clipped primitive is determined from the primitives of the rendered object. The clipping flag is used to indicate whether the primitive belongs to the first clipped primitive, the second primitive before clipping, or the third primitive before clipping.

6. The method according to claim 1, characterized in that, The method further includes: During the clipping stage of rendering the rendered object, the clipping flags of the primitives of the rendered object are determined; Based on the clipping flag, determine the second primitive before clipping and the vertex flags of each vertex of the second primitive from the primitives of the rendered object; The second primitive is cropped to obtain the cropped first primitive corresponding to the second primitive, as well as the centroid coordinates and attribute values ​​of the vertices in the first primitive caused by the cropping. The clipping flag of the first graphic element and the vertex flag of each vertex of the first graphic element are determined respectively.

7. The method according to claim 6, characterized in that, The method further includes: The primitive information of the first primitive and the primitive information of the second primitive are stored in a preset storage area; wherein, the primitive information of the first primitive includes the clipping flag of the first primitive, the vertex index and vertex flag of each vertex, the centroid coordinates and attribute values ​​of the vertices generated by clipping, and the primitive information of the second primitive includes the clipping flag of the second primitive, the vertex index, vertex flag and attribute values ​​of each vertex. The method further includes, before sending the attribute values ​​of the first attribute of each vertex of the second primitive to the fragment shader: From the storage area, obtain the attribute values ​​of the first attribute of each vertex of the second primitive.

8. The method according to claim 6, characterized in that, The method further includes: Based on the clipping flag, determine the uncropped third primitive from the primitives of the rendered object; For any third primitive, determine the vertex markers of each vertex of the third primitive.

9. The method according to claim 3, characterized in that, Determining the second centroid coordinates of the first vertex relative to the second primitive according to the order includes any one of the following: In the case that the order is the first order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (1, 0, 0). In the case that the order is the second order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 1, 0). In the case of the third order, the second centroid coordinates of the first vertex relative to the second primitive are determined to be (0, 0, 1).

10. A rendering processing apparatus, characterized in that, include: The primitive determination module is used to determine the first clipped primitive from the primitives of the rendering object during the interpolation stage of rendering the rendering object. The centroid coordinate determination module determines the first centroid coordinates of any pixel in the first primitive if the pixel has a first attribute in its attributes that requires the fragment shader to pass attribute values ​​and does not require interpolation. The second primitive is the primitive before clipping corresponding to the first primitive. The sending module is used to send the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive to the fragment shader, so that the first centroid coordinates and the attribute values ​​of the first attributes of each vertex of the second primitive participate in the shading process of the fragment shader on the pixel.

11. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the rendering processing method as described in any one of claims 1-9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the rendering processing method as described in any one of claims 1-9.

13. A computer program product, characterized in that, Includes computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the rendering processing method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Grid point data visualization method and system adaptable to WebGIS (Web Geographic Information System) platform

    CN114491351A

  • Graph rendering method and system based on GLSL shader

    CN119313799A