Batch rendering method, device, equipment and storage medium

By dynamically adjusting the display level of the primitives, the problem of excessive rendering batches caused by hierarchical misalignment in the existing combined batch rendering technology is solved, and a more efficient rendering process is achieved, reducing the burden on the GPU.

CN114066714BActive Publication Date: 2025-08-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111643813.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2021-01-14
Filing Date
2021-12-29
Publication Date
2025-08-12
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

The existing combined batch rendering technology relies too much on the artist's hierarchy setting, resulting in hierarchy misalignment and inability to combine batches, resulting in a large number of rendering batches, increasing the burden on the GPU, and making it difficult to meet the game quality requirements.

Method used

By obtaining the drawing status and reachable area of the primitives, dynamically adjusting the display level of the primitives, realizing the batches of the primitives collection, reducing the rendering batches, and improving rendering efficiency.

Benefits of technology

Without changing the rendering results, merge as many primitives as possible in the same batch to reduce the rendering batches, reduce the GPU burden, and improve rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114066714B_ABST
    Figure CN114066714B_ABST
Patent Text Reader

Abstract

The present application discloses a batch rendering method, apparatus, device and storage medium, which obtains a first drawing primitive list corresponding to a first image frame, wherein the first drawing primitive list includes a plurality of primitives, and the plurality of primitives are grouped according to the drawing status of the primitives to obtain a primitive set. The display level of the primitive to be adjusted in the set of primitives to be batched is adjusted to the display level of the target primitive, and the target primitive is determined based on the display level and reachable area of the primitive in the set of primitives to be batched. Adjusting the display level of the primitive in the reachable area will not change the rendering result. The primitives in the set of primitives to be batched are batched according to the adjusted display level to obtain a first batch result, and then the screen rendering of the first image frame is performed according to the first batch result. By dynamically adjusting the display level of the primitives, as many primitives as possible are merged into the same batch without changing the rendering result, thereby reducing the rendering batches, thereby reducing the rendering burden and improving the rendering efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 14, 2021, application number 202110048559.1, and application name “A batch rendering method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of Internet technology, and in particular to a batch rendering method, apparatus, device, and storage medium. Background Art

[0003] With the development of the electronic entertainment industry, games and animations are becoming increasingly popular. The image quality and rendering quality of games or animations directly affect the user experience. However, the more sophisticated the rendering effect, the more space it takes up and the slower the rendering speed.

[0004] During the rendering process, the central processing unit (CPU) sends draw calls (DCs) to the graphics processing unit (GPU). The DCs instruct the GPU to perform rendering operations. The number of DCs is a key factor affecting game performance. Excessive DCs can overload the GPU's rendering process, increasing frame times and leading to game lag and other issues.

[0005] Currently, batching can be used to reduce the number of drawing instructions. However, current batching technology relies heavily on the artist's layer settings, which are in turn based on the screen's display logic. Therefore, layer misalignment often leads to batch failures, resulting in large batch sizes. To reduce the number of batches and thus GPU consumption, artists may spend a long time adjusting, but still struggle to achieve the required game quality. Summary of the Invention

[0006] In order to solve the above technical problems, the present application provides a batch rendering method, device, equipment and storage medium, which uses the reachable area of the primitive to dynamically adjust the display level of the primitive without the intervention of the artist, thereby merging as many primitives as possible into the same batch without changing the rendering results, minimizing the rendering batches, thereby reducing the rendering burden of the GPU and improving rendering efficiency.

[0007] The embodiments of this application disclose the following technical solutions:

[0008] In a first aspect, an embodiment of the present application provides a batch rendering method, the method comprising:

[0009] Obtaining a first drawing primitive list corresponding to the first image frame, wherein the first drawing primitive list includes a plurality of primitives, each of the primitives having a corresponding drawing state and display level;

[0010] Grouping the plurality of primitives according to the drawing state to obtain a primitive set;

[0011] For the set of graphics elements to be batched in the graphics element set, adjusting the display level of the graphics element to be adjusted in the set of graphics elements to be batched to the display level of the target graphics element in the set of graphics elements to be batched, where the target graphics element is determined based on the display level of the graphics element in the set of graphics elements to be batched and a reachable area of the graphics element, where the reachable area of the graphics element is used to indicate an adjustable range of the display level of the graphics element;

[0012] Batching the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame;

[0013] The first image frame is rendered according to the first batch result.

[0014] In a second aspect, an embodiment of the present application provides a batch rendering device, the device comprising an acquisition unit, a determination unit, an adjustment unit, a batch unit, and a rendering unit:

[0015] The acquiring unit is configured to acquire a drawing primitive list corresponding to the first image frame, wherein the drawing primitive list includes a plurality of primitives, each of which has a corresponding drawing state and display level;

[0016] The determining unit is configured to group the plurality of primitives according to the drawing state to obtain a primitive set;

[0017] The adjusting unit is configured to adjust, for the set of graphics primitives to be batched in the graphics primitive set, a display level of a graphics primitive to be adjusted in the graphics primitive set to be batched to a display level of a target graphics primitive in the graphics primitive set to be batched, wherein the target graphics primitive is determined based on the display level of the graphics primitive in the graphics primitive set to be batched and a reachable area of the graphics primitive, wherein the reachable area of the graphics primitive is used to indicate an adjustable range of the display level of the graphics primitive;

[0018] The batching unit is configured to batch the graphics elements in the set of graphics elements to be batched according to the adjusted display level, to obtain a batching result corresponding to the first image frame;

[0019] The rendering unit is used to render the first image frame according to the batching result corresponding to the first image frame.

[0020] In a third aspect, an embodiment of the present application provides a device for batch rendering, the device comprising a processor and a memory:

[0021] The memory is used to store program code and transmit the program code to the processor;

[0022] The processor is configured to execute the method according to the first aspect according to the instructions in the program code.

[0023] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program code, and the program code is used to execute the method described in the first aspect.

[0024] It can be seen from the above technical solution that when the present application needs to render an image frame, such as the first image frame, the first drawing primitive list corresponding to the first image frame can be obtained. The first drawing primitive list includes multiple primitives, and each primitive has a corresponding drawing state and display level. Under normal circumstances, if the drawing states and display levels of different primitives are the same, they can be batched. The drawing state and display level are set by the artist, and the drawing state is not adjustable. Therefore, in the present application, it can be further determined whether the display levels of different primitives with the same drawing state set by the artist can be made the same through adjustment, so as to merge as many primitives as possible into the same batch and minimize the rendering batches. Therefore, in the present application, multiple primitives can be grouped according to the drawing state to obtain a primitive set, and the drawing state of all primitives included in the same primitive set is the same. For the set of primitives to be batched in the primitive set, the display level of the primitive to be adjusted in the set of primitives to be batched is adjusted to the display level of the target primitive in the set of primitives to be batched. The target primitive is determined based on the display level of the primitive in the set of primitives to be batched and the reachable area of the primitive. The reachable area of the primitive is used to indicate the adjustable range of the display level of the primitive. Adjusting the display level of the primitive in the reachable area will not change the rendering result. Then, the primitives in the set of primitives to be batched are batched according to the adjusted display level to obtain the first batch result corresponding to the first image frame, and then the screen rendering of the first image frame is performed according to the first batch result. This method dynamically adjusts the display level of the primitives in the set of primitives to be batched using the reachable area of the primitives without the intervention of artists, thereby merging as many primitives as possible into the same batch without changing the rendering result, minimizing the rendering batches, thereby reducing the rendering burden of the GPU and improving rendering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technical members in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0026] Figure 1 A schematic diagram of the system architecture of a batch rendering method provided in an embodiment of the present application;

[0027] Figure 2 A flowchart of a batch rendering method provided in an embodiment of the present application;

