WebGL application dynamic translation method and device for WebGPU

By rewriting and compiling the graphics rendering call instructions of WebGL applications, the instructions suitable for WebGPU are generated, which solves the problem that WebGL applications cannot effectively utilize WebGPU to improve graphics rendering performance, and achieves more efficient graphics rendering performance.

CN119273826BActive Publication Date: 2025-04-04PEKING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411803903.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-04
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

WebGL applications cannot effectively utilize WebGPU to improve graphics rendering performance because WebGPU applications cannot render using rendering instructions that are adapted to WebGL applications.

Method used

By obtaining the graphics rendering call instructions for the WebGL application in the target browser, overwrite it based on the type of the instruction, generating a new graphics rendering call instructions that are adapted to the WebGPU application, and compiling it for graphics rendering in the WebGPU application.

Benefits of technology

This enables WebGL applications to utilize WebGPU applications to achieve their own graphics rendering needs, thereby improving the graphics rendering performance of WebGL applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119273826B_ABST
    Figure CN119273826B_ABST
Patent Text Reader

Abstract

The present application provides a WebGL application dynamic translation method and device for WebGPU, including: obtaining a first graphics rendering call instruction of a WebGL application in a target browser, rewriting the first graphics rendering call instruction based on a first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, compiling the second graphics rendering call instruction to obtain a first graphics rendering code, performing graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic, so that the WebGL application can use the WebGPU application to realize the graphics rendering requirements of the WebGL application itself, thereby improving the graphics rendering performance of the WebGL application to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method and device for dynamic translation of WebGL applications for WebGPU. Background Art

[0002] Web graphics rendering has become an indispensable component of network applications. This technology has greatly improved the user experience in online multimedia fields, such as games, visual effects, data visualization, and virtual reality. Therefore, how to achieve high-performance and convenient graphics rendering has become a new research direction. WebGL (Web Graphics Library) was proposed in 2009 and can achieve high-performance interactive 3D and 2D graphics rendering. In WebGL, developers only need to write a small amount of code to create complex graphics applications. This ease of use has promoted the widespread application of WebGL in the past decade. However, with the continuous improvement of hardware performance, the graphics rendering of the above method has been difficult to meet the performance requirements of modern graphics applications, and the graphics rendering effect of the above method in modern graphics applications is not high.

[0003] In related technologies, WebGPU (Web Graphics Processing Unit) can be used to implement graphics rendering for modern graphics applications. WebGPU is an application programming interface that provides significantly higher performance potential than WebGL. Recent studies have shown that WebGPU is significantly better than WebGL in rendering-intensive applications. Therefore, using the WebGPU application programming interface can improve graphics rendering performance.

[0004] However, in the above method, the WebGPU application cannot use the rendering instructions adapted to the WebGL application for rendering, which results in the WebGL application being unable to utilize the WebGPU to improve its own graphics rendering performance, and the graphics rendering performance of the WebGL application is still not high. Summary of the invention

[0005] In view of the above problems, the embodiments of the present application provide a WebGL application dynamic translation method, device, electronic device and readable storage medium for WebGPU, so as to overcome the above problems or at least partially solve the above problems.

[0006] In a first aspect, an embodiment of the present application provides a method for dynamic translation of WebGL applications for WebGPU, the method comprising:

[0007] Obtain a first graphics rendering call instruction of a WebGL application in a target browser;

[0008] Based on the first rendering call type of the first graphics rendering call instruction, rewrite the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser;

[0009] Compiling the second graphics rendering call instruction to obtain a first graphics rendering code;

[0010] Based on the first graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a first graphic.

[0011] Optionally, the rewriting of the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser includes:

[0012] In a case where the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call, replacing and updating the first global rendering context of the WebGL application based on the first graphics drawing state parameters included in the first graphics rendering call instruction to obtain a second global rendering context; wherein the first global rendering context includes the historical graphics drawing state parameters of the WebGL application;

[0013] Based on the second global rendering context, a second graphics rendering call instruction adapted to the WebGPU application of the target browser is generated.

[0014] Optionally, the rewriting of the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser includes:

[0015] When the first rendering call type of the first graphics rendering call instruction includes a shader compilation call, obtaining, in a first shader of the WebGL application, a first shared variable corresponding to the first graphics rendering call instruction;

[0016] Numbering the first shared variables to obtain a first shared variable sequence;

[0017] Based on the first shared variable sequence, a second graphics rendering call instruction adapted to the WebGPU application is generated.

[0018] Optionally, compiling the second graphics rendering call instruction to obtain the first graphics rendering code includes:

[0019] In a case where the first rendering call type of the first graphics rendering call instruction includes a uniform buffer call, determining, from the first uniform buffer corresponding to the WebGL application, a second uniform buffer corresponding to the first offset included in the first graphics rendering call instruction;

[0020] Based on the first buffer parameter information included in the second unified buffer, incrementally updating the first global unified buffer of the WebGPU application to obtain a second global unified buffer; wherein the storage space of the first global unified buffer is larger than the storage space of the first unified buffer;

[0021] In a case where the storage space in the second global unified buffer contains buffer parameter information, the second graphics rendering call instruction is replaced with information based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction;

[0022] The third graphics rendering calling instruction is compiled to obtain a first graphics rendering code.

[0023] Optionally, compiling the second graphics rendering call instruction to obtain the first graphics rendering code includes:

[0024] In a case where the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, replacing information of the second graphics rendering call instruction based on vertex texture parameter information included in the first graphics rendering call instruction to obtain a fourth graphics rendering call instruction;

