Graphics processing unit, primitive output method, chip, server and electronic device

By designing a geometry processing pipeline in a graphics processor, multiple primitive data types can be output using a single drawing instruction. This solves the performance consumption problem caused by multiple drawing instructions in existing technologies and improves the performance efficiency of the graphics processor.

WO2026145455A1PCT designated stage Publication Date: 2026-07-09MOORE THREADS TECHNOLOGY (CHENGDU) CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
MOORE THREADS TECHNOLOGY (CHENGDU) CO LTD
Filing Date
2025-12-29
Publication Date
2026-07-09

AI Technical Summary

Technical Problem

Existing graphics processors can only output primitive data of one primitive type when responding to user-input drawing commands. Multiple drawing commands are required to obtain primitive data of multiple types, resulting in excessive performance consumption.

Method used

A graphics processor is provided that can output primitive data of at least two primitive types, including points, lines and triangles, through a single drawing instruction, and achieve the output of multiple primitive types by utilizing the mesh shading rendering pipeline in the geometry processing pipeline.

Benefits of technology

It reduces the performance overhead of the graphics processor, improves the performance efficiency of the graphics processor, and avoids the performance consumption of multiple drawing instructions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025146775_09072026_PF_FP_ABST
    Figure CN2025146775_09072026_PF_FP_ABST
Patent Text Reader

Abstract

The present application belongs to the field of chips. Disclosed are a graphics processing unit, a primitive output method, a chip, a server and an electronic device. The graphics processing unit comprises a geometry processing pipeline. The geometry processing pipeline is used for executing graphics drawing on the basis of a first drawing instruction, so as to obtain a drawing result, wherein the drawing result comprises primitive data of at least two primitive types, the at least two primitive types comprise at least two of points, lines and triangles, and the first drawing instruction is used for instructing the geometry processing pipeline to implement a geometry processing function in a mesh shading rendering pipeline. In the present application, primitive data of a plurality of primitive types can be simply obtained by means of one drawing instruction, which avoids the situation where primitive data of a plurality of primitive types can be obtained only by performing repeated drawing by means of a plurality of drawing instructions, thereby reducing the performance overheads of the graphics processing unit.
Need to check novelty before this filing date? Find Prior Art

Description

Graphics processors, primitive output methods, chips, servers and electronic devices

[0001] This application claims priority to Chinese Patent Application No. 202411997333.6, filed on December 31, 2024, entitled "Graphics Processor, Primitive Output Method, Chip, Server and Electronic Device", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of chips, and in particular to a graphics processor, a primitive output method, a chip, a server, and an electronic device. Background Technology

[0003] The Graphics Processing Unit (GPU) provides the VTG rendering pipeline. The geometry processing pipeline within the VTG pipeline consists of vertex shaders, tessellation shaders (including shell shaders, tessellation units, and domain shaders), and geometry shaders. In the VTG rendering pipeline, vertex shaders and geometry shaders are processed sequentially, which limits the efficiency of parallel computation and can easily lead to performance bottlenecks.

[0004] The graphics processors of the related technologies provide a mesh shading rendering pipeline. The geometry processing pipeline in the mesh shading rendering pipeline includes an amplification shader and a mesh shader. The mesh shader can process multiple vertices and fragments in parallel, which improves the performance of the graphics processor.

[0005] In related technologies, in response to a drawing command input by the user, the output of the geometry processing pipeline in the mesh shading rendering pipeline only includes primitive data of one primitive type. When the user needs to obtain primitive data of different primitive types, a new drawing command needs to be initiated. At this time, the geometry processing part of the mesh shading rendering pipeline needs to redraw the primitives, which consumes a lot of graphics processor performance. Summary of the Invention

[0006] This application provides a graphics processor, a primitive output method, a chip, a server, and an electronic device. This application can obtain primitive data of multiple primitive types with only one drawing instruction, avoiding the need to repeatedly draw with multiple drawing instructions to obtain primitive data of multiple primitive types, thus saving the performance of the graphics processor.

[0007] According to one aspect of this application, a graphics processor is provided, the graphics processor including a geometry processing pipeline;

[0008] A geometry processing pipeline is used to perform graphics drawing based on a first drawing instruction to obtain drawing results. The drawing results include graphic data of at least two primitive types, including at least two of points, lines, and triangles. The first drawing instruction is used to instruct the geometry processing pipeline to implement the geometry processing function in the mesh shading rendering pipeline.

[0009] According to one aspect of this application, a primitive output method is provided, the method comprising:

[0010] In response to receiving a first drawing instruction, the system controls the geometry processing pipeline in the graphics processor to perform geometry processing in the mesh shading rendering pipeline, and controls the geometry processing pipeline to perform graphics drawing based on the first drawing instruction.

[0011] In response to receiving an input operation for the target primitive type, output primitive data of the target primitive type from the rendering results of the geometry processing pipeline;

[0012] The drawing results include primitive data of at least two primitive types, including at least two of the primitive types: points, lines, and triangles.

[0013] According to another aspect of this application, a primitive output device is provided, the device comprising:

[0014] The control module is used to respond to receiving a first drawing instruction, control the geometry processing pipeline in the graphics processor to implement the geometry processing function in the mesh shading rendering pipeline, and control the geometry processing pipeline to perform graphics drawing based on the first drawing instruction;

[0015] The output module is used to respond to the input operation of the target primitive type received, and output the primitive data of the target primitive type from the drawing results of the geometry processing pipeline;

[0016] The drawing results include primitive data of at least two primitive types, including at least two of the primitive types: points, lines, and triangles.

[0017] According to one aspect of this application, a chip is provided, the chip including the above-described graphics processor.

[0018] According to one aspect of this application, a server is provided, the server including the above-described graphics processor.

[0019] According to one aspect of this application, an electronic device is provided, which includes the aforementioned graphics processor.

[0020] According to one aspect of this application, an electronic device is provided, comprising: a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-described primitive output method.

[0021] According to one aspect of this application, a computer-readable storage medium is provided, which stores a computer program that is loaded and executed by a processor to implement the above-described primitive output method.

[0022] According to one aspect of this application, a computer program product is provided, which stores a computer program that is loaded and executed by a processor to implement the above-described primitive output method.

[0023] The beneficial effects of the technical solutions provided in this application include at least the following:

[0024] In this application, in response to a drawing instruction (first drawing instruction), the geometry processing pipeline in the graphics processor will execute the geometry processing function in the mesh shading rendering pipeline, and the geometry processing pipeline will output the drawing result of the mesh shader. The drawing result contains at least two primitive data types. That is, in this application, multiple primitive data types can be drawn with only one drawing instruction, avoiding the need for multiple drawing instructions to execute multiple drawings to obtain multiple primitive data types in related technologies, and reducing the performance overhead of the graphics processor. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0027] Figure 2 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0028] Figure 3 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0029] Figure 4 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0030] Figure 5 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0031] Figure 6 is a schematic diagram of a geometry processing pipeline provided in one embodiment of this application.

[0032] Figure 7 is a schematic diagram of the drawing result of a mesh shader provided in one embodiment of this application.

[0033] Figure 8 is a schematic diagram of the drawing result of a mesh shader provided in another embodiment of this application.

[0034] Figure 9 is a schematic diagram of a data block of a map provided in an embodiment of this application.

[0035] Figure 10 is a schematic diagram of additional attribute segmentation provided in one embodiment of this application.

[0036] Figure 11 is a schematic diagram of a quantity indication segment provided in one embodiment of this application.

[0037] Figure 12 is a flowchart of a primitive output method provided in an embodiment of this application.

[0038] Figure 13 is a schematic diagram of a method for specifying an index value provided in an embodiment of this application.

[0039] Figure 14 is a schematic diagram of a method for specifying point size according to an embodiment of this application.

[0040] Figure 15 is a schematic diagram of a method for specifying a filling pattern provided in an embodiment of this application.

[0041] Figure 16 is a structural block diagram of a primitive output device provided in an embodiment of this application.