[0028] Figure 3 An example diagram of a first primitive drawing list provided in an embodiment of the present application;

[0029] Figure 4 An example diagram of an equivalent sorting result obtained based on the first primitive drawing list provided in an embodiment of the present application;

[0030] Figure 5 An example diagram of a first primitive drawing list provided in an embodiment of the present application;

[0031] Figure 6 An example diagram of an equivalent sorting result obtained based on the first primitive drawing list provided in an embodiment of the present application;

[0032] Figure 7 An example diagram of the rendering order obtained based on the adjusted display level provided in an embodiment of the present application;

[0033] Figure 8a This is an example diagram of the interface of the first batch result provided in the embodiment of the present application;

[0034] Figure 8b An example diagram of UI rendering data corresponding to the batch rendering method provided for related technologies;

[0035] Figure 8c An example diagram of UI rendering data corresponding to the batch rendering method provided in an embodiment of the present application;

[0036] Figure 9 A schematic diagram of the relationship between the drawing positions of graphic elements and the determination of the reachable areas of the graphic elements provided in an embodiment of the present application;

[0037] Figure 10 A schematic diagram of the relationship between the drawing positions of graphic elements and the determination of the reachable areas of the graphic elements provided in an embodiment of the present application;

[0038] Figure 11A schematic diagram illustrating the relationship between the linked list provided in an embodiment of the present application and the reachable area of a determined graphic element;

[0039] Figure 12 A flowchart of a batch rendering method provided in an embodiment of the present application;

[0040] Figure 13 A flowchart of a batch rendering method provided in an embodiment of the present application;

[0041] Figure 14 A flowchart of a batch rendering method provided in an embodiment of the present application;

[0042] Figure 15 A structural diagram of a batch rendering device provided in an embodiment of the present application;

[0043] Figure 16 A structural diagram of a terminal provided in an embodiment of the present application;

[0044] Figure 17 A structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] The embodiments of the present application are described below with reference to the accompanying drawings.

[0046] Batching can currently be used to reduce the number of drawing instructions. However, current batching technology relies heavily on the artist's layer settings, which are in turn based on the screen's display logic. Therefore, layer misalignment often leads to batch failures, resulting in larger batch sizes. To reduce the number of batches and thus GPU consumption, artists may spend a long time adjusting, but still struggle to achieve the required game quality.

[0047] For example, in a game interface, a control button consists of a top and a bottom, with the top above the bottom. Clicking the control button will cause a dialog box to pop up, but the dialog box and the control button do not overlap. The rendering of the bottom, top, and dialog box is achieved through corresponding primitives. Based on this display logic, artists will set the primitive corresponding to the bottom to the lowest display level, the primitive corresponding to the top to the next highest, and the primitive corresponding to the dialog box to the highest display level. As a result, these three primitives cannot be batched together, resulting in a large number of rendering batches.

[0048] In order to solve the above technical problems, an embodiment of the present application provides a batch rendering method. When it is necessary to render an image frame, such as a first image frame, a first drawing primitive list corresponding to the first image frame can be obtained. The first drawing primitive list includes multiple primitives, and each primitive has a corresponding drawing state and display level. Under normal circumstances, if the drawing states and display levels of different primitives are the same, they can be batched. The drawing state and display level are set by the artist, and the drawing state is not adjustable. Therefore, in this application, it can be further determined whether the display levels of different primitives with the same drawing state set by the artist can be made the same through adjustment, so as to merge as many primitives as possible into the same batch and minimize the rendering batches.

[0049] It should be noted that the batch rendering method provided in the embodiment of the present application can be applied to an image processing device, which can be a server or a terminal. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0050] The batch rendering method provided in the embodiments of the present application can be applied to various screen rendering scenarios. In the screen rendering scenarios, various applications requiring screen rendering can be run on the terminal, such as game applications (game scenarios), animation applications (animation scenarios), etc. The game can be a 2D or 3D game, and the screen rendering performed can be 2D or 3D rendering.

[0051] In order to facilitate understanding of the technical solution of the present application, the batch rendering method provided in the embodiment of the present application is introduced below in combination with the actual application scenario (with the server as the execution entity and the application scenario being the game scenario).

[0052] See also Figure 1 , Figure 1 A schematic diagram of the system architecture for a batch rendering method is provided for an embodiment of the present application. The system architecture includes a terminal 101 and a server 102. A game application can be run on the terminal 101. When the game application is run on the terminal 101, the corresponding game screen can be rendered and displayed on the terminal 101, thereby presenting it to the user.

[0053] During the operation of the game application on the terminal 101, each image frame needs to be rendered. Taking the first image frame as an example, when the first image frame needs to be rendered, the server 102 can obtain the first drawing primitive list corresponding to the first image frame, and the first drawing primitive list includes multiple primitives. A primitive refers to a drawing instruction generated according to the game logic unit, and a primitive can be represented by DrawElement. Each primitive has a corresponding drawing state and display layer (Layer). The drawing state refers to the atlas used, the clipping area, the material (shader) and other information contained in a drawing instruction. The display layer reflects the rendering order and the display order. Generally, the higher the display layer, the later the rendering and the first the display. Taking the human eye viewing the user interface (UI) as an example, the human eye is used as a reference. The UI can be divided into multiple display layers when displayed. The closer the display layer is to the human eye, the higher the display layer.

[0054] Normally, if the drawing states and display levels of different primitives are the same, they can be batched. The drawing state and display level are set by the artist, and the drawing state is not adjustable. Therefore, in this application, it can be further determined whether the display levels of different primitives with the same drawing state set by the artist can be adjusted to make the display levels the same, so as to merge as many primitives as possible into the same batch and minimize the rendering batches. Therefore, in this application, the server 102 can group multiple primitives according to the drawing state to obtain a primitive set, and the drawing state of all primitives included in the same primitive set is the same. For the set of primitives to be batched in the primitive set, the display level of the primitive to be adjusted in the set of primitives to be batched is adjusted to the display level of the target primitive in the set of primitives to be batched. The target primitive is determined based on the display level of the primitive in the set of primitives to be batched and the reachable area of the primitive. The reachable area of the primitive is used to indicate the adjustable range of the display level of the primitive. Adjusting the display level of the primitive in the reachable area will not change the rendering result.

[0055] Then, the server 102 batches the graphics elements in the set of graphics elements to be batched according to the adjusted display level, obtains a first batching result corresponding to the first image frame, and then renders the first image frame according to the first batching result, thereby displaying the rendered first image frame on the terminal 101, so that the user can watch the first image frame displayed on the terminal 101.

[0056] This method uses the reachable area of the primitives in the set of primitives to be batched to adjust the display level of some primitives, such as the primitives to be adjusted, so as to merge as many primitives as possible into the same batch without changing the rendering results, minimize the rendering batches, thereby reducing the rendering burden of the GPU and improving rendering efficiency.

[0057] Next, the batch rendering method provided in the embodiment of the present application will be introduced in detail with the server as the execution body and in combination with the accompanying drawings.

[0058] See also Figure 2 , Figure 2 A flowchart of a batch rendering method is shown, the method comprising:

[0059] S201: Obtain a first drawing primitive list corresponding to a first image frame.

[0060] When rendering of the first image frame is required, the server may obtain a first drawing primitive list corresponding to the first image frame. The first drawing primitive list reflects the rendering information required for rendering the first image frame. The first drawing primitive list includes multiple primitives, each of which has a corresponding drawing state and display level. The drawing state can be represented by a hash value (BatchKey) of the drawing state. If the BatchKey values of different primitives are the same, the drawing state is the same. The display level can be represented by a Layer. If the Layer values of different primitives are the same, the display level is the same.