[0025] The fourth graphics rendering calling instruction is compiled to obtain a first graphics rendering code.

[0026] Optionally, the rewriting of the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser includes:

[0027] When there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, the first graphics rendering call instruction is rewritten based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0028] Optionally, the method further comprises:

[0029] In a case where there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, creating a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction;

[0030] The first conversion mapping is added to the first rendering package to update the first rendering package to obtain an updated first rendering package.

[0031] Optionally, the data structure of the first rendering package is a dictionary tree.

[0032] Optionally, the method further comprises:

[0033] When there is a first parameter rendering mapping matching the second graphics drawing state parameter included in the second graphics rendering call instruction in the first cache space, determining the second graphics rendering code corresponding to the second graphics rendering call instruction from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; and the data structure of the first cache space is a directed acyclic graph;

[0034] Based on the second graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a second graphics;

[0035] When there is no parameter rendering map matching the second graphics rendering state parameter in the first cache space, a second parameter rendering map is generated based on the second graphics rendering state parameter and the first graphics rendering code, and the second parameter rendering map is added to the first cache space.

[0036] In a second aspect, an embodiment of the present application provides a WebGL application dynamic translation device for WebGPU, the device comprising:

[0037] An acquisition module, used for acquiring a first graphics rendering call instruction of a WebGL application in a target browser;

[0038] A rewriting module, configured to rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser;

[0039] A compiling module, used for compiling the second graphics rendering calling instruction to obtain a first graphics rendering code;

[0040] The first rendering module is used to perform graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic.

[0041] Optionally, the rewriting module includes:

[0042] A first updating submodule is configured to replace and update the first global rendering context of the WebGL application based on the first graphics drawing state parameters included in the first graphics rendering call instruction to obtain a second global rendering context when the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call; wherein the first global rendering context includes the historical graphics drawing state parameters of the WebGL application;

[0043] The first generating submodule is used to generate a second graphics rendering calling instruction adapted to the WebGPU application of the target browser based on the second global rendering context.

[0044] Optionally, the rewriting module includes:

[0045] an acquisition submodule, configured to acquire, in a first shader of the WebGL application program, a first shared variable corresponding to the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a shader compilation call;

[0046] A numbering submodule, used for numbering the first shared variables to obtain a first shared variable sequence;

[0047] The second generating submodule is used to generate a second graphics rendering calling instruction adapted to the WebGPU application based on the first shared variable sequence.

[0048] Optionally, the compiling module includes:

[0049] A first determining submodule is used to determine, when the first rendering call type of the first graphics rendering call instruction includes a uniform buffer call, from the first uniform buffer corresponding to the WebGL application, a second uniform buffer corresponding to the first offset included in the first graphics rendering call instruction;

[0050] A second updating submodule is configured to perform incremental information update on the first global unified buffer of the WebGPU application based on the first buffer parameter information contained in the second unified buffer to obtain a second global unified buffer; wherein the storage space of the first global unified buffer is greater than the storage space of the first unified buffer;

[0051] A first replacement submodule is used for, when the storage space in the second global unified buffer contains buffer parameter information, replacing the second graphics rendering call instruction based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction;

[0052] The first compiling submodule is used to compile the third graphics rendering calling instruction to obtain a first graphics rendering code.

[0053] Optionally, the compiling module includes:

[0054] A second replacement submodule is used to replace information of the second graphics rendering call instruction based on the vertex texture parameter information included in the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, so as to obtain a fourth graphics rendering call instruction;

[0055] The second compiling submodule is used to compile the fourth graphics rendering calling instruction to obtain the first graphics rendering code.

[0056] Optionally, the rewriting module includes:

[0057] The rewriting submodule is used to rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0058] Optionally, the device further comprises:

[0059] A creation module is used to create a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application;

[0060] The first adding module is used to add the first conversion mapping to the first rendering package to update the first rendering package to obtain an updated first rendering package.

[0061] Optionally, the data structure of the first rendering package is a dictionary tree.

[0062] Optionally, the device further comprises:

[0063] A determination module, configured to determine, when there is a first parameter rendering mapping matching the second graphics drawing state parameter included in the second graphics rendering call instruction in the first cache space, the second graphics rendering code corresponding to the second graphics rendering call instruction from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; and the data structure of the first cache space is a directed acyclic graph;

[0064] A second rendering module, configured to perform graphics rendering in the WebGPU application based on the second graphics rendering code to obtain a second graphics;

[0065] The second adding module is used to generate a second parameter rendering map based on the second graphics rendering state parameters and the first graphics rendering code, and add the second parameter rendering map into the first cache space when there is no parameter rendering map matching the second graphics rendering state parameters in the first cache space.

[0066] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the WebGL application dynamic translation method for WebGPU as described in any one of the above.

[0067] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the method for dynamic translation of WebGL applications for WebGPU as described in any one of the above items is implemented.

[0068] The specific beneficial effects are:

[0069] The embodiment of the present application obtains a first graphics rendering call instruction of a WebGL application in a target browser, rewrites the first graphics rendering call instruction based on a first rendering call type of the first graphics rendering call instruction, obtains a second graphics rendering call instruction adapted to the WebGPU application of the target browser, compiles the second graphics rendering call instruction to obtain a first graphics rendering code, performs graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic, and can rewrite the first graphics rendering call instruction of the WebGL application in the target browser based on the rendering call type of the call instruction so that graphics rendering can be performed in the WebGPU application in the target browser to obtain the first graphic, so that the WebGL application can use the WebGPU application to implement the graphics rendering requirements of the WebGL application itself, thereby improving the graphics rendering performance of the WebGL application to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0071] Figure 1 It is a flowchart of a WebGL application dynamic translation method for WebGPU provided in an embodiment of the present application;