[0042] Figure 17 is a structural block diagram of an electronic device provided in an embodiment of this application.

[0043] Figure 18 is a schematic diagram of the structure of a server provided in one embodiment of this application. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0045] First, some terms used in the embodiments of this application will be introduced:

[0046] The geometry processing pipeline consists of two main parts: the geometry processing pipeline and the pixel processing pipeline. The geometry processing pipeline primarily processes the geometric coordinates and shape of the graphics, while the pixel processing pipeline mainly performs pixel operations on the graphics. In the VTG rendering pipeline proposed in DX11.3, the geometry processing pipeline includes vertex shaders, tessellation shaders (including hull shaders, tessellation stages, and domain shaders), and geometry shaders. In the mesh shading rendering pipeline proposed in DX12, the geometry processing pipeline includes amplification shaders and mesh shaders.

[0047] In the geometry processing pipeline of the VTG rendering pipeline, after receiving a drawing command, the initial drawing data first enters the vertex shader. The vertex shader performs coordinate transformations of the vertices. The vertex shader processes data on a vertex-by-vertex basis. After processing by the vertex shader, the data enters the tessellation shader, which is optional. In the tessellation shader, the shell shader performs pre-calculation of tessellation. The tessellation parameters output by the shell shader enter the tessellation stage, which calculates the new vertices after tessellation based on the tessellation parameters. The domain shader adjusts and calculates the coordinates of the new vertices. The domain shader inputs all vertices into the geometry shader, which performs addition, deletion, and modification operations on the vertices. The geometry shader is also optional.

[0048] In the geometry processing pipeline of the mesh shading rendering pipeline, the magnifying shader amplifies the received rendering data to generate more rendering data. The magnifying shader is an optional shader. After obtaining all the rendering data, the mesh shader processes the rendering data of the entire mesh. The mesh shader can process the entire mesh data at once, thereby achieving large-scale geometry data generation and processing.

[0049] Figure 1 is a schematic diagram of a geometry processing pipeline 100 provided in an exemplary embodiment of this application. The geometry processing pipeline 100 shown in Figure 1 is used to implement the functions of an amplification shader and a mesh shader. The geometry processing pipeline 100 includes a first task generation pipeline 110, a task control unit 120, a second task generation pipeline 130, and a shader execution unit 140.

[0050] The first task generation pipeline 110 generates an amplification shader thread group based on a first drawing instruction. The first drawing instruction instructs the generated thread group to implement the functionality of the amplification shader. The amplification shader thread group can also be called an amplification shader task. The amplification shader thread group is a thread group used to implement the functionality of the amplification shader. The first task generation pipeline 110 sends the amplification shader thread group to the shader execution unit 140 and sends the amplification task information corresponding to the amplification shader thread group to the task control unit 120. The amplification task information is the relevant information of the amplification shader thread group.

[0051] Shader execution unit 140 runs the amplified shader thread group to obtain amplified shading results and a second drawing instruction. The second drawing instruction indicates the number of mesh shader thread groups to be derived, and the amplified shading result characterizes the drawing result produced by the amplified shader. It is worth noting that the first drawing instruction is an instruction input by the user in the shader program, and the second drawing instruction is an instruction output by the amplified shader thread group during runtime. In this application, the first drawing instruction input by the user specifies the number of amplified shader thread groups to be generated, and the second drawing instruction output by shader execution unit 140 specifies the number of mesh shader thread groups to be generated.

[0052] The task control unit 120, based on the received magnification task information, obtains a second drawing instruction and inputs the second drawing instruction into the second task generation pipeline 130. The magnification task information includes information such as the instruction format and storage location of the second drawing instruction. The task control unit 120 can obtain the second drawing instruction based on the magnification task information. In this embodiment, a magnification shader processing pipeline is provided to implement the function of the magnification shader. The magnification shader processing pipeline includes a first task generation pipeline 110, a task control unit 120, and a shader execution unit 140.

[0053] The second task generation pipeline 130 creates a mesh shader thread group based on a second drawing instruction. This second drawing instruction instructs the generated thread group to implement the functionality of the mesh shader. The mesh shader thread group, also known as a mesh shader task, is a group of threads used to implement the mesh shader's functionality. The second task generation pipeline 130 inputs the mesh shader thread group into the shader execution unit 140 and sends the corresponding mesh task information to the task control unit 120. This mesh task information contains relevant information about the mesh shader thread group.

[0054] Shader execution unit 140 is used to run the mesh shader thread group to obtain the mesh shading result based on the magnified shading result. The mesh shading result is used to characterize the drawing result produced by the mesh shader. When running the mesh shader thread group, it is necessary to obtain the mesh shading result based on the generated magnified shading result. The generation of the mesh shading result depends on the magnified shading result.

[0055] The task control unit 120 obtains the mesh shading result based on the mesh task information and outputs the mesh shading result to the pipeline following the geometry processing pipeline. The mesh task information includes information such as the storage format and storage location of the mesh shading result, and the task control unit 120 can obtain the mesh shading result according to the instructions in the mesh task information. In this embodiment, a mesh shader processing pipeline is provided to implement the functions of the mesh shader. The mesh shader processing pipeline includes a second task generation pipeline 130, the task control unit 120, and a shader execution unit 140.

[0056] In one embodiment, the hardware units on the first task generation pipeline 110 and the second task generation pipeline 130 are different, meaning the two pipelines are completely independent. In another embodiment, the hardware units on the first task generation pipeline 110 and the second task generation pipeline 130 are partially the same, meaning the two generation pipelines share some hardware units.

[0057] In one embodiment, the mesh shading result output by the task control unit 120 enters the pixel processing pipeline. The pixel processing pipeline includes a rasterization stage, a pixel shader, and an output blending section. Optionally, the pixel processing pipeline can be a pixel processing pipeline using tile rendering, a tile-based pixel processing pipeline with deferred rendering, etc.; the tile-based pixel processing pipeline aims to divide the entire image into multiple small blocks (called "tiles"), and then process these tiles one by one to improve rendering efficiency and performance; the pixel processing pipeline with deferred rendering is used to separate the rendering of geometric information from lighting calculation, which can handle lighting in complex scenes more efficiently. That is, the geometry processing pipeline provided in this application is applicable to any type of pixel processing pipeline, meaning that the geometry processing pipeline provided in this application has broad applicability.

[0058] In summary, this application provides a geometry processing pipeline that supports both a magnifying shader and a mesh shader. Furthermore, it provides a resource scheduling scheme within this pipeline. In this application, the task control unit schedules the second drawing instructions output by the magnifying shader and the mesh shading results output by the mesh shader, improving the orderliness of the scheduling. Moreover, the geometry processing pipeline designed in this application is programmable, comprising a first task generation pipeline, a second task generation pipeline, a task execution unit, and a task control unit. This rich hardware configuration enhances programming flexibility and improves the overall throughput of the graphics processor.

[0059] In one embodiment, the first task generation pipeline 110 includes at least one of a first task generation unit, an amplification shading unit, and a shader task construction unit. The first task generation unit processes initially received first drawing instructions to generate an amplification shader thread group. The amplification shading unit adds resource requirement information to generate the amplification shader thread group. The shader task construction unit allocates resources to generate the amplification shader thread group. The first task generation pipeline 110 is formed based on at least one of the first task generation unit, the amplification shading unit, and the shader task construction unit; optionally, the first task generation pipeline 110 may also include other possible hardware units.

[0060] In one embodiment, the second task generation pipeline 130 includes at least one of a second task generation unit, a mesh shading unit, and a shader task construction unit. The second task generation unit processes received second drawing instructions to generate a mesh shader thread group. The mesh shading unit adds resource requirement information to generate the mesh shader thread group. The shader task construction unit allocates resources to generate the mesh shader thread group. The second task generation pipeline 130 is formed based on at least one of the second task generation unit, the mesh shading unit, and the shader task construction unit; optionally, the second task generation pipeline 130 may also include other possible hardware units.