[0061] For example, the first drawing primitive list can be found in Figure 3 As shown, Figure 3 The rectangular boxes of different colors represent a primitive. The first drawing primitive list includes four primitives, namely primitive 301, primitive 302, primitive 303 and primitive 304. The corresponding drawing states and display levels are: BatchKey=5 Layer=2, BatchKey=3 Layer=2, BatchKey=3 Layer=2 and BatchKey=5 Layer=2.

[0062] In this embodiment, taking a game scene as an example, the server can collect the first drawing primitive list through the game engine. The game engine can be Unreal Engine, Unity Engine, etc. The game engine can have its own batching solution. For example, the batching solution of the Unreal Engine allows artists to set the drawing state and display level. For different primitives, the drawing state and display level set by the artists must be the same before batching can be performed.

[0063] Based on the existing batching scheme, this application further adds a display level adjustment step to adjust the display levels of different graphics elements to the same display level as much as possible, so as to merge as many graphics elements as possible into the same batch and minimize rendering batches.

[0064] S202: Group the multiple primitives according to the drawing state to obtain a primitive set.

[0065] Since only primitives with the same drawing state can be batched, to minimize batches, primitives that need adjustment should be those with the same drawing state. Therefore, the server can group multiple primitives based on their drawing state to form primitive sets. Primitives in the same primitive set have the same drawing state.

[0066] Among them, grouping multiple primitives according to the drawing state to obtain a primitive set is equivalent to constructing the same drawing state function, which can be achieved through SameDrawParamMayBatch <FBatchKey,TArray <sorteditem>> indicates that FBatchKey represents the hash value function of the drawing state, and TArray represents an array, which stores the values of the sorted list (SortedItem).

[0067] It should be noted that because the primitives in the first drawing primitive list obtained in S201 have a certain arrangement order, primitives with the same drawing state are distributed in the first primitive drawing list under this arrangement order, and in most cases, they are not adjacent. Therefore, in order to ensure that primitives with the same drawing state are adjacent in the first primitive drawing list, so that all primitives with the same drawing state can be quickly and conveniently obtained in subsequent calculations without having to traverse the entire first primitive drawing list to obtain all primitives with the same drawing state, before executing S202, the server may also perform an equivalence sort on the first drawing primitive list based on the drawing state and display level. In the equivalence sorting result, primitives with the same drawing state are adjacent, and primitives with the same drawing state are arranged in order from low to high display level. In this way, S202 can be implemented by grouping multiple primitives according to the drawing state and the equivalence sorting result to obtain a primitive set.

[0068] Equivalence sorting means that rendering results are consistent before and after reordering. It's understandable that sorting is performed in the cache and doesn't actually change the order of the first primitive drawing list. Furthermore, in the cache after equivalence sorting, the sorted primitives still need to be able to find their place in the original first primitive drawing list. The goal of equivalence sorting is to produce a list where, while each primitive is non-intersecting, the preceding primitives in the list are guaranteed to be drawn before the primitive itself, and the following primitives are guaranteed to be drawn after the primitive itself.

[0069] by Figure 3 Take the first primitive drawing list shown as an example, Figure 3 If the four primitives shown are non-intersecting, their equivalent ordering is based on their drawing state and display level. Unreal Engine's batching scheme determines the order of rendering based on their drawing state and display level: primitive 301, primitive 304, primitive 302, and primitive 303. Furthermore, there are only two batches: one with BatchKey = 5, and one with BatchKey = 3. The rendering order refers to the order in which primitives are drawn, i.e., the order in which they are drawn.

[0070] Then Figure 3 The first drawing primitive list shown is sorted equivalently to obtain Figure 4 The equivalent sorting result shown in FIG, in which the order of the primitives is primitive 301, primitive 304, primitive 302 and primitive 303, so the rendering order is also primitive 301, primitive 304, primitive 302 and primitive 303, which is the same as Figure 3 Compared to the first drawing primitive list shown, the rendering result is consistent.

[0071] S203 . For the set of graphics elements to be batched in the graphics element set, adjust the display level of the graphics elements to be adjusted in the set of graphics elements to be batched to the display level of the target graphics elements in the set of graphics elements to be batched.

[0072] It should be noted that the set of primitives to be batched can be the entire set of primitives, that is, during the rendering process of a frame of image, all primitives in all drawing states are batched. The primitives to be adjusted are primitives whose display level can be adjusted to the display level of the target primitive without affecting the rendering result.

[0073] The set of primitives to be batched can also be a partial set of primitives, that is, in the process of rendering a frame of image, the primitives corresponding to some drawing states are batched. The set of primitives to be batched can be arbitrarily selected, but usually, when determining the set of primitives to be batched for the current frame image, it is generally arbitrarily selected from the primitives corresponding to the drawing states that were not selected in the previous frame image. In other words, the batching is amortized to the rendering process of each frame of the image through frame calculation. In this way, the batch can be reduced to the lowest value within any frame, so there will be no load spikes in the amount of calculation amortized to each frame. This is load-friendly for complex UI scenes, and because the calculation of each frame is rendering equivalent, there will be no UI flickering and the user will not perceive it.

[0074] For example, the first drawing primitive list corresponding to the first image frame includes 10 drawing states. However, when rendering the first image frame, only two of the drawing states can be batched using steps S201-S204, and the remaining drawing states can be batched in the next image frame.

[0075] Among them, the target primitive is determined based on the display level of the primitive in the set of primitives to be batched and the reachable area of the primitive. The reachable area of the primitive is used to indicate the adjustable range of the display level of the primitive. Therefore, adjusting the display level of the primitive to be adjusted in the reachable area will not change the rendering result.

[0076] Assume that the first drawing primitive list is Figure 5 As shown, Figure 5 The rectangles of different colors represent a primitive. The first drawing primitive list includes four primitives, namely primitive 501, primitive 502, primitive 503 and primitive 504. The corresponding drawing states and display levels are: BatchKey=5 Layer=2, BatchKey=3 Layer=3, BatchKey=3Layer=3 and BatchKey=5 Layer=4. According to the current drawing state and display level, three batches can be obtained, that is, primitives 502 and 503 are in one batch, primitive 501 is in one batch, and 504 is in another batch. After performing equivalent sorting on the first drawing primitive list, the equivalent sorting results can be seen in Figure 6 As shown, the arrangement order is primitive 502, primitive 503, primitive 501 and primitive 504. If it is determined through S201-S204 that the target primitive in the set of primitives to be batched including primitives 501 and 504 is primitive 504, then Figure 6 Based on the above, the display level of primitive 501 (i.e., the primitive to be adjusted) can be adjusted to the display level of primitive 504, that is, the Layer corresponding to primitive 501 is adjusted from 2 to 4. At this time, the rendering order obtained based on the adjusted display level can be referred to Figure 7 shown.

[0077] In this embodiment, the target primitive required can be understood as the optimal solution that needs to be determined in mathematical calculations. Of course, it can also be a suboptimal solution. There are many algorithms for finding the optimal solution or suboptimal solution, such as greedy algorithms, dynamic programming algorithms, etc. In one possible implementation, a greedy algorithm can be used to determine the target primitive. The greedy algorithm means that when solving a problem, the best choice is always made at the moment. Based on this, in this embodiment, the method for determining the target primitive based on the display level of the primitives in the set of primitives to be combined and the reachable area of the primitives can be to determine the number of display levels of each primitive in the set of primitives to be combined that are covered by the reachable areas of other primitives in the set of primitives to be combined, and the primitive covered by the reachable areas of the largest number of other primitives is determined as the target primitive. At this time, the primitives to be adjusted are other primitives whose reachable areas cover the target primitives, and for other primitives whose reachable areas do not cover the target primitives, their display levels remain unchanged.

