Data processing method and device, electronic equipment and computer readable medium

By merging adjacent rendering stages and utilizing the pixel local storage function, the problem of excessive memory bandwidth in game rendering is solved, rendering operations are completed directly on the GPU, memory bandwidth is reduced, and rendering efficiency is improved.

CN118799466APending Publication Date: 2024-10-18SHANGHAI JINSHENG COMM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310403423.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-14
Publication Date
2024-10-18

Smart Images

  • Figure CN118799466A_ABST
    Figure CN118799466A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device, electronic equipment and a computer readable medium, and relates to the technical field of computers, and the method comprises the steps: obtaining two adjacent rendering stages, and recording the two rendering stages as a first rendering stage and a second rendering stage; if the first rendering stage and the second rendering stage meet a merging condition, merging the first rendering stage and the second rendering stage into a target rendering stage; and executing the target rendering stage through a pixel local storage function. Due to the fact that the pixel local storage function cannot span different rendering stages, data stored by the pixel local in the previous rendering stage cannot be used after the frame buffer is switched, the two rendering stages are combined into one rendering stage, and the rendering efficiency is improved. The operations of the two rendering stages can be directly completed on a chip through a pixel local storage function, the data volume written into a memory is reduced, and the memory bandwidth is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a data processing method, device, electronic device and computer-readable medium. Background Art

[0002] Pixel Local Storage (PLS) is a data access method of OpenGL ES. Data declared with PLS will be stored in the GPU's tile buffer.

[0003] At present, some games have complex scenes, and rendering a frame usually requires multiple rendering stages (Pass), for example, it has at least a dozen rendering stages. Then, during the rendering process, too many rendering stages will seriously increase the memory bandwidth and power consumption. How to use PLS to solve the problem of excessive memory bandwidth during the rendering process is currently a difficult problem. Summary of the invention

[0004] The present application proposes a data processing method, device, electronic device and computer-readable medium to improve the above-mentioned defects.

[0005] In a first aspect, an embodiment of the present application provides a data processing method applied to a graphics application program interface of an Android framework layer, the method comprising: obtaining two adjacent rendering stages, respectively recorded as a first rendering stage and a second rendering stage; if the first rendering stage and the second rendering stage meet a merging condition, merging the first rendering stage and the second rendering stage into a target rendering stage; and executing the target rendering stage through a pixel local storage function.

[0006] In the second aspect, an embodiment of the present application also provides a data processing device, which is applied to a graphics application program interface of an Android framework layer, and the device includes: an acquisition unit, which is used to acquire two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage; a merging unit, which is used to merge the first rendering stage and the second rendering stage into a target rendering stage if the first rendering stage and the second rendering stage meet a merging condition; and an execution unit, which is used to execute the target rendering stage through a pixel local storage function.

[0007] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: one or more processors; a memory; a graphics application program interface of an Android framework layer, wherein the graphics application program interface is used to perform image rendering, and the image rendering corresponds to multiple rendering stages; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the above method.

[0008] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the readable storage medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the above method.

[0009] The data processing method, device, electronic device and computer-readable medium provided by the present application obtain two adjacent rendering stages, which are respectively recorded as the first rendering stage and the second rendering stage; if the first rendering stage and the second rendering stage meet the merging condition, the first rendering stage and the second rendering stage are merged into a target rendering stage; and the target rendering stage is executed through the pixel local storage function. Since the pixel local storage function cannot span different rendering stages, the pixel local storage data of the previous rendering stage cannot be used after the frame cache is switched. Therefore, by merging the two rendering stages into one rendering stage, the operations of the two rendering stages can be completed directly on the chip through the pixel local storage function, reducing the amount of data written to the memory and reducing the memory bandwidth.

[0010] Other features and advantages of the embodiments of the present application will be described in the subsequent description, and partly become apparent from the description, or can be understood by practicing the embodiments of the present application. The purposes and other advantages of the embodiments of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0012] Figure 1 A schematic diagram showing an application scenario of the data processing method provided in an embodiment of the present application;

[0013] Figure 2 A method flow chart of a data processing method provided by an embodiment of the present application is shown;

[0014] Figure 3 A method flow chart of a data processing method provided by another embodiment of the present application is shown;

[0015] Figure 4 A schematic diagram of adjacent related rendering stages provided by an embodiment of the present application is shown;

[0016] Figure 5A method flow chart of a data processing method provided by another embodiment of the present application is shown;

[0017] Figure 6 A schematic diagram of adjacent related rendering stages provided by another embodiment of the present application is shown;

[0018] Figure 7 A schematic diagram showing the merging of adjacent related rendering stages provided by an embodiment of the present application is shown;

[0019] Figure 8 A schematic diagram showing the merging of adjacent related rendering stages provided by another embodiment of the present application is shown;

[0020] Fig. 9 A schematic diagram showing the merging of adjacent related rendering stages provided by another embodiment of the present application is shown;

[0021] Fig.10 A module block diagram of a data processing device provided by an embodiment of the present application is shown;

[0022] Fig.11 A schematic diagram of an electronic device provided by an embodiment of the present application is shown;

[0023] Fig.12 A schematic diagram of a computer-readable medium provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0024] In order to make those skilled in the art better understand the present application scheme, the technical scheme in the present application embodiment will be clearly and completely described below in conjunction with the drawings in the present application embodiment. Obviously, the described embodiment is only a part of the present application embodiment, rather than all the embodiments. The components of the present application embodiment usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiment of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0025] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0026] Mobile GPUs (i.e. GPUs used in mobile terminals such as laptops and mobile phones) are different from desktop GPUs (i.e. GPUs used in terminals such as desktop computers). Most mobile GPUs use a tile rendering architecture, which divides the screen into several tiles of equal size and renders them in tiles. This introduces the tile cache, which is a high-speed cache on the GPU chip. The tile rendering architecture allows multiple renderings within a tile to stay on the tile cache and only write to the memory after the entire tile is rendered, which can reduce memory bandwidth.

[0027] Many mobile games are limited by the memory bandwidth and power consumption of mobile phones. In the process of rendering a frame, the rendering target is not switched multiple times. However, for some complex scenes, rendering a frame usually has multiple rendering stages (Pass), for example, there are at least a dozen rendering stages. The direct connection between the stages is the texture stored in the memory, which can record various information such as color, depth, normal, occlusion, etc.

[0028] Pixel Local Storage (PLS) is a data access method of OpenGL ES. Data declared with PLS will be stored in the GPU's Tile buffer. Framebuffer Fetch technology allows developers to write shader code to access the color, depth and other values ​​of the current pixel stored in the Tile Cache. Both technologies can reduce memory bandwidth.

[0029] However, the inventors found in their research that PLS and Framebuffer Fetch are not mandatory extensions of the graphics application programming interface (API) in the operating system, and not all GPUs support PLS and Framebuffer Fetch. For example, Adreno GPU does not currently support PLS. There is a game engine between the game and the graphics driver. For compatibility reasons, the game engine may not necessarily support PLS or Framebuffer Fetch. If the game uses a game engine, such as unity, even the most customizable Scriptable Render Pipeline (SRP) does not allow game developers to directly write GLSL (i.e., OpenGL shading language) shader code, and there is no way to support PLS. Because the working mode of shader programming in unity is to convert shader languages ​​such as HLSL into shader languages ​​that can be run on the target platform according to different configurations, such as GLSL for mobile platforms, this process is uncontrollable for most game developers who do not have unity source code. In addition, there is a time difference between the time to market and the time to develop the game. The game engine version used by the current popular games may be an early version and does not yet support PLS technology.

