Graphics processor, primitive output method, chip, server and electronic equipment

By designing a graphics processor that can output multiple element types of primitive data with one drawing instruction in the graphics processor, the performance consumption problem caused by multiple drawing instructions in the prior art acquisition of multiple element types of data is solved, and more efficient graphics processing performance is achieved.

CN119809913AActive Publication Date: 2025-04-11MOORE THREADS TECHNOLOGY (CHENGDU) CO LTD

Patent Information

Application Number
CN202411997333.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-11
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

In the prior art, in the graphics processor, multiple drawing instructions are required to obtain the metadata of multiple primitive types, resulting in high performance consumption.

Method used

By designing a graphics processor in the graphics processor, it can output multiple primitive types of primitive data with one drawing instruction, including points, lines, triangles, etc., to realize the geometric processing function of the grid shading rendering pipeline.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119809913A_ABST
    Figure CN119809913A_ABST
Patent Text Reader

Abstract

The invention discloses a graphics processor, a primitive output method, a chip, a server and electronic equipment, and belongs to the field of chips. The graphics processor comprises a geometric processing pipeline; the geometric processing pipeline is used for executing graph drawing based on the first drawing instruction to obtain a drawing result, the drawing result comprises primitive data of at least two primitive types, and the at least two primitive types comprise at least two of points, lines and triangles; the first drawing instruction is used for indicating the geometric processing pipeline to realize a geometric processing function in the grid coloring rendering pipeline. According to the method and the device, the primitive data of the multiple primitive types can be obtained only through one drawing instruction, the situation that the primitive data of the multiple primitive types can be obtained only through repeated drawing of multiple drawing instructions is avoided, and the performance of the graphics processor is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of chips, and in particular to a graphics processor, a graphics primitive output method, a chip, a server and an electronic device. Background Art

[0002] The graphics processing unit (GPU) provides a VTG rendering pipeline. The geometry processing pipeline in the VTG rendering pipeline is composed 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 serially, which limits the efficiency of parallel computing and easily leads to performance bottlenecks.

[0003] The graphics processor of the related art provides 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, thereby improving the performance of the graphics processor.

[0004] In the related art, in response to a drawing instruction input by a user, the output of the geometry processing pipeline in the mesh shading rendering pipeline only includes metadata of one primitive type. When the user needs to obtain metadata of a different primitive type, a new drawing instruction needs to be initiated. At this time, the geometry processing part of the mesh shading rendering pipeline needs to redraw the primitives, and the redrawing consumes more performance of the graphics processor. Summary of the invention

[0005] The present application provides a graphics processor, a primitive output method, a chip, a server and an electronic device. The present application can obtain primitive data of multiple primitive types with only one drawing instruction, avoiding repeated drawing through multiple drawing instructions to obtain primitive data of multiple primitive types, thereby saving the performance of the graphics processor.

[0006] According to one aspect of the present application, a graphics processor is provided, the graphics processor comprising a geometry processing pipeline;

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

[0008] According to one aspect of the present application, a method for outputting a graphic element is provided, the method comprising:

[0009] In response to receiving the first drawing instruction, controlling the geometry processing pipeline in the graphics processor to implement the geometry processing function in the mesh shading rendering pipeline, and controlling the geometry processing pipeline to perform graphics drawing based on the first drawing instruction;

[0010] In response to receiving an input operation of a target primitive type, outputting primitive data of the target primitive type from a rendering result of the geometry processing pipeline;

[0011] The drawing result includes graphic element data of at least two graphic element types, and the at least two graphic element types include at least two of points, lines and triangles.

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

[0013] A control module, configured to control a geometry processing pipeline in a graphics processor to implement a geometry processing function in a mesh shading rendering pipeline in response to receiving a first drawing instruction, and to control the geometry processing pipeline to perform graphics drawing based on the first drawing instruction;

[0014] An output module, configured to output primitive data of the target primitive type from the rendering result of the geometry processing pipeline in response to receiving an input operation of the target primitive type;

[0015] The drawing result includes graphic element data of at least two graphic element types, and the at least two graphic element types include at least two of points, lines and triangles.

[0016] According to one aspect of the present application, a chip is provided, and the chip includes the above-mentioned graphics processor.

[0017] According to one aspect of the present application, a server is provided, and the server includes the above-mentioned graphics processor.

[0018] According to one aspect of the present application, an electronic device is provided, and the electronic device includes the above-mentioned graphics processor.

[0019] According to one aspect of the present application, an electronic device is provided, 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 above-mentioned primitive output method.

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

[0021] According to one aspect of the present application, a computer program product is provided. The computer program product stores a computer program, and the computer program is loaded and executed by a processor to implement the above-mentioned primitive output method.

[0022] The beneficial effects brought about by the technical solution provided in the embodiments of the present application include at least the following.

[0023] In the present application, in response to a drawing instruction (a 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, and the drawing result includes metadata of at least two types of primitives. That is, in the present application, only one drawing instruction can be used to draw metadata of multiple types of primitives, avoiding the need for multiple drawing instructions to execute multiple drawings in the related art to obtain metadata of multiple types of primitives, thereby reducing the performance overhead of the graphics processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0025] Figure 1 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0026] Figure 2 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0027] Figure 3 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0028] Figure 4 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0029] Figure 5 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0030] Figure 6 It is a schematic diagram of a geometry processing pipeline provided by an embodiment of the present application.

[0031] Figure 7 This is a schematic diagram of the drawing result of a mesh shader provided by an embodiment of the present application.

[0032] Figure 8 It is a schematic diagram of the drawing result of the mesh shader provided by another embodiment of the present application.

[0033] Fig. 9 This is a schematic diagram of a graphic element data block provided by an embodiment of the present application.

[0034] Fig.10 It is a schematic diagram of additional attribute segmentation provided by an embodiment of the present application.

[0035] Fig.11 It is a schematic diagram of quantity indication segmentation provided by an embodiment of the present application.

[0036] Fig.12 This is a flowchart of a method for outputting graphics primitives provided by an embodiment of the present application.

[0037] Fig.13 It is a schematic diagram of a method for specifying an index value provided by an embodiment of the present application.

[0038] Fig.14 It is a schematic diagram of a method for specifying a point size provided by an embodiment of the present application.

[0039] Fig.15 It is a schematic diagram of a method for specifying a fill mode provided by an embodiment of the present application.

[0040] Fig.16 It is a structural block diagram of a graphic element output device provided by an embodiment of the present application.

[0041] Fig.17 It is a structural block diagram of an electronic device provided by an embodiment of the present application.

[0042] Fig.18 It is a schematic diagram of the structure of a server provided in one embodiment of the present application. DETAILED DESCRIPTION

[0043] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0044] First, some terms in the embodiments of the present application are introduced:

[0045] Geometry processing pipeline: The graphics processor is mainly composed of two parts, the geometry processing pipeline and the pixel processing pipeline. The geometry processing pipeline is mainly used to process the geometric coordinates and shapes of the graphics, and the pixel processing pipeline is mainly used to perform pixel operations on the graphics. In the VTG rendering pipeline proposed by DX11.3, the geometry processing pipeline includes the vertex shader (Vertex Shader), the tessellation shader (including the hull shader (Hull Shader), the tessellation stage (Tessellator) and the domain shader (Domain Shader)) and the geometry shader (Geometry Shader). In the mesh shading rendering pipeline proposed by DX12, the geometry processing pipeline includes the amplification shader (Amplification Shader) and the mesh shader (Mesh Shader).

[0046] In the geometry processing pipeline of the VTG rendering pipeline, after receiving the drawing instruction, the initial drawing data first enters the vertex shader, and the vertex shader completes the coordinate transformation of the vertex. The vertex shader is processed based on the vertex as the basic unit. After the vertex shader is completed, it will enter the tessellation shader, which is an optional shader. In the tessellation shader, the shell shader completes the pre-calculation process of the tessellation, and the tessellation parameters output by the shell shader enter the tessellation stage. The tessellation stage will calculate the new vertices after the tessellation according to the tessellation parameters, and the domain shader adjusts and calculates the coordinates of the new vertices. The domain shader inputs all vertices into the geometry shader, and the geometry shader adds, deletes, and modifies the vertices. The geometry shader is also an optional shader.

[0047] In the geometry processing pipeline of the mesh shading rendering pipeline, the magnification shader will magnify the received drawing data to generate more drawing data. The magnification shader is an optional shader. After the mesh shader obtains all the drawing data, it will process the drawing data of the entire mesh. The mesh shader can process the data of the entire mesh at one time, thereby realizing large-scale geometry data generation and processing.

[0048] Figure 1 is a schematic diagram of a geometry processing pipeline 100 provided by an exemplary embodiment of the present application, Figure 1 The geometry processing pipeline 100 shown is used to implement the functions of the magnification shader and the 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 .

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

[0050] The shader execution unit 140 runs the enlarged shader thread group to obtain an enlarged shading result and a second drawing instruction, the second drawing instruction is used to indicate the number of mesh shader thread groups that need to be derived, and the enlarged shading result is used to characterize the drawing result generated by the enlarged 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 when the enlarged shader thread group is running. In this application, the first drawing instruction input by the user specifies the number of enlarged shader thread groups that need to be generated, and the second drawing instruction output by the shader execution unit 140 specifies the number of mesh shader thread groups that need to be generated.

[0051] The task control unit 120 obtains the second drawing instruction according to the instruction of the received magnification task information, and inputs the second drawing instruction into the second task generation pipeline 130. The magnification task information includes the instruction format, storage location and other information of the second drawing instruction. The task control unit 120 can obtain the second drawing instruction according to the instruction of the magnification task information. In an embodiment of the present application, an amplification shader processing pipeline is provided to implement the function of the amplification shader. The amplification shader processing pipeline includes a first task generation pipeline 110, a task control unit 120 and a shader execution unit 140.

[0052] The second task generation pipeline 130 creates a mesh shader thread group based on the second drawing instruction. The second drawing instruction indicates that the generated thread group is used to implement the function of the mesh shader. The mesh shader thread group can also be called a mesh shader task. The mesh shader thread group is a thread group used to implement the mesh shader function. The second task generation pipeline 130 inputs the mesh shader thread group into the shader execution unit 140, and sends the mesh task information corresponding to the mesh shader thread group to the task control unit 120. The mesh task information is the relevant information of the mesh shader thread group.

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

[0054] The task control unit 120 obtains the mesh shading result according to the instructions of the mesh task information, and outputs the mesh shading result to the pipeline after the geometry processing pipeline. The mesh task information includes information such as the storage format and storage location of the mesh shading result. The task control unit 120 can obtain the mesh shading result according to the instructions of the mesh task information. In an embodiment of the present application, a mesh shader processing pipeline is provided to implement the function of the mesh shader. The mesh shader processing pipeline includes a second task generation pipeline 130, a task control unit 120, and a shader execution unit 140.

[0055] In one embodiment, the hardware units on the first task generation pipeline 110 and the hardware units on the second task generation pipeline 130 are different, that is, the two pipelines are completely independent. In another embodiment, the hardware units on the first task generation pipeline 110 and the hardware units on the second task generation pipeline 130 are partially the same, that is, the two generation pipelines have some shared hardware units.

[0056] In one embodiment, the grid shading result output by the task control unit 120 will enter the pixel processing pipeline. The pixel processing pipeline includes a rasterization stage, a pixel shader, and an output blending part. 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 pixel processing pipeline of tile rendering is intended 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 the lighting calculation, and can more efficiently process the lighting in complex scenes. That is, the geometry processing pipeline provided in the present application is applicable to any type of pixel processing pipeline, that is, the geometry processing pipeline provided in the present application has a wide range of applicability.

[0057] In summary, the present application provides a geometry processing pipeline that supports magnification shaders and mesh shaders. Furthermore, the present application provides a resource scheduling solution within the geometry processing pipeline that supports magnification shaders and mesh shaders. Moreover, in the present application, the task control unit schedules the second drawing instruction output by the magnification shader, and schedules the mesh shading result output by the mesh shader, thereby improving the orderliness of the scheduling. Moreover, the geometry processing pipeline designed in the present application is programmable, and the geometry processing pipeline includes a first task generation pipeline, a second task generation pipeline, a task execution unit, and a task control unit. The rich hardware units improve the flexibility of programming and improve the overall throughput of the graphics processor.

[0058] Figure 2 FIG. 1 shows a schematic diagram of a geometry processing pipeline 100 provided by an exemplary embodiment of the present application. Figure 2 The geometry processing pipeline 100 shown is used to implement the functions of the magnification shader and the 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 magnification 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.

[0059] For the first task, a pipeline 110 is generated

[0060] The first task generating unit 111 creates a first thread group based on the first drawing instruction, and sends the first thread group to the magnifying shader unit 112. The first thread group is a thread group specified by the first drawing instruction for implementing the function of the magnifying shader. Schematically, the first drawing instruction includes three 32-bit parameters. For example, if the first drawing instruction includes parameters (4, 3, 2), the first task generating unit 111 will generate 4*3*2==24 first thread groups. The 24 first thread groups generated by the first drawing instruction are used to implement the function of the magnifying 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. The mesh refers to the geometric structure of a three-dimensional model, which is usually composed of vertices, edges and faces; or, multiple threads of the at least two threads are used together to process one or more meshes. This application does not limit this.