[0078] Since the reachable areas of the primitives in the set of primitives to be batched are required in S203, in this embodiment, the server may also determine the reachable area of each primitive in the first drawing primitive list before executing S203 for use in step S203. However, in some cases, when rendering the first image frame, only primitives in a partially drawn state may be batched. In this case, it is not necessary to know the reachable areas of all primitives. Therefore, to reduce the amount of computation allocated to the first image frame, the server may only determine the reachable area of each primitive in the set of primitives to be batched, thereby eliminating the need to calculate the reachable areas of other primitives and reducing unnecessary computation.

[0079] S204 , batching the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame.

[0080] Based on the adjusted display level, the server can merge the graphics elements with the same display level in the same set of graphics elements to be batched together and render them as a batch to obtain the first batch result. Figure 7 For example, primitive 501 and primitive 504 can be combined together and rendered as a batch. It can be seen that one batch is reduced compared to before the display level is adjusted.

[0081] It should be noted that after the batch is completed, you can check the first batch result to determine whether the first batch result meets the artistic expectations. Taking the game scene as an example, you can open the UI batch result (such as the first batch result) through the game manager (GAME MASTER, GM) to check whether the batch result meets the artistic expectations. The display interface of the first batch result can be seen in Figure 8a As shown, the UI in the rectangular box with the same line indicates that it has been batched, for example, Figure 8a The UIs in the black solid line rectangle are from the same batch, the UIs in the black dotted line rectangle are from the same batch, the UIs in the gray solid line rectangle are from the same batch, the UIs in the gray dotted line rectangle are from the same batch, and the UIs in the black dotted line rectangle are from the same batch (e.g. Figure 8a ("22" in Chinese).

[0082] S205: Render the first image frame according to the first batching result.

[0083] After obtaining the first batching result, the server may perform screen rendering of the first image frame based on the first batching result.

[0084] It can be seen from the above technical solution that when the present application needs to render an image frame, such as the first image frame, the first drawing primitive list corresponding to the first image frame can be obtained. The first drawing primitive list includes multiple primitives, and each primitive has a corresponding drawing state and display level. Under normal circumstances, if the drawing states and display levels of different primitives are the same, they can be batched. The drawing state and display level are set by the artist, and the drawing state is not adjustable. Therefore, in the present application, it can be further determined whether the display levels of different primitives with the same drawing state set by the artist can be made the same through adjustment, so as to merge as many primitives as possible into the same batch and minimize the rendering batches. Therefore, in the present application, multiple primitives can be grouped according to the drawing state to obtain a primitive set, and the drawing state of all primitives included in the same primitive set is the same. For the set of primitives to be batched in the primitive set, the display level of the primitive to be adjusted in the set of primitives to be batched is adjusted to the display level of the target primitive in the set of primitives to be batched. The target primitive is determined based on the display level of the primitive in the set of primitives to be batched and the reachable area of the primitive. The reachable area of the primitive is used to indicate the adjustable range of the display level of the primitive. Adjusting the display level of the primitive in the reachable area will not change the rendering result. Then, the primitives in the set of primitives to be batched are batched according to the adjusted display level to obtain the first batch result corresponding to the first image frame, and then the screen rendering of the first image frame is performed according to the first batch result. This method dynamically adjusts the display level of the primitives in the set of primitives to be batched using the reachable area of the primitives without the intervention of artists, thereby merging as many primitives as possible into the same batch without changing the rendering result, minimizing the rendering batches, thereby reducing the rendering burden of the GPU and improving rendering efficiency.

[0085] At the same time, this method can dynamically adjust the display level during the rendering process to reduce the number of batches and reduce GPU consumption, without requiring artists to waste a lot of time making adjustments to meet game quality requirements.

[0086] In addition, for some products that support UI customization, such as game applications in gaming scenarios, the layout is completely unpredictable due to the game's support for UI customization. Traditional batching methods may result in an unimaginable number of UI batches. However, the batch rendering method provided in the embodiments of the present application can dynamically adjust the display level of primitives during the rendering process to reduce the number of batches, ensuring that player-customized UIs can also be achieved with extremely low batches.

[0087] In the game scenario, because UI rendering accounts for a small proportion of the game, the experimental results improved 0.3 frames and reduced power consumption by 3% in the released version of the game battle. However, looking only at the batch reduction rate and absolute improvement time of the UI itself, the batch rendering method provided in the embodiment of the present application is still more obvious than the optimization of related technologies.

[0088] by Figure 8a As an example of the game scene shown in FIG, the UI rendering data corresponding to the rendering method provided by the related art and the batch rendering method provided in the embodiment of the present application are respectively referred to as Figure 8b and Figure 8c As shown, in Figure 8b In the figure, we can see that the number of Draw Calls is 44, the consumption of the rendering thread is 4.54ms, and the Add Element Time (rendering time) is 1.13ms. However, after optimization using the method provided in the embodiment of the present application, we can see that the number of Draw Calls has become 21, the consumption of the rendering thread is reduced to 2.59ms, the algorithm gain is 1.95ms, and the algorithm increases the Add Element Time to 1.28ms, with an algorithm cost of 0.15ms. It can be seen that the rendering cost is significantly reduced, and the algorithm gain is significantly higher than the algorithm cost, which is a good improvement compared to the related technologies.

[0089] Next, we will introduce in detail how to determine the reachable area of a primitive. The reachable area of a primitive is used to indicate the adjustable range of the primitive's display level. Adjusting the primitive's display level in the reachable area will not change the rendering result. Its measurement indicator is the display level, which indicates the area in the first drawing primitive list after equivalent sorting that can be translated without affecting the rendering result. The area outside is an unreachable area. After moving to the unreachable area, the rendering result will be destroyed. In this way, each primitive has its own reachable area, or its reachable area is the entire first drawing primitive list, or its reachable area is only itself, and its rendering level cannot be adjusted.

[0090] It should be noted that the first drawing primitive list may also include the drawing position corresponding to the primitive. The drawing position may refer to the two-dimensional position of the primitive on the display interface. Whether adjusting the display level will destroy the rendering result can be determined by the drawing position between the primitives. Since the method for determining the reachable area of each primitive is similar, this embodiment takes any primitive whose reachable area is to be determined as an example to introduce the method for determining the reachable area of the primitive. If the primitive in the reachable area to be determined is the first primitive, the primitives other than the first primitive in the first drawing primitive list are the second primitives. The method for determining the reachable area of the first primitive can be to determine whether the second primitive blocks the movement of the display level of the first primitive based on the drawing position of the first primitive and the drawing position of the second primitive, and obtain the reachable area of the first primitive based on the determination result. Generally, if the determination result indicates that the second primitive blocks the movement of the display level of the first primitive, it means that the display level of the first primitive cannot be moved to the display level of the second primitive. The same method is used for each second primitive to determine the adjustable range of the display level of the first primitive, that is, the reachable area of the first primitive.

[0091] Take the first drawing primitive list as Figure 5 For example, if primitive 502 and primitive 503 do not block primitive 501, or if primitive 502 and primitive 503 do not block primitive 504, then primitive 501 and primitive 504 can be drawn in one batch. Figure 9 More intuitively reflects the relationship between the drawing position of the primitives and the determination of the reachable area of the primitives. Figure 9 In the figure, the display level increases gradually in the direction of the arrow on the left, that is, the display level of the primitive 504 is the largest and is displayed in the front, followed by the primitive 502 and the primitive 503, and finally the primitive 501, and Figure 9 The position of the graphic element on the display interface is determined by the drawing position. Figure 9 As can be seen from the figure, the accessible area of ​​the primitive 504 is blocked by the primitives 502 and 503, that is, the display level of the primitive 504 cannot be reduced to the display level of the primitive 501, otherwise the rendering result will be changed. However, the accessible area of ​​the primitive 501 is not affected by the primitives 502 and 503, and the display level of the primitive 501 can be increased to the display level of the primitive 504, so the rendering order of the primitive 501 can be adjusted backward, and then we can get Figure 7 Rendering order shown.

[0092] The above description is just a very ideal state, and the relationship between primitives may not be that simple. For example, the reachable area of a primitive is blocked by primitives in the same drawing state, that is, the determination result indicates that the second primitive blocks the movement of the display level of the first primitive, and the second primitive has the same drawing state as the first primitive. At this time, the reachable area of the first primitive can be determined based on the reachable area of the second primitive, that is, the upper or lower limit of the reachable area of the first primitive must refer to the upper or lower limit of the reachable area of the second primitive. At this time, the reachable area of the second primitive can be used as a reference area. Among them, the most common situation may be that artists use the same atlas of maps to make the face and bottom of a control button.

[0093] See also Figure 10 As shown, Figure 10 The drawing state of primitives A, B, C and D is the same as that of primitives B. If the first primitive is primitive A, then Figure 10 It can be seen that the movement of the display level of element A is blocked by element B (i.e., the second element), that is, the lower limit of the reachable area of the display level of element A refers to the lower limit of the reachable area of element B.

[0094] It should be noted that, in the process of calculation, the graphics elements that have been batched are equivalent to adjusting the display level of these graphics elements, which does not mean that the display level adjustment of subsequent graphics elements will not be affected at all. In other words, the determination of the reachable area must be calculated based on the state after the display level is adjusted. Therefore, in one possible implementation method, after adjusting the display level of the graphics element in the set of graphics elements to be batched to the display level of the target graphics element in the set of graphics elements to be batched, the server can record the adjusted display level of the graphics element through a linked list, so that the change process of the display level of the graphics element can be recorded, thereby obtaining the accurate display level of the graphics element when calculating the reachable area.

[0095] See also Figure 11 As shown, in Figure 11 Figures 1101, 1102, 1103, and 1104 respectively illustrate the adjustments to the display levels of graphic elements A2, A4, B1, B3, C3, and D2. Figures 1102 and 1103 are the result of adjusting the display levels of graphic elements A4 and B1 using Figure 1101. Compared to Figure 1101, Figure 1102 reduces the display level of graphic element A4. Compared to Figure 1101, Figure 1103 increases the display level of graphic element B1. Regarding Figure 1104, since the display levels of graphic elements A4 and B1 have already been adjusted to those shown in Figure 1102 or Figure 1103, the display level of graphic element A4 cannot be adjusted to the display level of graphic elements D2 and A2 using Figures 1102 or 1103. However, if the display levels of primitives A4 and B1 are not recorded as having been adjusted to the states shown in diagram 1102 or 1103, the display level of primitive A4 will continue to be adjusted to the display level of primitives D2 and A2 based on diagram 1101, which will change the rendering result. If a linked list is present, the display level of primitives A4 and B1 can be prevented from being adjusted to the state shown in diagram 1104.

[0096] Therefore, in order to avoid changing the rendering results due to unreasonable display level adjustments, the display level of the adjusted primitive can be recorded through a linked list, so that the change process of the display level of the primitive to be adjusted can be recorded, thereby obtaining the accurate display level of the primitive when calculating the reachable area.

[0097] It is understandable that, due to the use of frame-by-frame calculation, that is, the batch rendering method provided in the embodiment of the present application can be used to render the image frame for each image frame, and in different image frames, the required rendering information (i.e., the list of drawing primitives) may or may not change. For example, in a game scene, the player may not operate the game for most of the time, so that the required rendering information does not change. In this way, if one of the image frames has completed the batching, the batching result that has been obtained can be directly used to avoid repeated calculations and reduce unnecessary calculations. Therefore, in one possible implementation method, the first drawing primitive list is obtained (see Figure 12 After S1201), if the second image frame is the previous frame of the first image frame, the server can compare the first drawing primitive list with the second drawing primitive list corresponding to the second image frame to see if they are consistent (see Figure 12 In S1202), if the comparison result indicates that the first drawing primitive list is consistent with the second drawing primitive list, the first image frame is rendered according to the second batch result corresponding to the second image frame (see Figure 12 At this time, the rendering order is restored according to the first drawing primitive list and the second batch result, and a parent linked list is generated with FrontHeadIndex>=0 as a child linked list, that is, the pointer position is changed to point to the drawing primitive list corresponding to the restored rendering order.

[0098] If the comparison result indicates that the first drawing primitive list is inconsistent with the second drawing primitive list, the step of adjusting the display level of the primitive to be adjusted in the primitive set to be batched is performed to the display level of the target primitive in the primitive set to be batched (see Figure 12 (S1204).

[0099] It should be noted that during the rendering process of each image frame, this solution may be used to batch only some or all primitives in the rendering state. When this solution is used for batching, the primitives are calculated. The calculated primitives are marked as calculated and stored in the batch result map (LastBatchRectMap). The LastBatchRectMap caches data so that only a portion of the calculation can be performed at a time until no further batching is possible.

[0100] In the process of rendering the second image frame, not all primitives are necessarily calculated. Therefore, when the first drawing primitive list is consistent with the second drawing primitive list, after executing S201-S202 (where S201 is equivalent to Figure 13 S1301 and S202 are equivalent to Figure 13 In S1302), for the set of primitives to be batched, if all the primitives in the set of primitives to be batched are located in the batch result map, it means that all the primitives have been calculated, and the second batch result can be directly used as the first batch result to render the first image frame. If it is determined that there is a third primitive in the set of primitives to be batched that is not located in the batch result map (see Figure 13 In S1303), the display level of the to-be-adjusted primitive in the to-be-combined primitive set is adjusted to the display level of the target primitive in the to-be-combined primitive set. At this time, the third primitive is extracted in the form of a sorted list (SortedList). Each primitive in the SortedList can be called a SortedItem. Specifically, the reachable area of each third primitive is calculated (see Figure 13 S1304), a greedy algorithm is used to determine the target primitive (see Figure 13 In S1305), the display level of the third element in the set of elements to be combined is adjusted to the display level of the target element (see Figure 13 (S1306).

[0101] In this embodiment, there are various reasons why the first and second drawing primitive lists may be inconsistent. For example, if primitives are added or removed, or the drawing position of a non-negligible primitive changes, these may cause inconsistency between the first and second drawing primitive lists, prompting recalculation. However, if the drawing position of a non-negligible primitive changes, the first and second drawing primitive lists are not considered inconsistent, and recalculation is not triggered.

[0102] If the drawing position of a non-negligible primitive changes, causing inconsistency between the first drawing primitive list and the second drawing primitive list. For example, the drawing position of the fourth primitive in the first drawing primitive list is different from the drawing position of the fourth primitive in the second drawing primitive list. Then, before recalculation, all cached information corresponding to the primitive set including the fourth primitive needs to be cleared to avoid using the cached information of the fourth primitive before the drawing position change for subsequent calculations, which may lead to inaccurate calculation results.

[0103] If the addition of primitives causes inconsistencies between the first and second drawing primitive lists, for example, if new primitives appear in the first drawing primitive list relative to the second drawing primitive list, it is necessary to first regroup the multiple primitives in the first drawing primitive list according to the drawing state to obtain a primitive set. Then, for the primitive set to be batched, the display level of the primitive to be adjusted in the primitive set to be batched is adjusted to the display level of the target primitive in the primitive set to be batched.

[0104] Next, we will introduce the batch rendering method provided by the embodiment of this application in combination with actual application scenarios. In the game application scenario, it is necessary to render the game screen. In order to reduce the number of DC commands that affect the game performance, this solution reduces the GPU rendering burden by calculating reasonable batches. Figure 14 , the method comprising:

[0105] S1401: The server obtains a first drawing primitive list corresponding to a first image frame.

[0106] S1402. The server compares the first drawing primitive list with the second drawing primitive list corresponding to the second image frame to see if they are consistent. If they are consistent and all primitives have been calculated, execute S1403. If they are consistent and there is a third primitive that has not been calculated, execute S1404. If the drawing position of the fourth primitive has changed, resulting in inconsistency, execute S1409. If a new primitive has appeared, resulting in inconsistency, execute S1410.

[0107] The second image frame is a frame preceding the first image frame.

[0108] S1403: Directly use the second batch result as the first batch result to perform image rendering of the first image frame.

[0109] At this time, FrontHeadIndex>=0 can be used as a child linked list to generate a parent linked list, that is, the pointer position is changed to point to the drawing primitive list corresponding to the restored rendering order.

[0110] S1404. Restore the previous result according to the batch result in the batch result diagram.

[0111] Since there are elements in the set of elements to be batched that have not been calculated, there are also elements that have been calculated. For the elements that have been calculated, the previous results can be restored according to the batch results in the batch result graph to avoid repeated calculations.

[0112] S1405: The server determines that there is a third primitive in the set of primitives to be batched that is not in the batch result graph.

[0113] S1406: Calculate the reachable area of each third primitive.

[0114] When calculating the reachable area, if there is a graphic element that blocks the movement of the display layer of the third graphic element, and the graphic element that blocks the third graphic element has the same drawing state as the third graphic element, the reachable area of the graphic element that blocks the third graphic element will be used as a reference area to determine the reachable area of the third graphic element.

[0115] S1407: Determine the target primitive using a greedy algorithm.

[0116] S1408: Adjust the display level of the third graphic element in the graphic element set to be batched to the display level of the target graphic element.

[0117] It should be noted that, for the third primitive, a linked list is constructed, the FrontHeadIndex of the largest reachable primitive points to the primitive with the smallest sorting, the FrontHeadIndex of the remaining primitives is -1, and the NextIndex of each primitive points to the next one.

[0118] Among them, S1406-S1408 can be found in Figure 14 As shown in the dotted circle, under normal circumstances, the steps in the dotted circle can be performed twice, that is, steps S1406-S1408 are executed for the sets of primitives to be batched in two drawing states.

[0119] It should be noted that if there is only one third primitive determined, the third primitive is marked as calculated and stored in LastBatchRectMap.

[0120] When determining the target primitive, the primitive covered by the reachable area of the largest number of other primitives is determined as the target primitive. If the largest number is only one, the third primitive is marked as calculated and stored in the LastBatchRectMap.

[0121] S1409: Clear all cache information corresponding to the graphic element set including the fourth graphic element.

[0122] After executing S1409, execute S1404.

[0123] S1410. Clear all caches.

[0124] S1411. Record the drawing position of each graphic element.

[0125] S1412: Perform equivalent sorting on the first drawing primitive list.

[0126] The FrontHeadIndex of each primitive points to itself, and NextIndex=1.

[0127] S1413: Group the multiple primitives according to the drawing state to obtain a primitive set.

[0128] After obtaining the primitive set, execute step S1405.

[0129] Based on the batch rendering method provided in the above embodiment, the present application embodiment also provides a batch rendering device, see Figure 15 The apparatus includes an acquiring unit 1501, a determining unit 1502, an adjusting unit 1503, a batching unit 1504, and a rendering unit 1505:

[0130] The acquiring unit 1501 is configured to acquire a drawing primitive list corresponding to the first image frame, wherein the drawing primitive list includes a plurality of primitives, each of which has a corresponding drawing state and display level;

[0131] The determining unit 1502 is configured to group the plurality of primitives according to the drawing state to obtain a primitive set;

[0132] The adjusting unit 1503 is configured to adjust the display level of the graphics element to be adjusted in the graphics element set to be batched together to the display level of the target graphics element in the graphics element set to be batched together, wherein the target graphics element is determined based on the display level of the graphics element in the graphics element set to be batched together and the reachable area of the graphics element, and the reachable area of the graphics element is used to indicate an adjustable range of the display level of the graphics element;

[0133] The batching unit 1504 is configured to batch the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a batching result corresponding to the first image frame;

[0134] The rendering unit 1505 is configured to render the first image frame according to the batching result corresponding to the first image frame.

[0135] In a possible implementation, the determining unit 1502 is further configured to:

[0136] Determine the amount of each primitive in the set of primitives to be batched that is covered by reachable areas of other primitives in the set of primitives to be batched;

[0137] Determine the primitive covered by the reachable areas of the largest number of other primitives as the target primitive;

[0138] Correspondingly, the to-be-adjusted primitives are other primitives whose reachable areas cover the target primitive.

[0139] In a possible implementation, the determining unit 1502 is further configured to:

[0140] Determining a reachable area of each primitive in the first drawing primitive list;

[0141] Alternatively, the reachable area of each primitive in the set of primitives to be batched is determined.

[0142] In one possible implementation, the first drawing primitive list also includes drawing positions corresponding to the primitives, the primitives in the reachable area to be determined are used as first primitives, and the primitives in the first drawing primitive list other than the first primitives are used as second primitives. The determining unit 1502 is further configured to:

[0143] Determining, according to a drawing position of the first graphic element and a drawing position of the second graphic element, whether the second graphic element blocks movement of a display layer of the first graphic element;

[0144] The reachable area of the first graphic element is obtained according to the determination result.

[0145] In a possible implementation, the determining unit 1502 is further configured to:

[0146] If the second graphic element blocks the movement of the display layer of the first graphic element, and the second graphic element and the first graphic element have the same drawing state, the reachable area of the first graphic element is determined according to the reachable area of the second graphic element.

[0147] In a possible implementation, after adjusting the display level of the to-be-adjusted primitive in the to-be-batch primitive set to the display level of the target primitive in the to-be-batch primitive set, the apparatus further includes a recording unit:

[0148] The recording unit is configured to record the display level of the to-be-adjusted graphic element after adjustment through a linked list.

[0149] In a possible implementation, after obtaining the first drawing primitive list corresponding to the first image frame, the apparatus further includes a comparison unit:

[0150] The comparing unit is configured to compare the first drawing primitive list with a second drawing primitive list corresponding to a second image frame, where the second image frame is a frame preceding the first image frame;

[0151] The rendering unit 1505 is further configured to render the first image frame according to a second batch result corresponding to the second image frame if the comparison result indicates that the first drawing primitive list is consistent with the second drawing primitive list.

[0152] In a possible implementation, the rendering unit 1505 is further configured to:

[0153] If all the graphics elements in the set of graphics elements to be batched are located in the batch result image, the second batch result is used as the first batch result to perform image rendering of the first image frame;

[0154] If there is a third primitive in the set of primitives to be merged that is not located in the batch result image, a step is performed for the set of primitives to be merged in the primitive set, where the display level of the primitive to be adjusted in the set of primitives to be merged is adjusted to the display level of the target primitive in the set of primitives to be merged.

[0155] In one possible implementation, if the comparison result indicates that the first drawing primitive list is inconsistent with the second drawing primitive list, the adjustment unit 1503 is triggered to execute a step of adjusting the display level of the primitive to be adjusted in the primitive set to be merged to the display level of the target primitive in the primitive set to be merged.

[0156] In a possible implementation, the first drawing primitive list and the second drawing primitive list are inconsistent, including:

[0157] A drawing position of the fourth primitive in the first drawing primitive list is different from a drawing position of the fourth primitive in the second drawing primitive list;

[0158] The device further comprises a cleaning unit:

[0159] The clearing unit is configured to clear all cache information corresponding to the graphic element set including the fourth graphic element.

[0160] In a possible implementation, the first drawing primitive list and the second drawing primitive list are inconsistent, including:

[0161] New primitives appear in the first drawing primitive list relative to the second drawing primitive list;

[0162] Before executing the step of adjusting the display level of the to-be-adjusted primitives in the to-be-batch-merged primitive set to the display level of the target primitives in the to-be-batch-merged primitive set, the determining unit 1502 is triggered to execute the step of grouping multiple primitives in the first drawing primitive list according to the drawing state to obtain a primitive set.

[0163] In a possible implementation, the apparatus further includes a sorting unit:

[0164] The sorting unit is configured to perform an equivalence sort on the first drawing primitive list according to the drawing state and the display level before the determining unit 1502 groups the plurality of primitives according to the drawing state to obtain a primitive set, wherein in the equivalence sorting result, primitives with the same drawing state are adjacent to each other, and primitives with the same drawing state are arranged in descending order of display level;

[0165] The determining unit 1502 is specifically configured to:

[0166] The plurality of graphic elements are grouped according to the drawing state and the equivalent sorting result to obtain the graphic element set.

[0167] The embodiment of the present application further provides a device for batch rendering, which may be an image processing device, and the image processing device may be a terminal. For example, the terminal is a smartphone:

[0168] Figure 16 The block diagram shows a partial structure of a smart phone related to the terminal provided in the embodiment of the present application. Figure 16 The smartphone includes components such as a radio frequency (RF) circuit 1610, a memory 1620, an input unit 1630, a display unit 1640, a sensor 1650, an audio circuit 1660, a wireless fidelity (WiFi) module 1670, a processor 1680, and a power supply 1690. The input unit 1630 may include a touch panel 1631 and other input devices 1632, the display unit 1640 may include a display panel 1641, and the audio circuit 1660 may include a speaker 1661 and a microphone 1662. Those skilled in the art will appreciate that Figure 16 The structure of the smartphone shown in the figure does not constitute a limitation on the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0169] The memory 1620 can be used to store software programs and modules. The processor 1680 executes the various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1620. The memory 1620 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created based on the use of the smartphone (such as audio data, a phone book, etc.). In addition, the memory 1620 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0170] Processor 1680 is the control center of the smartphone, connecting all components of the smartphone using various interfaces and circuits. It executes software programs and / or modules stored in memory 1620 and accesses data stored in memory 1620 to perform various smartphone functions and process data. Optionally, processor 1680 may include one or more processing units. Preferably, processor 1680 integrates an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 1680.

[0171] In this embodiment, the processor 1680 in the terminal may perform the following steps:

[0172] Obtaining a first drawing primitive list corresponding to the first image frame, wherein the first drawing primitive list includes a plurality of primitives, each of the primitives having a corresponding drawing state and display level;

[0173] Grouping the plurality of primitives according to the drawing state to obtain a primitive set;

[0174] For the set of graphics elements to be batched in the graphics element set, adjusting the display level of the graphics element to be adjusted in the set of graphics elements to be batched to the display level of the target graphics element in the set of graphics elements to be batched, wherein the target graphics element is determined according to the display level of the graphics element in the set of graphics elements to be batched and the reachable area of the graphics element, and the reachable area of the graphics element is used to indicate an adjustable range of the display level of the graphics element;

[0175] Batching the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame;

[0176] The first image frame is rendered according to the first batch result.

[0177] The image processing device can also be a server, see Figure 17 As shown, Figure 17 The structural diagram of the server 1700 provided in the embodiment of the present application, the server 1700 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1722 (for example, one or more processors) and memories 1732, and one or more storage media 1730 (for example, one or more mass storage devices) for storing application programs 1742 or data 1744. Among them, the memories 1732 and the storage media 1730 can be temporary storage or permanent storage. The program stored in the storage medium 1730 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1722 can be configured to communicate with the storage medium 1730 to execute a series of instruction operations in the storage medium 1730 on the server 1700.

[0178] The server 1700 may also include one or more power supplies 1726, one or more wired or wireless network interfaces 1750, one or more input and output interfaces 1758, and / or one or more operating systems 1741, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0179] In this embodiment, the central processor 1722 in the server 1700 may perform the following steps:

[0180] Obtaining a first drawing primitive list corresponding to the first image frame, wherein the first drawing primitive list includes a plurality of primitives, each of the primitives having a corresponding drawing state and display level;

[0181] Grouping the plurality of primitives according to the drawing state to obtain a primitive set;

[0182] For the set of graphics elements to be batched in the graphics element set, adjusting the display level of the graphics element to be adjusted in the set of graphics elements to be batched to the display level of the target graphics element in the set of graphics elements to be batched, wherein the target graphics element is determined according to the display level of the graphics element in the set of graphics elements to be batched and the reachable area of the graphics element, and the reachable area of the graphics element is used to indicate an adjustable range of the display level of the graphics element;

[0183] Batching the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame;

[0184] The first image frame is rendered according to the first batch result.

[0185] According to one aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store program code, and the program code is used to execute the batch rendering method described in each of the aforementioned embodiments.

[0186] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above-described embodiments.

[0187] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0188] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0189] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0190] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0191] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0192] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, ordinary technical members in this field should understand that they can still modify the technical solutions recorded in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.< / sorteditem>