[0030] In addition, the shader can only access the current pixel one-to-one, which is not applicable to algorithms that need to access adjacent pixels, such as Gaussian filtering.

[0031] Therefore, how to use PLS to solve the problem of excessive memory bandwidth during the rendering process is currently a difficult problem.

[0032] Next, the present application embodiment first introduces the scenario in which the data processing method of the present application is applied. Figure 1 As shown, Figure 1 The graphics API hook in the basic application is the execution subject of the data processing method. The graphics API hook may refer to installing some hooks on the graphics application program interface called by the game to achieve the purpose of fine-tuning the semantics of the graphics application program interface, that is, changing some codes based on the code of the graphics application program interface. Among them, the hook is the HOOK mechanism, which allows the application to intercept and process messages or specified events. When the specified message is sent, the HOOK program can capture the message before it reaches the target object, thereby obtaining control over the message, and then the message can be processed or modified. In the embodiment of the present application, Figure 1As shown, the graphics API hook is located in the Android framework layer, that is to say, some hooks are installed on the graphics application program interface called by the game application to adjust the semantics of the graphics application program interface, so as to enable it to have the function of executing the data processing method provided in the embodiment of the present application. Exemplarily, the graphics application program interface can be a GLES (OpenGL for Embedded System) API, and the function of the data processing method provided in the embodiment of the present application is implemented on the GLES API through API hook technology and GLES layer mechanism. OpenGL (OpenGraphics Library) is a programming interface that defines a cross-programming language and cross-platform, which is used for two-dimensional or three-dimensional graphics drawing. OpenGL is a professional graphics program interface, a powerful and easy-to-call underlying graphics library.

[0033] Exemplarily, the semantic modifications to the GLES API may at least include: 1) modifying the GL_DRAW_FRAMEBUFFER bound to glBindFramebuffer so that two passes that meet the merging conditions can be merged; 2) modifying the parameters of glViewport and glScissor so that the resolution can be modified; 3) modifying the parameters of glShaderSource so that the shader in the pass can be replaced; 4) adding a new glShadingRateQCOM function call to perform variable rate shading (VRS).

[0034] See also Figure 2 , Figure 2 A data processing method is shown, which is applied to the above-mentioned graphical application program interface of the Android framework layer, that is, a graphical application program interface with hooks and changed semantics. The method includes: S201 to S203.

[0035] S201: Obtain two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage.

[0036] As mentioned earlier, in some complex scenarios, electronic devices require multi-channel rendering to complete the display of the final image. Multi-channel rendering technology is multiple renderings, and the results of each rendering process will be accumulated to the final presentation result. The rendering stage is Render Pass. Simply put, a single-channel rendering machine completes the graphics rendering process in one pass to obtain a frame of data. Multi-channel rendering is multiple passes, which is actually the process of rendering a frame and requiring multiple passes to cooperate to complete the effect of the last frame. For example, shadow drawing requires a pass to render the depthmap to obtain depth information, and another pass to render the scene to obtain scene information. Then the scene rendering information uses texture sampling to obtain the data (that is, depth information) rendered in the previous pass to comprehensively calculate the shadow information and add it to the scene rendering information to complete the final shadow rendering.

[0037] Therefore, for multi-pass rendering, two adjacent rendering stages are obtained and named as the first rendering stage and the second rendering stage, respectively. Specifically, the first rendering stage of the two adjacent rendering stages can be recorded as the first rendering stage, that is, PASS N, and the second rendering stage of the two adjacent rendering stages can be recorded as the second rendering stage, that is, PASS N+1. Of course, the first rendering stage of the two adjacent rendering stages can also be recorded as the second rendering stage and the second rendering stage can be recorded as the first rendering stage. Specifically, it is not limited here.

[0038] As an implementation mode, the rendering stage has multiple rendering operations, which usually include drawing instructions, which are used to obtain the object to be rendered, that is, the image data to be processed, and perform drawing operations, that is, rendering operations. In addition, other instructions may also be included, such as cropping instructions, etc., which are not specifically limited here. In the multi-rendering stage technology, the results obtained in each rendering stage are finally integrated into the final required image. It should be noted that a rendering stage may include multiple drawing instructions, and usually the data output by the first drawing instruction is used as the input of the next drawing instruction.

[0039] S202: If the first rendering stage and the second rendering stage meet a merging condition, merge the first rendering stage and the second rendering stage into a target rendering stage.

[0040] As an implementation method, the merging condition may be a condition set according to actual use requirements. It should be noted that the merging condition may be based on the correlation of the objects to be rendered processed by the two rendering stages, the memory layout of the two rendering stages, etc. Specifically, the merging condition will be described in detail in the subsequent embodiments. Exemplarily, the merging condition is used to determine whether the two adjacent rendering stages can be merged for processing, so as to provide basic conditions for using the pixel local storage function.

[0041] S203: Execute the target rendering phase through the pixel local storage function.

[0042] It should be noted that pixel local storage PLS is a technology deployed in the graphics processing unit (GPU) and is a data access method of OpenGL ES. Data declared with PLS will be stored on the GPU's tile buffer. Due to hardware limitations, the pixel local storage technology cannot be stored across different rendering stages. After the frame buffer is switched, the data stored in the PLS of the previous rendering stage cannot be used. Therefore, by merging two adjacent rendering stages that meet the merging conditions, the two rendering stages are merged into one rendering stage, which not only reduces the rendering stage, that is, reduces the redundancy of rendering operations, but also enables both rendering stages to use pixel local storage technology, thereby reducing the bandwidth of memory data, because if not merged, the data output by the first rendering stage needs to be written into the memory so that the second rendering stage can perform rendering operations.

[0043] It should be noted that, in an embodiment of the present application, the merging of the first rendering stage and the second rendering stage may include retaining one instruction of the two instructions in the two rendering stages, deleting or setting the other instruction to a no operation (also called no operation). Specifically, instructions of the same type may be merged, and the merging method may be to integrate the two instructions into one instruction, and delete or set the other instruction to a no operation. For details, please refer to the subsequent embodiments.

[0044] Therefore, in the data processing method provided by the present application, two adjacent rendering stages are obtained, which are recorded as the first rendering stage and the second rendering stage respectively; if the first rendering stage and the second rendering stage meet the merging condition, the first rendering stage and the second rendering stage are merged into the target rendering stage; and the target rendering stage is executed through the pixel local storage function. Since the pixel local storage function cannot be used in different rendering stages, the pixel local storage data of the previous rendering stage cannot be used after the frame cache is switched. Therefore, by merging the two rendering stages into one rendering stage, the operations of the two rendering stages can be completed directly on the chip through the pixel local storage function, reducing the amount of data written to the memory and reducing the memory bandwidth.

[0045] See also Figure 3 , Figure 3 A data processing method is shown, which is applied to the above-mentioned graphical application program interface of the Android framework layer, that is, a graphical application program interface with hooks and changed semantics. The method includes: S301 to S304.