[0061] The enlarged shading unit 112 adds the first resource requirement information to the first thread group to obtain the second thread group; and sends the second thread group to the shader task construction unit 113. The first resource requirement information refers to the resources required to run the enlarged shader thread group. Optionally, the first resource requirement information includes the storage location of the second drawing instruction, the instruction format, the storage format of the enlarged shading result, the storage location of the enlarged shading result, the address of the temporary storage space used when running the enlarged shader thread group, the address of the result storage space, and other resource request information. Optionally, the first resource requirement information includes the request information of the grid load packet, which is a load packet used to accommodate the enlarged shading result.

[0062] The shader task construction unit 113 allocates resources to the second thread group based on the first resource requirement information, and uses the second thread group after resource allocation as the enlarged shader thread group. The shader task construction unit 113 sends the enlarged shader thread group to the shader execution unit 140. The shader task construction unit 113 also sends the enlarged task information corresponding to the enlarged shader thread group to the task control unit 120, where the enlarged task information is the information of the resources allocated by the shader task construction unit 113 to the second thread group.

[0063] Generate pipeline 130 for the second task

[0064] The second task generating 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 a thread group specified by the second drawing instruction for implementing the function of the mesh shader. Schematically, the second drawing instruction includes three 32-bit parameters. For example, the second drawing instruction includes parameters (6, 3, 2), then the second task generating unit 131 will generate 6*3*2==36 third thread groups. The 36 third thread groups generated by the second drawing instruction 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 mesh or multiple meshes, or multiple threads of the at least two threads are used together to process one mesh or multiple meshes. This application does not limit this.

[0065] The mesh shading unit 132 is used to add the second resource requirement information to the third thread group to obtain a fourth thread group; and send the fourth thread group to the shader task construction unit 113. The second resource requirement information refers to the resources required to run the first thread group. Optionally, the second 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.

[0066] The shader task construction unit 113 is used to allocate resources to the fourth thread group based on the second resource requirement information, and use the fourth thread group after resource allocation 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 mesh task information corresponding to the mesh shader thread group to the task control unit 120, where the mesh task information is information about the resources allocated by the shader task construction unit 113 to the fourth thread group.

[0067] In the above embodiment, the first task generation pipeline 110 and the second task generation pipeline 130 have their own task generation units and shading units for requesting resources, as well as a shared shader task construction unit 113. The sharing of the shader task construction unit 113 can save the use of hardware and reduce the hardware density on the graphics processor. In addition, in addition to allocating resources to the thread group, the shader task construction unit 113 will also send resource information, that is, task information, to the task control unit 120, so that the task control unit 120 can use the task information to perform scheduling, that is, the present application provides a method for generating task information, and the task control unit 120 can use the task information to better schedule the second drawing instruction and the grid shading result. In addition, each task generation pipeline provided by the present application has its own task generation unit and shading unit for requesting resources. The task generation unit and the shading unit for requesting resources are programmable hardware, that is, the rich hardware units in the present application improve the flexibility of programming.

[0068] Figure 3 FIG. 1 is a schematic diagram of a geometry processing pipeline 100 provided by another exemplary embodiment of the present application. Figure 3 The geometry processing pipeline 100 shown is used to implement the functions of the magnifying shader and the mesh shader. The geometry processing pipeline 100 includes a magnifying shader processing pipeline, a task control unit 120 and a mesh shader processing pipeline. The magnifying 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, a magnifying shading unit 112 and a shader task construction unit 113;

[0069] 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 .

[0070] For enlarging the shader processing pipeline

[0071] The related introduction of the first task generation pipeline 110 and the shader execution unit 140 can be found above and will not be repeated here.

[0072] The result storage unit 150 is used to store at least one of the enlarged shading result and the second drawing instruction output by the shader execution unit 140. 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 instruction of the enlarged task information, and sends the second drawing instruction to the second task generation unit 131.

[0073] The temporary storage unit 160 is used to temporarily store the data read and written when the shader execution unit 140 executes the enlarged shader thread group. Optionally, the temporary storage unit 160 is used to store the enlarged shading result output by the shader execution unit 140. Optionally, the temporary storage unit 160 is the on-chip storage space of the graphics processor. Optionally, the temporary storage unit 160 can also be the off-chip storage space of the graphics processor. In one embodiment, the grid load packet allocated by the shader task construction unit 113 is located in the temporary storage unit 160. The grid load packet is a temporary load packet, and the grid load packet is used to accommodate the enlarged shading result output by the shader execution unit 140. When the shader execution unit 140 runs the grid shader thread group, it will obtain the enlarged shading result from the temporary storage unit 160. When the shader execution unit 140 runs the grid shader thread group to generate the grid shading result, it needs to rely on the enlarged shading result.

[0074] For the mesh shader processing pipeline

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

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

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

[0078] In the embodiment of the present application, the enlarged shader processing pipeline and the mesh shader processing pipeline will share the result storage unit 150 and the temporary storage unit 160. The sharing of the result storage unit 150 and the temporary storage unit 160 can save the use of hardware and reduce the hardware density on the graphics processor. In addition, the present 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 the 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.

[0079] In the embodiment of the present application, the grid load packet is a temporary load packet allocated by the first task generation pipeline 110, specifically, a temporary load packet allocated by the shader task construction unit 113, and the grid load packet is used to accommodate the enlarged shading result. Since the grid load packet is a temporary load packet, it is necessary to release the grid load packet in time after the enlarged shading result is used to avoid the accumulation of the grid load packet and occupying the storage space.

[0080] In one embodiment, the second task generation pipeline 130 is further used to add an end mark 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 mark is detected.

[0081] The task control unit 120 detects the end mark, indicating that the shader execution unit 140 has run to the last mesh shader thread group. When the last mesh shader thread group is finished running, it means that the enlarged shading result has been used up, and then the mesh load package can be released to clear the enlarged shading result.

[0082] In one embodiment, based on Figure 2 The geometry processing pipeline 100 shown, 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 thread groups; 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 thread groups. The task control unit 120 is used to clear the mesh load packet when the end flag is detected.

[0083] It can be understood that the second drawing instruction sent by the task control unit 120 to the second task generation unit 131 includes 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 generated is the last group of third thread groups. Therefore, the second task generation unit 131 can add an end flag to the last group of third thread groups.

[0084] In the present application, the method of marking the end mark on the last mesh shader thread group is adopted. When the task control unit 120 detects the end mark, it can timely control the release of the mesh load packet. Compared with the method of releasing the enlarged shading result by using reference counting in the related art, the operation is simple and not prone to errors. The related art uses reference counting to manage the output of the enlarged shader (i.e., the enlarged shading result). The related art requires the storage of a reference counter in an additional storage space. The reference counter is used to record the number of times the enlarged shading result is referenced, i.e., the reference count, and uses atomic instructions to subtract the reference count. When the subtraction result is zero, the mesh load packet is released. The hardware design of the related art is relatively complex, while the present application can directly mark the end mark in the data stream without storing the reference counter, and the overall hardware design is simpler.