Claims

1. A batch rendering method, characterized in that: The method comprises: Obtaining a first drawing primitive list corresponding to the first image frame, wherein the first drawing primitive list includes a plurality of primitives and corresponding drawing positions of the primitives, each of the primitives having a corresponding drawing state and display level; Grouping the plurality of primitives according to the drawing state to obtain a primitive set; For the set of graphics elements to be batched in the graphics element set, adjusting the display level of the graphics elements to be adjusted in the set of graphics elements to be batched to the display level of the target graphics elements in the set of graphics elements to be batched; Batching the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame; Performing image rendering of the first image frame according to the first batch result; The method for determining the target primitive includes: Determine the amount by which the display level of each primitive in the set of primitives to be batched is covered by the reachable areas of other primitives in the set of primitives to be batched; the reachable area of a primitive is used to indicate an adjustable range of the display level of the primitive without changing the rendering result; Determine the primitive covered by the reachable areas of the largest number of other primitives as the target primitive; The methods for determining the reachable area of a primitive include: The primitive in the reachable area to be determined is used as the first primitive, and the primitives in the first drawing primitive list other than the first primitive are used as the second primitive; Determining, according to respective drawing positions of the first graphic element and the second graphic element, whether the second graphic element blocks movement of a display layer of the first graphic element; The reachable area of the first graphic element is obtained according to the determination result.