[0046] S301: Obtain two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage.

[0047] S302: If the rendering objects corresponding to the first rendering stage and the second rendering stage meet a preset condition, the memory layouts corresponding to the first rendering stage and the second rendering stage are compatible, and both support a pixel local storage function, then it is determined that the first rendering stage and the second rendering stage meet a merging condition.

[0048] It can be seen that the merging conditions that the first rendering stage and the second rendering stage need to meet may include that the rendering objects of the two stages meet preset conditions, the memory layouts of the two stages are compatible, and the two stages support the pixel local storage function. The reason why the rendering objects of the two stages meet the preset conditions is to ensure that the rendering objects of the two stages are associated with each other, so as to avoid forgetting to render one of the rendering objects or causing confusion in the rendering order when the rendering objects of the first rendering stage and the second rendering stage are different or have no association. Therefore, the preset condition may be a representation that the rendering objects of the first rendering stage and the second rendering stage are the same object, or that the rendering object of the second rendering stage is the output object of the first rendering stage.

[0049] In addition, the memory layout compatibility of the first rendering stage and the second rendering stage may include that the pixel layout of the rendering object of the first rendering stage is consistent with the pixel layout of the rendering object of the second rendering stage. For example, different pixels have different formats, such as some are 24 bits and some are 32 bits, which are incompatible. Even if the pixels are all 32 bits, they have different layouts, such as some are RGBA8_UNORM and some are R32F. Whether they are compatible is also related to GPU hardware and GLES specifications. Through a pre-set query instruction, it is possible to query whether the memory layout of the first rendering stage and the second rendering stage are compatible.

[0050] Furthermore, since the rendering stage after the merger needs to be rendered based on the pixel local storage function, the first rendering stage and the second rendering stage both support the pixel local storage function, which is a prerequisite for the merger of the two.

[0051] The following further explains that the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions.

[0052] Exemplarily, the first rendering stage is the previous stage of the second rendering stage, and the implementation method in which the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions is that the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage. It should be noted that the rendering stage may include multiple drawing instructions, and the first drawing instruction is often used as the instruction for performing the first drawing operation on the rendering object in the rendering stage, and the last drawing instruction will experience the last drawing operation performed after the aforementioned multiple drawing instructions as the output data of the rendering stage. Therefore, if the data sampled by the first drawing instruction of the second rendering stage happens to be the texture data output by the last drawing instruction of the first rendering stage, this means that the second rendering stage is just a further rendering based on the first rendering stage, so the two meet the preset conditions in the merging conditions, that is, the rendering operations of the two rendering stages can be integrated and completed in one rendering stage.

[0053] Further, the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, and the shader used by the first drawing instruction of the second rendering stage does not include the code for texture coordinate offset. That is, the first rendering stage is the stage before the second rendering stage, and the implementation method in which the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions is that the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, and the shader used by the first drawing instruction of the second rendering stage does not include the code for texture coordinate offset. That is, the shader (Fragment Shader) used by the first drawing instruction of the second rendering stage only samples the current pixel, which can be the same pixel as that of the first rendering stage, or can be the texture data output by the last drawing instruction of the first rendering stage, that is, the shader used by the first drawing instruction of the second rendering stage only samples the texture data output by the last drawing instruction of the first rendering stage, that is, the texture coordinate offset is not performed, that is, other pixels other than the pixels corresponding to the texture data are not collected.

[0054] Specifically, the code of the shader used by the first drawing instruction of the second rendering stage that does not include the texture coordinate offset can be a pseudo code in the following form: texture(sampler2DpreviousTexture,gl_FragCoord.xy), and the pseudo code of the code of the shader used by the first drawing instruction of the second rendering stage that includes the texture coordinate offset is in the following form: texture(sampler2DpreviousTexutre,gl_FragCoord.xy+offset). Therefore, by analyzing the code of the shader used by the first drawing instruction of the second rendering stage, it is possible to determine whether the shader used by the first drawing instruction of the second rendering stage includes the code of the texture coordinate offset.

[0055] Further, the first rendering stage is the previous stage of the second rendering stage, and the implementation method that the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions may be that the rendering objects of the first rendering stage are not multiple, and the shader using the texture data output by the first rendering stage in the second rendering stage meets the application scenario of the pixel local storage function. That is to say, the first rendering stage does not have multiple rendering targets (Multiple Render Target, MRT), and the shader using the texture data output by the first rendering stage in the second rendering stage does not have shader code that does not meet other requirements, wherein the absence of shader code that does not meet other requirements is the aforementioned application scenario that meets the pixel local storage function PLS, such as the scenario of modifying the depth value in the shader is the application scenario that does not meet the pixel local storage function PLS. Specifically, multiple target application scenarios that meet the pixel local storage function PLS can be pre-set, and then, it is determined whether the function of the shader of the second rendering stage matches the target application scenario. If it matches, it is determined that the shader meets the application scenario of the pixel local storage function.

[0056] It should be noted that only one of the above-mentioned different preset conditions needs to be met, that is, the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, which can determine that the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions; or, there are not multiple rendering objects in the first rendering stage, and the shader in the second rendering stage that uses the texture data output by the first rendering stage meets the application scenario of the pixel local storage function, which can determine that the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions.

[0057] In the embodiment of the present application, the rendering objects corresponding to the first rendering stage and the second rendering stage satisfying the preset conditions may include: there are not multiple rendering objects in the first rendering stage, and the shader using the texture data output by the first rendering stage in the second rendering stage meets the application scenario of the pixel local storage function, and the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage. Furthermore, the first drawing instruction of the second rendering stage sampling the texture data output by the last drawing instruction of the first rendering stage also needs to further satisfy that the shader used by the first drawing instruction of the second rendering stage does not include the code for texture coordinate offset.

[0058] S303: If the first rendering stage and the second rendering stage meet a merging condition, merge the first rendering stage and the second rendering stage into a target rendering stage.

[0059] It should be noted that the combination of the first rendering stage and the second rendering stage is actually a modification of the operation instructions in the two rendering stages. Specifically, the instructions of each rendering stage include standard instructions and non-standard instructions. The standard instructions may refer to standard instructions of a graphics application program interface, for example, standard instructions of a GLES API, such as Figure 4 As shown, "1.glBindFramebuffer binding frame buffer object" and "3.glDrawElements and other drawing instructions" of the first rendering stage Pass N, and "4.glBindFramebuffer binding frame buffer object" and "6.glDrawElements and other drawing instructions" of the second rendering stage Pass N+1 are all standard instructions, and other GLES API calls are all non-standard instructions. When merging, the standard instructions in the first rendering stage and the second rendering stage can be merged, and the non-standard instructions in the second rendering stage and the second rendering stage are not merged.

[0060] S304: Execute the target rendering phase through the pixel local storage function.

[0061] Therefore, in the embodiment of the present application, for those first rendering stages and second rendering stages that meet the merging conditions, the target rendering stage is obtained by merging the two rendering stages that meet the merging conditions. The merging of the two rendering stages that meet the merging conditions may not cause disorder or omission of the drawing operations of the rendering objects of the two rendering stages. Moreover, by merging the two rendering stages into one rendering stage, the operations of the two rendering stages can be completed directly on the chip through the pixel local storage function, thereby reducing the amount of data written to the memory and reducing the memory bandwidth.