[0085] Figure 4 FIG. 1 shows a geometry processing pipeline 100 provided by an exemplary embodiment of the present application. Figure 4 The geometry processing pipeline 100 in the embodiment is used to implement the function of the 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.

[0086] The third task generation pipeline 410 creates a mesh shader thread group based on the third drawing instruction. The third drawing instruction indicates that the generated thread group is used to implement the function of the mesh shader. The third drawing instruction is used to indicate the number of generated mesh shader thread groups. The mesh shader thread group can also be called a mesh shader task. The mesh shader thread group is a thread group used to implement the mesh shader function. The third task generation pipeline 410 inputs the mesh shader thread group into the shader execution unit 140, and sends the mesh task information corresponding to the mesh shader thread group to the task control unit 120. The mesh task information is the relevant information of the mesh shader thread group. Optionally, the third drawing instruction is an instruction input by the user on the shader program.

[0087] The shader execution unit 140 is used to run the mesh shader thread group to obtain a mesh shading result.

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

[0089] In one embodiment, the grid shading result output by the task control unit 120 will enter the pixel processing pipeline. The pixel processing pipeline includes a rasterization stage, a pixel shader, and an output blending part. 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 by the present application is applicable to any type of pixel processing pipeline, that is, the geometry processing pipeline provided by the present application has a wide range of applicability.

[0090] In summary, the present application provides a geometry processing pipeline that supports mesh shaders. Furthermore, the present application provides a resource scheduling solution within the geometry processing pipeline that supports mesh shaders. Moreover, in the present application, the mesh shading results output by the mesh shader are scheduled by the task control unit, which improves the orderliness of the scheduling. Moreover, the geometry processing pipeline designed by the present application is programmable and includes a third task generation pipeline, a task execution unit, and a task control unit. The rich hardware units improve the flexibility of programming and the overall throughput of the graphics processor.

[0091] And, in contrast Figure 1 and Figure 4 From the geometry processing pipeline shown, it can be found that the geometry processing pipeline provided by the present application can support two modes at the same time: mesh shader only, magnification shader and mesh shader. The shader execution unit 140 and task control unit 120 in the present application can support two modes at the same time.

[0092] Figure 5 FIG. 4 shows a geometry processing pipeline provided by an exemplary embodiment of the present application. Figure 5 The geometry processing pipeline 100 shown is used to implement the function of the mesh shader, and 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 enlargement shading unit 112, a second task generation unit 131, a mesh shading unit 132, and a shader task construction unit 113.

[0093] 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 magnification shading unit 112. The fifth thread group is a thread group specified by the third drawing instruction for implementing the function of the mesh shader. Schematically, the third drawing instruction includes three 32-bit parameters. For example, 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 36 fifth thread groups specified by the third drawing instruction are used to implement the function of the mesh shader. Optionally, each fifth thread group includes at least two threads. Optionally, each thread of the at least two threads is used to process one or more meshes. The mesh refers to the geometric structure of a three-dimensional model, which is usually composed of vertices, edges and faces. Alternatively, multiple threads of the at least two threads are used to process one or more meshes together. This application does not limit this.

[0094] The enlarged shading unit 112 is used to transparently transmit the fifth thread group to the second task generating unit 131;

[0095] The second task generating unit 131 is used for transparently transmitting the fifth thread group to the grid shading unit 132;

[0096] The mesh shading unit 132 is used to add the third resource requirement information to the fifth thread group to obtain the sixth thread group; the sixth thread group is sent to the shader task construction unit 113; the third resource requirement information refers to the resources required for running the fifth thread group. Optionally, the third resource requirement information includes the storage format of the mesh shading results, the storage location of the mesh shading results, 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.

[0097] The shader task construction unit 113 is used to allocate resources to the sixth thread group based on the third resource requirement information, and use the sixth thread group after resource allocation 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, where the mesh task information is the information of the resources allocated by the shader task construction unit 113 to the sixth thread group.

[0098] In the above embodiment, compared Figure 2 and Figure 5 The geometry processing pipeline shown in the figure shows that the geometry processing pipeline provided by the present application can support two modes at the same time: only mesh shader, magnification shader and mesh shader. The first task generation unit 111, magnification shading unit 112, second task generation unit 131 and mesh shading unit 132 in the present application can support two modes at the same time.

[0099] Figure 6FIG. 4 shows a geometry processing pipeline provided by an exemplary embodiment of the present application. Figure 6 The geometry processing pipeline 100 shown is used to implement the function of the mesh shader, and the geometry processing pipeline 100 includes a first task generation unit 111, an enlargement 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.

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

[0101] In the above embodiment, compared Figure 3 and Figure 6 From the geometry processing pipeline shown, it can be found that the geometry processing pipeline provided by the present application can support two modes at the same time: only mesh shader, magnification shader and mesh shader. The result storage unit 150 and the temporary storage unit 160 in the present application can support two modes at the same time. In addition, the present 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 the 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.

[0102] In one embodiment, for the two modes of mesh shader only and amplification shader plus mesh shader, the formats of the stored mesh shading results may be the same or different. Among the two modes, the layout of the mesh shading results corresponding to at least one mode may be the following layout.

[0103] In the following, the mesh shading result is also referred to as the rendering result.

[0104] In an embodiment of the present application, a graphics processor includes a geometry processing pipeline, which is used to receive a first drawing instruction, and the first drawing instruction is used to instruct the geometry processing pipeline to implement the geometry processing function in the mesh shading rendering pipeline, and the first drawing instruction is a DispatchMesh instruction; the geometry processing pipeline is used to perform graphics drawing based on the first drawing instruction to obtain a drawing result, and the drawing result includes at least two types of primitive data, and the at least two types of primitives include at least two of points, lines and triangles.

[0105] In one embodiment, the geometry processing pipeline is used to implement the function of the mesh shader, that is, the mesh shader-only mode introduced above is used to obtain the drawing result output by the mesh shader. 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 function of the amplification shader and the mesh shader, that is, the amplification shader and the mesh shader mode introduced above is used to obtain the drawing result output by the mesh shader. In this case, the first drawing instruction is used to instruct the geometry processing pipeline to execute the function of the amplification shader and the mesh shader.

[0106] In the present 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, and the drawing result includes graphics metadata of at least two types of primitives, that is, in the present application, graphics metadata of multiple types of primitives can be drawn by only one drawing instruction.