[0061] The following description will focus on the first task generation pipeline 110, which includes a first task generation unit, an amplification shading unit, and a shader task construction unit, and the second task generation pipeline 130, which includes a second task generation unit, a mesh shading unit, and a shader task construction unit.

[0062] Figure 2 shows a schematic diagram of a geometry processing pipeline 100 provided in an exemplary embodiment of this application. The geometry processing pipeline 100 shown in Figure 2 is used to implement the functions of an amplified shader and a mesh shader. The geometry processing pipeline 100 includes a first task generation pipeline 110, a task control unit 120, a second task generation pipeline 130, and a shader execution unit 140. The first task generation pipeline 110 includes a first task generation unit 111, an amplified shading unit 112, and a shader task construction unit 113. The second task generation pipeline 130 includes a second task generation unit 131, a mesh shading unit 132, and a shader task construction unit 113.

[0063] For the first task generation pipeline 110

[0064] The first task generation unit 111 creates a first thread group based on a first drawing instruction and sends the first thread group to the magnification shader unit 112. The first thread group is the thread group specified by the first drawing instruction for implementing the function of the magnification shader. Illustratively, the first drawing instruction includes three 32-bit parameters. For example, if the first drawing instruction includes parameters (4, 3, 2), then the first task generation unit 111 will generate 4*3*2 = 24 first thread groups. The first drawing instruction specifies that the generated 24 first thread groups are used to implement the function of the magnification shader. Optionally, each first thread group includes at least two threads. Optionally, each of the at least two threads is used to process one or more meshes. A mesh refers to the geometric structure of a 3D model, typically composed of vertices, edges, and faces; or, multiple threads in the at least two threads are used together to process one or more meshes. This application does not limit this.

[0065] The amplification shading unit 112 adds first resource requirement information to the first thread group to obtain a second thread group; the second thread group is then sent to the shader task construction unit 113. The first resource requirement information refers to the resources required to run the amplification shader thread group. Optionally, the first resource requirement information includes the storage location of the second drawing instructions, the instruction format, the storage format of the amplification shading results, the storage location of the amplification shading results, the address of the temporary storage space used when running the amplification shader thread group, the address of the result storage space, and other resource request information. Optionally, the first resource requirement information includes mesh load packet request information, where the mesh load packet is a load packet used to hold the amplification shading results.

[0066] The shader task construction unit 113 allocates resources to the second thread group based on the first resource requirement information, and uses the resource-allocated second thread group as the amplified shader thread group. The shader task construction unit 113 then sends the amplified shader thread group to the shader execution unit 140. The shader task construction unit 113 also sends the amplified task information corresponding to the amplified shader thread group to the task control unit 120; the amplified task information is the resource information allocated by the shader task construction unit 113 to the second thread group.

[0067] For the second task generation pipeline 130

[0068] The second task generation unit 131 is used to create a third thread group based on the second drawing instruction and send the third thread group to the mesh shading unit. The third thread group is the thread group specified by the second drawing instruction for implementing the function of the mesh shader. Illustratively, the second drawing instruction includes three 32-bit parameters. For example, if the second drawing instruction includes parameters (6, 3, 2), then the second task generation unit 131 will generate 6 * 3 * 2 = 36 third thread groups. The second drawing instruction specifies that the generated 36 third thread groups are used to implement the function of the mesh shader. Optionally, each third thread group includes at least two threads. Optionally, each of the at least two threads is used to process one or more meshes, or multiple threads in the at least two threads are used together to process one or more meshes; this application does not limit this.

[0069] Mesh shading unit 132 is used to add second resource requirement information to the third thread group to obtain a fourth thread group; and send the fourth thread group to shader task construction unit 113. The second resource requirement information refers to the resources required to run the mesh shader thread group. Optionally, the second resource requirement information includes resource request information such as the storage format of the mesh shading result, the storage location of the mesh shading result, the address of the temporary storage space used when running the mesh shader thread group, and the address of the result storage space.

[0070] The shader task construction unit 113 is used to allocate resources to the fourth thread group based on the second resource requirement information, and to designate the resource-allocated fourth thread group as the mesh shader thread group. The shader task construction unit 113 sends the mesh shader thread group to the shader execution unit 140. The shader task construction unit 113 also sends the mesh task information corresponding to the mesh shader thread group to the task control unit 120; the mesh task information is the information about the resources allocated by the shader task construction unit 113 to the fourth thread group.

[0071] In the above embodiments, the first task generation pipeline 110 and the second task generation pipeline 130 each have their own task generation unit and a shading unit for requesting resources, as well as a shared shader task construction unit 113. The sharing of the shader task construction unit 113 saves hardware usage and reduces the hardware density on the graphics processor. Furthermore, in addition to allocating resources to the thread group, the shader task construction unit 113 also sends resource information, i.e., task information, to the task control unit 120, facilitating the task control unit 120 to perform scheduling using the task information. That is, this application provides a method for generating task information, allowing the task control unit 120 to better schedule the second drawing instructions and mesh shading results using the task information. Moreover, each task generation pipeline provided in this application has its own task generation unit and a shading unit for requesting resources. The task generation unit and the shading unit for requesting resources are programmable hardware, meaning that the abundant hardware units in this application improve programming flexibility.

[0072] In some embodiments, the graphics processor further includes at least one of a temporary storage unit and a result storage unit, wherein the temporary storage unit is used to temporarily store data read and written during the execution of shader tasks, and the result storage unit is used to store shader results obtained from the execution of shader tasks.

[0073] The following will use a graphics processor, which includes temporary storage units and result storage units, as an example.

[0074] Figure 3 shows a schematic diagram of a geometry processing pipeline 100 provided in another exemplary embodiment of this application. The geometry processing pipeline 100 shown in Figure 3 is used to implement the functions of an amplification shader and a mesh shader. The geometry processing pipeline 100 includes an amplification shader processing pipeline, a task control unit 120, and a mesh shader processing pipeline. The amplification shader processing pipeline includes a first task generation pipeline 110, a shader execution unit 140, a result storage unit 150, and a temporary storage unit 160. The first task generation pipeline 110 includes a first task generation unit 111, an amplification shader unit 112, and a shader task construction unit 113.

[0075] The mesh shader processing pipeline includes a second task generation pipeline 130, a shader execution unit 140, a result storage unit 150, and a temporary storage unit 160. The second task generation pipeline 130 includes a second task generation unit 131, a mesh shading unit 132, and a shader task construction unit 113.

[0076] For amplification shader processing pipelines

[0077] The relevant descriptions of the first task generation pipeline 110 and the shader execution unit 140 can be found above, and will not be repeated here.

[0078] The result storage unit 150 is used to store at least one of the magnified shading result output by the shader execution unit 140 and the second drawing instruction. Optionally, the result storage unit 150 is used to store the second drawing instruction, and the task control unit 120 obtains the second drawing instruction from the result storage unit 150 according to the magnification task information and sends the second drawing instruction to the second task generation unit 131.

[0079] Temporary storage unit 160 is used to temporarily store data read and written by shader execution unit 140 when executing the amplified shader thread group. Optionally, temporary storage unit 160 is used to store the amplified shading results output by shader execution unit 140. Optionally, temporary storage unit 160 is on-chip storage space of graphics processor. Optionally, temporary storage unit 160 can also be off-chip storage space of graphics processor. In one embodiment, the mesh payload allocated by shader task construction unit 113 is located in temporary storage unit 160. The mesh payload is a temporary payload used to contain the amplified shading results output by shader execution unit 140. When shader execution unit 140 runs the mesh shader thread group, it obtains the amplified shading results from temporary storage unit 160. Shader execution unit 140 relies on the amplified shading results when generating mesh shading results by running mesh shader thread group.

[0080] For mesh shader processing pipeline

[0081] The relevant descriptions of the second task generation pipeline 130 and the shader execution unit 140 can be found above, and will not be repeated here.

[0082] The result storage unit 150 is used to store the mesh shading results output by the shader execution unit 140. The task control unit 120 retrieves the mesh shading results from the result storage unit 150 according to the mesh task information and outputs the mesh shading results to the pipeline after the geometry processing pipeline 100.