[0072] Figure 2 It is a flowchart of another method for dynamic translation of WebGL applications for WebGPU provided in an embodiment of the present application;

[0073] Figure 3 It is a flowchart of a specific implementation method of a WebGL application dynamic translation method for WebGPU provided in an embodiment of the present application;

[0074] Figure 4 It is a logic block diagram of a WebGL application dynamic translation device for WebGPU provided in an embodiment of the present application;

[0075] Figure 5 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0076] The exemplary embodiments of the present application will be described in more detail below in conjunction with the accompanying drawings in the embodiments of the present application. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to enable the scope of the present application to be fully communicated to those skilled in the art.

[0077] Reference Figure 1 , Figure 1 A flowchart of a WebGL application dynamic translation method for WebGPU provided in an embodiment of the present application, the method comprising:

[0078] Step 101: Obtain a first graphics rendering call instruction of a WebGL application in a target browser.

[0079] In an embodiment of the present application, WebGL is a 3D drawing protocol that allows complex three-dimensional graphics and animations to be displayed on a web page. The graphics rendering process can be divided into the following processing stages: application processing stage, geometry processing stage, rasterization stage, pixel processing stage and frame buffer operation stage. The above stages can be performed under a graphics rendering call instruction. In a browser, WebGL can be used as a drawing protocol for a graphics rendering application and is bound to a graphics rendering application, i.e., a WebGL application. A user can send a first graphics rendering call instruction to a WebGL application in a target browser so that a controller of an operating system where the target browser is located can obtain the first graphics rendering call instruction. The first graphics rendering call instruction and the WebGL drawing protocol are usually written in the JavaScript programming language. Due to the dynamic nature of JavaScript, a prototype chain modification technique (Prototype Patching) can be used to capture the call instruction of the WebGL application. Among them, the target browser can be any web browser.

[0080] Step 102: rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0081] In an embodiment of the present application, the first graphics rendering call instruction may include one or more first rendering call types, and different first rendering call types may correspond to different call instruction rewriting methods. This rewriting method can also be regarded as a translation method, that is, translating call instructions applicable to WebGL into call instructions applicable to WebGPU. For example, if the first graphics rendering call instruction includes vertex and texture data calls, it is only necessary to modify the data format of the vertex and texture data contained in the first graphics rendering call instruction so that the data format of the vertex and texture data in the obtained second graphics rendering call instruction can be applied in the WebGPU application.

[0082] Step 103: compile the second graphics rendering call instruction to obtain a first graphics rendering code.

[0083] In an embodiment of the present application, during the graphics rendering process, the graphics rendering call instruction needs to be compiled into a machine code recognizable by a graphics processing unit (GPU), so the second graphics rendering call instruction can be compiled to obtain the first graphics rendering code. The compilation protocol used in the compilation process can be provided by the manufacturer of the graphics processor and integrated into the driver corresponding to the graphics processor.

[0084] Step 104: Based on the first graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a first graphic.

[0085] In an embodiment of the present application, graphics rendering can be performed in a WebGPU application of a target browser according to the first graphics rendering code, so that a first graphic can be obtained and displayed in the target browser.

[0086] In an embodiment of the present application, by obtaining a first graphics rendering call instruction of a WebGL application in a target browser, rewriting the first graphics rendering call instruction based on a first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, compiling the second graphics rendering call instruction to obtain a first graphics rendering code, performing graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic, the first graphics rendering call instruction of the WebGL application in the target browser can be rewritten based on the rendering call type of the call instruction so that graphics rendering can be performed in the WebGPU application in the target browser to obtain the first graphic, which enables the WebGL application to utilize the WebGPU application to implement the graphics rendering requirements of the WebGL application itself, thereby improving the graphics rendering performance of the WebGL application to a certain extent.

[0087] Reference Figure 2 , Figure 2 A flowchart of another method for dynamic translation of WebGL applications for WebGPU provided in an embodiment of the present application may include:

[0088] Step 201: Obtain a first graphics rendering call instruction of a WebGL application in a target browser.

[0089] In the embodiments of the present application, the implementation content of this step can refer to the embodiment content of step 101, which will not be repeated here.

[0090] Step 202: rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0091] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 102, which will not be repeated here.

[0092] Optionally, step 202 may include the following sub-steps:

[0093] Sub-step 2021, when the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call, based on the first graphics drawing state parameters included in the first graphics rendering call instruction, the first global rendering context of the WebGL application is replaced and updated to obtain a second global rendering context; wherein the first global rendering context includes the historical graphics drawing state parameters of the WebGL application.