[0062] See also Figure 5 , Figure 5A data processing method is shown, which is applied to the above-mentioned graphical application program interface of the Android framework layer, that is, a graphical application program interface with hooks and changed semantics. The method includes: S501 to S504.

[0063] S501: Obtain two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage.

[0064] Exemplarily, the data processing method provided in the embodiment of the present application is applicable to the rendering of game scenes. Specifically, the first rendering stage and the second rendering stage can be the respective rendering stages of the 3D main scene and the respective rendering stages of the UI mixing, which are not limited here.

[0065] like Figure 6 As shown, Figure 6 An example of the first rendering stage and the second rendering stage is shown, the first rendering stage is Pass N, the second rendering stage is Pass N+1, and the first rendering stage is the previous stage of the second rendering stage. It can be seen that the first rendering stage includes the first binding frame buffer instruction (glBindFramebuffer binding frame buffer object 1), the first viewport setting instruction (glViewport setting viewport size 1), the first clipping area setting instruction (glScissor setting clipping area size 1) and the first drawing instruction (glDrawElements drawing instruction 1), wherein the first binding frame buffer instruction of the first rendering stage is used to bind the frame buffer object 1, the frame buffer is located in the memory, and the first binding frame buffer instruction is used to read the frame buffer object 1 from the cache area corresponding to the frame buffer object 1 in the memory, so that other instructions of the first rendering stage process the frame buffer object 1. The first viewport setting instruction is used to set the size of the viewport (viewport), and the first viewport setting instruction of the first rendering stage is used to set the size of the viewport (viewport) to size 1, i.e., size 1. The first clipping area setting instruction is used to set the size of the clipping area, where the clipping area or clipping area, also known as the visible area, is set by the canvas; it refers to setting an area on the canvas. Once the canvas sets the visible area, anything drawn outside this area will not be visible. The clipping area setting instruction of the first rendering stage is used to set the size of the clipping area to size 1, i.e., size 1.

[0066] Similarly, if Figure 6As shown, the second rendering stage includes a second frame buffer binding instruction (glBindFramebuffer binds frame buffer object 2), a second viewport setting instruction (glViewport sets viewport size 2), a second clipping region setting instruction (glScissor sets clipping region size 2) and a second drawing instruction (glDrawElements drawing instruction 2). It should be noted that the frame buffer object 2 bound by the second frame buffer binding instruction of the second rendering stage and the frame buffer object 1 bound by the first frame buffer binding instruction of the first rendering stage need to meet the preset conditions in the aforementioned merging conditions, that is, the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, or the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, and the shader used by the first drawing instruction of the second rendering stage does not include the code for texture coordinate offset. In addition, the number of the frame buffer objects 1 is not multiple, that is, the frame buffer object 1 and the frame buffer object 2 correspond to the same rendering object, that is, the pixel area, and the frame buffer object 2 can be the texture data obtained after the frame buffer object 1 is drawn by the drawing instruction 1.

[0067] The viewport size and the clipping area size can determine the target resolution corresponding to the rendering stage, that is, the resolution of the texture data output by the rendering stage. The target resolution can be regarded as the resolution of the image expected to be obtained in the rendering stage, for example, the resolution of the rendered data obtained after an image data is processed by the rendering stage.

[0068] S502: If the first rendering stage and the second rendering stage meet a merging condition, a first shader used by a drawing instruction of the first rendering stage and a second shader used by a drawing instruction of the second rendering stage are changed, and the changed first shader and second shader both support a pixel local storage function.

[0069] After determining that the first rendering stage and the second rendering stage meet the merging conditions, in order to enable the merged rendering stage to use the PLS technology, it is necessary to first change the shaders in the drawing instructions in the first rendering stage and the second rendering stage so that both shaders can use the PLS technology. It should be noted that the first shader used by the drawing instructions of the first rendering stage mentioned above can refer to the general term for the shaders of all drawing instructions in the first rendering stage, and is not limited to only one shader. Similarly, the second shader used by the drawing instructions of the second rendering stage can refer to the general term for the shaders of all drawing instructions in the second rendering stage.

[0070] It should be noted that the first shader and the second shader are both fragment shaders, that is, fragmentshaders. The shader can be changed by changing the source code of the shader, for example, adding a field similar to the following to the shader code:

[0071]

[0072] For example, Figure 6 The code of the shaders in "glDrawElements drawing instruction 1" and "glDrawElements drawing instruction 2" are changed. The texture data output by glDrawElements drawing instruction 1 can be stored locally through PLS technology, that is, on the chip, that is, in the storage space of the GPU. Then, glDrawElements drawing instruction 2 can read the texture data output by glDrawElements drawing instruction 1 from the local of the GPU through PLS technology.

[0073] As an implementation method, the data processing method provided in the embodiment of the present application is applicable to the rendering of game scenes. In order to quickly locate the shader that needs to be modified, the modification method, etc., the drawing instructions of each rendering stage in the game scene can be analyzed offline in advance, and the shader source code supporting PLS technology for each drawing instruction can be created in advance. Among them, offline analysis refers to the analysis of multiple rendering stages that may be used by the application in advance in the time period before the application is started.

[0074] Specifically, multiple rendering stages of the game screen are determined in advance, and two rendering stages that meet the merging conditions are determined, the fragment shader source code used in the two rendering stages is analyzed, and the corresponding modified version supporting PLS is created. Then, the features of the two rendering stages are analyzed, and the features can be used as the identity of the two rendering stages, so that the corresponding relationship between the features and the shader code supporting PLS can be obtained, as shown in Table 1 for example:

[0075] Table 1

[0076] Rendering stage feature Modified shader code Pass N Feature 1 Shader 1 Pass N+1 Feature 2 Shader 2

[0077] It should be noted that the characteristics of the rendering stage may include parameters such as the size, format, and dimensions (i.e., quantity) of the attachments bound to the FBO of the rendering stage. For example, Figure 6 The glBindFramebuffer in the code binds frame buffer object 1 and the glBindFramebuffer in the code binds frame buffer object 2. Specifically, FBO is a frame buffer object, namely, Frame BufferObject. The attachment of FBO refers to the color texture, depth texture and other data attached to FBO.

[0078] After establishing the above correspondence, when the application starts, the characteristics of the offline record and the characteristics of the runtime can be associated with a data structure, that is, the characteristics of the rendering stage used at runtime are determined, and then the currently running rendering stage is determined in the pre-established offline record, wherein the offline record includes the characteristics of each rendering stage, the corresponding shader code and the running logic, and the running logic includes the running time, etc., which is used to characterize the sequence between the rendering stage and other rendering stages. Therefore, by searching the rendering stage corresponding to the characteristics of the currently running rendering stage in the offline record, the modified shader code and running logic corresponding to the currently running rendering stage can be determined, so as to accurately locate the API call timing, that is, the execution timing of the glDrawElements drawing instruction and the glBindFramebuffer binding frame buffer object in the rendering stage.