[0083] Temporary storage unit 160 is used to temporarily store data read and written by the shader execution unit 140 when executing the mesh shader thread group. Optionally, temporary storage unit 160 is on-chip storage space of the graphics processor. Optionally, temporary storage unit 160 can also be off-chip storage space of the graphics processor.

[0084] In this embodiment, the amplification shader processing pipeline and the mesh shader processing pipeline share the result storage unit 150 and the temporary storage unit 160. Sharing the result storage unit 150 and the temporary storage unit 160 saves hardware usage and reduces the hardware density on the graphics processor. Furthermore, this application divides the hardware into the result storage unit 150 and the temporary storage unit 160 to better serve the shader execution unit 140. The temporary storage unit 160 stores intermediate data output by the shader execution unit 140, and the result storage unit 150 stores the result data output by the shader execution unit 140.

[0085] In this embodiment, the mesh payload is a temporary payload allocated by the first task generation pipeline 110, specifically, a temporary payload allocated by the shader task construction unit 113. The mesh payload is used to hold the amplified shading results. Since the mesh payload is a temporary payload, it needs to be released promptly after the amplified shading results are used to avoid the accumulation of mesh payloads and the occupation of storage space.

[0086] In one embodiment, the second task generation pipeline 130 is further configured to add an end flag to the last mesh task information corresponding to the last mesh shader thread group, and the task control unit 120 clears the mesh load packet when the end flag is detected.

[0087] The task control unit 120 detects the end flag, indicating that the shader execution unit 140 has run to the last mesh shader thread group. When the last mesh shader thread group finishes running, it means that the amplified shading results have been used up, and then the mesh load pack can be released and the amplified shading results can be cleared.

[0088] In one embodiment, based on the geometry processing pipeline 100 shown in FIG2, the second task generation pipeline 130 includes a second task generation unit 131, a mesh shading unit 132, and a shader task construction unit 113. The second task generation unit 131 is used to add an end flag (Lsat flag) to the last group of third threads; the mesh shading unit 132 transmits the end flag, and the shader task construction unit 113 adds an end flag to the last mesh task information corresponding to the last group of third threads. The task control unit 120 is used to clear the mesh payload packet upon detecting the end flag.

[0089] It is understandable that the second drawing instruction sent by the task control unit 120 to the second task generation unit 131 contains the number of mesh shader thread groups to be generated. Therefore, the second task generation unit 131 can know which group of third thread groups is the last group of third thread groups. Thus, the second task generation unit 131 can add an end marker to the last group of third thread groups.

[0090] In this application, an end flag is added to the last mesh shader thread group. When the task control unit 120 detects the end flag, it can promptly control the release of the mesh load packet. Compared to the related technologies that use reference counting to release the amplified shading result, this method is simpler to operate and less prone to errors. Related technologies use reference counting to manage the output of the amplified shader (i.e., the amplified shading result). These technologies require additional storage space to store a reference counter, which records the number of times the amplified shading result is referenced. An atomic instruction is used to subtract this reference count, and the mesh load packet is released when the subtraction result is zero. The hardware design of these related technologies is relatively complex. In contrast, this application can directly add an end flag to the data stream without storing a reference counter, resulting in a simpler overall hardware design.

[0091] Figure 4 illustrates a geometry processing pipeline 100 provided in an exemplary embodiment of this application. The geometry processing pipeline 100 in Figure 4 is used to implement the function of a mesh shader. The geometry processing pipeline 100 includes a third task generation pipeline 410, a task control unit 120, and a shader execution unit 140.

[0092] The third task generation pipeline 410 creates mesh shader thread groups based on third drawing instructions. These third drawing instructions specify the number of mesh shader thread groups to be generated, each also referred to as a mesh shader task. The third task generation pipeline 410 inputs the mesh shader thread groups into the shader execution unit 140 and sends the corresponding mesh task information to the task control unit 120. This mesh task information contains relevant information about the mesh shader thread groups. Optionally, the third drawing instructions are instructions entered by the user into the shader program.

[0093] Shader execution unit 140 is used to run the mesh shader thread group to obtain the mesh shading result.

[0094] The task control unit 120 obtains the mesh shading result based on the mesh task information and outputs the mesh shading result to the pipeline following the geometry processing pipeline. The mesh task information includes information such as the storage format and storage location of the mesh shading result, and the task control unit 120 can obtain the mesh shading result according to the instructions in the mesh task information.

[0095] In one embodiment, the mesh shading result output by the task control unit 120 enters the pixel processing pipeline. The pixel processing pipeline includes a rasterization stage, a pixel shader, and an output blending section. Optionally, the pixel processing pipeline can be a pixel processing pipeline using tile rendering, a tile-based pixel processing pipeline with deferred rendering, etc., that is, the geometry processing pipeline provided in this application is applicable to any type of pixel processing pipeline, meaning that the geometry processing pipeline provided in this application has broad applicability.

[0096] In summary, this application provides a geometry processing pipeline that supports mesh shaders. Furthermore, it provides a resource scheduling scheme within this pipeline. In this application, the mesh shading results output by the mesh shader are scheduled by the task control unit, improving the orderliness of the scheduling. Moreover, the geometry processing pipeline designed in this application is programmable, containing a third task generation pipeline, a task execution unit, and a task control unit. This rich hardware configuration enhances programming flexibility and improves the overall throughput of the graphics processor.

[0097] Furthermore, comparing the geometry processing pipelines shown in Figures 1 and 4, it can be seen that the geometry processing pipeline provided in this application can simultaneously support two modes: mesh shader only, magnified shader, and mesh shader. The shader execution unit 140 and task control unit 120 in this application can simultaneously support both modes.

[0098] Figure 5 illustrates a geometry processing pipeline provided in an exemplary embodiment of this application. The geometry processing pipeline 100 shown in Figure 5 is used to implement the function of a mesh shader. The geometry processing pipeline 100 includes a third task generation pipeline 410, a task control unit 120, and a shader execution unit 140. The third task generation pipeline 410 includes a first task generation unit 111, an amplified shading unit 112, a second task generation unit 131, a mesh shading unit 132, and a shader task construction unit 113.

[0099] The first task generation unit 111 is used to create a fifth thread group based on the third drawing instruction and send the fifth thread group to the amplification shading unit 112. The fifth thread group is the thread group specified by the third drawing instruction to implement the function of the mesh shader. Illustratively, the third drawing instruction includes three 32-bit parameters. For example, if the third drawing instruction includes parameters (6, 3, 2), then the first task generation unit 111 will generate 6 * 3 * 2 = 36 fifth thread groups. The third drawing instruction specifies that the generated 36 fifth thread groups are used to implement the function of the mesh shader. Optionally, each fifth thread group includes at least two threads. Optionally, each of the at least two threads is used to process one or more meshes. A mesh refers to the geometric structure of a 3D model, usually composed of vertices, edges, and faces; or, multiple threads in the at least two threads are used together to process one or more meshes. This application does not limit this.

[0100] The amplified coloring unit 112 is used to pass through the fifth thread group to the second task generation unit 131;

[0101] The second task generation unit 131 is used to pass the fifth thread group to the mesh coloring unit 132.

[0102] Mesh shading unit 132 is used to add third resource requirement information to the fifth thread group to obtain a sixth thread group; and send the sixth thread group to shader task construction unit 113; the third resource requirement information refers to the resources required to run the fifth thread group. Optionally, the third resource requirement information includes the storage format of the mesh shading result, the storage location of the mesh shading result, the address of the temporary storage space used when running the mesh shader thread group, the address of the result storage space, and other resource request information.

[0103] The shader task construction unit 113 is used to allocate resources to the sixth thread group based on the third resource requirement information, and to use the resource-allocated sixth thread group as the mesh shader thread group. The shader task construction unit 113 sends the mesh task information corresponding to the mesh shader thread group to the task control unit 120. The mesh task information is the information of the resources allocated by the shader task construction unit 113 to the sixth thread group.