[0107] The drawing result (meshlet) includes the metadata of various primitive types. Figure 7 As shown, Figure 7 A schematic diagram of a drawing result is shown, and the drawing result includes a vertex data area 710 and an image data area 720. The vertex data area 710 includes vertex attributes of at least two vertices; the image data area 720 includes multiple image data blocks 721, and the multiple image data blocks 721 correspond to multiple primitives one by one. Each image data block 721 in the multiple image data blocks 721 is used to accommodate the primitive attributes of the current primitive. In other words, the i-th image data block 721 is used to accommodate the primitive attributes of the i-th primitive. In one embodiment, the image data blocks of the same primitive type indicated in the multiple image data blocks will be clustered and arranged. For example, among the multiple image data blocks, the front image data block is used to accommodate the image data of the point type, the middle image data block is used to accommodate the image data of the line type, and the rear image data block is used to accommodate the image data of the triangle type.

[0108] In one embodiment, the vertex data area 710 and the graphics data area 720 are spliced. At this time, the data format of the drawing result can be fully expressed by the three parameters of the base address, the size of the vertex data area 710 and the size of the graphics 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, only these three parameters are needed to access the target data. For example, when accessing the vertex data area 710, it is only necessary to start accessing from the base address; when accessing the graphics data area 720, it is only necessary to start accessing from the base address plus the size of the vertex data area 710.

[0109] In one embodiment, Figure 8As shown, in addition to the multiple data blocks 721, the primitive data area 720 also includes a quantity indication segment 722, which 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 primitive data area 720. Optionally, the quantity indication segment 722 is located at the end of the primitive data area 720. At this time, if an external component wants to access the quantity indication segment 722, it only needs to add the size of the vertex data area 710 and the size of the primitive data area 720 to the base address, and then subtract the size of the quantity indication segment 722 (which is a fixed value, optionally 32 bits).

[0110] Optionally, the quantity indication segment 722 may also be located at the head of the vertex data area 710. In this case, if an external component wants to access the quantity indication segment 722, it only needs to start accessing 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 base address to the size of the quantity indication segment 722 (a fixed value, optionally 32 bits).

[0111] In one embodiment, each primitive data block includes the index values ​​of the vertices that make up the current primitive in the vertex data area 710, the primitive type of the current primitive (including any one of point, line, triangle), whether the specified point size is supported, the filling mode, etc. The details will be introduced below.

[0112] In the related art, the definition of the meshlet output by the mesh shader is given, but the definition of the meshlet given in the related art is relatively complex, and the entire data is as many as four segments, which brings difficulties to the allocation and access of the meshlet. In this application, a two-segment layout of the drawing result is provided, and the two-segment layout is relatively simple. Since there are only two segments of space, it is relatively simple for the hardware to allocate the resources occupied by the drawing result, and the layout of the entire drawing result only needs the above three parameters (base address, size of the vertex data area, size of the primitive data area) to be fully expressed, and it is relatively simple for the hardware to access the drawing result.

[0113] Metadata Block

[0114] Based on the above introduction, the primitive data area includes multiple primitive data blocks, each primitive data block corresponds to a primitive, and each primitive data block is used to accommodate the primitive attributes of a primitive.

[0115] Fig. 9A schematic diagram of a graphic element data block provided by an exemplary embodiment of the present application is shown. The graphic element data block includes a topological attribute segment and multiple other attribute segments (attribute segment 0, attribute segment 1 to attribute segment N), and the topological attribute segment includes a first index segment, a second index segment, a third index segment, and an additional attribute segment. In one embodiment, the size of the topological attribute segment is the same as that of any one of the multiple other attribute segments, for example, both are 32 bits. Optionally, the size of the first index segment, the second index segment, the third index segment, and the additional attribute segment are the same, for example, both are 8 bits.

[0116] In one embodiment, the additional attribute segment includes a type segment, and the type segment is used to contain the type identifier of the current primitive. The additional attribute segment also includes an indication segment of other topology information, which will be described below.

[0117] When the primitive type of the current primitive corresponding to the primitive data block is a point, the first index segment is used to accommodate the index value of the first vertex of the current primitive in the vertex data area, and the type segment is used to accommodate the type identifier of the point. 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 express each index value is sufficient to meet the requirements. At this time, the values ​​on the second index segment and the third index segment are in an invalid state. Optionally, 2 bits are used to accommodate the type identifier of the point, for example, 01 is used to identify the point type.

[0118] In the case where the primitive type of the current primitive corresponding to the primitive data block is a line, the first index segment and the second index segment of the three index segments are used to respectively accommodate the index values ​​of the first vertex and the second vertex of the current primitive in the vertex data area, and the type segment is used to accommodate the type identification of the line. Optionally, the first index segment and the second index segment each contain 8 bits. In this case, the two index segments can each index 256 vertices, and the value on the third index segment is invalid. Optionally, 2 bits are used to accommodate the type identification of the line, for example, 10 is used to identify the line type.

[0119] In the case where the primitive type of the current primitive corresponding to the primitive data block is a triangle, the first index segment, the second index segment and the third index segment of the three index segments are respectively used to accommodate the index values ​​of the first vertex, the second vertex and the third vertex of the current primitive in the vertex data area, and the type segment is used to accommodate the type identification of the triangle. Optionally, the first index segment, the second index segment and the third index segment each contain 8 bits. In this case, each of the three index segments can index 256 vertices. Optionally, the type identification of the triangle is accommodated by 2 bits, for example, the triangle type is identified by 11.