2. The method according to claim 1, characterized in that The to-be-adjusted primitives are other primitives whose reachable areas cover the target primitive.

3. The method according to claim 1, characterized in that The method further comprises: Determining a reachable area of each primitive in the first drawing primitive list; Alternatively, the reachable area of each primitive in the set of primitives to be batched is determined.

4. The method according to claim 1, wherein The obtaining of the reachable area of the first graphic element according to the determination result includes: If the second graphic element blocks the movement of the display layer of the first graphic element, and the second graphic element and the first graphic element have the same drawing state, the reachable area of the first graphic element is determined according to the reachable area of the second graphic element.

5. The method according to any one of claims 1 to 4, characterized in that After adjusting the display level of the to-be-adjusted primitive in the set of primitives to be batched together to the display level of the target primitive in the set of primitives to be batched together, the method further includes: The display level of the adjusted graphic element to be adjusted is recorded in a linked list.

6. The method according to any one of claims 1 to 4, characterized in that After obtaining the first drawing primitive list corresponding to the first image frame, the method further includes: comparing the first drawing primitive list with a second drawing primitive list corresponding to a second image frame, where the second image frame is a frame previous to the first image frame; If the comparison result indicates that the first drawing primitive list is consistent with the second drawing primitive list, the first image frame is rendered according to the second batch result corresponding to the second image frame.