[0079] For example, if the offline analysis finds that a certain rendering stage Pass uses multiple texture attachments, the multiple attachments can be used as a feature to mark the rendering stage Pass. Then the feature of the rendering stage is recorded as three textures, that is, the size of the texture, and such a mapping is established using C++std::map to obtain the features of the rendering stage and the rendering stage, thereby determining the modified shader code corresponding to the rendering stage and the API call timing, that is, the call timing of APIs such as glDrawElements and glBindFramebuffer.

[0080] Therefore, after the application is started, two modified fragment shaders are created when the shader is compiled. When the first shader used by the drawing instructions of the first rendering stage and the second shader used by the drawing instructions of the second rendering stage are changed, the first shader used by the drawing instructions of the first rendering stage and the second shader used by the drawing instructions of the second rendering stage are respectively connected to the two pre-created modified fragment shaders. That is to say, the two modified fragment shaders are created as global variables of the rendering stage and can be called through a main function.

[0081] It should be noted that the usage of the above Table 1 is that one of the shaders of the two rendering stages in Table 1 is used to output data, and the other is used to input data, that is, the output of one shader is used as the input of another shader. When the application is running, for the two adjacent rendering stages currently running, the table can be used to determine the API call timing, and thus the rendering stage of the shader that needs to output data and the rendering stage of the shader that needs to input data can be determined. It is assumed that when the shader is compiled, the two modified fragment shaders created are shader s1 and shader s2, respectively, and shader s1 is used to write data (i.e., output data) through PLS, and shader s2 is used to read data (i.e., input data) through PLS. Then, when the shader program is linked, the shader that needs to output data in the two rendering stages can be linked to shader s1, and the shader that needs to input data can be linked to shader s2.

[0082] Thus, the first shader used by the drawing instructions of the first rendering stage and the second shader used by the drawing instructions of the second rendering stage can be changed, so that the shaders of the two rendering stages can support the pixel local storage function.

[0083] It should be noted that the implementation method of the first rendering stage and the second rendering stage satisfying the merging condition can refer to the aforementioned embodiment, which will not be described in detail here.

[0084] S503: Merge the updated first rendering stage and the updated second rendering stage into a target rendering stage.

[0085] The shader changes in the aforementioned rendering stage can be made at the beginning of the application startup, that is, when the fragment shader is compiled. Of course, it can also be made during the running of the game, which is not limited here.

[0086] During the running of the game, the updated first rendering stage and the updated second rendering stage can be merged into a target rendering stage. As an implementation method, the updated first rendering stage and the updated second rendering stage are merged into the target rendering stage by obtaining a first target resolution corresponding to the first rendering stage and a second target resolution corresponding to the second rendering stage; based on the first target resolution and the second target resolution, the updated first rendering stage and the updated second rendering stage are merged into the target rendering stage.

[0087] As an implementation method, the first rendering stage and the second rendering stage include, in addition to instructions for binding frame buffer objects and drawing instructions, instructions that may change the resolution, such as viewport setting instructions and clipping area setting instructions. Therefore, when the drawing instructions of the first rendering stage output texture data, the first rendering stage may cause the resolution of the texture data output by the first rendering stage to be different from the resolution requirement of the second rendering stage due to the existence of instructions for changing the resolution. If the resolution of the texture data output by the first rendering stage cannot adapt to the instructions for changing the resolution of the second rendering stage, that is, it cannot meet the resolution requirement of the second rendering stage, it is necessary to determine whether the instructions for changing the resolution of the two rendering stages can be merged based on whether the second rendering stage can be changed to obtain the required resolution on the basis of the first rendering stage.

[0088] As an implementation method, based on the first target resolution and the second target resolution, an implementation method of merging the updated first rendering stage and the updated second rendering stage into a target rendering stage may be: if the first target resolution and the second target resolution are the same, or the first target resolution is higher than the second target resolution, the first rendering target corresponding to the binding frame buffer operation in the first rendering stage is changed to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage to obtain the first rendering stage to be merged; the binding frame buffer operation in the second rendering stage is changed to a null operation to obtain the second rendering stage to be merged; and the first rendering stage to be merged and the second rendering stage to be merged are merged into the target rendering stage.

[0089] That is to say, since the first rendering stage and the second rendering stage meet the merging condition, the rendering objects of the first rendering stage and the second rendering stage are associated, and the processing object of the first rendering stage is the output object of the first rendering stage. Therefore, the first rendering target corresponding to the binding frame buffer operation in the first rendering stage is changed to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage, so that the two rendering stages directly perform the drawing operations of their respective rendering stages on the same object. For example, the first rendering stage sprays an apple red, and the second rendering stage sprays the apple green. If it is not merged, it means that after the first rendering stage sprays the apple red, a red apple is obtained, and then the red apple is put into the cache, and then the second rendering stage takes the red apple out of the memory and sprays it green to obtain the final apple. If it is merged, it means obtaining an apple image, spraying it red first and then spraying it green, and outputting the final apple at one time. Therefore, the binding frame buffer operation of the second rendering stage is changed to a no operation, that is, there is no need to obtain the operation object from the frame buffer. Among them, the binding frame buffer operation is the aforementioned glBindFramebuffer binding frame buffer object.

[0090] Specifically, Figure 7 As shown, Figure 7 1 shows the target rendering stage after the first rendering stage and the second rendering stage are merged. Figure 6 It can be seen from the comparison that if the first rendering stage and the second rendering stage meet the merging condition, and the first target resolution corresponding to the first rendering stage is consistent with the second target resolution corresponding to the second rendering stage or the first target resolution is higher than the second target resolution, then the "1.glBindFramebuffer bind frame buffer object 1" of the original first rendering stage is changed to "1.glBindFramebuffer bind frame buffer object 2", that is, the merged rendering stage only performs the operation of binding the frame buffer object once, and the bound object is the object corresponding to the operation of binding the frame buffer of the second rendering stage. Then, the "1.glBindFramebuffer bind frame buffer object 2" of the original second rendering stage is changed to a no operation, which is actually an operation that does not perform any operation, which is equivalent to deleting the operation and retaining the no operation, so as not to change the sequence of the original rendering stage, that is, retain the GLES API sequence called by the application to avoid disorder, and the "glViewport sets the viewport size 1" and "glScissor sets the clipping area size 1" of the original first rendering stage are not changed, and the "glViewport sets the viewport size 2" and "glScissor sets the clipping area size 2" of the original second rendering stage are not changed. In addition, the "glDrawElements drawing instruction 1" of the original first rendering stage was changed to have the function of using PLS output, and the "glDrawElements drawing instruction 2" of the original second rendering stage was changed to have the function of reading data from PLS. Therefore, the bound frame buffer object of the original second rendering stage does not need to be executed, because there is no need to read data from the memory, but the data can be read directly through PLS.

[0091] Therefore, since the first target resolution and the second target resolution are the same, the "glViewport set viewport size 1" of the original first rendering stage may not be merged with the "glViewport set viewport size 2" of the second rendering stage, of course, you can choose to merge them. Similarly, since the first target resolution and the second target resolution are the same, the "glScissor set clipping area size 1" of the original first rendering stage may not be merged with the "gglScissor set clipping area size 2" of the second rendering stage, of course, you can choose to merge them.