[0104] In the above embodiments, comparing the geometry processing pipelines shown in Figures 2 and 5, it can be found that the geometry processing pipeline provided in this application can simultaneously support two modes: mesh shader only, magnifying shader, and mesh shader. The first task generation unit 111, magnifying shader unit 112, second task generation unit 131, and mesh shader unit 132 in this application can simultaneously support both modes.

[0105] Figure 6 illustrates a geometry processing pipeline provided in an exemplary embodiment of this application. The geometry processing pipeline 100 shown in Figure 6 is used to implement the function of a mesh shader. The geometry processing pipeline 100 includes a first task generation unit 111, an amplified shading unit 112, a second task generation unit 131, a mesh shading unit 132, a shader task construction unit 113, a task control unit 120, a shader execution unit 140, a result storage unit 150, and a temporary storage unit 160.

[0106] The result storage unit 150 is used to store the mesh shading results output by the shader execution unit 140. The temporary storage unit 160 is used to temporarily store data read and written by the shader execution unit 140 when executing the mesh shader thread group. Other details have been described above and will not be repeated here.

[0107] In the above embodiments, comparing the geometry processing pipelines shown in Figures 3 and 6, it can be found that the geometry processing pipeline provided in this application can simultaneously support two modes: mesh shader only, magnifying shader, and mesh shader. The result storage unit 150 and temporary storage unit 160 in this application can simultaneously support both modes. Furthermore, this application divides the hardware into the result storage unit 150 and the temporary storage unit 160 to better serve the shader execution unit 140. The temporary storage unit 160 is used to store intermediate data output by the shader execution unit 140, and the result storage unit 150 is used to store the result data output by the shader execution unit 140.

[0108] In one embodiment, for both the mesh shader-only and mesh shader-plus-mesh-shader modes, the stored mesh shading results can have the same or different formats. In either of these modes, the layout of the mesh shading results corresponding to at least one mode can be as follows.

[0109] In the following text, the mesh coloring result is also referred to as the drawing result.

[0110] In this embodiment, the graphics processor includes a geometry processing pipeline. The geometry processing pipeline is used to receive a first drawing instruction, which instructs the geometry processing pipeline to perform geometry processing functions in the mesh shading rendering pipeline. The first drawing instruction is a DispatchMesh Call instruction. The geometry processing pipeline is used to perform graphics drawing based on the first drawing instruction to obtain a drawing result. The drawing result includes primitive data of at least two primitive types, which include at least two of points, lines, and triangles.

[0111] In one embodiment, the geometry processing pipeline is used to implement the function of the mesh shader, that is, to obtain the drawing result output by the mesh shader using the mesh shader-only mode described above. In this case, the first drawing instruction is used to instruct the geometry processing pipeline to execute the function of the mesh shader. In another embodiment, the geometry processing pipeline is used to implement the functions of the magnifying shader and the mesh shader, that is, to obtain the drawing result output by the mesh shader using the magnifying shader and mesh shader mode described above. In this case, the first drawing instruction is used to instruct the geometry processing pipeline to execute the functions of the magnifying shader and the mesh shader.

[0112] In this application, in response to a drawing instruction (first drawing instruction), the geometry processing pipeline in the graphics processor will execute the geometry processing function in the mesh shader rendering pipeline, and the geometry processing pipeline will output the drawing result of the mesh shader. The drawing result contains at least two primitive data types. That is, in this application, multiple primitive data types can be drawn by only one drawing instruction.

[0113] The rendering result (meshlet) includes metadata for various primitive types. As shown in Figure 7, which illustrates the rendering result, the result includes a vertex data area 710 and a metadata area 720. The vertex data area 710 includes vertex attributes of at least two vertices. The metadata area 720 includes multiple metadata blocks 721, each corresponding to a primitive. Each metadata block 721 is used to store the primitive attributes of the current primitive. Alternatively, the i-th metadata block 721 is used to store the primitive attributes of the i-th primitive. In one embodiment, metadata blocks indicating the same primitive type are grouped together. For example, the first metadata block might store point-type metadata, the middle metadata block might store line-type metadata, and the last metadata block might store triangle-type metadata.

[0114] In one embodiment, the vertex data area 710 and the graph data area 720 are concatenated. In this case, the data format of the drawing result can be fully expressed using three parameters: the base address, the size of the vertex data area 710, and the size of the graph data area 720. The base address refers to the starting address of the vertex data area 710. When an external component wants to access the drawing result, it only needs these three parameters to access the target data. For example, when accessing the vertex data area 710, it only needs to start accessing from the base address; when accessing the graph data area 720, it only needs to start accessing from the base address plus the size of the vertex data area 710.

[0115] In one embodiment, as shown in FIG8, the graph data area 720 includes, in addition to multiple data blocks 721, a quantity indicator segment 722. The quantity indicator segment 722 is used to indicate the number of at least two vertices in the vertex data area 710 and the number of multiple primitives in the graph data area 720. Optionally, the quantity indicator segment 722 is located at the end of the graph data area 720. In this case, if an external component wants to access the quantity indicator segment 722, it only needs to add the size of the vertex data area 710 and the size of the graph data area 720 to the base address, and then subtract the size of the quantity indicator segment 722 (which is a fixed value, optionally 32 bits).

[0116] Optionally, the quantity indicator segment 722 can also be located in the header of the vertex data area 710. In this case, if an external component wants to access the quantity indicator segment 722, it only needs to access it starting from the base address; if an external component wants to access the vertex attribute part in the vertex data area 710, it only needs to add the size of the quantity indicator segment 722 (which is a fixed value, optionally 32 bits) to the base address.

[0117] In one embodiment, each graph data block includes the index value of the vertices that make up the current graph element in the vertex data area 710, the graph element type of the current graph element (including any one of point, line, and triangle), whether it supports specifying the point size, fill mode, etc., which will be described in detail below.

[0118] In related technologies, definitions of meshlets output by mesh shaders are provided. However, these definitions are complex, involving as many as four data segments, which complicates meshlet allocation and access. This application provides a two-segment layout for rendering results, which is simpler. With only two segments, hardware allocation of rendering resources is simpler, and the entire layout can be fully expressed using only the three parameters mentioned above (base address, vertex data area size, and graph data area size), simplifying hardware access to the rendering results.

[0119] Image data block

[0120] Based on the above introduction, the graph data area contains multiple graph data blocks, each graph data block corresponds to a graph element, and each graph data block is used to contain the graph element attributes of a graph element.

[0121] Figure 9 illustrates a schematic diagram of a map data block provided in an exemplary embodiment of this application. The map data block includes a topology attribute segment and multiple other attribute segments (attribute segment 0, attribute segment 1 to attribute segment N). The topology attribute segment includes a first index segment, a second index segment, a third index segment, and an additional attribute segment. In one embodiment, the topology attribute segment and any one of the multiple other attribute segments are of the same size, for example, all are 32 bits. Optionally, the first index segment, the second index segment, the third index segment, and the additional attribute segment are all of the same size, for example, all are 8 bits.

[0122] In one embodiment, the additional attribute segment includes a type segment that holds the type identifier of the current primitive. The additional attribute segment also includes an indication segment for other topological information, which will be described below.

[0123] When the primitive type corresponding to the primitive data block is a point, the first index segment is used to store the index value of the first vertex of the current primitive in the vertex data area, and the type segment is used to store the point's type identifier. Optionally, the first index segment contains 8 bits. In this case, the first index segment can index 256 vertices. For the current DirectX and Vulkan specifications, using 8 bits to represent each index value is sufficient. At this time, the values ​​in the second and third index segments are invalid. Optionally, the point's type identifier can be stored using 2 bits, for example, using 0 and 1 to identify the point type.