[0094] In an embodiment of the present application, the rendering call type of the graphics rendering call instruction can be divided into four types, namely, graphics drawing state call, shader compilation call, uniform buffer call and vertex texture call, and the first rendering call type of the first graphics rendering call instruction can include one or more of the above four types, wherein call is a term in programming, which refers to the use of the logical function of the sub-function in the form of a sub-function name. Among the above four types, the graphics drawing state can refer to various parameters and properties set and controlled in the rendering pipeline, which determine how to convert a three-dimensional scene into a two-dimensional image. In OpenGL or Direct3D, the rendering state is used to control the rendering behavior of the renderer, and the application can control the rendering behavior of OpenGL or Direct3D by changing the rendering state. If the first rendering call type includes a graphics drawing state call, there will be a first graphics drawing state parameter in the first graphics rendering call instruction, therefore, the first global rendering context of the WebGL application can be replaced and updated according to the first graphics drawing state parameter contained in the first graphics rendering call instruction to obtain a second global rendering context. The global rendering context may refer to a data structure used to store and record all relevant state information and resources during the graphics rendering process of a WebGL application. The first global rendering context may include historical graphics drawing state parameters of the WebGL application. The historical graphics drawing state parameters may refer to the graphics drawing state parameters obtained after the WebGL application last executed graphics rendering. Replacing and updating the first global rendering context means replacing the historical graphics drawing state parameters in the first global rendering context with the first graphics drawing state parameters in the first graphics rendering call instruction. After the replacement is completed, the second global rendering context can be obtained.

[0095] Sub-step 2022: generating, based on the second global rendering context, a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0096] In an embodiment of the present application, a second graphics rendering call instruction can be generated based on all graphics rendering related state information and resources contained in the second global rendering context, combined with the graphics rendering logic of the WebGPU application of the target browser. In this way, the second graphics rendering call instruction can call the WebGPU application to perform graphics rendering through the application programming interface corresponding to the WebGPU application. Obviously, the instruction writing logic of the second graphics rendering call instruction is different from that of the first graphics rendering call instruction.

[0097] In an embodiment of the present application, by replacing and updating the first global rendering context of the WebGL application based on the first graphics drawing state parameters contained in the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call, a second global rendering context is obtained; wherein the first global rendering context includes historical graphics drawing state parameters of the WebGL application, and based on the second global rendering context, a second graphics rendering call instruction adapted to the WebGPU application of the target browser is generated; when the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call, the first global rendering context can be updated, and the second graphics rendering call instruction can be generated by the second global rendering context obtained after the update, thereby improving the accuracy and reliability of the second graphics rendering call instruction to a certain extent.

[0098] Sub-step 2023: When the first rendering call type of the first graphics rendering call instruction includes a shader compilation call, obtaining a first shared variable corresponding to the first graphics rendering call instruction in the first shader of the WebGL application.

[0099] In an embodiment of the present application, shader compilation is the process of converting the written shader code into machine code executable by the graphics processor. If the first rendering call type includes a shader compilation call, the first graphics rendering call instruction may include a specific entry of the shader compilation call. At this time, the first shared variable corresponding to the first graphics rendering call instruction can be obtained in the first shader of the WebGL application through the specific entry of the above call. Among them, the shared variables of the shader refer to variables that can be accessed and modified jointly between multiple shader stages or computing tasks during the graphics rendering process.

[0100] Sub-step 2024: number the first shared variables to obtain a first shared variable sequence.

[0101] In an embodiment of the present application, the first shared variables may be assigned numbers, so as to obtain a first shared variable sequence consisting of the numbered first shared variables. The numbering sequence may be a natural number sequence starting from zero.

[0102] Sub-step 2025: generating a second graphics rendering call instruction adapted to the WebGPU application based on the first shared variable sequence.

[0103] In an embodiment of the present application, a second shader may be included in the WebGPU application of the target browser, and a second graphics rendering call instruction may be generated based on the first shared variable sequence and the shader compilation logic of the second shader in the WebGPU application. In this way, the second graphics rendering call instruction may be adapted to the WebGPU application, that is, the second shader may recognize the second graphics rendering call instruction and may start executing shader compilation in response to the second graphics rendering call instruction.

[0104] In an embodiment of the present application, by obtaining, in a first shader of a WebGL application, a first shared variable corresponding to the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a shader compile call, numbering the first shared variable to obtain a first shared variable sequence, and generating, based on the first shared variable sequence, a second graphics rendering call instruction adapted to the WebGPU application; when the first rendering call type of the first graphics rendering call instruction includes a shader compile call, a first shared variable sequence corresponding to the first shared variable of the WebGL application can be generated, and a second graphics rendering call instruction corresponding to the first shared variable sequence can be further generated, thereby improving the accuracy and reliability of the second graphics rendering call instruction to a certain extent.

[0105] Sub-step 2026, when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, the first graphics rendering call instruction is rewritten based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0106] In an embodiment of the present application, a rendering package is a collection of tools and software for converting a three-dimensional model or scene into a two-dimensional image in computer graphics. The rendering package may include a rendering call instruction conversion mapping, that is, a mapping between the graphics rendering instructions of a WebGL application and the graphics rendering instructions of a WebGPU application. The WebGPU application can be connected to the first rendering package, and can detect whether there is a call instruction conversion mapping that matches the first graphics rendering call instruction in the first rendering package. If there is no call instruction conversion mapping that matches the second graphics rendering call instruction in the first rendering package, the first graphics rendering call instruction can be rewritten according to the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction that is adapted to the WebGPU application of the target browser. The specific implementation content of the above rewriting can refer to the embodiment content of step 102, which will not be repeated here.

[0107] Optionally, the data structure of the first rendering package is a dictionary tree.

[0108] In an embodiment of the present application, the data structure of the first rendering package may be a dictionary tree. A dictionary tree is also called a word search tree, a Trie tree, which is a tree data structure and a variant of a hash tree. In data whose data structure is a dictionary tree, the common prefix of the string can be used to reduce the query time, minimize unnecessary string comparisons, and the query efficiency is higher than that of a hash tree. In other words, if the data structure of the first rendering package is a dictionary tree, then when detecting whether there is a call instruction conversion mapping that matches the first graphics rendering call instruction in the first rendering package, the string corresponding to the first graphics rendering call instruction can be directly searched and detected. This can reduce the time of the above detection to a certain extent, thereby improving the efficiency of graphics rendering.

