Task processing method and device, equipment, storage medium and program product
By identifying the dependencies between rendering tasks and building a resource dependency graph, the execution order of rendering tasks is rearranged, which solves the problem of frequently switching task types during the GPU rendering process and improves rendering efficiency.
Patent Information
- Application Number
- CN202410565720.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Existing GPUs frequently switch rendering task types during the rendering process, resulting in low rendering efficiency and unable to effectively improve rendering speed and efficiency.
By identifying the dependencies between rendering tasks, a resource dependency graph is constructed, and a breadth-first traversal algorithm is used to determine the traversal order of resource nodes, thereby rearranging the execution order of rendering tasks and reducing the number of rendering task type switches.
It effectively reduces the number of rendering task type switching, improves the rendering efficiency of the GPU, and increases the rendering speed.
Smart Images

Figure CN118152142B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task processing method and apparatus, equipment, storage medium and program product. Background Art
[0002] Graphics Processing Unit (GPU) is a microprocessor specially used for processing graphics and image related operations. GPU can achieve efficient rendering performance by processing large amounts of data. With the development of graphics applications, more and more complex scenes need to be rendered, and the requirements for graphics and image processing are very high. It is necessary to further speed up the rendering speed of graphics and images and improve the GPU rendering efficiency. Summary of the invention
[0003] In view of this, embodiments of the present application hope to provide a task processing method and apparatus, device, storage medium and program product that can improve rendering efficiency.
[0004] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a task processing method, which includes:
[0006] Receiving a plurality of task queues associated with a rendering target, each of the task queues comprising at least one rendering task;
[0007] Identifying dependencies between the rendering tasks;
[0008] According to the dependency relationship, traverse the resource nodes generated by the rendering task and determine the traversal order;
[0009] Determining the execution order of the corresponding rendering tasks according to the traversal order of the resource nodes;
[0010] The plurality of rendering tasks are executed in the execution order.
[0011] In some embodiments, identifying the dependency relationship between the rendering tasks includes:
[0012] Determine a resource dependency graph consisting of resource nodes according to the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks;
[0013] The traversing the resource nodes generated by the rendering task according to the dependency relationship and determining the traversal order includes:
[0014] Taking the rendering target as a starting point, performing a breadth-first traversal of the resource nodes in the resource dependency graph;
[0015] A traversal order of the breadth-first traversal is determined.
[0016] In some embodiments, taking the rendering target as a starting point, performing a breadth-first traversal of the resource nodes in the resource dependency graph includes: traversing the resource nodes in the resource dependency graph layer by layer;
[0017] In which, in response to the same layer in the resource dependency graph including a plurality of the rendering tasks, the resource nodes generated corresponding to the plurality of rendering tasks are traversed in sequence in the reverse order of receiving the rendering tasks.
[0018] In some embodiments, the method further comprises:
[0019] In response to the fact that the multiple rendering tasks at the same layer in the resource dependency graph include at least two types of rendering tasks, an updated execution order is determined according to a preset priority order; wherein the priority order is the priority order of at least two types of rendering tasks.
[0020] The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
[0021] In some embodiments, the method further comprises:
[0022] In response to the task types of a plurality of adjacent rendering tasks in the execution order being the same, determining an updated execution order according to the order in which the rendering tasks are received;
[0023] The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
[0024] In some embodiments, each of the rendering tasks corresponds to a rendering subtarget;
[0025] The executing of the plurality of rendering tasks in an execution order comprises:
[0026] In response to the rendering sub-targets corresponding to the plurality of rendering tasks being the same, the plurality of rendering tasks corresponding to the same rendering sub-target are merged and executed.
[0027] In some embodiments, the rendering task includes a drawing task and a copying task; the drawing task includes a pipeline drawing command and a pipeline computing command; the pipeline drawing command is used to instruct the drawing of geometric figures; and the pipeline computing command is used to instruct the startup of a computing shader.
[0028] In some embodiments, the plurality of task queues include one or more of the following: a pixel data queue, a vertex data queue, a two-dimensional data queue, and a computational data queue.
[0029] Based on the same inventive concept, an embodiment of the present application further provides a task processing device, which includes: a receiving unit, an identification unit, a traversal unit, a first determination unit and an execution unit.
[0030] The receiving unit is configured to receive a plurality of task queues related to the rendering target, each of the task queues including at least one rendering task;
[0031] The identification unit is configured to identify dependencies between the rendering tasks;
[0032] The traversal unit is configured to traverse the resource nodes generated by the rendering task according to the dependency relationship and determine a traversal order;
[0033] The first determining unit is configured to determine the execution order of the corresponding rendering tasks according to the traversal order of the resource nodes;
[0034] The execution unit is configured to execute the plurality of rendering tasks in the execution order.
[0035] In some embodiments, the identification unit is specifically configured to determine a resource dependency graph consisting of resource nodes according to the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks;
[0036] The traversal unit is specifically configured to perform a breadth-first traversal on the resource nodes in the resource dependency graph with the rendering target as a starting point; and determine a traversal order of the breadth-first traversal.
[0037] In some embodiments, the traversal unit is specifically configured to: traverse the resource nodes in the resource dependency graph layer by layer in sequence; wherein, in response to the same layer in the resource dependency graph including multiple rendering tasks, the resource nodes generated corresponding to the multiple rendering tasks are traversed in sequence in the reverse order of receipt of the rendering tasks.
[0038] In some embodiments, the device also includes: a second determination unit, the second determination unit is configured to, in response to the fact that the multiple rendering tasks at the same layer in the resource dependency graph include at least two types of rendering tasks, determine an updated execution order according to a preset priority order; wherein the priority order is the priority order of at least two types of rendering tasks; the execution unit is further configured to: execute the multiple rendering tasks in the updated execution order.
[0039] In some embodiments, the apparatus further includes: a third determining unit, the third determining unit being configured to, in response to the fact that the task types of the adjacent plurality of rendering tasks in the execution order are the same, determine the updated execution order according to the order in which the rendering tasks are received;
[0040] The execution unit is further configured to execute the plurality of rendering tasks in the updated execution order.
[0041] In some embodiments, each of the rendering tasks corresponds to a rendering sub-target; the execution unit is specifically configured to: in response to the rendering sub-targets corresponding to the multiple rendering tasks being the same, merge and execute the multiple rendering tasks corresponding to the rendering sub-targets.
[0042] In some embodiments, the rendering task includes a drawing task and a copying task; the drawing task includes a pipeline drawing command and a pipeline computing command; the pipeline drawing command is used to instruct the drawing of geometric figures; and the pipeline computing command is used to instruct the startup of a computing shader.
[0043] In some embodiments, the plurality of task queues include one or more of the following: a pixel data queue, a vertex data queue, a two-dimensional data queue, and a computational data queue.
[0044] Based on the same inventive concept, an embodiment of the present application further provides a computer device, the computer device comprising: a processor and a memory for storing computer instructions that can be run on the processor;
[0045] The processor is used to execute the above-mentioned task processing method when running the computer instructions.
[0046] Based on the same inventive concept, an embodiment of the present application further provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned task processing method is implemented.
[0047] Based on the same inventive concept, an embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned task processing method when executed by a processor.
[0048] The task processing method provided in the embodiment of the present application identifies the dependencies between rendering tasks, traverses the resource nodes corresponding to each rendering task, and rearranges the receiving order based on the traversal order of the resource nodes to obtain a new execution order, which can reduce the probability of switching rendering task types and improve the rendering efficiency of the GPU. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1A schematic diagram of a task queue of a task processing method in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the execution sequence of a task processing method in an embodiment of the present application;
[0051] Figure 3 A step diagram of a task processing method in an embodiment of the present application;
[0052] Figure 4 A schematic diagram of a task queue of a task processing method in another embodiment of the present application;
[0053] Figure 5 A resource dependency graph of a task processing method in an embodiment of the present application;
[0054] Figure 6 A schematic diagram of the sorting of a task processing method in an embodiment of the present application;
[0055] Figure 7 A schematic diagram of the execution sequence of a task processing method in another embodiment of the present application;
[0056] Figure 8 A schematic diagram of a task queue of a task processing method in another embodiment of the present application;
[0057] Fig. 9 A schematic diagram of a task queue of a task processing method in yet another embodiment of the present application;
[0058] Fig.10 A schematic diagram of the execution sequence of a task processing method in another embodiment of the present application;
[0059] Fig.11 This is a structural diagram of a task processing device in an embodiment of the present application;
[0060] Fig.12 It is a schematic diagram of the structure of a computer device in one embodiment of the present application. DETAILED DESCRIPTION
[0061] The following will be combined with the embodiments of the present application and the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] In the following description, a large number of specific details are given to provide a more thorough understanding of the present application. However, it is obvious to those skilled in the art that the present application can be implemented without one or more of these details. In other examples, in order to avoid confusion with the present application, some technical features well known in the art are not described; that is, all features of the actual embodiments are not described here.
[0063] The purpose of the terms used herein is only to describe specific embodiments and is not intended to be limiting of the present application. When used herein, the singular forms "one", "an" and "said / the" are also intended to include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "consisting of" and / or "comprising", when used in this specification, determine the presence of the features, integers, steps, operations, elements and / or parts, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, parts and / or groups. When used herein, the term "and / or" includes any and all combinations of the relevant listed items.
[0064] In order to thoroughly understand the present application, detailed steps and detailed structures will be presented in the following description to illustrate the technical solution of the present application. The preferred embodiments of the present application are described in detail below, but in addition to these detailed descriptions, the present application may also have other implementation methods.
[0065] In 3D computer graphics, image rendering refers to the process of projecting object models in a 3D scene into 2D digital images according to the set parameters such as environment, material, lighting and rendering. In a series of operations performed by the GPU, rendering is the last important step, that is, after the model is processed by texture, binding, animation, lighting, etc., the final display effect of the model and animation is obtained through rendering.
[0066] Application Programming Interface (API): is a set of interfaces that define how software components interact with each other. API allows software developers to use the functions of other components without knowing the internal implementation details. Through API, software components can communicate, pass data and request services. Program developers can use API to define rendering targets and rendering tasks associated with rendering targets.
[0067] Generally, the GPU needs to process multiple task queues. The GPU cannot process multiple task queues simultaneously through parallel processing (a task queue may include one or more rendering tasks), but instead integrates multiple task queues into one task queue. Figure 1As shown, the GPU receives three task queues (task queue 1, task queue 2 and task queue 3), including six rendering tasks (rendering task D0, rendering task C1, rendering task D2, rendering task C3, rendering task D4, rendering task C5); among them, rendering task D0, rendering task D2 and rendering task D4 are all first-category rendering tasks, such as drawing tasks; and rendering task C1, rendering task C3 and rendering task C5 are all second-category rendering tasks, such as copying tasks.
[0068] The GPU integrates the above three task queues into one task queue according to the initial order of the rendering tasks received and / or defined by the API, and the GPU executes them in the order 1 (such as Figure 2 As shown in FIG. 1 , each rendering task is executed sequentially by the GPU. In the process of sequentially executing the integrated task queue, the rendering task type may be frequently switched, that is, switching from one type of rendering task to another type of rendering task, including switching from the first type of rendering task to the second type of rendering task, such as Figure 2 The C task shown is switched to the D task; and the second type of rendering task is switched to the first type of rendering task, as shown Figure 2 The D task shown is switched to the C task. Since the switching of the rendering task type may involve unnecessary changes in the configuration of the rendering pipeline, loading of new shader programs or data, etc., these operations may cause the GPU pipeline to stall, thereby reducing the GPU rendering efficiency.
[0069] It should be noted that the execution subject in the embodiment of the present application can be a GPU for integrating the task queue, or other processors or electronic devices that can be used to integrate the task queue. For ease of explanation, the task processing method provided in the embodiment of the present application is described below with the GPU as the execution subject.
[0070] In view of this, an embodiment of the present application provides a task processing method, such as Figure 3 As shown, the task processing method includes:
[0071] S100: Receive multiple task queues related to a rendering target, each task queue including at least one rendering task.
[0072] S200: Identify dependencies between rendering tasks.
[0073] S300: Traversing the resource nodes generated by the rendering task according to the dependency relationship, and determining the traversal order.
[0074] S400: Determine the execution order of corresponding rendering tasks according to the traversal order of resource nodes.
[0075] S500: Execute multiple rendering tasks in execution order.
[0076] The GPU can use one or more render targets (RT) to render graphics data. A render target is data that can be read and written at runtime. A render target can be thought of as a buffer. Creating a render target may involve allocating a new area in memory for drawing. A render target can be associated with several rendering tasks (rendering commands), and the contents of a render target can be modified by one or more rendering tasks.
[0077] The GPU receives multiple task queues related to the same rendering target, each task queue includes one or more rendering tasks, wherein the rendering tasks in the multiple task queues are received in sequence according to the initial order defined by the API.
[0078] The execution of a rendering task specifically refers to the rendering processing of resources, which can be textures, mesh models, shader constants, etc. The resources used by the GPU when executing a rendering task are source resources, and the resources obtained by the GPU after executing the rendering task are the resources generated by the rendering task. After executing a rendering task, the GPU will generate the resources corresponding to the rendering task based on the source resources; and the execution of the next rendering task may depend on the generated resources.
[0079] The dependency between rendering tasks means that during the rendering process, some rendering tasks need to be completed before they can be executed. The latter rendering task depends on the resources generated by the previous rendering task. This dependency ensures the correctness and order of the rendering process.
[0080] The GPU identifies the dependencies between rendering tasks, takes the resources generated by the rendering tasks as resource nodes, and traverses each resource node. By determining the traversal order of the resource nodes, the traversal order and execution order of the rendering tasks corresponding to each resource node can be determined. The GPU then executes multiple rendering tasks in the determined execution order. In some embodiments, the GPU can execute each rendering task in sequence according to the execution order of the rendering tasks.
[0081] The task processing method provided in the embodiment of the present application identifies the dependencies between rendering tasks, traverses the resource nodes corresponding to each rendering task, and rearranges the receiving order based on the traversal order of the resource nodes to obtain a new execution order, which can reduce the probability of switching rendering task types and improve the rendering efficiency of the GPU.
[0082] Exemplary, reference Figure 1, the GPU receives task queue 1 to task queue 3 in sequence, and the order in which each rendering task is received is: D0-C1-D2-C3-D4-C5. If each rendering task is executed in sequence according to the order in which the rendering tasks are received, then the GPU will have a total of 5 rendering task type switches from D0 to C1, C1 to D2, D2 to C3, C3 to D4, and D4 to C5 during the execution of the rendering task. By identifying the dependency relationship between rendering tasks, specifically including: rendering task C1 needs to be executed after the completion of rendering task D0, rendering task C3 needs to be executed after the completion of rendering task D2, and rendering task C5 needs to be executed after the completion of rendering task D4. Traverse the resource nodes corresponding to each rendering task, and determine the execution order of the rendering tasks according to the traversal order of the resource nodes as follows: Figure 2 Execution order 2 (D0-D2-D4-C1-C3-C5) is shown. When the GPU executes in order 2 (D0-D2-D4-C1-C3-C5), it only switches the rendering task type once from D4 to C1, which effectively reduces the number of switching rendering task types and improves the rendering efficiency of the GPU.
[0083] In some embodiments, the multiple task queues include one or more of the following: a pixel data queue, a vertex data queue, a two-dimensional data queue, and a computational data queue. The pixel data queue includes rendering tasks related to pixel processing, the vertex data queue includes rendering tasks related to vertex processing, the two-dimensional data queue includes rendering tasks related to two-dimensional image and image data processing, and the computational data queue includes rendering tasks related to general computing.
[0084] In some embodiments, identifying the dependency relationship between the rendering tasks includes: determining a resource dependency graph composed of resource nodes based on the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks.
[0085] The traversing of the resource nodes generated by the rendering task according to the dependency relationship and determining the traversal order includes: taking the rendering target as the starting point, performing a breadth-first traversal of the resource nodes in the resource dependency graph; and determining the traversal order of the breadth-first traversal.
[0086] After identifying the dependencies between rendering tasks, the GPU uses the resources generated by the rendering tasks as resource nodes to build a resource dependency graph to represent the dependencies between the rendering tasks. Each resource node represents a resource generated by a different rendering task, and the edge represents each rendering task.
[0087] For example, reference Figure 4 and Figure 5, GPU receives task queue 4 to task queue 6 in the order D0-D1-C2-D3-C4-D5-D6-C7- D8 (such as Figure 4 After identifying the dependencies between the rendering tasks, the following are generated accordingly: Figure 5 The resource dependency graph shown. Among them, the first rendering task (rendering tasks D0, D1 and D6) in each task queue has the same source resource R, that is, after executing rendering task D0 according to source resource R, resource R0 corresponding to rendering task D0 can be generated; executing rendering task D1 according to source resource R can generate resource R1 corresponding to rendering task D1; executing rendering task D6 according to source resource R can generate resource R6 corresponding to rendering task D6. After executing the last rendering task (rendering tasks D5, C2 and D8) in each task queue, the generated resources, namely the rendering target RT, can be obtained. It should be noted that rendering task D3 uses resource nodes R0 and R2 as source resources for rendering and generates resource node R3.
[0088] Taking the rendering target RT as the starting point and the source resource R as the end point, the resource nodes generated by each rendering task in the resource dependency graph are traversed in a breadth-first manner, and the traversal order of each resource node is determined. Correspondingly, the traversal order of the resource tasks corresponding to each resource node can be determined according to the traversal order of each resource node. Among them, breadth-first traversal is a traversal algorithm that visits nodes in order of their distance from the root node (starting point). Specifically, the distance between each node and the root node is calculated by the number of edges, that is, all nodes that are closer to the root node are visited first, and then nodes that are farther from the root node are visited.
[0089] In some embodiments, the resource nodes in the resource dependency graph are traversed in breadth-first manner starting from the rendering target, including: traversing the resource nodes in the resource dependency graph layer by layer; wherein, in response to the same layer in the resource dependency graph including multiple rendering tasks, the resource nodes generated corresponding to the rendering task are traversed in reverse order of receipt of the rendering tasks.
[0090] For example, Figure 5 The resource dependency graph shown is traversed layer by layer. Starting from the rendering target RT, first visit all nodes that are 1 away from the rendering target (including nodes R4 and R7), then visit all nodes that are 2 away from the rendering target (including nodes R3 and R6), then visit all nodes that are 3 away from the rendering target (including nodes R0 and R2), then visit all nodes R1 that are 4 away from the rendering target, and finally visit the source resource node R. At this point, all nodes in the resource dependency graph are visited. Among them, if the same layer includes multiple rendering tasks, the multiple rendering tasks are traversed in reverse order of receiving the rendering tasks. Specifically, as Figure 5As shown, in the process of visiting all nodes that are 1 away from the rendering target, that is, when visiting node R4 and node R7, the traversal order of the nodes is determined in the reverse order of acceptance of the rendering tasks, that is, node R7 is visited first, and then node R4. It can be understood that in the process of visiting all nodes that are 2 away from the rendering target, node R6 is visited first, and then node R3; in the process of visiting all nodes that are 3 away from the rendering target, node R2 is visited first, and then node R0. Finally, the source resource node R is visited. That is, the traversal order of each resource node in the resource dependency graph is RT-R7-R4-R6-R3-R2-R0-R1-R. It can be understood that the traversal order of each edge can be determined according to the traversal order of each node in the resource dependency graph, that is, the traversal order of each rendering task in the resource dependency graph can be determined. As shown Figure 6 As shown, in the process of first visiting all nodes that are 1 away from the rendering target, the corresponding rendering tasks of the first layer are determined to be rendering tasks D5 and D8. Then, in the process of visiting all nodes that are 2 away from the rendering target, the corresponding rendering tasks of the second layer are determined to be rendering tasks C4 and C7. Then, in the process of visiting all nodes that are 3 away from the rendering target, the corresponding rendering tasks of the third layer are determined to be rendering tasks D3 and D6. Then, in the process of visiting all nodes that are 4 away from the rendering target, the corresponding rendering tasks of the fourth layer are determined to be rendering tasks D0 and C2. Finally, in the process of visiting the virtual terminal node R, the corresponding rendering task of the fifth layer is determined to be rendering task D1. That is, the traversal order of the rendering tasks in the resource dependency graph is D8-D5-C7-C4-D6-D3-C2-D0-D1.
[0091] The execution order of the rendering tasks is determined according to the reverse order of the traversal order of each rendering task. For example, when the traversal order of each node in the resource dependency graph as shown in the figure is determined to be RT-R7-R4-R6-R3-R2-R0-R1-R, that is, when the traversal order of each rendering task is determined to be D8-D5-C7-C4-D6-D3-C2-D0-D1, the execution order of each rendering task by the GPU can be determined to be D1-D0-C2-D3-D6-C4-C7-D5-D8 according to the reverse order of the traversal order of the rendering tasks.
[0092] like Figure 7As shown in the figure, if the GPU directly executes according to the order in which the rendering tasks are received, that is, when executing according to execution order 3 (D0-D1-C2-D3-C4-D5-D6-C7-D8), there are 6 rendering task type switches from D1 to C2, C2 to D3, D3 to C4, C4 to D5, D6 to C7, and C7 to D8. When executing according to the rearranged execution order 4 (D1-D0-C2-D3-D6-C4-C7-D5-D8), there are only 4 rendering task type switches from D0 to C2, C2 to D3, D6 to C4, and C7 to D5, which effectively reduces the number of rendering task type switches and improves the rendering efficiency of the GPU.
[0093] The task processing method provided in the embodiment of the present application can effectively reduce the number of switching times of rendering task types and improve rendering efficiency by identifying the dependencies between rendering tasks, taking the rendering target as the starting point, performing a breadth-first traversal of each resource node in the resource dependency graph containing the dependencies, and redetermining the execution order of each rendering task.
[0094] In some embodiments, the task processing method also includes: in response to multiple rendering tasks at the same layer in the resource dependency graph including at least two types of rendering tasks, determining an updated execution order according to a preset priority order; wherein the priority order is the priority order of at least two types of rendering tasks.
[0095] The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
[0096] In the above embodiment, the resource dependency graph is traversed layer by layer to determine the execution order. However, the same layer in the resource dependency graph may also contain multiple rendering tasks, so it is necessary to determine the execution order of the rendering tasks in each layer. Considering that rendering tasks may include at least two different types, different types of rendering tasks may require different sets of resources, and switching of task types may involve operations such as drawing calls, state changes, and resource binding. Frequent switching of task types may lead to frequent loading and unloading of resources. Therefore, for rendering tasks in the same layer, a priority order can be preset for different types, and then the execution order of the updated rendering tasks can be determined based on the priority order. In other words, for multiple types of rendering tasks in each layer, they are executed in sequence according to different types.
[0097] In some embodiments, the rendering task includes a drawing task and a copying task; the drawing task includes a pipeline drawing command and a pipeline computing command; the pipeline drawing command is used to instruct the drawing of geometric figures; the pipeline computing command is used to instruct the startup of a computing shader.
[0098] Rendering tasks can be divided into drawing tasks and copying tasks by type. For example, among multiple rendering tasks included in the same layer in the resource dependency graph, if there are both drawing tasks and copying tasks, that is, the same layer includes both types of rendering tasks, then based on the principle of production (drawing tasks) before consumption (copying tasks), that is, the principle of drawing tasks taking precedence over copying tasks, it is determined that the drawing tasks in this layer of rendering tasks take precedence over the copying tasks in this layer, so as to further increase the correctness of the execution order.
[0099] It should be noted that, when multiple rendering tasks on the same layer include drawing tasks and copy tasks, if the drawing task is received after the copy task, the drawing task in this layer is still executed before the copy task on the same layer according to the principle of drawing task priority.
[0100] Exemplary, reference Figure 8 , the GPU receives multiple rendering tasks in task queue 7 and task queue 8 in sequence. Task queue 7 includes drawing task D0 and copy task C1; task queue 8 includes drawing task D2 and drawing task D3. A corresponding resource dependency graph is constructed according to the dependency relationship between rendering tasks, and each resource node in the resource dependency graph is traversed in breadth first with the rendering target as the starting point and the source resource as the end point. According to the obtained traversal order of each resource node, the traversal order of each rendering task can be determined as: D3-C1-D2-D0. Among them, drawing task D3 and copy task C1 are first-layer rendering tasks, and drawing task D2 and drawing task D0 are second-layer rendering tasks. According to the traversal order of the rendering tasks, the execution order of the rendering tasks can be determined as: D0-D2-C1-D3. In response to the fact that the rendering tasks in the same layer include drawing tasks and copy tasks, it can be determined that the drawing task D3 takes precedence over the copy task C1 in the same layer according to the preset priority order, that is, the drawing task takes precedence over the copy task, and the updated execution order is obtained, that is, D0-D2-D3-C1.
[0101] In some embodiments, executing the multiple rendering tasks in the execution order includes: executing the multiple rendering tasks in the updated execution order. Specifically, when the multiple rendering tasks in the same layer of the resource dependency graph include drawing tasks and copy tasks, after determining the updated execution order of the rendering tasks according to the principle of drawing task priority, the GPU executes the multiple rendering tasks in the updated execution order.
[0102] In some embodiments, the task processing method further includes: in response to a plurality of adjacent rendering tasks in the execution order having the same task type, determining an updated execution order according to the order in which the rendering tasks are received.
[0103] The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
[0104] In the execution order determined according to the traversal order, if the task types of the adjacent rendering tasks are the same, that is, the adjacent rendering tasks are both drawing tasks or both copying tasks, the original execution order is adjusted according to the receiving order to obtain an updated execution order. Figure 6 and Figure 7 , in the execution order 4 (D1-D0-C2-D3-D6-C4-C7-D5-D8) determined by the traversal order, the adjacent rendering task D1 and rendering task D0 are both drawing tasks, and rendering task D1 and rendering task D0 are located in different layers of the resource dependency graph (rendering task D1 is the fifth layer, and rendering task D0 is the fourth layer). Then, according to the receiving order (digital part) of the rendering tasks, that is, according to the principle that the rendering tasks received first are executed first, it is determined that rendering task D0 is executed first, and then rendering task D1. At this time, the updated execution order is as follows Figure 7 The execution order 5 (D0-D1-C2-D3-D6-C4-C7-D5-D8) shown in the figure. Subsequently, the GPU executes each rendering task in the updated execution order. Similarly, if multiple adjacent rendering tasks in the execution order are all copy tasks, the execution order is updated according to the order in which the rendering tasks are received, that is, the updated execution order of the rendering tasks is determined according to the principle that the rendering tasks received first are executed first, and then the GPU executes multiple rendering tasks in the updated execution order.
[0105] It is understandable that if multiple adjacent rendering tasks are located at the same layer in the resource dependency graph, there is no need to update the execution order. Specifically, if multiple rendering tasks are located at the same layer in the resource dependency graph, the execution order determined by the traversal order already meets the principle that the rendering task received first is executed first, so there is no need to further update the execution order. For example, Figure 6 As shown, the rendering tasks in the second layer include copy task C4 and copy task C7. When determining the traversal order, it is determined that copy task C4 is executed before copy task C7.
[0106] In some embodiments, each rendering task in the above step S100 corresponds to a rendering sub-target; executing the multiple rendering tasks in the execution order includes: in response to the rendering sub-targets corresponding to the multiple rendering tasks being the same, merging and executing the multiple rendering tasks corresponding to the rendering sub-targets.
[0107] Each rendering task corresponds to a rendering sub-target. After executing a rendering task, the GPU needs to write the resources generated by the rendering task directly into the corresponding rendering sub-target. If the rendering sub-targets corresponding to multiple rendering tasks are the same, these rendering tasks can be merged to further improve the rendering efficiency of the GPU. In some embodiments, continuous drawing calls may involve the same geometry, texture, or other resources. If these drawing calls are merged together for execution, repeated resource binding and loading can be reduced, the number of drawing calls can be reduced, and rendering efficiency can be improved. Exemplarily, in task queues 4-6, rendering task D5 and rendering task D8 correspond to the same rendering sub-target, that is, rendering target RT. After identifying the rendering tasks with the same rendering sub-target, these rendering tasks (rendering task D5 and rendering task D8) are sent together to the GPU for execution. Merging rendering tasks with the same rendering target can reduce the generation of duplicate data and greatly improve the execution efficiency of the GPU.
[0108] In some embodiments, if the GPU directly executes each rendering task in the order in which the rendering tasks are received, it may also cause frequent switching of rendering sub-targets. Fig. 9 As shown, when the GPU executes the rendering tasks included in task queues 9 to 11, if the GPU directly executes the rendering tasks according to the order in which they are received, that is, according to Fig.10 When executing sequence 6 (D0-D1-C2-D3-C4-D5) in the above example, there are 5 rendering sub-target switches from D0 to D1, D1 to D2, D2 to D3, D3 to D4, and D4 to C5; Fig.10 When the execution order 7 (D0-D2-D4-D1-D3-D5) shown is executed, only one rendering sub-target switch from D4 to D1 is included, which effectively reduces the number of rendering sub-target switches and improves the rendering efficiency of the GPU.
[0109] This application also provides the following examples:
[0110] In common engines such as Unity and UE, rendering tasks are generally executed in the order of API instructions. There is a common phenomenon of frequent switching of rendering task types and rendering sub-targets, which leads to frequent switching of GPU tasks or frequent interruption of GPU tasks, seriously affecting the performance of GPU. To improve rendering efficiency, you can identify the dependencies of each rendering task at the resource layer, adjust the order of API instructions, and execute rendering tasks in the adjusted execution order to reduce the switching of rendering task types and the switching of rendering sub-targets.
[0111] Exemplary, reference Figure 4, the GPU receives task queues 4-6 related to the rendering target. Among them, task queue 4 includes drawing task D0, drawing task D3, copy task C4 and drawing task D5; task queue 5 includes drawing task D1 and copy task C2; task queue 6 includes drawing task D6, copy task C7 and drawing task D8. The GPU uses the resources generated by each rendering task as resource nodes to construct Figure 5 The resource dependency graph shown is used to represent the dependency relationship between rendering tasks. Each node in the resource dependency graph refers to the source resource of the rendering task and the resource generated by each rendering task. Among them, node R represents the source resource; node R0 represents the resource generated by executing the drawing task D0 based on the source resource R; node R1 represents the resource generated by executing the drawing task D1 based on the source resource R; node R2 represents the resource generated by executing the copy task C2 based on the resource R1; node R3 represents the resource generated by executing the drawing task D3 based on the resources R0 and R2; node R4 represents the resource generated by executing the copy task C4 based on the resource R3; node R6 represents the resource generated by executing the drawing task D6 on the source resource R; node R7 represents the resource generated by executing the copy task C7 based on the resource R6; node RT represents the resource generated by executing the drawing tasks D5 and D8 based on the resources R4 and R7.
[0112] Then, with the rendering target RT in the resource dependency graph as the starting point and the source resource R as the end point, the resource nodes in the resource dependency graph are traversed in a breadth-first manner, and the traversal order is determined. Specifically, the resource nodes in the resource dependency graph are traversed layer by layer, wherein, in response to the same layer in the resource dependency graph including multiple rendering tasks, the resource nodes generated corresponding to the rendering tasks are traversed in reverse order of reception of the rendering tasks. The traversal order of each resource node in the resource dependency graph can be determined to be RT-R7-R4-R6-R3-R2-R0-R1-R.
[0113] According to the traversal order of each resource node RT-R7-R4-R6-R3-R2-R0-R1-R, the traversal order of the corresponding rendering task can be determined as D8-D5-C7-C4-D6-D3-C2-D0-D1; the execution order of the GPU is determined to be D1-D0-C2-D3-D6-C4-C7-D5-D8.
[0114] In response to the fact that tasks D1 and D0 of adjacent rendering tasks D1-D0-C2-D3-D6-C4-C7-D5-D8 in the execution order are of the same task type, an updated execution order is determined to be D0-D1-C2-D3-D6-C4-C7-D5-D8 according to the order in which the rendering tasks are received. The GPU executes each rendering task in this execution order.
[0115] Compared to executing each rendering task in sequence according to the API instruction order (D0-D1-C2-D3-C4-D5-D6-C7-D8), executing in the execution order (D0-D1-C2-D3-D6-C4-C7-D5-D8) determined by the method provided in the embodiment of the present application can effectively reduce the type switching of rendering tasks and improve the rendering efficiency of the GPU.
[0116] In addition, in the adjusted execution order, the adjacent drawing tasks D5 and D8 correspond to the same rendering sub-target. To reduce the generation of duplicate data and improve the execution efficiency of the GPU, the GPU can merge the drawing tasks D5 and D8 with the same rendering sub-target.
[0117] Based on the same inventive concept, the embodiment of the present application further provides a task processing device 110, such as Fig.11 As shown, the task processing device 110 includes: a receiving unit 111, an identification unit 112, a traversal unit 113, a first determination unit 114 and an execution unit 115. The receiving unit 111 is configured to receive a plurality of task queues related to a rendering target, each task queue including at least one rendering task; the identification unit 112 is configured to identify the dependency relationship between rendering tasks; the traversal unit 113 is configured to traverse the resource nodes generated by the rendering tasks according to the dependency relationship and determine the traversal order; the first determination unit 114 is configured to determine the execution order of the corresponding rendering tasks according to the traversal order of the resource nodes; and the execution unit 115 is configured to execute the plurality of rendering tasks in the execution order.
[0118] In some embodiments, the identification unit is specifically configured to determine a resource dependency graph consisting of resource nodes according to the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks;
[0119] The traversal unit is specifically configured to perform a breadth-first traversal on the resource nodes in the resource dependency graph starting from the rendering target; and determine a traversal order of the breadth-first traversal.
[0120] In some embodiments, the traversal unit is specifically configured to: traverse the resource nodes in the resource dependency graph layer by layer in sequence; wherein, in response to the same layer in the resource dependency graph including multiple rendering tasks, the resource nodes generated corresponding to the multiple rendering tasks are traversed in sequence in the reverse order of receipt of the rendering tasks.
[0121] In some embodiments, the task processing device further includes: a second determination unit. The second determination unit is configured to, in response to the plurality of rendering tasks at the same layer in the resource dependency graph including at least two types of rendering tasks, determine an updated execution order according to a preset priority order; wherein the priority order is the priority order of at least two types of rendering tasks; and the execution unit is further configured to execute the plurality of rendering tasks according to the updated execution order.
[0122] In some embodiments, the task processing device also includes: a third determination unit, which is configured to, in response to the fact that the task types of multiple adjacent rendering tasks in the execution order are the same, determine the updated execution order according to the order in which the rendering tasks are received; the execution unit is also configured to: execute multiple rendering tasks in the updated execution order.
[0123] In some embodiments, each rendering task received by the receiving unit corresponds to a rendering sub-target; the executing unit is specifically configured to: in response to the rendering sub-targets corresponding to the multiple rendering tasks being the same, merge and execute the multiple rendering tasks corresponding to the rendering sub-targets.
[0124] In some embodiments, the rendering task includes a drawing task and a copying task; the drawing task includes a pipeline drawing command and a pipeline computing command; the pipeline drawing command is used to instruct the drawing of geometric figures; the pipeline computing command is used to instruct the startup of a computing shader.
[0125] In some embodiments, the plurality of task queues include one or more of the following: a pixel data queue, a vertex data queue, a two-dimensional data queue, and a computational data queue.
[0126] Based on the same inventive concept, the embodiment of the present application further provides a computer device 120, such as Fig.12 As shown, the computer device 120 includes: a processor 121 and a memory 122 for storing computer instructions that can be executed on the processor 121; the processor 121 is used to execute the above-mentioned task processing method when executing the computer instructions.
[0127] Based on the same inventive concept, the embodiment of the present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned task processing method is implemented. Since the computer storage medium can execute the above-mentioned task processing method when the processor runs the computer program, the computer storage medium has similar beneficial technical effects as the above-mentioned task processing method. Therefore, the beneficial effects of the computer storage medium will not be repeated here.
[0128] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, the computer program product includes a computer program, and the computer program implements the above-mentioned task processing method when executed by a processor. Since the computer program in the computer program product can implement the above-mentioned task processing method when executed by the processor, the computer program product has similar beneficial technical effects as the above-mentioned task processing method. Therefore, the beneficial effects of the computer storage medium are not repeated here.
[0129] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, read-only memories (ROM), magnetic disks or optical disks.
[0130] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0131] The various embodiments / implementations provided in this application can be combined with each other without causing any contradiction.
[0132] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A task processing method, characterized in that: include: Receiving a plurality of task queues associated with a rendering target, each of the task queues comprising at least one rendering task; Identifying the dependency relationship between the rendering tasks, including: determining a resource dependency graph composed of resource nodes according to the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks, and the first rendering tasks received in the multiple task queues have the same resource node; According to the dependency relationship, traverse the resource nodes generated by the rendering task and determine the traversal order; Determining the execution order of the corresponding rendering tasks according to the traversal order of the resource nodes; The plurality of rendering tasks are executed in the execution order.
2. The task processing method according to claim 1, characterized in that: The traversing the resource nodes generated by the rendering task according to the dependency relationship and determining the traversal order includes: Taking the rendering target as a starting point, performing a breadth-first traversal of the resource nodes in the resource dependency graph; A traversal order of the breadth-first traversal is determined.
3. The task processing method according to claim 2, characterized in that: The step of taking the rendering target as a starting point and performing a breadth-first traversal on the resource nodes in the resource dependency graph includes: Traversing the resource nodes in the resource dependency graph layer by layer; In which, in response to the same layer in the resource dependency graph including a plurality of the rendering tasks, the resource nodes generated corresponding to the plurality of rendering tasks are traversed in sequence in the reverse order of receiving the rendering tasks.
4. The task processing method according to claim 3, characterized in that: The method further comprises: In response to the plurality of rendering tasks at the same layer in the resource dependency graph including at least two types of rendering tasks, determining an updated execution order according to a preset priority order; wherein the priority order is a priority order of at least two types of rendering tasks; The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
5. The task processing method according to claim 3, characterized in that: The method further comprises: In response to the task types of a plurality of adjacent rendering tasks in the execution order being the same, determining an updated execution order according to the order in which the rendering tasks are received; The executing the plurality of rendering tasks in the execution order includes: executing the plurality of rendering tasks in the updated execution order.
6. The task processing method according to claim 1, characterized in that: Each of the rendering tasks corresponds to a rendering sub-target; The executing of the plurality of rendering tasks in the execution order comprises: In response to the rendering sub-targets corresponding to the plurality of rendering tasks being the same, the plurality of rendering tasks corresponding to the rendering sub-targets are merged and executed.
7. The task processing method according to claim 1, characterized in that: The rendering task includes a drawing task and a copying task; The drawing task includes a pipeline drawing command and a pipeline calculation command; the pipeline drawing command is used to instruct the drawing of geometric figures; the pipeline calculation command is used to instruct the startup of a calculation shader.
8. The task processing method according to claim 1, characterized in that: The multiple task queues include one or more of the following: a pixel data queue, a vertex data queue, a two-dimensional data queue, and a calculation data queue.
9. A task processing device, characterized in that: include: A receiving unit, configured to receive a plurality of task queues related to a rendering target, each of the task queues including at least one rendering task; an identification unit configured to identify the dependency relationship between the rendering tasks; the identification unit is specifically configured to: determine a resource dependency graph consisting of resource nodes according to the resources generated by the rendering tasks; wherein the resource dependency graph is used to represent the dependency relationship between the rendering tasks, and the first rendering tasks received in the multiple task queues have the same resource node; A traversal unit, configured to traverse the resource nodes generated by the rendering task according to the dependency relationship and determine a traversal order; A first determining unit is configured to determine an execution order of the corresponding rendering tasks according to a traversal order of the resource nodes; The execution unit is configured to execute the plurality of rendering tasks in the execution order.
10. A computer device, characterized in that: include: a processor and a memory for storing computer instructions capable of being executed on said processor; The processor is used to execute the task processing method according to any one of claims 1 to 8 when running the computer instructions.
11. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the task processing method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that The computer program implements the task processing method according to any one of claims 1 to 8 when executed by a processor.