[0120] It should be noted that the above example uses 8 bits for each index segment. In fact, when it is necessary to expand to indicate more vertices, the 32-bit topological attribute segment can be divided into three 10-bit index segments, and the other two bits are used to accommodate the type identifier. At this time, each index segment can index 1024 vertices. And if 1024 vertices still cannot exhaust the vertices in the vertex index area, the next other attribute segment (i.e. Figure 6 0 in the attribute segment), or the next two other attribute segments (i.e. Figure 6 The size of each attribute segment is 32 bits. At this time, the first two or three 32 bits will be used to represent the topological structure of the primitive.

[0121] To summarize, each primitive data block includes a type segment, and the setting of the type segment allows the user to specify the output primitive type in the shader program; and each primitive data block includes three index segments, and the setting of the three index segments allows the user to specify the output vertex index value in the shader program.

[0122] Additional attribute segment

[0123] Based on the above introduction, each primitive data block includes a topological attribute segment, and the topological attribute segment includes an additional attribute segment and three index segments. The additional attribute segment includes at least one of a type segment (used to indicate the primitive type of the current primitive), a first indication segment (used to indicate whether the size of the specified point is supported), and a second indication segment (used to indicate the fill mode of the current primitive), and the fill mode includes any one of point filling, line filling, and solid filling. The present application does not limit the distribution of the type segment, the first indication segment, and the second indication segment in the additional attribute segment. A possible distribution will be introduced below.

[0124] like Fig.10 As shown, Fig.10 A schematic diagram of an additional attribute segment is shown, in which the type segment, the second indication segment and the first indication segment are spliced ​​from low to high according to the bit position. In one embodiment, the size of the additional attribute segment is 8 bits, and the type segment includes the first two bits from right to left, namely bit[0:1]. At this time, the three types of primitives, point, line and triangle, can be encoded by two bits; the second indication segment includes bit[2:4], and the fill mode of the current primitive can be encoded by three bits. For example, bit[2] indicates whether it is point filling, bit[3] indicates whether it is line filling, bit[4] indicates whether it is solid filling, etc. The first indication segment includes bit[5]. The value of bit[5] is 0, indicating that the current primitive does not support the specified point size, and the value of bit[5] is 1, indicating that the current primitive supports the specified point size.

[0125] For the first indication segment, if the first indication segment indicates that the current primitive supports the size of the specified point, then Fig. 9 Among the multiple other attribute segments shown, there is an attribute segment for indicating the size of the point. For example, the first other attribute segment after the topological attribute segment is used to store the size of the point. In one embodiment, if the primitive type of the current primitive is a point, the first indication segment indicates that the current primitive supports the size of the specified point. The size of the point refers to the number of pixels occupied by the vertex on the primitive, for example, a vertex occupies 30 pixels.

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

[0127] To summarize, the additional attribute segment includes a first indication segment, and the setting of the first indication segment allows the user to specify the output point size in the shader program; and the additional attribute segment includes a second indication segment, and the setting of the second indication segment allows the user to specify the output fill mode in the shader program.

[0128] Quantity indication segment

[0129] Based on the above introduction, there is a quantity indication segment in the primitive data area, and 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 primitives in the primitive data area. The quantity indication segment includes a vertex quantity segment and a primitive quantity segment. The present application does not limit the distribution of the vertex quantity segment and the primitive quantity segment in the quantity indication segment. A distribution situation will be introduced below.

[0130] like Fig.11 As shown, the primitive number segment and vertex number segment in the quantity indication segment are spliced ​​from low to high according to the bit position. In one embodiment, the quantity indication segment contains 32 bits, of which the upper 16 bits are used to express the number of vertices in the vertex data area, and the lower 16 bits are used to express the number of primitives in the primitive data area. According to the specifications of DirectX and Vulkan, both actually only need 8 bits.

[0131] In one embodiment, the number of primitives segments and the number of vertices segments are spliced ​​from low to high according to the bit position, wherein the upper 16 bits are used to express the number of vertices in the vertex data area, and the lower 16 bits are used to express the number of primitives in the primitive data area. In another embodiment, the number of vertices segments and the number of primitives segments are spliced ​​from low to high according to the bit position, wherein the upper 16 bits are used to express the number of primitives in the primitive data area, and the lower 16 bits are used to express the number of vertices in the vertex data area.

[0132] In another embodiment, the upper 8 bits of the lower 16 bits are used to express the number of vertices in the vertex data area, and the lower 8 bits are used to express the number of vertices in the graphics data area. The opposite is also true.

[0133] In another embodiment, the upper 8 bits of the upper 16 bits are used to express the number of vertices in the vertex data area, and the lower 8 bits are used to express the number of vertices in the graphics data area. The opposite is also true.

[0134] In summary, the setting of the quantity indication segment allows the user to more easily obtain the number of vertices and the number of primitives, so that the user can know more information.

[0135] The above describes that the drawing results output by the graphics processor contain metadata of various primitive types. The following describes how users can specify the target primitive type to output from the various primitive types.

[0136] Fig.12 A flowchart of a method for outputting a graphics primitive provided by an exemplary embodiment of the present application is shown. The method is illustrated by taking the method executed by a shader application on a terminal device as an example. The method includes:

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

[0138] The shader program interface will receive the code input by the user (developer), and according to the code input by the user, control the operation of the geometry processing pipeline in the graphics processor to realize the function of the mesh shader.

[0139] Schematically, the shader program interface receives the dispatchmesh instruction, controls the geometry processing pipeline in the graphics processor to start the mesh shader, and performs graphics drawing through the mesh shader. Optionally, the dispatchmesh instruction instructs the geometry processing pipeline to only start the function of the mesh shader; optionally, the dispatchmesh instruction instructs the geometry processing pipeline to start the functions of the magnification shader and the mesh shader.

[0140] Step 1240, in response to receiving an input operation of a target primitive type, outputting metadata of the target primitive type from a drawing result of the geometry processing pipeline, the drawing result including metadata of at least two primitive types, the at least two primitive types including at least two of points, lines, and triangles.

[0141] According to the above introduction, the drawing result of the mesh shader includes a vertex data area and a primitive data area. The vertex data area includes vertex attributes of at least two vertices, and the primitive data area includes multiple primitive data blocks. The multiple primitive data blocks correspond one-to-one to multiple primitives. Each primitive data block in the multiple primitive data blocks includes a type segment of the current primitive, and the type segment is used to accommodate the type identifier of the current primitive.

[0142] In one embodiment, in response to the shader program interface receiving an input operation of a target primitive type, a 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 the present application, the drawing result output by the mesh shader includes primitive data of multiple primitive types, such as at least two primitive data of points, lines, and triangles. The user can specify the output primitive type in the shader program interface, such as specifying the output point primitive data. Optionally, if the user does not specify the output primitive type, the default output triangle primitive data is output.

[0143] To sum up, in the above embodiment, through one drawing instruction, the mesh shader on the graphics processor can output metadata of multiple primitive types, and the user can further select the metadata of the target primitive type from them to output, thereby avoiding the need in the related art to output metadata of multiple primitive types through multiple drawing instructions. For example, the user initially draws the metadata of "triangle" through one drawing instruction. If the user wants to switch to obtain the metadata of "line", a new drawing instruction needs to be sent, and the mesh shader draws the same batch of data to be drawn again to obtain the metadata of "line". At this time, the performance consumption of the graphics processor is relatively large, and the mesh shader needs to draw the same batch of data to be drawn multiple times to obtain metadata of multiple primitive types.

[0144] Specify vertex index values

[0145] According to the above introduction, each primitive 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.

[0146] In one embodiment, in response to the shader program interface receiving an input operation of a target index value under a target primitive type, a first primitive data block corresponding to the target index value is determined from the target primitive data block. Fig.13As shown, the target metadata block includes a metadata block corresponding to the first index value, a metadata block corresponding to the second index value, a metadata block corresponding to the third index value, and so on. According to the target index value input by the user, the first metadata block corresponding to the target index value is determined from the target metadata block.

[0147] For point type, in response to the shader program interface receiving the input operation of the point type and the first index value of the first vertex, the target primitive data block corresponding to the first index value under the point type is determined from the primitive data area. The user uses the unit3 type indices to specify the vertex index value in the shader program interface. For point type, only the first index on the indices is valid, and the values ​​on the other two indices are ignored.

[0148] For the line type, in response to the shader program interface receiving the input operation of the line type, the first index value of the first vertex and the second index value of the second vertex, a target primitive data block corresponding to the first index value and the second index value under the line type is determined from the primitive data area. At this time, among the indices used by the user in the shader program interface, only the first two indexes are valid, and the value on the other index is ignored.

[0149] For the triangle type, in response to the shader program interface receiving the input operation 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 primitive data block corresponding to the first index value, the second index value, and the third index value under the triangle type is determined from the primitive data area. At this time, in the indices used by the user in the shader program interface, all three indexes are valid.

[0150] In the above embodiment, through one drawing instruction, the mesh shader on the graphics processor can output metadata of multiple primitive types. For various primitive types, the user can further specify the output of metadata corresponding to a given vertex index value, that is, the present application provides a solution that supports user-specified primitive types and vertex index values.

[0151] Specify point size

[0152] According to the above introduction, each primitive data block also includes a first indication segment and a first attribute segment. The first indication segment is used to indicate that the current primitive supports the size of the specified point, or is used to indicate that the current primitive 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.

[0153] After the user specifies the primitive type, the user may further specify the primitive data that the size of the output point satisfies the given target point size. Of course, the user may not choose to specify the point size.

[0154] In one embodiment, in response to the shader program interface receiving an input operation of a target point size under a target primitive type, a second primitive data block supporting the specified point size and having a point size that conforms to the target point size is output from the target primitive data block. Fig.14 As shown, the target primitive data block includes a primitive data block corresponding to the first point size, a primitive data block corresponding to the second point size, a primitive data block corresponding to the third point size, and so on. According to 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. The embodiment of the present application provides two shader program syntaxes, namely, ConstructPrimitive1 that supports the specified point size and ConstructPrimitive2 that does not support the specified point size. For platforms that do not support point types as mesh shader outputs, or cannot support the specified point size, it is only necessary to support the ConstructPrimitive2 syntax.

[0155] In the above embodiment, through one drawing instruction, the mesh shader on the graphics processor can output metadata corresponding to a variety of point sizes, and the user can select the metadata corresponding to the target point size for output. That is, the above embodiment further provides a user-specified output primitive attribute.

[0156] Specify fill mode

[0157] According to the above introduction, each primitive data block also includes a second indication segment; the second indication segment is used to indicate the filling mode adopted by the current primitive, and the filling mode includes any one of point filling, line filling and solid filling.

[0158] After the user specifies the primitive type, the user may further specify the primitive data whose output fill mode satisfies the given target fill mode. Of course, the user may not choose to specify the fill mode.

[0159] In one embodiment, in response to the shader program interface receiving an input operation of a target fill mode under a target primitive type, a second primitive data block having a fill mode that conforms to the target fill mode is output from the target primitive data block. Fig.15 As shown, the target primitive data block includes a primitive data block corresponding to the first filling mode, a primitive data block corresponding to the second filling mode, a primitive data block corresponding to the third filling mode, etc., and the third primitive data block corresponding to the target filling mode is determined from the target primitive data block according to the target filling mode input by the user. For example, in response to the shader program interface receiving an input operation of a point filling mode under a line type, a primitive data block of a point filling mode is output from the primitive data block of the line type.

[0160] The following are the constraints used by users:

[0161] For point types, the syntax restricts the user to only selecting output point fill modes;

[0162] For line types, the syntax restricts the user to either point fill mode or line fill mode;

[0163] For triangle type, the syntax restricts users to select point fill mode, line fill mode, or solid fill mode (Solid fill mode);

[0164] In the above embodiment, through one drawing instruction, the mesh shader on the graphics processor can output metadata under multiple fill modes, and the user can select the metadata of the target fill mode from them to output, thereby avoiding the need in the related art to output metadata of multiple fill modes through multiple drawing instructions. For example, the user initially draws a triangle with a line fill mode through one drawing instruction. If the user wants to switch to obtain metadata of a solid fill mode, a new drawing instruction must be sent, and the mesh shader must draw the same triangle again to obtain metadata of the solid fill mode. At this time, the performance consumption of the graphics processor is relatively large, and the mesh shader must draw a triangle multiple times to obtain metadata of multiple fill modes.

[0165] Fig.16 The structure block diagram of a primitive output device provided by an exemplary embodiment of the present application is shown, and the device includes:

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

[0167] An output module 1602, for outputting primitive data of the target primitive type from the rendering result of the geometry processing pipeline in response to the shader program interface receiving an input operation of the target primitive type;

[0168] The drawing result includes graphic element data of at least two graphic element types, and the at least two graphic element types include at least two of points, lines and triangles.

[0169] In an optional embodiment, the drawing result includes a vertex data area and a primitive data area, the vertex data area includes vertex attributes of at least two vertices, the primitive data area includes a plurality of primitive data blocks, the plurality of primitive data blocks correspond to each other one by one, each primitive data block in the plurality of primitive data blocks includes a type segment of the current primitive, the type segment is used to accommodate a type identifier of the current primitive;

[0170] The output module 1602 is used to output a target primitive data block corresponding to the target primitive type from the primitive data area in response to the shader program interface receiving an input operation of the target primitive type.

[0171] In an optional embodiment, each primitive data block further 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;

[0172] The output module 1602 is further configured to output a first primitive data block corresponding to the target index value from the target primitive data block in response to the shader program interface receiving an input operation of a target index value under a target primitive type.

[0173] In an optional embodiment, each primitive data block further includes a first indication segment and a first attribute segment, wherein the first indication segment is used to indicate that the current primitive supports the size of the specified point, or is used to indicate that the current primitive 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;

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

[0175] In an optional embodiment, each primitive data block further includes a second indication segment; the second indication segment is used to indicate a filling mode adopted by the current primitive, and the filling mode includes any one of point filling, line filling and solid filling;

[0176] The output module 1602 is further configured to output a third primitive data block whose filling mode conforms to the target filling mode from the target primitive data block in response to the shader program interface receiving an input operation of a target fill mode under a target primitive type.

[0177] To sum up, in the above embodiment, through one drawing instruction, the mesh shader on the graphics processor can output metadata of multiple primitive types, and the user can further select the metadata of the target primitive type from them to output, thereby avoiding the need in the related art to output metadata of multiple primitive types through multiple drawing instructions. For example, the user initially draws the metadata of "triangle" through one drawing instruction. If the user wants to switch to obtain the metadata of "line", a new drawing instruction needs to be sent, and the mesh shader draws the same batch of data to be drawn again to obtain the metadata of "line". At this time, the performance consumption of the graphics processor is relatively large, and the mesh shader needs to draw the same batch of data to be drawn multiple times to obtain metadata of multiple primitive types.

[0178] Fig.17The structure block diagram of an electronic device 1700 provided by an exemplary embodiment of the present application is shown. Optionally, the electronic device 1700 includes a graphics processor provided by an embodiment of the present application, and / or is used to execute the primitive output method provided by the present application.

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

[0180] The processor 1701 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1701 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1701 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1701 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1701 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0181] 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 and flash memory storage devices.