[0109] In an embodiment of the present application, by rewriting the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction when there is no call instruction conversion mapping that matches the first graphics rendering call instruction in the first rendering package of the WebGPU application, and obtaining a second graphics rendering call instruction adapted to the WebGPU application of the target browser, it is possible to pre-check whether there is a call instruction conversion mapping that matches the first graphics rendering call instruction in the first rendering package of the WebGPU application. If there is no call instruction conversion mapping, the first graphics rendering call instruction can be rewritten according to the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, thereby improving the reliability of the rewriting method from the first graphics rendering call instruction to the second graphics rendering call instruction to a certain extent.

[0110] Sub-step 2027: if there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, create a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction.

[0111] In an embodiment of the present application, if there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction can be created.

[0112] Sub-step 2028: adding the first conversion mapping to the first rendering package to update the first rendering package to obtain an updated first rendering package.

[0113] In an embodiment of the present application, the first conversion mapping can be added to the first rendering package for storage, so that the first rendering package can be updated to obtain an updated first rendering package. In this way, when the same first graphics rendering call instruction appears next time, the second graphics rendering call instruction can be directly obtained in the first rendering package according to the call instruction conversion mapping, without having to rewrite the first graphics rendering call instruction.

[0114] In an embodiment of the present application, by creating a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering package of the WebGPU application, the first conversion mapping is added to the first rendering package to update the first rendering package to obtain an updated first rendering package, a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction can be generated, and the first rendering package can be incrementally updated through the first conversion mapping, which can improve the conversion efficiency of the first graphics rendering call instruction to the second graphics rendering call instruction when reused, thereby improving the graphics rendering performance.

[0115] Step 203: compile the second graphics rendering call instruction to obtain a first graphics rendering code.

[0116] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 103, which will not be repeated here.

[0117] Optionally, step 203 may include the following sub-steps:

[0118] Sub-step 2031, when the first rendering call type of the first graphics rendering call instruction includes a uniform buffer call, determining a second uniform buffer corresponding to the first offset included in the first graphics rendering call instruction from the first uniform buffer corresponding to the WebGL application.

[0119] In an embodiment of the present application, a uniform buffer is a technology used to transfer constant data in computer graphics programming. When updating data in a uniform buffer, only a sub-region of the uniform buffer can be updated without updating the entire buffer. A uniform buffer call is a call instruction for updating data in a uniform buffer. If the first rendering call type of a first graphics rendering call instruction includes a uniform buffer call, the first graphics rendering call instruction may include a first offset, which is a region identifier of a uniform buffer. A second uniform buffer corresponding to the first offset can be determined from the first uniform buffer corresponding to the WebGL application. Obviously, the second uniform buffer is a sub-region of the first uniform buffer.

[0120] Sub-step 2032: Based on the first buffer parameter information contained in the second unified buffer, incremental information is updated on the first global unified buffer of the WebGPU application to obtain a second global unified buffer; wherein the storage space of the first global unified buffer is larger than the storage space of the first unified buffer.

[0121] In an embodiment of the present application, a WebGPU application can be connected to a first global unified buffer, and incremental information can be updated on the first global unified buffer according to the first buffer parameter information contained in the second unified buffer, thereby obtaining a second global unified buffer. The global unified buffer can be used to cache the parameter information called in the first unified buffer, that is, the first buffer parameter information in the second unified buffer.

[0122] Sub-step 2033: When the storage space in the second global unified buffer contains buffer parameter information, the second graphics rendering call instruction is replaced based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction.

[0123] In an embodiment of the present application, if the storage space in the second global unified buffer contains buffer parameter information, the second global unified buffer is in a data saturation state. At this time, the second graphics rendering call instruction can be replaced with information according to the buffer parameter information in the storage space, so as to obtain a third graphics rendering call instruction. First, the parameter type of the buffer parameter information can be determined, and then, according to the parameter type, the call information with the same parameter type as the second graphics rendering call instruction can be found, and then the call information can be replaced with the buffer parameter information. In this way, the information replacement of the second graphics rendering call instruction is completed, so as to obtain the third graphics rendering call instruction.

[0124] Sub-step 2034, compile the third graphics rendering call instruction to obtain a first graphics rendering code.

[0125] In the embodiment of the present application, the third graphics rendering call instruction can be compiled to obtain the first graphics rendering code. The implementation content of the compilation process can refer to the embodiment content of step 103, which will not be repeated here.

[0126] In an embodiment of the present application, when the first rendering call type of the first graphics rendering call instruction includes a unified buffer call, the second unified buffer corresponding to the first offset included in the first graphics rendering call instruction is determined from the first unified buffer corresponding to the WebGL application, and based on the first buffer parameter information included in the second unified buffer, the first global unified buffer of the WebGPU application is incrementally updated to obtain the second global unified buffer; wherein the storage space of the first global unified buffer is larger than the storage space of the first unified buffer, and when the storage space in the second global unified buffer includes buffer parameter information, the second graphics rendering call instruction is replaced with information based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction, and the third graphics rendering call instruction is compiled to obtain the first graphics rendering code, and when the first rendering call type of the first graphics rendering call instruction includes a unified buffer call, the data of the second unified buffer can be saved in the first global unified buffer area, and when the first global unified buffer area is in an information saturated state, the first graphics rendering code with higher call information richness can be generated according to the data saved in the first global unified buffer area, which can improve the accuracy and availability of the first graphics rendering code to a certain extent.