7. The method according to claim 6, characterized in that The rendering of the first image frame according to the second batch result corresponding to the second image frame includes: If all the graphics elements in the set of graphics elements to be batched are located in the batch result image, the second batch result is used as the first batch result to perform image rendering of the first image frame; If there is a third primitive in the set of primitives to be merged that is not located in the batch result image, a step is performed for the set of primitives to be merged in the primitive set, where the display level of the primitive to be adjusted in the set of primitives to be merged is adjusted to the display level of the target primitive in the set of primitives to be merged.

8. The method according to claim 6, characterized in that The method further comprises: If the comparison result indicates that the first drawing primitive list is inconsistent with the second drawing primitive list, a step is performed to adjust the display level of the primitive to be adjusted in the primitive set to be merged to the display level of the target primitive in the primitive set to be merged.

9. The method according to claim 8, characterized in that The first drawing primitive list and the second drawing primitive list are inconsistent, including: A drawing position of the fourth primitive in the first drawing primitive list is different from a drawing position of the fourth primitive in the second drawing primitive list; The method further comprises: All cache information corresponding to the graphic element set including the fourth graphic element is cleared.

10. The method according to claim 8, characterized in that The first drawing primitive list and the second drawing primitive list are inconsistent, including: New primitives appear in the first drawing primitive list relative to the second drawing primitive list; Before executing the step of adjusting the display level of the to-be-adjusted primitives in the to-be-batch-combined primitive set to the display level of the target primitives in the to-be-batch-combined primitive set, the method further includes: The plurality of primitives in the first drawing primitive list are grouped according to the drawing state to obtain a primitive set.