[0124] When the primitive type corresponding to the primitive data block is line, the first and second index segments of the three index segments are used to store the index values ​​of the first and second vertices of the current primitive in the vertex data area, respectively. The type segment is used to store the line type identifier. Optionally, both the first and second index segments contain 8 bits. In this case, each of the two index segments can index 256 vertices, and the value on the third index segment is invalid. Optionally, the line type identifier can be stored using 2 bits, for example, using 10 bits to identify the line type.

[0125] When the primitive type corresponding to the primitive data block is triangle, the first, second, and third index segments of the three index segments are used to store the index values ​​of the first, second, and third vertices of the current primitive in the vertex data area, respectively. The type segment is used to store the triangle type identifier. Optionally, the first, second, and third index segments each contain 8 bits, in which case each of the three index segments can index 256 vertices. Optionally, the triangle type identifier can be stored in 2 bits, for example, using 11 to identify the triangle type.

[0126] It should be noted that the above example uses 8 bits per index segment. In practice, when it is necessary to expand to indicate more vertices, the 32-bit topological attribute segment can be divided into three index segments of 10 bits each, with the additional two bits used to hold the type identifier. In this case, each index segment can index 1024 vertices. Furthermore, if 1024 vertices are still insufficient to exhaust all vertices in the vertex index area, the next other attribute segment (i.e., attribute segment 0 in Figure 6) or the next two other attribute segments (i.e., attribute segments 0 and 1 in Figure 6) can be used. Each attribute segment is 32 bits in size. In this case, the first two or the first three 32 bits will be used to represent the topological structure of the primitive.

[0127] In summary, each primitive data block includes a type segment, which allows the user to specify the primitive type to be output in the shader program; and each primitive data block includes three index segments, which allow the user to specify the vertex index values ​​to be output in the shader program.

[0128] Additional attribute segmentation

[0129] Based on the above description, each graphic data block contains a topology attribute segment, which includes one additional attribute segment and three index segments. The additional attribute segment contains at least one of the following: a type segment (indicating the type of the current graphic element), a first indicator segment (indicating whether a specified point size is supported), and a second indicator segment (indicating the fill mode of the current graphic element). The fill mode includes any one of point fill, line fill, and solid fill. This application does not limit the distribution of the type segment, the first indicator segment, and the second indicator segment in the additional attribute segment; one possible distribution will be described below.

[0130] As shown in Figure 10, Figure 10 illustrates an additional attribute segment, in which the type segment, the second indicator segment, and the first indicator segment are concatenated from low to high bits. In one embodiment, the size of the additional attribute segment is 8 bits. The type segment includes the first two bits from right to left, i.e., bits [0:1]. At this time, two bits can encode the three primitive types: point, line, and triangle. The second indicator segment includes bits [2:4]. Three bits can encode the filling mode of the current primitive. For example, bit [2] indicates whether it is a point fill, bit [3] indicates whether it is a line fill, and bit [4] indicates whether it is a solid fill. The first indicator segment includes bit [5]. A value of 0 on bit [5] indicates that the current primitive does not support the specified point size, and a value of 1 indicates that the current primitive supports the specified point size.

[0131] For the first indicator segment, if the first indicator segment indicates that the current primitive supports the size of a specified point, then among the multiple other attribute segments shown in Figure 9, one attribute segment is used to indicate the point size. For example, the first other attribute segment after the topology attribute segment is used to store the point size. In one embodiment, if the primitive type of the current primitive is a point, then the first indicator segment indicates that the current primitive supports the size of a specified point. The size of a point refers to the number of pixels occupied by a vertex on the primitive; for example, a vertex occupies 30 pixels.

[0132] For the second indicator segment, if the current element type is a point, the second indicator segment will specify the fill mode of the current element within the range including point fill mode; if the current element type is a line, the second indicator segment will specify the fill mode of the current element within the range including point fill mode and line fill mode; if the current element type is a triangle, the second indicator segment will specify the fill mode of the current element within the range including point fill mode, line fill mode and solid fill mode.

[0133] In summary, the additional attribute segment includes a first indicator segment, which allows the user to specify the output point size on the shader program; and the additional attribute segment includes a second indicator segment, which allows the user to specify the output fill mode on the shader program.

[0134] Quantity indicator segmentation

[0135] Based on the above introduction, a quantity indicator segment exists within the graph data data area. This quantity indicator segment is used to indicate the number of at least two vertices in the vertex data area and the number of multiple primitives in the graph data data area. The quantity indicator segment includes a vertex quantity segment and a primitive quantity segment. This application does not limit the distribution of the vertex quantity segment and the primitive quantity segment in the quantity indicator segment. One distribution will be described below.

[0136] As shown in Figure 11, the primitive count segment and vertex count segment in the quantity indicator segment are concatenated from low to high bits. In one embodiment, the quantity indicator segment contains 32 bits, of which the high 16 bits are used to express the number of vertices in the vertex data area and the low 16 bits are used to express the number of primitives in the primitive data area. According to the DirectX and Vulkan specifications, both actually only require 8 bits.

[0137] In one embodiment, the primitive count segment and the vertex count segment are concatenated from low to high bit order, where the high 16 bits represent the number of vertices in the vertex data area and the low 16 bits represent the number of primitives in the primitive data area. In another embodiment, the vertex count segment and the primitive count segment are concatenated from low to high bit order, where the high 16 bits represent the number of primitives in the primitive data area and the low 16 bits represent the number of vertices in the vertex data area.

[0138] In another embodiment, the high 8 bits of the lower 16 bits are used to express the number of vertices in the vertex data area, and the low 8 bits are used to express the number of vertices in the graph data area. The reverse is also true.

[0139] In another embodiment, the high 8 bits of the high 16 bits are used to express the number of vertices in the vertex data area, and the low 8 bits are used to express the number of vertices in the graph data area. The reverse is also true.

[0140] In summary, the segmented quantity indicator makes it easier for users to obtain the number of vertices and primitives, allowing them to access more information.

[0141] The previous section introduced that the rendering results output by the graphics processor contain primitive data of various primitive types. The following section will introduce how users can specify the target primitive type for the output from a variety of primitive types.

[0142] Figure 12 shows a flowchart of a primitive output method provided in an exemplary embodiment of this application, illustrated by an example of the method being executed by a shader program on a terminal device. The method includes:

[0143] Step 1220: In response to receiving the first drawing instruction, control the geometry processing pipeline in the graphics processor to implement the geometry processing function in the mesh shading rendering pipeline, and control the geometry processing pipeline to perform graphics drawing based on the first drawing instruction;

[0144] Schematic: The shader program receives a dispatchmesh call instruction from the application, controlling the geometry processing pipeline in the graphics processor to start the mesh shader and perform graphics rendering through the mesh shader. Optionally, the dispatchmesh call instruction instructs the geometry processing pipeline to only start the mesh shader; alternatively, the dispatchmesh call instruction instructs the geometry processing pipeline to start both the magnification shader and the mesh shader.

[0145] Step 1240: In response to receiving an input operation for the target primitive type, output the primitive data of the target primitive type from the drawing results of the geometry processing pipeline. The drawing results include primitive data of at least two primitive types, including at least two of points, lines, and triangles.

[0146] As described above, the drawing result of the mesh shader includes a vertex data area and a graph data area. The vertex data area includes the vertex attributes of at least two vertices. The graph data area includes multiple graph data blocks, which correspond one-to-one with multiple primitives. Each graph data block includes a type segment for the current primitive, which is used to hold the type identifier of the current primitive.

[0147] In one embodiment, in response to the shader program receiving an input operation for a target primitive type, the target primitive data block corresponding to the target primitive type is determined from the primitive data area, and the target primitive data block is output. In this application, the drawing result output by the mesh shader includes primitive data of multiple primitive types, such as primitive data of at least two of the following: points, lines, and triangles. The shader program accepts user or requirement-specified output primitive types, such as specifying the output primitive data of points. Optionally, if no output primitive type is specified, the primitive data of triangles is output by default.