[0127] Sub-step 2035, when the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, based on the vertex texture parameter information included in the first graphics rendering call instruction, the second graphics rendering call instruction is replaced with information to obtain a fourth graphics rendering call instruction.

[0128] In an embodiment of the present application, a graphics processor can process the vertices and textures of a mesh into pixels in a rendering target through a graphics pipeline. In the vertex processing stage, the graphics processor can calculate the position of each vertex; in the fragment processing stage, the graphics processor can calculate the color of each fragment, and the intersection of fragments of different colors can form a texture. A vertex texture call is a call type that changes vertices and fragments. If the first rendering call type of a first graphics rendering call instruction includes a vertex texture call, the second graphics rendering call instruction can be replaced with information based on the vertex texture parameter information contained in the first graphics rendering call instruction to obtain a fourth graphics rendering call instruction. For example, the call information of vertices and textures can be found from the second graphics rendering call instruction, and then the call information can be replaced with the vertex texture information contained in the first graphics rendering call instruction. In this way, the information replacement of the second graphics rendering call instruction is completed, so that the fourth graphics rendering call instruction can be obtained.

[0129] Sub-step 2036: compile the fourth graphics rendering call instruction to obtain a first graphics rendering code.

[0130] In the embodiment of the present application, the fourth graphics rendering call instruction can be compiled to obtain the first graphics rendering code. The implementation content of the compilation process can refer to the embodiment content of step 103, which will not be repeated here.

[0131] In an embodiment of the present application, by replacing information of the second graphics rendering call instruction based on the vertex texture parameter information contained in the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, and obtaining a fourth graphics rendering call instruction, the fourth graphics rendering call instruction is compiled to obtain the first graphics rendering code, so that the first graphics rendering code with richer call information can be obtained, which can improve the accuracy and usability of the first graphics rendering code to a certain extent.

[0132] Step 204: Based on the first graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a first graphic.

[0133] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 104, which will not be repeated here.

[0134] Step 205: When there is a first parameter rendering mapping in the first cache space that matches the second graphics drawing state parameter included in the second graphics rendering call instruction, determine the second graphics rendering code corresponding to the second graphics rendering call instruction from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; and the data structure of the first cache space is a directed acyclic graph.

[0135] In an embodiment of the present application, a WebGPU application may have a first cache space and be connected to the first cache space to store a parameter rendering mapping between a second graphics rendering call instruction and a graphics rendering code. It may be detected in the first cache space whether there is a first parameter rendering mapping that matches the second graphics drawing state parameter contained in the second graphics rendering call instruction, wherein the first parameter rendering mapping matches the second graphics drawing state parameter may refer to the first parameter rendering mapping containing the same parameter information as the second graphics drawing state parameter. If there is a first parameter rendering mapping that matches the second graphics drawing state parameter contained in the second graphics rendering call instruction in the first cache space, the second graphics rendering code may be determined from the first parameter rendering mapping, and it is obvious that the second graphics rendering code corresponds to the second graphics rendering call instruction. In addition, the data structure in the first cache space may be a directed acyclic graph.

[0136] Step 206: Perform graphics rendering in the WebGPU application based on the second graphics rendering code to obtain a second graphic.

[0137] In an embodiment of the present application, graphics rendering can be performed in a WebGPU application according to the second graphics rendering code, so that the second graphics can be obtained and displayed in a target browser.

[0138] Step 207: if there is no parameter rendering mapping matching the second graphics rendering state parameters in the first cache space, generate a second parameter rendering mapping based on the second graphics rendering state parameters and the first graphics rendering code, and add the second parameter rendering mapping to the first cache space.

[0139] In an embodiment of the present application, if there is no parameter rendering mapping matching the second graphics rendering state parameter in the first cache space, a second parameter rendering mapping from the second graphics rendering state parameter to the first graphics rendering code can be generated, and then the second parameter rendering mapping can be added to the first cache space for storage.

[0140] In a possible embodiment, the parameter rendering map can be a mapping between a hash value of a graphics drawing state parameter and a first graphics rendering code, so that the storage space occupied by each parameter rendering map can be reduced, so that more parameter rendering maps can be stored in the first cache space. At the same time, since the data format of the hash value is relatively simple, this method can also improve the efficiency of querying the parameter rendering map in the first cache space. When querying, the hash value of the graphics drawing state parameter to be queried can be calculated first, and the query can be performed in the first cache space according to the hash value.

[0141] In an embodiment of the present application, when there is a first parameter rendering mapping matching the graphics drawing state parameters included in the second graphics rendering call instruction in the first cache space, the second graphics rendering code corresponding to the second graphics rendering call instruction is determined from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; the data structure of the first cache space is a directed acyclic graph, and based on the second graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a second graphic, and when there is no parameter rendering mapping matching the graphics drawing state parameters in the first cache space, a second parameter rendering mapping is generated based on the graphics drawing state parameters and the first graphics rendering code, and the second parameter rendering mapping is added to the first cache space, and the cache space with a data structure as a directed acyclic graph can be used to store the first parameter rendering mapping between the graphics drawing state parameters and the graphics rendering code, and the newly appearing first parameter rendering mapping can be saved through the above-mentioned cache space, and when the second graphics rendering call instruction is reused, the second graphics rendering code corresponding to the second graphics rendering call instruction can be quickly found, thereby improving the graphics rendering performance to a certain extent.