[0182] In some embodiments, the electronic device 1700 may further include: a peripheral device interface 1703 and at least one peripheral device. Those skilled in the art will appreciate that Fig.17 The structure shown in the figure does not constitute a limitation on the electronic device 1700, and may include more or less components than those shown in the figure, or combine certain components, or adopt a different component arrangement.

[0183] The present application also provides a chip, which includes a graphics processor as described in the above embodiment.

[0184] The present application also provides a graphics card, which includes a graphics processor as described in the above embodiment.

[0185] The present application also provides a server, which includes a graphics processor as described in the above embodiment.

[0186] Fig.18 A schematic diagram of the structure of a server provided by an exemplary embodiment of the present application is shown, where the server 1800 includes multiple graphics processors 1801, and at least one of the multiple graphics processors 1801 is a graphics processor provided by an embodiment of the present application.

[0187] The present application also provides a computer-readable storage medium, in which at least one instruction, at least one program, a code set or an instruction set is stored. 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 graphic element output method provided by the above method embodiment.

[0188] The present application provides a computer program product or a computer program, which 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 the processor executes the computer instructions, so that the electronic device executes the primitive output method provided by the above method embodiment.

Claims

1. A graphics processor, characterized in that: The graphics processor includes a geometry processing pipeline; The geometry processing pipeline is used to perform graphics drawing based on a first drawing instruction to obtain a drawing result, wherein the drawing result includes graphic element data of at least two types of graphic elements, wherein the at least two types of graphic elements include at least two of points, lines and triangles, and 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 primitive data area, wherein the vertex data area includes vertex attributes of at least two vertices; The graphics data area includes multiple graphics data blocks, and the multiple graphics data blocks correspond to multiple graphics elements one by one. Each of the multiple graphics data blocks includes a type segment of the current graphics element, and the type segment is used to accommodate the type identifier of the current graphics element.