[0148] In summary, in the above embodiments, the mesh shader on the graphics processor can output metadata for multiple primitive types with a single drawing instruction. Furthermore, the target primitive type's metadata can be selected for output. This avoids the need for multiple drawing instructions in related technologies to output metadata for multiple primitive types. For example, if a drawing instruction initially draws metadata for a "triangle," and you want to switch to obtaining metadata for a "line," a new drawing instruction needs to be sent, and the mesh shader needs to draw the same batch of data again to obtain the metadata for the "line." This consumes significant graphics processor resources, as the mesh shader needs to draw the same batch of data multiple times to obtain metadata for multiple primitive types.

[0149] Specify vertex index value

[0150] As described above, each primitive data block also includes three index segments; these three index segments are used to hold the index values ​​of the vertices of the current primitive in the vertex data area.

[0151] In one embodiment, in response to the shader program receiving an input operation for a target index value under the target primitive type, the first primitive data block corresponding to the target index value is determined from the target primitive data blocks. As shown in Figure 13, the target primitive data blocks include primitive data blocks corresponding to the first index value, primitive data blocks corresponding to the second index value, primitive data blocks corresponding to the third index value, etc. Based on the target index value specified by the user, the first primitive data block corresponding to the target index value is determined from the target primitive data blocks.

[0152] For vertex types, in response to the shader program receiving input of vertex type and the first index value of the first vertex, the target graph data block corresponding to the first index value of the vertex type is determined from the graph data data area. Users specify vertex index values ​​using unit3 type indices in the shader program. For vertex types, only the first index in indices is valid; the values ​​of the other two indices are ignored.

[0153] For line types, in response to the shader program receiving input of the line type, the first index value of the first vertex, and the second index value of the second vertex, the target graph data block corresponding to the line type and the first and second index values ​​is determined from the graph data area. At this time, in the indices used by the shader program, only the first two indices are valid, and the value at the other index is ignored.

[0154] For triangle types, in response to the shader program receiving input of the triangle type, the first index value of the first vertex, the second index value of the second vertex, and the third index value of the third vertex, the target graph data block corresponding to the triangle type and the first, second, and third index values ​​is determined from the graph data area. At this point, all three indices are valid in the indices used by the shader program.

[0155] In the above embodiments, the mesh shader on the graphics processor can output metadata for various primitive types through a single drawing instruction. For each primitive type, the user can further specify the metadata corresponding to a given vertex index value. That is, this application provides a scheme in which both primitive type and vertex index value can be specified by the user.

[0156] Specify point size

[0157] As described above, each graphic element data block also includes a first indicator segment and a first attribute segment. The first indicator segment is used to indicate whether the current graphic element supports the size of a specified point, or to indicate whether the current graphic element does not support the size of a specified point; the first attribute segment is used to indicate the size of a point on the current graphic element.

[0158] After the user specifies the primitive type, the user can further specify primitive data whose output point size meets the given target point size. Of course, the user can also choose not to specify the point size.

[0159] In one embodiment, in response to the shader program receiving an input operation specifying the target point size under the target primitive type, a second primitive data block that supports the specified point size and whose point size conforms to the target point size is output from the target primitive data block. As shown in Figure 14, the target primitive data block includes primitive data blocks corresponding to the first point size, the second point size, the third point size, and so on. Based on the target point size input by the user, the second primitive data block corresponding to the target point size is determined from the target primitive data block. This application provides two shader program syntaxes: ConstructPrimitive1, which supports specifying the point size, and ConstructPrimitive2, which does not support specifying the point size. For platforms that do not support point types as mesh shader output or cannot support specifying point sizes, only the ConstructPrimitive2 syntax needs to be supported.

[0160] In the above embodiments, the mesh shader on the graphics processor can output multiple graph data corresponding to various point sizes through a single drawing instruction. The user can select the graph data corresponding to the target point size for output. That is, the above embodiments further provide a graph attribute that the user can specify for output.

[0161] Specify fill pattern

[0162] As described above, each graphic element data block also includes a second indicator segment; the second indicator segment is used to indicate the fill mode adopted by the current graphic element, and the fill mode includes any one of point fill, line fill and solid fill.

[0163] After specifying the primitive type, the user can further specify the primitive data that satisfies the given target fill mode. Of course, the user can also choose not to specify a fill mode.

[0164] In one embodiment, in response to the shader program receiving an input operation indicating a target fill mode for a target primitive type, a second primitive data block whose fill mode matches the target fill mode is output from the target primitive data block. As shown in Figure 15, the target primitive data block includes primitive data blocks corresponding to a first fill mode, a second fill mode, a third fill mode, and so on. Based on the target fill mode input by the user, the third primitive data block corresponding to the target fill mode is determined from the target primitive data block. For example, in response to the shader program receiving an input operation indicating a point fill mode for a line type, a primitive data block indicating a point fill mode is output from the line type primitive data block.

[0165] The following are the constraints used by the user:

[0166] For point types, the syntax restricts users to only selecting the output point fill mode;

[0167] For line types, the syntax restricts users to choose between dot fill mode or line fill mode;

[0168] For triangle types, the syntax restricts users to choose between point fill mode, line fill mode, or solid fill mode.

[0169] In the above embodiments, the mesh shader on the graphics processor can output metadata for multiple fill modes with a single drawing instruction. The user can then select the metadata for the target fill mode. This avoids the need for multiple drawing instructions in related technologies to output metadata for multiple fill modes. For example, if the user initially draws a triangle with a line fill mode using a single drawing instruction, and then wants to switch to obtaining metadata for a solid fill mode, a new drawing instruction must be sent, and the mesh shader must draw the same triangle again to obtain the metadata for the solid fill mode. In this case, the graphics processor consumes significant resources, and the mesh shader needs to draw a triangle multiple times to obtain metadata for multiple fill modes.

[0170] Figure 16 shows a structural block diagram of a primitive output device provided in an exemplary embodiment of this application. The device includes:

[0171] The control module 1601 is used to respond to receiving a first drawing instruction, control the geometry processing pipeline in the graphics processor to implement the geometry processing function in the mesh shading rendering pipeline, and control the geometry processing pipeline to perform graphics drawing based on the first drawing instruction;

[0172] Output module 1602 is used to respond to the input operation of the target primitive type received by the shader program interface and output the primitive data of the target primitive type from the drawing results of the geometry processing pipeline;

[0173] The drawing results include primitive data of at least two primitive types, including at least two of the primitive types: points, lines, and triangles.

[0174] In an optional embodiment, the drawing result includes a vertex data area and a graph data area. The vertex data area includes the vertex attributes of at least two vertices. The graph data area includes multiple graph data blocks, which correspond one-to-one with multiple graph primitives. Each graph data block includes a type segment of the current graph primitive, which is used to hold the type identifier of the current graph primitive.

[0175] The output module 1602 is used to respond to the input operation of the target primitive type received by the shader program interface and output the target primitive data block corresponding to the target primitive type from the primitive data area.

[0176] In an optional embodiment, each primitive data block further includes three index segments; the three index segments are used to hold the index values ​​of the vertices of the current primitive in the vertex data area;

[0177] The output module 1602 is also used to respond to the input operation of the target index value under the target primitive type received by the shader program interface, and output the first primitive data block corresponding to the target index value from the target primitive data block.

[0178] In an optional embodiment, each graphic element block further includes a first indicator segment and a first attribute segment. The first indicator segment is used to indicate whether the current graphic element supports the size of a specified point, or to indicate whether the current graphic element does not support the size of a specified point. The first attribute segment is used to indicate the size of a point on the current graphic element.

[0179] The output module 1602 is also used to respond to the input operation of the target point size under the target primitive type received by the shader program interface, and to output a second primitive data block from the target primitive data block that supports the size of the specified point and the size of the point conforms to the target point size.

[0180] In an optional embodiment, each graphic element block further includes a second indicator segment; the second indicator segment is used to indicate the fill mode adopted by the current graphic element, the fill mode including any one of point fill, line fill and solid fill;

[0181] The output module 1602 is also used to respond to the input operation of the target fill mode under the target primitive type received by the shader program interface, and output a third primitive data block whose fill mode conforms to the target fill mode from the target primitive data block.