[0142] Reference Figure 3 , Figure 3It is a flowchart of a specific implementation method of a WebGL application dynamic translation method for WebGPU provided by an embodiment of the present application. In the figure, a WebGL application can be used to capture the call instruction of WebGL, and then three operations can be performed according to the call instruction: first, a shader transformation can be performed, that is, the shader call logic in the call instruction is transformed into a shader call logic available to the WebGPU application, and then a global state simulation can be performed according to the new shader compilation instruction obtained after the transformation, wherein the global state simulation means that the processor can simulate the graphics rendering process of WebGL, but does not generate the final graphics to obtain the data of each stage in WebGL; second, the global state simulation can be performed directly according to the call instruction; third, a unified buffer batch merge can be performed, that is, the data of multiple called unified buffers are sent to a global unified buffer for batch processing. After the global state simulation is performed, the WebGPU rendering state parameters obtained by the simulation can be saved in the cache space. After the data is saved in the cache space and the batch merge of the unified buffer is completed, the mapping saved in the rendering package can be used for fast compilation. If there is no usable mapping in the rendering package, the corresponding mapping can be generated according to the data before and after the compilation after normal compilation, and the generated mapping can be saved in the rendering package. After the compilation is completed, you can perform graphics rendering in the WebGPU application, and after the rendering is completed, you can get the graphics.

[0143] Reference Figure 4 , Figure 4 A logical block diagram of a WebGL application dynamic translation device for WebGPU provided in an embodiment of the present application, the device 400 may include:

[0144] An acquisition module 401 is used to acquire a first graphics rendering call instruction of a WebGL application in a target browser;

[0145] A rewriting module 402, configured to rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser;

[0146] A compiling module 403, used for compiling the second graphics rendering calling instruction to obtain a first graphics rendering code;

[0147] The first rendering module 404 is configured to perform graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic.

[0148] Optionally, the rewriting module 402 includes:

[0149] A first updating submodule is configured to replace and update the first global rendering context of the WebGL application based on the graphics drawing state parameters included in the first graphics rendering call instruction to obtain a second global rendering context when the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call; wherein the first global rendering context includes the historical graphics drawing state parameters of the WebGL application;

[0150] The first generating submodule is used to generate a second graphics rendering calling instruction adapted to the WebGPU application of the target browser based on the second global rendering context.

[0151] Optionally, the rewriting module 402 includes:

[0152] an acquisition submodule, configured to acquire, in a first shader of the WebGL application program, a first shared variable corresponding to the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a shader compilation call;

[0153] A numbering submodule, used for numbering the first shared variables to obtain a first shared variable sequence;

[0154] The second generating submodule is used to generate a second graphics rendering calling instruction adapted to the WebGPU application based on the first shared variable sequence.

[0155] Optionally, the compiling module 403 includes:

[0156] A first determining submodule is used to determine, when the first rendering call type of the first graphics rendering call instruction includes a uniform buffer call, from the first uniform buffer corresponding to the WebGL application, a second uniform buffer corresponding to the first offset included in the first graphics rendering call instruction;

[0157] A second updating submodule is configured to perform incremental information update on the first global unified buffer of the WebGPU application based on the first buffer parameter information contained in the second unified buffer to obtain a second global unified buffer; wherein the storage space of the first global unified buffer is greater than the storage space of the first unified buffer;

[0158] A first replacement submodule is used for, when the storage space in the second global unified buffer contains buffer parameter information, replacing the second graphics rendering call instruction based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction;

[0159] The first compiling submodule is used to compile the third graphics rendering calling instruction to obtain a first graphics rendering code.

[0160] Optionally, the compiling module 403 includes:

[0161] A second replacement submodule is used to replace information of the second graphics rendering call instruction based on the vertex texture parameter information included in the first graphics rendering call instruction when the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, so as to obtain a fourth graphics rendering call instruction;

[0162] The second compiling submodule is used to compile the fourth graphics rendering calling instruction to obtain the first graphics rendering code.

[0163] Optionally, the rewriting module 402 includes:

[0164] The rewriting submodule is used to rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

[0165] Optionally, the device 400 further includes:

[0166] A creation module is used to create a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application;

[0167] The first adding module is used to add the first conversion mapping to the first rendering package to update the first rendering package to obtain an updated first rendering package.

[0168] Optionally, the data structure of the first rendering package is a dictionary tree.

[0169] Optionally, the device 400 further includes:

[0170] A determination module, configured to determine, when there is a first parameter rendering mapping matching the graphics drawing state parameters included in the second graphics rendering call instruction in the first cache space, the second graphics rendering code corresponding to the second graphics rendering call instruction from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; and the data structure of the first cache space is a directed acyclic graph;

[0171] A second rendering module, configured to perform graphics rendering in the WebGPU application based on the second graphics rendering code to obtain a second graphics;

[0172] The second adding module is used to generate a second parameter rendering map based on the graphics drawing state parameters and the first graphics rendering code when there is no parameter rendering map matching the graphics drawing state parameters in the first cache space, and add the second parameter rendering map into the first cache space.

[0173] The WebGL application dynamic translation device for WebGPU in the embodiment of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. Exemplarily, the electronic device can be a GPUBOX, a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0174] The WebGL application dynamic translation device for WebGPU in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, a Linux operating system, a Windows operating system, etc., or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0175] The WebGL application dynamic translation device for WebGPU provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.

[0176] The present application embodiment provides an electronic device, see Figure 5The electronic device 50 includes: a processor 501, a memory 502, and a computer program 5021 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the program, the WebGL application dynamic translation method for WebGPU of the aforementioned embodiment is implemented.