[0092] Similarly, the first target resolution is higher than the second target resolution. After executing the first drawing instruction for the first target resolution in the original first rendering stage, the second rendering stage needs to execute the second drawing instruction for the second resolution. Therefore, the "glViewport sets the viewport size to 2" and "gglScissor sets the clipping area size to 2" of the original second rendering stage cannot be deleted. The viewport setting operations and clipping area operations of the two rendering stages should be retained.

[0093] As another implementation manner, based on the first target resolution and the second target resolution, an implementation manner of merging the updated first rendering stage and the updated second rendering stage into a target rendering stage may be: if the first target resolution is lower than the second target resolution, the first rendering target corresponding to the binding frame buffer operation in the first rendering stage is changed to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage, to obtain the first rendering stage to be merged; the binding frame buffer operation in the second rendering stage is changed to a null operation, to obtain the second rendering stage to be merged; the area size corresponding to the area operation of the first rendering stage to be merged and the area size corresponding to the area operation of the second rendering stage to be merged are set to be the same, to obtain the third rendering stage to be merged; the area operation of the second rendering stage to be merged is set to a null operation, to obtain a fourth rendering stage to be merged; and the third rendering stage to be merged and the fourth rendering stage to be merged are merged into the target rendering stage.

[0094] It should be noted that when the first rendering stage and the second rendering stage are merged, the changes in the bound frame buffer operation can refer to the aforementioned content and will not be repeated here. In addition, the region operation may refer to the operation of changing the region, for example, the aforementioned viewport setting instruction and cropping region setting instruction, etc., which need to set the sizes of the two to be the same. Specifically, the size corresponding to the rendering stage with a lower resolution in the first target resolution and the second target resolution can be used, or the size corresponding to the rendering stage with a higher resolution in the first target resolution and the second target resolution can be used.

[0095] It can be understood that the third rendering stage to be merged refers to the original first rendering stage after the first rendering target corresponding to the binding frame buffer operation in the first rendering stage is changed to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage and the area size corresponding to the area operation of the first rendering stage to be merged and the area size corresponding to the area operation of the second rendering stage to be merged are set to the same, and the fourth rendering stage to be merged refers to the rendering stage after the binding frame buffer operation and the area operation in the original second rendering stage are both set to no operation.

[0096] As an implementation mode, the region operation includes a viewport size setting operation and a cropping region size setting operation, and an implementation mode of setting the region size corresponding to the region operation of the first rendering stage to be merged and the region size corresponding to the region operation of the second rendering stage to be merged to be the same may be to keep the first viewport size of the viewport size setting operation in the first rendering stage to be merged and the second viewport size of the viewport size setting operation in the second rendering stage to be merged consistent; and keep the first cropping region size of the cropping region size setting operation in the first rendering stage to be merged and the second cropping region size of the cropping region size setting operation in the second rendering stage to be merged consistent.

[0097] Specifically, Figure 8 As shown, Figure 7 In comparison, except that "1.glBindFramebuffer binds frame buffer object 1" is changed to "1.glBindFramebuffer binds frame buffer object 2", the shaders of "4.glDrawElements drawing instruction 1" and "8.glDrawElements drawing instruction 2" are changed, and "1.glBindFramebuffer binds frame buffer object 2" is changed to a no-operation, the "2.glViewport sets viewport size 1" of the original first rendering stage is changed to "2.glViewport sets viewport size 2", and the "3.glScissor sets clipping region size 1" of the original first rendering stage is changed to "3.glScissor sets clipping region size 2", that is, the viewport size of the original first rendering stage adopts the viewport size of the original second rendering stage, and the clipping region size of the original first rendering stage adopts the clipping region size of the original second rendering stage, and then, the "6.glViewport sets viewport size 2" and "7.glScissor sets clipping region size 2" of the original second rendering area are both set to no-operation.

[0098] After completing the above changes, the changed first rendering stage and the second rendering stage are merged. The merging method is to splice the second rendering stage after the first rendering stage, that is, the first instruction of the second rendering stage is located after the last instruction of the first rendering stage, such as Figure 7 and 8 As shown, Figure 6 In comparison, the sum of the total instructions of the merged target rendering stage and the first rendering stage and the second rendering stage remains unchanged, wherein a no-op is also regarded as one instruction.

[0099] As an implementation, a variable shading rate operation may be added before the specified drawing instruction of the to-be-processed rendering stage, so that variable rate shading (VRS) can be performed. By adding a variable shading rate operation before the specified drawing instruction, the specified drawing instruction can render the to-be-rendered object corresponding to the target rendering stage through the variable rate rendering operation based on the shading rate to obtain a rendering result, and the variable shading rate operation is used to determine the shading rate. As an implementation, a variable shading rate operation may be added before the first drawing instruction of the merged target rendering stage, such as Fig. 9 As shown, Figure 8 In comparison, Figure 8 The variable shading rate setting operation is added before the "4.glDrawElements drawing instruction 1". Figure 8 The serial numbers of 4, 5, 6, 7, 8 are changed to 5, 6, 7, 8, 9 respectively.

[0100] Specifically, a variable shading rate operation is set to determine the shading rate according to the following formula: w,h =(floor(clamp(W N+1 / W N ,1,4)),floor(clamp(H N+1 / H N ,1,4)));

[0101] Where Rw,h is the shading rate, N is the frame number of the object to be rendered corresponding to the target rendering stage, W is the screen space width, H is the screen space height, the clamp function is used to limit the value between 1 and 4, because most GPUs currently support shading with a ratio of 4 times the width or height, and the floor function is used to round down. w,h Performs a rendering operation on the data to be rendered.

[0102] As an implementation, the implementation of adding a variable shading rate setting operation before the specified drawing instruction of the pending rendering stage may include: if it is detected that the target rendering stage meets the specified conditions, then adding a variable shading rate setting operation before the specified drawing instruction of the pending rendering stage.

[0103] In some embodiments, the target rendering stage satisfies the specified condition including predicting that the quality of the target image rendered by the target rendering stage is different from the quality of the object to be rendered corresponding to the target rendering stage. Specifically, it can be predicted by the aforementioned offline analysis, that is, analyzing the historical data of the application program to determine whether the quality of the target image obtained after the two current rendering stages are merged will be different from the quality of the object to be rendered corresponding to the target rendering stage if the variable shading rate operation is not set, that is, the variable ratio rendering is not adopted. If so, it is determined that the target rendering stage satisfies the specified condition.

[0104] In other embodiments, the target rendering stage satisfies the specified condition including predicting that the computational amount of the target rendering stage is greater than a preset threshold. The preset threshold may refer to the conventional computational amount of the GPU, that is, the conventional computational amount when the GPU processes each rendering stage. The preset threshold may be obtained through offline analysis based on historical data statistics. The computational amount of the target rendering stage may be predicted based on the current instructions of the target rendering stage, for example, through the number of codes, the size of data to be processed, the complexity of the code, etc.

[0105] S504: Execute the target rendering phase through the pixel local storage function.

[0106] After the first rendering stage and the second rendering stage are merged in the above manner to obtain the target rendering stage, each instruction in the target rendering stage is executed in sequence, and each drawing instruction in the target rendering stage transmits the data to be processed through PLS. For example, the texture data obtained after the shader rendering of a drawing instruction is completed is written into the GPU local storage through PLS, and the shader of the subsequent drawing instruction reads the texture data stored locally on the GPU through PLS to perform rendering operations.