[0182] In summary, in the above embodiments, the mesh shader on the graphics processor can output metadata for multiple primitive types with a single drawing instruction. The user can then select the metadata for the target primitive type. This avoids the need for multiple drawing instructions in related technologies to output metadata for multiple primitive types. For example, if a user initially draws metadata for a "triangle" using a single drawing instruction, and then wants to switch to obtaining metadata for a "line," a new drawing instruction must be sent. The mesh shader then needs to draw the same batch of data again to obtain the metadata for the "line." This consumes significant graphics processor resources, as the mesh shader needs to draw the same batch of data multiple times to obtain metadata for multiple primitive types.

[0183] Figure 17 shows a structural block diagram of an electronic device 1700 provided in an exemplary embodiment of this application. Optionally, the electronic device 1700 includes a graphics processor provided in an embodiment of this application, and / or is used to execute the primitive output method provided in this application.

[0184] Optionally, the electronic device can be a portable mobile terminal, such as a smartphone, tablet, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop, or desktop computer. The electronic device 1700 may also be referred to as a user device, portable terminal, laptop terminal, desktop terminal, or other names. Typically, the electronic device 1700 includes a processor 1701 and memory 1702.

[0185] Processor 1701 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1701 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1701 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1701 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 1701 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0186] The memory 1702 may include one or more computer-readable storage media, which may be non-transitory. The memory 1702 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices.

[0187] In some embodiments, the electronic device 1700 may also optionally include a peripheral device interface 1703 and at least one peripheral device. Those skilled in the art will understand that the structure shown in FIG17 does not constitute a limitation on the electronic device 1700, and may include more or fewer components than illustrated, or combine certain components, or employ different component arrangements.

[0188] This application also provides a chip that includes a graphics processor as described in the embodiments above.

[0189] This application also provides a graphics card that includes a graphics processor as described in the embodiments above.

[0190] This application also provides a server that includes a graphics processor as described in the embodiments above.

[0191] Figure 18 shows a schematic diagram of the structure of a server provided in an exemplary embodiment of this application. The server 1800 includes a plurality of graphics processors 1801, and at least one of the graphics processors 1801 is a graphics processor provided in an embodiment of this application.

[0192] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the primitive output method provided in the above method embodiments.

[0193] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the primitive output method provided in the above-described method embodiments.

Claims

1. A graphics processor, the graphics processor comprising a geometry processing pipeline; The geometry processing pipeline is used to perform graphics drawing based on a first drawing instruction to obtain drawing results. The drawing results include graphic data of at least two primitive types, including at least two of points, lines, and triangles. The first drawing instruction is used to instruct the geometry processing pipeline to implement the geometry processing function in the mesh shading rendering pipeline.

2. The graphics processor according to claim 1, wherein, The drawing result includes a vertex data area and a graph data area, wherein the vertex data area includes the vertex attributes of at least two vertices; The image data area includes multiple image data blocks, each of which corresponds to a multiple image element. Each image data block includes a type segment for the current image element, which is used to store the type identifier of the current image element.

3. The graphics processor according to claim 2, wherein, Each graph data block further includes three index segments; the three index segments are used to hold the index values ​​of the vertices of the current graph element in the vertex data area.

4. The graphics processor according to claim 2, wherein, Each map data block further includes a first indicator segment and a first attribute segment; The first indication segment is used to indicate that the current graphic element supports the size of the specified point, or to indicate that the current graphic element does not support the size of the specified point; The first attribute segment is used to indicate the size of the point on the current primitive.

5. The graphics processor according to claim 2, wherein, Each map data block also includes a second indicator segment; The second indicator segment is used to indicate the fill mode adopted by the current graphic element, and the fill mode includes any one of point fill, line fill and solid fill.

6. The graphics processor according to claim 2, wherein, The graph data area further includes a quantity indicator segment, which is used to indicate the number of at least two vertices in the vertex data area and the number of multiple graph elements in the graph data area.

7. The graphics processor according to any one of claims 2 to 6, wherein, The vertex data area and the graph data area in the drawing result are spliced ​​together; The quantity indication segment in the graph data data area is located at the end of the graph data data area. The quantity indication segment is used to indicate the number of at least two vertices in the vertex data area and the number of multiple graph elements in the graph data data area.

8. The graphics processor according to any one of claims 2 to 6, wherein, Each of the plurality of graph data blocks includes a topology attribute segment and a plurality of other attribute segments. The topology attribute segment is used to indicate the topology of the current graph element. The plurality of other attribute segments correspond one-to-one with a plurality of attributes of the current graph element. The topology attribute segment includes the type segment.

9. A primitive output method, the method comprising: In response to receiving a first drawing instruction, the geometry processing pipeline in the graphics processor is controlled to perform geometry processing in the mesh shading rendering pipeline, and the geometry processing pipeline is controlled to perform graphics drawing based on the first drawing instruction. In response to receiving an input operation for a target primitive type, the primitive data of the target primitive type is output from the drawing results of the geometry processing pipeline; The drawing result includes at least two primitive types of primitive data, and the at least two primitive types include at least two of points, lines, and triangles.

10. The method according to claim 9, wherein, The drawing result includes a vertex data area and a graph data area. The vertex data area includes vertex attributes of at least two vertices. The graph data area includes multiple graph data blocks, which correspond one-to-one with multiple primitives. Each graph data block includes a type segment of the current primitive, which is used to store the type identifier of the current primitive. The step of responding to an input operation of the target primitive type by outputting the primitive data of the target primitive type from the rendering result of the geometry processing pipeline includes: In response to receiving an input operation for the target primitive type, the target primitive data block corresponding to the target primitive type is output from the primitive data area.

11. The method according to claim 10, wherein, Each graph data block also includes three index segments; The three index segments are used to accommodate the index values ​​of the vertices of the current primitive in the vertex data area; The method further includes: In response to receiving an input operation for a target index value under the target primitive type, the first primitive data block corresponding to the target index value is output from the target primitive data block.

12. The method according to claim 10, wherein, Each graphic element data block further includes a first indicator segment and a first attribute segment, wherein the first indicator segment is used to indicate that the current graphic element supports the size of a specified point, or to indicate that the current graphic element does not support the size of the specified point; The first attribute segment is used to indicate the size of the point on the current primitive; The method further includes: In response to receiving an input operation on the target point size under the target primitive type, a second primitive data block that supports the size of the specified point and whose point size conforms to the target point size is output from the target primitive data block.

13. The method according to claim 10, wherein, Each graphic element data block further includes a second indicator segment; the second indicator segment is used to indicate the fill mode adopted by the current graphic element, the fill mode including any one of point fill, line fill and solid fill; The method further includes: In response to receiving an input operation for a target fill pattern under the target primitive type, a third primitive data block whose fill pattern conforms to the target fill pattern is output from the target primitive data block.

14. A primitive output device, the device comprising: The control module is configured to, in response to receiving a first drawing instruction, control the geometry processing pipeline in the graphics processor to implement the geometry processing function in the mesh shading rendering pipeline, and control the geometry processing pipeline to perform graphics drawing based on the first drawing instruction; The output module is configured to, in response to receiving an input operation of the target primitive type, output primitive data of the target primitive type from the drawing results of the geometry processing pipeline; The drawing result includes at least two primitive types of primitive data, and the at least two primitive types include at least two of points, lines, and triangles.

15. A chip comprising a graphics processor as described in any one of claims 1 to 8.

16. A server comprising a graphics processor as described in any one of claims 1 to 8.

17. An electronic device comprising a graphics processor as claimed in any one of claims 1 to 8.

18. An electronic device, the electronic device comprising: A processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the primitive output method as described in any one of claims 9 to 13.

19. A computer-readable storage medium storing a computer program, the computer program being loaded and executed by a processor to implement the primitive output method as described in any one of claims 9 to 13.

20. A computer program product storing a computer program that is loaded and executed by a processor to implement the primitive output method as described in any one of claims 9 to 13.