[0177] The embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps in the method for dynamic translation of WebGL applications for WebGPU disclosed in the embodiment of the present application are implemented.

[0178] The embodiment of the present application also provides a computer program product. When the computer program product is run on an electronic device, the processor is enabled to implement the steps in the method for dynamic translation of WebGL applications for WebGPU as disclosed in the embodiment of the present application.

[0179] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0180] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0183] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0184] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0185] The above is a detailed introduction to a WebGL application dynamic translation method for WebGPU provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A WebGL application dynamic translation method for WebGPU, characterized in that: The method comprises: Obtain a first graphics rendering call instruction of a WebGL application in a target browser; In a case where there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, rewriting the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, wherein the first graphics rendering call instruction includes one or more first rendering call types, and different first rendering call types correspond to different call instruction rewriting methods; Compiling the second graphics rendering call instruction to obtain a first graphics rendering code; Based on the first graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a first graphic.

2. The method according to claim 1, characterized in that The first rendering call type based on the first graphics rendering call instruction, rewriting the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, includes: In a case where the first rendering call type of the first graphics rendering call instruction includes a graphics drawing state call, replacing and updating the first global rendering context of the WebGL application based on the first graphics drawing state parameters included in the first graphics rendering call instruction to obtain a second global rendering context; wherein the first global rendering context includes the historical graphics drawing state parameters of the WebGL application; Based on the second global rendering context, a second graphics rendering call instruction adapted to the WebGPU application of the target browser is generated.

3. The method according to claim 1, characterized in that The first rendering call type based on the first graphics rendering call instruction, rewriting the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, includes: When the first rendering call type of the first graphics rendering call instruction includes a shader compilation call, obtaining, in a first shader of the WebGL application, a first shared variable corresponding to the first graphics rendering call instruction; Numbering the first shared variables to obtain a first shared variable sequence; Based on the first shared variable sequence, a second graphics rendering call instruction adapted to the WebGPU application is generated.

4. The method according to claim 1, characterized in that The compiling the second graphics rendering call instruction to obtain the first graphics rendering code includes: In a case where the first rendering call type of the first graphics rendering call instruction includes a uniform buffer call, determining, from the first uniform buffer corresponding to the WebGL application, a second uniform buffer corresponding to the first offset included in the first graphics rendering call instruction; Based on the first buffer parameter information included in the second unified buffer, incrementally updating the first global unified buffer of the WebGPU application to obtain a second global unified buffer; wherein the storage space of the first global unified buffer is larger than the storage space of the first unified buffer; In a case where the storage space in the second global unified buffer contains buffer parameter information, the second graphics rendering call instruction is replaced with information based on the buffer parameter information in the storage space to obtain a third graphics rendering call instruction; The third graphics rendering calling instruction is compiled to obtain a first graphics rendering code.

5. The method according to claim 1, characterized in that The compiling the second graphics rendering call instruction to obtain the first graphics rendering code includes: In a case where the first rendering call type of the first graphics rendering call instruction includes a vertex texture call, replacing information on the second graphics rendering call instruction based on vertex texture parameter information included in the first graphics rendering call instruction to obtain a fourth graphics rendering call instruction; The fourth graphics rendering calling instruction is compiled to obtain a first graphics rendering code.

6. The method according to claim 1, characterized in that The first rendering call type based on the first graphics rendering call instruction, rewriting the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, includes: When there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, the first graphics rendering call instruction is rewritten based on the first rendering call type of the first graphics rendering call instruction to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser.

7. The method according to claim 6, characterized in that The method further comprises: In a case where there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application, creating a first conversion mapping between the first graphics rendering call instruction and the second graphics rendering call instruction; The first conversion mapping is added to the first rendering package to update the first rendering package to obtain an updated first rendering package.

8. The method according to claim 6, characterized in that The data structure of the first rendering package is a dictionary tree.

9. The method according to claim 1, characterized in that: The method further comprises: When there is a first parameter rendering mapping matching the second graphics drawing state parameter included in the second graphics rendering call instruction in the first cache space, determining the second graphics rendering code corresponding to the second graphics rendering call instruction from the first parameter rendering mapping; wherein the first cache space is connected to the WebGPU application; and the data structure of the first cache space is a directed acyclic graph; Based on the second graphics rendering code, graphics rendering is performed in the WebGPU application to obtain a second graphics; When there is no parameter rendering map matching the second graphics rendering state parameter in the first cache space, a second parameter rendering map is generated based on the second graphics rendering state parameter and the first graphics rendering code, and the second parameter rendering map is added to the first cache space.

10. A WebGL application dynamic translation device for WebGPU, characterized in that: The device comprises: An acquisition module, used for acquiring a first graphics rendering call instruction of a WebGL application in a target browser; A rewriting module is used to rewrite the first graphics rendering call instruction based on the first rendering call type of the first graphics rendering call instruction when there is no call instruction conversion mapping matching the first graphics rendering call instruction in the first rendering packet of the WebGPU application to obtain a second graphics rendering call instruction adapted to the WebGPU application of the target browser, wherein the first graphics rendering call instruction includes one or more first rendering call types, and different first rendering call types correspond to different call instruction rewriting methods; A compiling module, used for compiling the second graphics rendering calling instruction to obtain a first graphics rendering code; The first rendering module is used to perform graphics rendering in the WebGPU application based on the first graphics rendering code to obtain a first graphic.

Citation Information

Patent Citations

  • Image rendering method and device, computer equipment and storage medium

    CN112381918A

  • Graph rendering method and device, electronic equipment and storage medium

    CN113515396A