[0107] by Fig. 9 For example, execute "1.glBindFramebuffer to bind frame buffer object 2" to obtain the object to be processed, that is, frame buffer object 2, and execute "2.glViewport to set viewport size 2" and "3.glScissor to set clipping area size 2" in sequence to obtain the viewport size and the clipping area size, then, execute the operation of setting the variable shading rate to obtain the variable shading rate, execute "5.glDrawElements drawing instruction 1", based on VRS, according to the viewport size and the clipping area size, perform a rendering operation on the object to be processed, obtain texture data, and write it to the local storage space of the GPU through PLS, then, execute three empty operations in sequence, and then execute "9.glDrawElements drawing instruction 2" to obtain the aforementioned texture data from the local storage space of the GPU through PLS technology to perform a rendering operation.

[0108] Therefore, by merging the instructions of the two rendering stages, changing the way of no operation and shader, combining adjacent Pass merging, shader replacement and variable ratio shading technology, and using the PLS function of the mobile GPU, the memory bandwidth occupied by the texture is reduced.

[0109] See also Fig.10 , which shows a structural block diagram of a data processing device provided in an embodiment of the present application. The device may include: an acquisition unit 1001, a merging unit 1002 and an execution unit 1003.

[0110] The acquisition unit 1001 is used to acquire two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage.

[0111] The merging unit 1002 is configured to merge the first rendering stage and the second rendering stage into a target rendering stage if the first rendering stage and the second rendering stage meet a merging condition.

[0112] Furthermore, the merging unit 1002 is also used to determine that the first rendering stage and the second rendering stage meet the merging condition before merging the first rendering stage and the second rendering stage into a target rendering stage if the rendering objects corresponding to the first rendering stage and the second rendering stage meet a preset condition, the memory layouts corresponding to the first rendering stage and the second rendering stage are compatible, and both support the pixel local storage function.

[0113] Furthermore, the first rendering stage is a stage before the second rendering stage, and the rendering objects corresponding to the first rendering stage and the second rendering stage meet the preset conditions including: the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage.

[0114] Furthermore, the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, including: the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, and the shader used by the first drawing instruction of the second rendering stage does not include the code for texture coordinate offset.

[0115] Furthermore, the first rendering stage is the previous stage of the second rendering stage, and the rendering objects corresponding to the first rendering stage and the second rendering stage meet preset conditions, including: there are not multiple rendering objects in the first rendering stage, and the shader in the second rendering stage that uses the texture data output by the first rendering stage meets the application scenario of the pixel local storage function.

[0116] Furthermore, the merging unit 1002 is also used to change the first shader used by the drawing instructions of the first rendering stage and the second shader used by the drawing instructions of the second rendering stage if the first rendering stage and the second rendering stage meet the merging conditions, and the changed first shader and second shader both support the pixel local storage function; and merge the updated first rendering stage and the updated second rendering stage into the target rendering stage.

[0117] Furthermore, the merging unit 1002 is also used to obtain a first target resolution corresponding to the first rendering stage and a second target resolution corresponding to the second rendering stage; based on the first target resolution and the second target resolution, the updated first rendering stage and the updated second rendering stage are merged into a target rendering stage.

[0118] Furthermore, the merging unit 1002 is also used to change the first rendering target corresponding to the binding frame buffer operation in the first rendering stage to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage if the first target resolution is consistent with the second target resolution, or the first target resolution is higher than the second target resolution, to obtain the first rendering stage to be merged; change the binding frame buffer operation in the second rendering stage to a null operation to obtain the second rendering stage to be merged; and merge the first rendering stage to be merged and the second rendering stage to be merged into the target rendering stage.

[0119] Furthermore, the merging unit 1002 is also used to, if the first target resolution is lower than the second target resolution, change the first rendering target corresponding to the binding frame buffer operation in the first rendering stage to the second rendering target corresponding to the binding frame buffer operation in the second rendering stage to obtain the first rendering stage to be merged; change the binding frame buffer operation in the second rendering stage to a no operation to obtain the second rendering stage to be merged; set the area size corresponding to the area operation of the first rendering stage to be merged and the area size corresponding to the area operation of the second rendering stage to be merged to be the same, to obtain the third rendering stage to be merged; set the area operation of the second rendering stage to be merged to a no operation to obtain a fourth rendering stage to be merged; and merge the third rendering stage to be merged and the fourth rendering stage to be merged into the target rendering stage.

[0120] Furthermore, the merging unit 1002 is also used to keep the first viewport size of the viewport size operation set in the first rendering stage to be merged consistent with the second viewport size of the viewport size operation set in the second rendering stage to be merged; and keep the first clipping area size of the clipping area size operation set in the first rendering stage to be merged consistent with the second clipping area size of the clipping area size operation set in the second rendering stage to be merged.

[0121] Furthermore, the merging unit 1002 is also used to merge the third rendering stage to be merged and the fourth rendering stage to be merged to obtain a rendering stage to be processed; adding a variable shading rate setting operation before the specified drawing instruction of the rendering stage to be processed, the variable shading rate setting operation is used to determine the shading rate, and the specified drawing instruction is used to render the object to be rendered corresponding to the target rendering stage through the variable ratio rendering operation based on the shading rate to obtain a rendering result.

[0122] Furthermore, a variable shading rate operation is set to determine the shading rate according to the following formula:

[0123] R w,h =(floor(clamp(W N+1 / W N ,1,4)),floor(clamp(H N+1 / H N ,1,4)));

[0124] Among them, R w,h is the shading rate, N represents the frame number of the object to be rendered corresponding to the target rendering stage, W represents the screen space width, H represents the screen space height, the clamp function is used to limit the value between 1 and 4, and the floor function is used to round down.

[0125] Furthermore, the merging unit 1002 is further configured to add a variable shading rate setting operation before a specified drawing instruction of the rendering stage to be processed if it is detected that the target rendering stage meets a specified condition.

[0126] Furthermore, the target rendering stage satisfies the specified condition including predicting that the image quality of the target image rendered in the target rendering stage is different from the image quality of the to-be-rendered object corresponding to the target rendering stage.

[0127] Furthermore, the target rendering stage satisfies the specified condition including predicting that the computation amount of the target rendering stage is greater than a preset threshold.

[0128] The execution unit 1003 is used to execute the target rendering stage through the pixel local storage function.

[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0130] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0131] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0132] Please refer to Fig.11 , which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 can be an electronic device such as a smart phone, a tablet computer, an e-book, etc. that can run applications. The electronic device 100 in the present application may include one or more of the following components: a graphics application program interface of the Android framework layer, the graphics application program interface is used to perform image rendering, the image rendering corresponds to multiple rendering stages, a processor 110, a memory 120, and one or more applications, wherein one or more applications can be stored in the memory 120 and configured to be executed by one or more processors 110, and one or more programs are configured to execute the method as described in the aforementioned method embodiment.

[0133] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0134] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0135] Please refer to Fig.12 , which shows a structural block diagram of a computer-readable medium provided in an embodiment of the present application. The computer-readable medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0136] The computer readable medium 800 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable medium 800 includes a non-transitory computer-readable storage medium. The computer readable medium 800 has storage space for program code 810 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.