3. The graphics processor according to claim 2, characterized in that: Each primitive data block further includes three index segments; the three index segments are used to accommodate index values ​​of the vertices of the current primitive in the vertex data area.

4. The graphics processor according to claim 2, characterized in that: Each of the graphic element data blocks further includes a first indication segment and a first attribute segment; The first indication segment is used to indicate that the current primitive supports the size of the specified point, or is used to indicate that the current primitive 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, characterized in that: Each of the image data blocks also includes a second indication segment; The second indication segment is used to indicate a filling mode adopted by the current primitive, and the filling mode includes any one of point filling, line filling and solid filling.

6. The graphics processor according to claim 2, characterized in that: The primitive data area further includes a quantity indication segment, and the quantity indication segment is used to indicate the quantity of the at least two vertices in the vertex data area and the quantity of the plurality of primitives in the primitive data area.

7. The graphics processor according to any one of claims 2 to 6, characterized in that: The vertex data area and the graphics data area in the drawing result are spliced; The quantity indication segment in the primitive data area is located at the end of the primitive data area, and the quantity indication segment is used to indicate the quantity of the at least two vertices in the vertex data area and the quantity of the multiple primitives in the primitive data area.

8. The graphics processor according to any one of claims 2 to 6, characterized in that: Each of the multiple primitive data blocks includes a topological attribute segment and multiple other attribute segments, the topological attribute segment is used to indicate the topological structure of the current primitive, the multiple other attribute segments correspond one-to-one to multiple attributes of the current primitive, and the topological attribute segment includes the type segment.

9. A method for outputting a graphic element, characterized in that: Applied to a shader program, the method comprises: In response to receiving a first drawing instruction, controlling a geometry processing pipeline in the graphics processor to implement a geometry processing function in a mesh shading rendering pipeline, and controlling the geometry processing pipeline to perform graphics drawing based on the first drawing instruction; In response to receiving an input operation of a target primitive type, outputting primitive data of the target primitive type from a rendering result of the geometry processing pipeline; The drawing result includes graphic element data of at least two graphic element types, and the at least two graphic element types include at least two of points, lines and triangles.

10. The method according to claim 9, characterized in that The drawing result includes a vertex data area and an image data area, the vertex data area includes vertex attributes of at least two vertices, the image data area includes a plurality of image data blocks, the plurality of image data blocks correspond to a plurality of image primitives one by one, each image data block in the plurality of image data blocks includes a type segment of the current image primitive, the type segment is used to accommodate a type identifier of the current image primitive; In response to receiving an input operation of a target primitive type, outputting primitive data of the target primitive type from a rendering result of the geometry processing pipeline includes: In response to receiving an input operation of the target primitive type, a target primitive data block corresponding to the target primitive type is output from the primitive data area.

11. The method according to claim 10, characterized in that Each of the metadata blocks 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 comprises: In response to receiving an input operation of a target index value under the target primitive type, a 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, characterized in that Each primitive data block further includes a first indication segment and a first attribute segment, wherein the first indication segment is used to indicate that the current primitive supports the size of a specified point, or is used to indicate that the current primitive 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 comprises: In response to receiving an input operation of a target point size under the target primitive type, a second primitive data block supporting the specified point size and having the point size conforming to the target point size is output from the target primitive data block.

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

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

15. A chip, characterized in that: The chip comprises a graphics processor as claimed in any one of claims 1 to 8.

16. A server, characterized in that: The server comprises a graphics processor as claimed in any one of claims 1 to 8.

17. An electronic device, characterized in that: The electronic device comprises the graphics processor as claimed in any one of claims 1 to 8.

18. An electronic device, characterized in that: The electronic device comprises: a processor and a memory, wherein the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the primitive output method as claimed in any one of claims 9 to 13.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is loaded and executed by a processor to implement the primitive output method according to any one of claims 9 to 13.

20. A computer program product, characterized in that The computer program product stores a computer program, and the computer program is loaded and executed by a processor to implement the primitive output method according to any one of claims 9 to 13.

Citation Information

Patent Citations

  • Techniques for representing and processing geometry within extended graphics processing pipeline

    CN110084738A

  • Multi-primitive graphics rendering pipeline

    US20140098117A1

Cited By

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

    WO2026145455A1