11. The method according to any one of claims 1 to 4, characterized in that: Before grouping the plurality of primitives according to the drawing state to obtain a primitive set, the method further includes: performing equivalent sorting on the first drawing primitive list according to the drawing state and the display level, wherein primitives with the same drawing state are adjacent to each other, and primitives with the same drawing state are arranged in descending order of display level; The grouping of the plurality of primitives according to the drawing state to obtain a primitive set includes: The plurality of graphic elements are grouped according to the drawing state and the equivalent sorting result to obtain the graphic element set.

12. A batch rendering device, characterized in that: The device includes an acquisition unit, a determination unit, an adjustment unit, a batching unit, and a rendering unit: The acquiring unit is configured to acquire a first drawing primitive list corresponding to the first image frame, wherein the first drawing primitive list includes a plurality of primitives and corresponding drawing positions of the primitives, and each primitive has a corresponding drawing state and display level; The determining unit is configured to group the plurality of primitives according to the drawing state to obtain a primitive set; The adjusting unit is configured to adjust, for the set of graphics primitives to be batched in the graphics primitive set, the display level of the graphics primitives to be adjusted in the set of graphics primitives to be batched to the display level of the target graphics primitives in the set of graphics primitives to be batched; The batching unit is configured to batch the graphics elements in the set of graphics elements to be batched according to the adjusted display level to obtain a first batching result corresponding to the first image frame; The rendering unit is configured to perform image rendering of the first image frame according to the first batching result; The determining unit is further configured to: Determine the amount by which the display level of each primitive in the set of primitives to be batched is covered by the reachable areas of other primitives in the set of primitives to be batched; the reachable area of a primitive is used to indicate an adjustable range of the display level of the primitive without changing the rendering result; Determine the primitive covered by the reachable areas of the largest number of other primitives as the target primitive; The determining unit is further configured to: The primitive in the reachable area to be determined is used as the first primitive, and the primitives in the first drawing primitive list other than the first primitive are used as the second primitive; Determining, according to respective drawing positions of the first graphic element and the second graphic element, whether the second graphic element blocks movement of a display layer of the first graphic element; The reachable area of the first graphic element is obtained according to the determination result.

13. The device according to claim 12, characterized in that The to-be-adjusted primitives are other primitives whose reachable areas cover the target primitive.

14. The device according to claim 12, characterized in that The determining unit is further configured to: Determining a reachable area of each primitive in the first drawing primitive list; Alternatively, the reachable area of each primitive in the set of primitives to be batched is determined.

15. The device according to claim 12, characterized in that The determining unit is further configured to: If the second graphic element blocks the movement of the display layer of the first graphic element, and the second graphic element and the first graphic element have the same drawing state, the reachable area of the first graphic element is determined according to the reachable area of the second graphic element.

16. The device according to any one of claims 12 to 15, characterized in that After adjusting the display level of the to-be-adjusted primitive in the to-be-combined primitive set to the display level of the target primitive in the to-be-combined primitive set, the apparatus further comprises: a recording unit; The recording unit is configured to record the display level of the to-be-adjusted graphic element after adjustment through a linked list.

17. The device according to any one of claims 12 to 15, characterized in that After obtaining the first drawing primitive list corresponding to the first image frame, the apparatus further includes: a comparison unit; The comparing unit is configured to compare the first drawing primitive list with a second drawing primitive list corresponding to a second image frame, where the second image frame is a frame preceding the first image frame; The rendering unit is further configured to perform screen rendering of the first image frame according to a second batch result corresponding to the second image frame if the comparison result indicates that the first drawing primitive list is consistent with the second drawing primitive list.

18. The device according to claim 17, characterized in that The rendering unit is further configured to: If all the graphics elements in the set of graphics elements to be batched are located in the batch result image, the second batch result is used as the first batch result to perform image rendering of the first image frame; If there is a third primitive in the set of primitives to be merged that is not located in the batch result image, a step is performed for the set of primitives to be merged in the primitive set, where the display level of the primitive to be adjusted in the set of primitives to be merged is adjusted to the display level of the target primitive in the set of primitives to be merged.

19. The device according to claim 17, characterized in that If the comparison result indicates that the first drawing primitive list is inconsistent with the second drawing primitive list, the adjustment unit is triggered to execute a step of adjusting the display level of the to-be-adjusted primitives in the to-be-merged primitive set in the primitive set to the display level of the target primitives in the to-be-merged primitive set.

20. The device according to claim 19, characterized in that The first drawing primitive list and the second drawing primitive list are inconsistent, including: A drawing position of the fourth primitive in the first drawing primitive list is different from a drawing position of the fourth primitive in the second drawing primitive list; The device further comprises: a cleaning unit; The clearing unit is configured to clear all cache information corresponding to the graphic element set including the fourth graphic element.

21. The device according to claim 19, characterized in that The first drawing primitive list and the second drawing primitive list are inconsistent, including: New primitives appear in the first drawing primitive list relative to the second drawing primitive list; Before executing the step of adjusting the display level of the to-be-adjusted primitives in the to-be-batch-merged primitive set to the display level of the target primitives in the to-be-batch-merged primitive set, the determining unit is triggered to group multiple primitives in the first drawing primitive list according to the drawing state to obtain a primitive set.

22. The device according to any one of claims 12 to 15, characterized in that The device further comprises: a sorting unit; The sorting unit is configured to perform equivalence sorting on the first drawing primitive list according to the drawing state and the display level before the determining unit groups the plurality of primitives according to the drawing state to obtain a primitive set, wherein in the equivalence sorting result, primitives with the same drawing state are adjacent to each other, and primitives with the same drawing state are arranged in descending order of display level; The determining unit is specifically configured to: The plurality of graphic elements are grouped according to the drawing state and the equivalent sorting result to obtain the graphic element set.

23. A device for batch rendering, characterized in that: The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method according to any one of claims 1 to 11 according to instructions in the program code.

24. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store program code, and the program code is used to implement the method according to any one of claims 1 to 11 when executed by a processor.

25. A computer program product, characterized in that The method comprises computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Batch rendering method for improving display efficiency of building model

    CN109978981A

  • Indexes of graphics processing objects in graphics processing unit commands

    US20080246773A1