[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned 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.

Claims

1. A data processing method, characterized in that: A graphical application programming interface applied to an Android framework layer, the method comprising: Obtain two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage; If the first rendering stage and the second rendering stage meet a merging condition, merging the first rendering stage and the second rendering stage into a target rendering stage; The target rendering phase is performed through a pixel local storage function.

2. The method according to claim 1, characterized in that If the first rendering stage and the second rendering stage meet the merging condition, before merging the first rendering stage and the second rendering stage into the target rendering stage, the method further includes: If the rendering objects corresponding to the first rendering stage and the second rendering stage meet preset conditions, the memory layouts corresponding to the first rendering stage and the second rendering stage are compatible, and both support the pixel local storage function, it is determined that the first rendering stage and the second rendering stage meet the merging conditions.

3. The method according to claim 2, characterized in that The first rendering stage is a stage before the second rendering stage, and rendering objects corresponding to the first rendering stage and the second rendering stage meet preset conditions, including: the first drawing instruction of the second rendering stage samples texture data output by the last drawing instruction of the first rendering stage.

4. The method according to claim 3, characterized in that The first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, including: the first drawing instruction of the second rendering stage samples the texture data output by the last drawing instruction of the first rendering stage, and the shader used by the first drawing instruction of the second rendering stage does not include the code of texture coordinate offset.

5. The method according to claim 2, characterized in that: The first rendering stage is the previous stage of the second rendering stage, and the rendering objects corresponding to the first rendering stage and the second rendering stage meet preset conditions, including: there are not multiple rendering objects in the first rendering stage, and the shader using the texture data output by the first rendering stage in the second rendering stage meets the application scenario of the pixel local storage function.

6. The method according to claim 1, characterized in that If the first rendering stage and the second rendering stage meet a merging condition, merging the first rendering stage and the second rendering stage into a target rendering stage includes: If the first rendering stage and the second rendering stage meet the merging condition, change a first shader used by a drawing instruction of the first rendering stage and a second shader used by a drawing instruction of the second rendering stage, and the changed first shader and the second shader both support a pixel local storage function; The updated first rendering stage and the updated second rendering stage are merged into a target rendering stage.

7. The method according to claim 6, characterized in that The step of merging the updated first rendering stage and the updated second rendering stage into a target rendering stage includes: Obtaining a first target resolution corresponding to the first rendering stage and a second target resolution corresponding to the second rendering stage; Based on the first target resolution and the second target resolution, the updated first rendering stage and the updated second rendering stage are merged into a target rendering stage.

8. The method according to claim 7, characterized in that The step of merging the updated first rendering stage and the updated second rendering stage into a target rendering stage based on the first target resolution and the second target resolution includes: If the first target resolution is consistent with the second target resolution, or the first target resolution is higher than the second target resolution, changing the first rendering target corresponding to the frame buffer binding operation in the first rendering stage to the second rendering target corresponding to the frame buffer binding operation in the second rendering stage, to obtain a first rendering stage to be merged; The frame buffer binding operation in the second rendering stage is changed to a no operation to obtain a second rendering stage to be merged; The first rendering stage to be merged and the second rendering stage to be merged are merged into a target rendering stage.

9. The method according to claim 7, characterized in that: The step of merging the updated first rendering stage and the updated second rendering stage into a target rendering stage based on the first target resolution and the second target resolution includes: If the first target resolution is lower than the second target resolution, changing the first rendering target corresponding to the frame buffer binding operation in the first rendering stage to the second rendering target corresponding to the frame buffer binding operation in the second rendering stage to obtain a first rendering stage to be merged; The frame buffer binding operation in the second rendering stage is changed to a no operation to obtain a second rendering stage to be merged; The region size corresponding to the region operation of the first rendering stage to be merged is set to be the same as the region size corresponding to the region operation of the second rendering stage to be merged, so as to obtain a third rendering stage to be merged; Setting the region operation of the second rendering stage to be merged to a null operation to obtain a fourth rendering stage to be merged; The third rendering stage to be merged and the fourth rendering stage to be merged are merged into a target rendering stage.

10. The method according to claim 9, characterized in that The region operation includes a viewport size setting operation and a clipping region size setting operation, and the region size corresponding to the region operation of the first rendering stage to be merged is set to be the same as the region size corresponding to the region operation of the second rendering stage to be merged, to obtain a third rendering stage to be merged, including: Keeping the first viewport size of the viewport size setting operation in the first rendering stage to be merged consistent with the second viewport size of the viewport size setting operation in the second rendering stage to be merged; The first clipping region size in the clipping region size setting operation in the first rendering stage to be merged is kept consistent with the second clipping region size in the clipping region size setting operation in the second rendering stage to be merged.

11. The method according to claim 9, characterized in that The step of merging the third rendering stage to be merged and the fourth rendering stage to be merged into a target rendering stage includes: Merging the third rendering stage to be merged and the fourth rendering stage to be merged to obtain a rendering stage to be processed; A variable shading rate setting operation is added before the specified drawing instruction of the rendering stage to be processed, the variable shading rate setting operation is used to determine the shading rate, and the specified drawing instruction is used to render the object to be rendered corresponding to the target rendering stage through the variable ratio rendering operation based on the shading rate to obtain a rendering result.

12. The method according to claim 11, characterized in that The setting variable shading rate operation is used to determine the shading rate according to the following formula: R w,h =(floor(clamp(W N+1 / W N ,1,4)),floor(clamp(H N+1 / H N ,1,4))); Among them, R w,h is the shading rate, N represents the frame number of the object to be rendered corresponding to the target rendering stage, W represents the screen space width, H represents the screen space height, the clamp function is used to limit the value between 1 and 4, and the floor function is used to round down.

13. The method according to claim 11, characterized in that The step of adding a variable shading rate setting operation before the specified drawing instruction of the rendering stage to be processed comprises: If it is detected that the target rendering stage meets the specified condition, a variable shading rate setting operation is added before the specified drawing instruction of the rendering stage to be processed.

14. The method according to claim 13, characterized in that The target rendering stage satisfies the specified condition including predicting that the image quality of the target image rendered in the target rendering stage is different from the image quality of the to-be-rendered object corresponding to the target rendering stage.

15. The method according to claim 13, characterized in that The target rendering stage satisfies the specified condition including predicting that the computation amount of the target rendering stage is greater than a preset threshold.

16. A data processing device, characterized in that: A graphical application programming interface applied to an Android framework layer, the device comprising: An acquisition unit, used for acquiring two adjacent rendering stages, which are respectively recorded as a first rendering stage and a second rendering stage; a merging unit, configured to merge the first rendering stage and the second rendering stage into a target rendering stage if the first rendering stage and the second rendering stage meet a merging condition; An execution unit is used to execute the target rendering stage through a pixel local storage function.

17. An electronic device, characterized in that: include: one or more processors; Memory; A graphics application programming interface of an Android framework layer, wherein the graphics application programming interface is used to perform image rendering, and the image rendering corresponds to a plurality of rendering stages; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-15.

18. A computer readable medium, characterized in that The computer-readable medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the method according to any one of claims 1 to 15.