Data processing method and device, storage medium and electronic equipment
By creating parallel compilation and execution threads in lightweight game applications, the stuttering problem caused by rendering time was solved, improving rendering efficiency and game smoothness.
Patent Information
- Application Number
- CN202410994131.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2026-01-23
AI Technical Summary
Lightweight game applications often experience interface lag due to long rendering times.
By creating compilation threads and runtime threads to process in parallel, in response to the launch of the target applet, the compilation thread is responsible for shader compilation, while the runtime thread obtains the compilation status and generates rendering instructions, using the graphics processor to render the program interface.
It improves the rendering efficiency of the program interface, reduces the load on running threads, enhances the game's startup speed and smoothness, and improves the user experience.
Smart Images

Figure CN121387291A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, in particular to a data processing method and device, a storage medium and an electronic device. BACKGROUND
[0002] Currently, in the related art, a game application program is usually loaded by a thread, and a lightweight game application program (for example, a small game) needs to implement user interaction logic, business execution logic, shader code compilation, rendering drawing and the like in a single thread. Since the shader code compilation takes a long time, if the interface rendering of the small game needs to rely on the compilation result generated by the shader code compilation, the rendering time of the small game interface will be further lengthened by performing the shader code compilation and then outputting the rendering instruction through a single thread, which causes the interface of the small game to appear to be stuck. That is, in the related art, there is a technical problem that the lightweight game application program appears to be stuck due to the long rendering time of the interface of the lightweight application program.
[0003] At present, no effective solution has been proposed for the above problems. SUMMARY
[0004] The embodiments of the present application provide a data processing method and device, a storage medium and an electronic device to at least solve the technical problem that the lightweight game application program appears to be stuck due to the long rendering time.
[0005] According to an aspect of an embodiment of the present application, a data processing method is provided, including: in response to a target mini-program being started, creating a compilation thread, wherein the running environment of the target mini-program is set to run through a single thread, and the thread running the target mini-program is a running thread; in response to receiving a target compilation request, controlling the running thread to forward the target compilation request to the compilation thread, wherein the target compilation request is used to access a pre-created shader object to perform a shader compilation work, the compilation thread is set to start processing the target compilation request when the target compilation request is received, and the running thread is set to work in parallel with the compilation thread; in response to the running thread starting to generate a rendering instruction, controlling the running thread to obtain a first compilation state message associated with the target compilation request from the compilation thread; in a case where the first compilation state message indicates that the compilation thread has generated a first compilation result, controlling the running thread to obtain the first compilation result and generate a target rendering instruction based on the first compilation result, wherein the target rendering instruction is used to be sent to a graphics processor to control the graphics processor to render a program interface of the target mini-program.
[0006] According to a further aspect of the embodiments of the present application, a data processing apparatus is also provided, comprising: a creating module configured to, in response to a target programlet being started, create a compiling thread, wherein a running environment of the target programlet is set to run by a single thread, and a thread running the target programlet is a running thread; a control module configured to, in response to receiving a target compiling request, control the running thread to forward the target compiling request to the compiling thread, wherein the target compiling request is used to access a pre-created shader object to perform a shader compiling work, the compiling thread is set to start processing the target compiling request when the target compiling request is received, and the running thread is set to work in parallel with the compiling thread; an obtaining module configured to, in response to the running thread starting to generate a rendering instruction, control the running thread to obtain a first compiling state message associated with the target compiling request from the compiling thread; and a generating module configured to, in a case where the first compiling state message indicates that the compiling thread has generated a first compiling result, control the running thread to obtain the first compiling result and generate a target rendering instruction based on the first compiling result, wherein the target rendering instruction is used to be sent to a graphics processor to control the graphics processor to render a program interface of the target programlet.
[0007] Optionally, the apparatus is further configured to, in a case where the first compiling state message indicates that the compiling thread has not generated the first compiling result, after the running thread starts to generate a rendering instruction and controls the running thread to obtain a first compiling state message associated with the target compiling request from the compiling thread, control the running thread to wait for a preset time length; in response to the running time length waiting for the preset time length, control the running thread to obtain a second compiling state message from the compiling thread; and in a case where the second compiling state message indicates that the compiling thread has generated the first compiling result, control the running thread to obtain the first compiling result and generate a target rendering instruction based on the first compiling result.
[0008] Optionally, the apparatus is configured to, in response to receiving a target compiling request, control the running thread to forward the target compiling request to the compiling thread by: in response to receiving a rendering request queue, determining whether the target compiling request is included in the rendering request queue, wherein the rendering request queue includes the target compiling request indicating that the rendering request queue needs to perform a shader compiling; and in response to the rendering request queue including the target compiling request, controlling the running thread to forward the target compiling request to the compiling thread.
[0009] Optionally, the apparatus is configured to control the running thread to acquire the first compilation status message associated with the target compilation request from the compilation thread in response to the running thread starting to generate the rendering instruction by: determining whether a first task being executed by the running thread needs to use the first compilation result in response to the running thread starting to generate the rendering instruction; and controlling the running thread to acquire the first compilation status message from the compilation thread in a case where the first task indicates that the first compilation result needs to be used.
[0010] Optionally, the apparatus is further configured to control the running thread to execute the first task in a case where the first task indicates that the first compilation result does not need to be used.
[0011] Optionally, the apparatus is configured to control the running thread to acquire the first compilation result and generate a target rendering instruction based on the first compilation result in a case where the first compilation status message indicates that the compilation thread has generated the first compilation result by: controlling the running thread to acquire the first compilation result and execute the first task based on the first compilation result in a case where the first task indicates that the first compilation result needs to be used and the first compilation status message indicates that the compilation thread has generated the first compilation result, until the running thread completes all tasks in the rendering request queue, controlling the running thread to generate the target rendering instruction.
[0012] Optionally, the apparatus is further configured to: control the running thread to skip the first task, acquire a second task to be executed by the running thread, and determine whether the second task needs to use the first compilation result in a case where the first compilation status message indicates that the compilation thread has not generated the first compilation result and the first task indicates that the first compilation result needs to be used, wherein the second task represents a task that is located after the first task in an execution order; control the running thread to execute the second task until the running thread completes all tasks in the rendering request queue, controlling the running thread to generate the target rendering instruction in a case where the second task indicates that the first compilation result does not need to be used; control the running thread to acquire a third compilation status message from the compilation thread in a case where the second task indicates that the first compilation result needs to be used; and control the running thread to acquire the first compilation result and execute the second task based on the first compilation result until the running thread completes all tasks in the rendering request queue, controlling the running thread to generate the target rendering instruction in a case where the third compilation status message indicates that the compilation thread has generated the first compilation result.
[0013] Optionally, the apparatus is further configured to: in a case where the first compilation state message indicates that the compilation thread has not generated the first compilation result and the first task indicates that the first compilation result is required, control the running thread to skip the first task, acquire a third task to be executed by the running thread, and determine whether the third task requires a second compilation result, wherein the third task represents a task that is in an execution order after the first task, and the second compilation result corresponds to a shader object that is different from a shader object corresponding to the first compilation result; in a case where the third task indicates that the second compilation result is required, control the running thread to acquire a fourth compilation state message from the compilation thread; in a case where the fourth compilation state message indicates that the compilation thread has generated the second compilation result, control the running thread to acquire the second compilation result and execute the third task based on the second compilation result, until the running thread completes all tasks in the rendering request queue, and control the running thread to generate the target rendering instruction.
[0014] Optionally, the apparatus is configured to create a compilation thread in response to a target miniprogram being started by: in response to the target miniprogram being started, pre-acquiring a set of shader objects, and in response to acquiring the set of shader objects, creating the compilation thread, wherein the set of shader objects includes at least one shader object to be compiled; and in response to receiving a target compilation request, controlling the running thread to forward the target compilation request to the compilation thread, including: in response to receiving the set of shader objects, forwarding each shader object in the set of shader objects to the compilation thread, and controlling the compilation thread to pre-compile the each shader object, wherein the first compilation state message includes a pre-compilation state of a target shader object corresponding to the target compilation request.
[0015] Optionally, the apparatus is configured to pre-acquire a set of shader objects in response to the target miniprogram being started, and in response to acquiring the set of shader objects, create the compilation thread by: in response to the target miniprogram being started, pre-acquiring the set of shader objects; in response to acquiring the set of shader objects, determining a number of shader objects in the set of shader objects; and creating the compilation thread according to the number of shader objects, wherein each compilation thread allows access to one or more shader objects, and one or more shader objects corresponding to the one or more shader objects are compiled into code that is executable by a graphics processing unit.
[0016] Optionally, the apparatus is configured to create the compiling threads in response to the target applet being launched by: obtaining a number of cores of a central processing unit in response to the target applet being launched; and creating the compiling threads according to the number of cores, wherein each of the compiling threads is allowed to access one or more of the shader objects and to compile code corresponding to the one or more of the shader objects into code executable by a graphics processing unit.
[0017] Optionally, the apparatus is further configured to: create M compiling threads according to a number of cores of a central processing unit of a target device in response to a target applet being launched, wherein the target device represents a device on which the target applet is loaded, the number of cores of the central processing unit is M, and M is a positive integer; forward the target compiling request to the M compiling threads by the running thread in response to receiving the target compiling request, wherein the target compiling request is related to an Nth program interface of the target applet, and N is a positive integer; obtain the first compiling state message associated with the target compiling request from a target compiling thread of the M compiling threads by the running thread in response to the running thread starting to generate a rendering instruction corresponding to the Nth program interface, wherein the first compiling state message comprises whether the target compiling request is compiled by the target compiling thread; and obtain the first compiling result and generate the target rendering instruction corresponding to the Nth program interface based on the first compiling result by the running thread in a case where the first compiling state message indicates that the target compiling thread has generated the first compiling result at an i-th frame, wherein i is a non-negative integer, and i is less than N.
[0018] According to another aspect of the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is configured to perform the data processing method when executed.
[0019] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, and the computer program product or the computer program comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the data processing method.
[0020] According to another aspect of the embodiments of the present application, an electronic device is provided, and the electronic device comprises a memory and a processor. The memory stores a computer program, and the processor is configured to perform the data processing method by using the computer program.
[0021] In the embodiment of the present application, a compilation thread is created in response to the target program being started, wherein the running environment of the target program is set to run through single thread, and the thread running the target program is a running thread; in response to receiving a target compilation request, the running thread is controlled to forward the target compilation request to the compilation thread, wherein the target compilation request is used to access a pre-created shader object to perform shader compilation work, the compilation thread is set to start processing the target compilation request when the target compilation request is received, and the running thread is set to work in parallel with the compilation thread; in response to the running thread starting to generate rendering instructions, the running thread is controlled to obtain a first compilation state message associated with the target compilation request from the compilation thread; in the case where the first compilation state message indicates that the compilation thread has generated a first compilation result, the running thread is controlled to obtain the first compilation result and generate target rendering instructions based on the first compilation result, wherein the target rendering instructions are used to be sent to a graphics processor to control the graphics processor to render a program interface of the target program. That is, by creating the above-mentioned compilation thread, the target compilation request is forwarded to the compilation thread by the above-mentioned running thread in the case where the target compilation request is received, so as to realize parallel processing of the compilation thread and the running thread, so that the running thread does not need to process the target compilation request, thereby reducing the load of the running thread, saving the processing time of the running thread and the computing resources, and obtaining the first compilation result by using the compilation thread, so as to render the program interface of the target program based on the first compilation thread, thereby achieving the technical effect of improving the rendering efficiency of the program interface. Further, the technical problem of causing the lightweight game application program to appear to be stuck due to long rendering time is solved.
[0022] On the other hand, in the embodiment of the present application, the above-mentioned compilation thread can be created at the beginning of the start of the target program, so that the target compilation request can be processed at the first time of receiving the target compilation request, for example, the shader code required for rendering the program interface of the target program is compiled in advance to obtain the first compilation result. For example, the target program is a single-thread running game, and in the running process of the subsequent game, the corresponding first compilation result can be directly obtained to render the program interface, thereby accelerating the start speed of the game, making the running process of the game more smooth, and improving the user experience. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and serve to explain the present application. In the drawings:
[0024] Figure 1 is a schematic diagram of an application environment of an optional data processing method according to an embodiment of the present application;
[0025] Figure 2 is a flowchart of an optional data processing method according to an embodiment of the application;
[0026] Figure 3 is a flowchart of an optional data processing method according to an embodiment of the application;
[0027] Figure 4 is a flowchart of an optional data processing method according to an embodiment of the application;
[0028] Figure 5 is a flowchart of an optional data processing method according to an embodiment of the application;
[0029] Figure 6 is a flowchart of an optional data processing method according to an embodiment of the application;
[0030] Figure 7 is a flowchart of an optional data processing method according to an embodiment of the application;
[0031] Figure 8 is a flowchart of an optional data processing method according to an embodiment of the application;
[0032] Figure 9 is a flowchart of an optional data processing method according to an embodiment of the application;
[0033] Figure 10 is a flowchart of an optional data processing method according to an embodiment of the application;
[0034] Figure 11 is a flowchart of an optional data processing method according to an embodiment of the application;
[0035] Figure 12 is a flowchart of an optional data processing method according to an embodiment of the application;
[0036] Figure 13 is a flowchart of an optional data processing method according to an embodiment of the application;
[0037] Figure 14 is a structural diagram of an optional data processing apparatus according to an embodiment of the application;
[0038] Figure 15 is a structural diagram of an optional data processing product according to an embodiment of the application;
[0039] Figure 16 is a structural diagram of an optional electronic device according to an embodiment of the application. DETAILED DESCRIPTION
[0040] In order to make the persons skilled in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the persons skilled in the art without any creative work should belong to the protection scope of the present application.
[0041] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the materials thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0042] The present application will be described in the following with reference to the embodiments:
[0043] According to an aspect of the embodiments of the present application, a data processing method is provided. Optionally, in the present embodiment, the above-mentioned data processing method can be applied to the hardware environment composed of the server 101 and the terminal device 103 as shown in Figure 1 . As shown in Figure 1As shown, the server 101 is connected with the terminal device 103 through a network, which can be used to provide services for the terminal device or the application program installed on the terminal device, and the application program 107 can be a video application program, a real-time communication application program, a browser application program, an education application program, a game application program, etc. The database 105 can be set on the server or independently of the server, which is used to provide data storage services for the server 101, for example, a game data storage server. The above network can include but is not limited to a wired network and a wireless network, wherein the wired network includes a local area network, a metropolitan area network and a wide area network, and the wireless network includes Bluetooth, WIFI and other wireless communication networks. The terminal device 103 can be a terminal configured with an application program, and can include but is not limited to at least one of the following: a mobile phone (such as an Android mobile phone, an iOS mobile phone, etc.), a notebook computer, a tablet computer, a palm computer, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart television, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, a VR (Virtual Reality) terminal, an AR (Augmented Reality) terminal, an MR (MixedReality) terminal, etc. The above server can be a single server, a server cluster composed of multiple servers, or a cloud server.
[0044] In combination Figure 1 As shown, the above data processing method can be executed by an electronic device, which can be a terminal device or a server. The above data processing method can be realized by the terminal device or the server respectively, or realized by the terminal device and the server jointly.
[0045] The above is only an example, and the present embodiment is not limited specifically.
[0046] Optionally, as an optional implementation manner, as shown in Figure 2 As shown, the above data processing method includes:
[0047] S202, in response to the target applet being started, a compiling thread is created, wherein the running environment of the target applet is set to run through a single thread, and the thread running the target applet is a running thread;
[0048] Exemplarily, the embodiments of the present application can be applied to various scenes such as games, cloud technology, artificial intelligence, intelligent transportation, and auxiliary driving.
[0049] Optionally, in the embodiments of the present application, the above target applet can include but is not limited to a lightweight application program, a web application program, a mobile application program, a desktop application program, an enterprise application program, etc.
[0050] In an exemplary embodiment, the target mini-program is used as an example of a lightweight application. The target mini-program does not require users to download and install it. It can be accessed and operated directly on a web website. The target mini-program can run in a WebGL and Wasm environment and perform related business functions through only one thread, that is, through the aforementioned running thread. For example, a single-threaded mini-game.
[0051] It's important to note that WebGL refers to a JavaScript API (Java Programming Language Interface) used to render interactive 2D and 3D graphics in any compatible web browser without the need for plugins. Plugins, on the other hand, refer to browser extensions or plugins used to add extra functionality to a browser. Compared to WebGL, plugins typically require manual installation and activation and may require specific browser support. Wasm is an abbreviation for WebAssembly, a portable, small, fast-loading code format that is compatible with existing web technologies.
[0052] Optionally, in the embodiments of this application, the aforementioned running thread refers to the thread responsible for handling the running logic and rendering in the target applet.
[0053] For example, taking a web game as the target mini-program, the running thread can be understood as the game thread. This game thread is responsible for updating the state of the game world, processing player input, calculating the position of the running virtual character and collision detection, and rendering the game screen, so as to maintain the smooth operation of the game and enable players to enjoy a good gaming experience.
[0054] Optionally, in the embodiments of this application, the aforementioned compilation thread refers to the thread in the compiler responsible for converting source code into executable code, which may include, but is not limited to, compiling shader code into code that a computer can execute, so that the target applet can accurately render the virtual screen in the program, etc.
[0055] In an exemplary embodiment, when the target mini-program is launched, the aforementioned compilation thread can be automatically created on the client side of the target mini-program to ensure that the single-threaded running mode can be automatically switched to a mode combining compilation threads and running threads to execute the corresponding tasks of the target mini-program, including but not limited to processing business logic, interaction, and rendering.
[0056] Exemplarily, the number of the above-mentioned compiling threads can also include, but is not limited to, being related to the CPU and GPU performance of the terminal device where the target applet is deployed, or being related to the time-consuming length of the shader code compilation. For example, the CPU of terminal device A is limited to creating a maximum of 10 compiling threads and a minimum of 1 compiling thread. Further, the specific number of compiling threads can be determined based on the complexity and time consumption of the current shader code to be compiled, or the number of compiling threads is set to the minimum or maximum value by default, that is, one compiling thread. In the subsequent running process of the target applet, the number of compiling threads is increased or decreased according to the business complexity and the difficulty of shader compilation, the compiling threads are created flexibly, the number of compiling threads is controlled flexibly, and unnecessary waste of computing resources and other phenomena are avoided.
[0057] It should be noted that the above-mentioned running threads and compiling threads can be executed on different CPU cores, avoiding competition and contention for resources between the running threads and the compiling threads.
[0058] S204, in response to receiving the target compilation request, the control running thread forwards the target compilation request to the compiling thread, wherein the target compilation request is used to access the pre-created shader object to perform the shader compilation work, and the compiling thread is set to start processing the target compilation request when receiving the target compilation request, and the running thread is set to work in parallel with the compiling thread;
[0059] Exemplarily, after starting the above-mentioned target applet and successfully creating the above-mentioned compiling threads, the running thread and the compiling thread are communicated to make the running thread and the compiling thread process in parallel, and the target compilation request is processed by the compiling thread.
[0060] Optionally, in the embodiment of the present application, the above-mentioned target compilation request can include, but is not limited to, the name and identification of the specified shader object to be accessed. The above-mentioned shader object refers to an object used to control the shading and rendering process in the graphics rendering pipeline, that is, the code compiled by the CPU and run by the GPU can be used to process vertex transformation and pixel shading of the graphics rendering pipeline, wherein the CPU refers to the central processing unit, which is the core component of the computer and is responsible for processing most of the computing tasks, and the GPU refers to the graphics processing unit, which can be used to process graphics and image computing processors with high parallel processing capability. For example, the CPU is responsible for compiling the code to convert the code into executable code for the GPU, and the GPU is responsible for running the code to perform actual computing tasks.
[0061] Optionally, in the embodiments of the present application, the shader compiling work can be understood as a process of converting the shader object into executable code that can run on the graphics processor. The shader code needs to be processed by a compiler and converted into underlying executable code before it can be executed by the GPU. The number of compiling threads can include but is not limited to several, and the present application does not limit the number of compiling threads.
[0062] For example, the shader compiling work can include but is not limited to lexical analysis, syntax analysis, semantic analysis, and code generation. During the compiling process, the compiling thread can check the syntax error, type error, and other issues of the shader code, and generate the final executable code.
[0063] In an exemplary embodiment, taking the target applet as a game for example, the shader object can be used to control the light, material, special effect, and other properties in the game scene. The shader object is used to realize the game visual effect, including but not limited to color filling, light calculation, special effect rendering, and the like.
[0064] In another exemplary embodiment, Figure 3 is a schematic diagram of another optional data processing method according to the embodiments of the present application, as Figure 3 shown, taking the target applet as a lightweight game for example, the running thread is a game thread, and the target applet has only one game thread. At this time, the shader code compiling work can be performed by increasing the compiling thread according to the embodiments of the present application. Specifically, when the game thread receives a request for shader code compiling, the game thread forwards the request to the compiling thread for processing.
[0065] In another exemplary embodiment, according to the target compiling request, the running thread can select any one or more threads from the several compiling threads to perform the shader compiling work, including but not limited to selecting the appropriate compiling thread to perform the shader compiling work according to the load condition, priority setting, current idle condition, and time-consuming length of the shader code compiling of the compiling thread, so as to effectively improve the efficiency and performance of the shader code compiling.
[0066] In another example embodiment, based on different shader compilation tasks, corresponding compilation threads can be flexibly selected for compilation, for example, because the priority of shader compilation task A is higher than the priority of shader compilation task B, more compilation threads can be allocated to shader compilation task A to speed up its compilation, and fewer compilation threads can be allocated to shader compilation task B, wherein the priorities of different shader compilation tasks can be flexibly set by humans, for example, the earlier the generation time of a shader compilation task, the higher the priority, the higher the complexity of a shader compilation task, the higher the priority, and the present application does not limit this.
[0067] S206, in response to the running thread starting to generate rendering instructions, the running thread obtains the first compilation state message associated with the target compilation request from the compilation thread;
[0068] Illustratively, if the running thread generates the rendering instructions described above, it indicates that the target applet needs to perform rendering work on the corresponding program interface, at which time the running thread can initiate a request to the compilation thread to obtain the corresponding first compilation state message.
[0069] Optionally, in the present embodiment, the first compilation state message can include but is not limited to numbers, characters, special symbols, etc., and the first compilation state message can also include but is not limited to being sent in the form of text, images, videos, etc.
[0070] It should be noted that the first compilation state message is associated with the target compilation request, for example, the target compilation request instructs the compilation thread to compile the shader object A, and the first compilation state message indicates the compilation state of the shader object A, including but not limited to using status code O to indicate that the shader object A is successfully compiled; using status code E to indicate that the shader object A is failed to compile; using status code W to indicate that the shader object A is being compiled, etc.
[0071] Illustratively, the running thread can include but is not limited to obtaining the first compilation state message through the interface provided by the compilation thread, specifically, taking a game as the target applet for example, assuming that the running thread is a game thread, in the case that the game thread forwards the target compilation request to the compilation thread and the compilation thread completes the shader code compilation task (the shader compilation task), the game thread can obtain the first compilation state message in real time.
[0072] In one example embodiment, taking a game as the target applet for example, assuming that the running thread is a game thread, Figure 4is a schematic diagram of another optional data processing method according to an embodiment of the present application. Before using the data processing method proposed in the present application, the game thread can include, but is not limited to, user interaction, business logic, shader code compilation and rendering drawing work in each frame, such as Figure 4 as shown in
[0073] S1, when running the game thread in the Nth frame, user interaction, business logic, shader code compilation, rendering drawing operation need to be processed in turn, and the actual time consumption exceeds the expected time consumption;
[0074] S2, when running the game thread in the N+1th frame, user interaction, business logic, rendering drawing operation need to be processed in turn, and the actual time consumption does not exceed the expected time consumption;
[0075] S3, when running the game thread in the N+2th frame, user interaction, business logic, shader code compilation, rendering drawing operation need to be processed in turn, and the actual time consumption exceeds the expected time consumption;
[0076] S4, when running the game thread in the N+3th frame, user interaction, business logic, rendering drawing operation need to be processed in turn, and the actual time consumption does not exceed the expected time consumption.
[0077] Exemplarily, in the process of running the game thread, each game frame can include a corresponding rendering production task. If the rendering drawing task needs the result of shader code compilation, the game thread will perform the shader code compilation operation in the corresponding game frame. For example, the Nth frame and the N+2th frame as shown in the figure, the actual time consumption required by the Nth frame and the N+2th frame will exceed the expected time consumption. If the rendering drawing task does not need the result of shader code compilation, the game thread will perform the shader code compilation operation in the corresponding game frame. Specifically:
[0078] as shown in the N+1th frame and the N+3th frame, Figure 4 Further, in the related art, in addition to the need to perform user interaction, business logic, rendering drawing operation in the Nth frame and the N+2th frame, the game thread also needs to perform the shader code compilation task, which causes the game frame processing time to be too long, resulting in too high load of the game thread. After using the data processing method proposed in the present application, Figure 5 is a schematic diagram of another optional data processing method according to an embodiment of the present application. As shown in the figure, by creating a compilation thread, the game thread can forward the shader code compilation task to the compilation thread, and the shader code compilation is performed by the compilation thread which is independent of the game thread, so that the frame time consumption of the game running meets the expected value, and the purpose of reducing the load of the game thread is achieved, thereby making the frame rate more stable and providing better game experience for the user, as shown in Figure 5
[0079] S1-1, when running the game thread at the Nth frame, user interaction and business logic need to be processed in turn, when the game thread confirms that shader code compilation needs to be performed, the shader code compilation task is forwarded to the compilation thread, and then subsequent rendering and drawing operations are performed, and the actual time consumption does not exceed the expected time consumption;
[0080] S1-2, when running the compilation thread at the Nth frame, since the forwarded shader compilation is received from the game thread, the shader code compilation is performed at the Nth frame, and the compilation result is sent to the game thread after the compilation is completed;
[0081] S2, when running the game thread at the N+1th frame, user interaction, business logic and rendering and drawing operations need to be processed in turn, and the actual time consumption does not exceed the expected time consumption;
[0082] S3-1, when running the game thread at the N+2th frame, user interaction and business logic need to be processed in turn, when the game thread confirms that shader code compilation needs to be performed, the shader code compilation task is forwarded to the compilation thread, and then subsequent rendering and drawing operations are performed, and the actual time consumption does not exceed the expected time consumption;
[0083] S3-2, when running the compilation thread at the N+2th frame, since the forwarded shader compilation is received from the game thread, the shader code compilation is performed at the N+2th frame, and the compilation result is sent to the game thread after the compilation is completed;
[0084] S4, when running the game thread at the N+3th frame, user interaction, business logic and rendering and drawing operations need to be processed in turn, and the actual time consumption does not exceed the expected time consumption.
[0085] Through the embodiments of the present application, based on the above S1-1 to S4, when the game frame needs to perform shader code compilation, the game thread can be used to perform subsequent rendering and drawing tasks, and the compilation thread can be used to compile the shader code in parallel, so that the processing time of the game frame does not exceed the expected time consumption, and then the corresponding compilation result is obtained for subsequent rendering and drawing tasks, and the efficiency of the shader code compilation is further improved.
[0086] In an exemplary embodiment, Figure 6 is a schematic diagram of another optional data processing method according to an embodiment of the present application, as Figure 6As shown, the game running in a single thread with the target applet as an example, the running thread is a game thread, and the compiling thread can provide two interfaces for the game thread, the first interface is used to query whether the shader code compilation is completed, and the second interface is used to wait for the completion of the shader code (the shader object) compilation. The interface for querying whether the shader is completed returns a value immediately, that is, if the shader code compilation task is completed, the first interface directly returns a corresponding state value to inform the game thread of the result of the shader code compilation. The interface for waiting for the completion of the shader code compilation is synchronous, that is, the program needs to be blocked to wait for the completion of the shader code compilation before executing the subsequent code. By setting the first interface and the second interface, a more flexible calling mode is provided for the game thread.
[0087] In an exemplary embodiment, the game thread can communicate with the compiling thread based on the first interface and the second interface to achieve the purpose of asynchronously executing the shader code compilation task, so that the game thread can more conveniently manage the compilation process of the shader, and the game performance and running stability are improved.
[0088] S208, in the case where the first compiling state message indicates that the compiling thread has generated the first compiling result, the running thread acquires the first compiling result, and generates a target rendering instruction based on the first compiling result, wherein the target rendering instruction is used to be sent to a graphics processing unit to control the graphics processing unit to render a program interface of the target applet.
[0089] For example, if it is determined through the first compiling state message that the first compiling result has been generated, the running thread can request the compiling thread to acquire the first compiling result, and then generate a target rendering instruction to execute the rendering task of the corresponding program interface.
[0090] Optionally, in the embodiment of the present application, the first compiling result can be understood as the compiling result of the shader object, for example, the code that can be directly recognized and executed by the GPU. The target rendering instruction can include but is not limited to numbers, characters, special symbols, etc., and can be used to indicate the generation of the program interface. The program interface can be understood as the display screen of the target applet. Taking the game as an example, the program interface can be used to display the virtual picture scene in the game.
[0091] For example, Figure 7 is a schematic diagram of another optional data processing method according to an embodiment of the present application, as Figure 7As shown, when the running thread performs a rendering task, this task requires a compiled shader object. The running thread can query the shader's compilation status in real time through interface one. If the shader object has not yet been compiled, the running thread can choose whether to wait based on the business logic. Specifically:
[0092] S702, begin;
[0093] S704, the running thread performs rendering and drawing tasks;
[0094] S706, determine whether the rendering task requires the result of compiling the shader code (the first compilation result mentioned above). If so, execute S708; otherwise, execute S718.
[0095] S708, the running thread can communicate with the compilation thread through interface one to request the compilation status of the shader code;
[0096] S710: The compilation thread determines whether the shader code compilation is complete. If it is complete, S712 is executed; otherwise, S714 is executed.
[0097] S712, the compilation thread sends the result of the shader code compilation to the running thread through interface one. The running thread obtains the shader code compilation result and uses the shader code compilation result to execute the rendering and drawing task.
[0098] S714 determines whether the game service needs to wait for the shader code to be compiled. If so, execute S716; otherwise, execute S718.
[0099] S716, the running thread waits for the shader code to finish compiling;
[0100] S718, End.
[0101] In another exemplary embodiment, suppose the running thread needs to load a new shader object to render the game scene. First, the running thread determines that it needs to call the compilation thread's interface to query whether the shader code compilation is complete. If the shader code compilation status value returned by interface one indicates that the shader has not yet been compiled, the running thread can continue to execute other tasks without waiting. After a certain period of time, these tasks may include, but are not limited to:
[0102] Figure 8 This is a schematic diagram of another optional data processing method according to an embodiment of this application, such as... Figure 8 As shown, interface one automatically returns the current shader code compilation status value (the first compilation status message mentioned above), informing the running thread that the shader code has been compiled successfully; or, Figure 9is a schematic diagram of another optional data processing method according to an embodiment of the present application, as shown in the figure, the running thread can be set to periodically call interface one, in the case that the running thread calls the interface one after the shader code is compiled, the interface one returns the current shader code compilation state value, and informs the running thread that the shader code compilation is successful.
[0103] Exemplarily, Figure 10 is a schematic diagram of another optional data processing method according to an embodiment of the present application, as Figure 10 shown, if the running thread needs to use the compiled shader to render the scene at the current time point, the running thread can also call the interface two to wait for the completion of the shader code compilation, after calling the interface two, the running thread will be blocked until the compilation thread compiles the shader code and returns the result, so that the running thread ensures that the shader code is compiled before using the shader.
[0104] Through the embodiments of the present application, the communication and cooperation between the running thread and the compilation thread can be realized by using the interface one and the interface two, the time for the running thread to wait for the completion of the shader code compilation is reduced, and the smoothness and performance of the game are improved.
[0105] It should be noted that the running thread and the compilation thread can also include but are not limited to the inter-thread communication through the shared memory, the message queue and the like.
[0106] Exemplarily, Figure 11 is a schematic diagram of another optional data processing method according to an embodiment of the present application, as Figure 11 shown, the communication between the running thread and the compilation thread through the shared memory can include but is not limited to: the running thread writes the shader code to be compiled into a specific position A in the shared memory; then, the compilation thread regularly checks the specific position A, if new shader code is found, the compilation thread directly acquires the shader code to perform the compilation operation; finally, the compilation thread writes the compiled shader code into a specific position B in the shared memory to indicate the completion of the compilation; the running thread regularly checks the compilation completion flag in the shared memory, if the shader code compilation is found to be completed, the running thread directly acquires the shader code compilation result from the specific position B, and loads the shader code compilation result into the GPU to perform the rendering.
[0107] Exemplarily, Figure 12 is a schematic diagram of another optional data processing method according to an embodiment of the present application, as Figure 12As shown, the communication between the running thread and the compiling thread through the message queue can include but is not limited to: the running thread can put the shader code (the above-mentioned shader object) that needs to be compiled into the message queue, and the compiling thread can take out the shader code that needs to be compiled from the message queue for compilation processing. After the shader code is compiled, the compiling thread returns the compilation result to the running thread, and the running thread applies the shader to the game scene, thereby accelerating the speed of shader code compilation and improving the rendering efficiency of the game.
[0108] In an exemplary embodiment, the data processing method proposed in the present application can be applied to the game field, Figure 13 is a schematic diagram of another optional data processing method according to an embodiment of the present application. Taking the above-mentioned target applet as a small game as an example, the shader code pre-compilation can also be performed in the small game startup phase. The shader code pre-compilation is currently not needed to participate in rendering and drawing, that is, when the running thread performs the rendering and drawing task in the subsequent running thread, if the rendering and drawing task needs to be compiled, the shader code compilation result obtained by the above-mentioned shader pre-compilation is directly obtained. In other words, when the running thread needs the pre-compiled shader code to participate in the rendering and drawing, the compiling thread has already compiled the shader code. Therefore, the running thread will not appear to be stuck because of the shader code compilation task, thereby achieving the technical effects of improving the startup speed and running performance of the game, and further improving the game experience, such as Figure 13 As shown, the communication between the running thread and the compiling thread through the message queue can include but is not limited to: the running thread can put the shader code (the above-mentioned shader object) that needs to be compiled into the message queue, and the compiling thread can take out the shader code that needs to be compiled from the message queue for compilation processing. After the shader code is compiled, the compiling thread returns the compilation result to the running thread, and the running thread applies the shader to the game scene, thereby accelerating the speed of shader code compilation and improving the rendering efficiency of the game.
[0109] S1302, the player starts a lightweight small game;
[0110] S1304, the game client automatically creates and runs the above-mentioned running thread and the above-mentioned compiling thread;
[0111] S1306, the compiling thread executes the pre-compiled shader code, and the running thread normally runs;
[0112] S1308, it is judged whether the current operation service of the running thread needs the shader code compilation result A. If yes, S1310 is executed, otherwise, S1318 is executed;
[0113] S1310, the running thread initiates a request to the compiling thread, requesting to obtain the shader code compilation result A in the pre-compiled shader code compilation result;
[0114] S1312, the compiling thread judges whether the pre-compiled shader code compilation result includes the shader code compilation result A. If yes, S1314 is executed, otherwise, S1316 is executed;
[0115] S1314, the running thread obtains the shader code compilation result A from the pre-compiled shader code compilation result;
[0116] S1316, the running thread calls interface one or interface two to execute the shader code compilation task;
[0117] S1318, end.
[0118] Exemplarily, the shader code required for the rendering production task in the target applet can be pre-acquired, and then a corresponding compilation thread can be created at the beginning of starting the target applet to directly perform the corresponding shader code compilation. Specifically, part or all of the shader code required for the rendering production task can be pre-acquired, which is not limited in the present application.
[0119] In yet another exemplary embodiment, the data processing method proposed in the present application can also be applied to the smart home field. Specifically, assuming that the smart home control terminal application is a single-threaded application, the present embodiment can automatically create a compilation thread when starting the smart home control terminal application, and compile the shader code corresponding to the program interface of the smart home control terminal application based on the compilation thread, thereby improving the smoothness of the smart home control terminal application during running. Specifically, it can include but is not limited to:
[0120] S1, the user starts the smart home control terminal application;
[0121] S2, the client of the smart home control terminal application automatically creates and runs the above running thread and the above compilation thread;
[0122] S3, the compilation thread executes the pre-compiled shader code, and the running thread normally runs;
[0123] S4, it is judged whether the current running service of the running thread needs the shader code compilation result A, if yes, S5 is executed, otherwise, S9 is executed;
[0124] S5, the running thread initiates a request to the compilation thread, requesting to obtain the shader code compilation result A in the pre-compiled shader code compilation result;
[0125] S6, the compilation thread judges whether the shader code compilation result A exists in the pre-compiled shader code compilation result, if yes, S7 is executed, otherwise, S8 is executed;
[0126] S7, the running thread obtains the shader code compilation result A from the pre-compiled shader code compilation result;
[0127] S8, the running thread calls interface one or interface two to execute the shader code compilation task;
[0128] S9, end.
[0129] By the embodiments of the present application, a compilation thread is created in response to the target program being started, wherein the running environment of the target program is set to run through single thread, and the thread running the target program is a running thread; in response to receiving a target compilation request, the running thread is controlled to forward the target compilation request to the compilation thread, wherein the target compilation request is used to access a pre-created shader object to perform shader compilation work, the compilation thread is set to start processing the target compilation request when the target compilation request is received, and the running thread is set to work in parallel with the compilation thread; in response to the running thread starting to generate rendering instructions, the running thread is controlled to obtain a first compilation state message associated with the target compilation request from the compilation thread; in the case that the first compilation state message indicates that the compilation thread has generated a first compilation result, the running thread is controlled to obtain the first compilation result and generate target rendering instructions based on the first compilation result, wherein the target rendering instructions are used to be sent to a graphics processor to control the graphics processor to render a program interface of the target program. That is, by creating the above-mentioned compilation thread, the target compilation request is forwarded to the compilation thread by the above-mentioned running thread in the case of receiving the target compilation request, so as to realize parallel processing of the compilation thread and the running thread, so that the running thread does not need to process the target compilation request, thereby reducing the load of the running thread, saving the processing time of the running thread and the computing resources, and obtaining the first compilation result by using the compilation thread, so as to render the program interface of the target program based on the first compilation thread, thereby achieving the technical effect of improving the rendering efficiency of the program interface. Further, the technical problem of causing the lightweight game application program to appear to be stuck due to long rendering time is solved.
[0130] On the other hand, in the embodiments of the present application, the above-mentioned compilation thread can be created at the beginning of the start of the target program, so that the target compilation request can be processed at the first time of receiving the target compilation request, for example, the shader code required for rendering the program interface of the target program is compiled in advance, and in the subsequent running process of the target program, the corresponding first compilation result can be directly obtained, for example, the target program is a single-threaded running game, and in the subsequent running process of the game, the corresponding first compilation result can be directly obtained to render the program interface, thereby accelerating the start speed of the game, making the running process of the game more smooth, and improving the user experience.
[0131] As an optional solution, after the running thread starts to generate the rendering instruction in response to the above, the method further comprises: in the case that the first compilation state message indicates that the compilation thread has not generated the first compilation result, controlling the running thread to wait for a preset time length; in response to the running time length waiting for the preset time length, controlling the running thread to obtain a second compilation state message from the compilation thread; in the case that the second compilation state message indicates that the compilation thread has generated the first compilation result, controlling the running thread to obtain the first compilation result and generate a target rendering instruction based on the first compilation result.
[0132] For example, after obtaining the first compilation state message, the running thread needs to wait for a preset time length if the compilation thread has not generated the first compilation result, and after waiting for the preset time length, a second compilation state message is obtained, that is, the running thread can periodically obtain the processing state of the target compilation request, and if the second compilation state message shows that the compilation thread has generated the first compilation result, the first compilation result can be directly obtained to generate the target rendering instruction.
[0133] Optionally, in the embodiment of the present application, the preset time length can be flexibly set, and the present application does not limit the same. The second compilation state message and the first compilation state message can include but are not limited to the same content, and the second compilation state message can also be used to determine the compilation progress of the shader object.
[0134] It should be noted that the second compilation state message can also include the number of times of obtaining the compilation progress of the shader object, the current compilation progress of the shader object, and the gap from the last compilation progress of the shader object, so as to realize the purpose of obtaining the compilation progress of the shader object in real time and facilitate timely adjustment of the compilation thread.
[0135] In an exemplary embodiment, the first compilation state message is obtained at a first time, and the first compilation state message is "the compilation progress of the shader object is 20%, and it is estimated that it will take 100 ms to complete the compilation". After the preset time length, the second compilation state message is obtained at a second time, and the second compilation state message is "so far, the number of times of the compilation progress of the shader object is 10, the compilation progress of the shader object is 80%, the gap from the last compilation progress of the shader object is 20, and it is estimated that it will take 20 ms to complete the compilation".
[0136] Through the embodiments of the present application, the running thread can periodically acquire the processing state of the target compilation request, and if the second compilation state message indicates that the compilation thread has generated the first compilation result, the first compilation result can be directly acquired to generate the target rendering instruction, thereby ensuring the smooth progress of the compilation and rendering processes.
[0137] As an optional solution, the response to receiving the target compilation request, the control of the running thread forwarding the target compilation request to the compilation thread includes: in response to receiving the rendering request queue, determining whether the target compilation request is included in the rendering request queue, wherein the rendering request queue includes the target compilation request indicating that the rendering request queue needs to perform the shader compilation; in response to the rendering request queue including the target compilation request, the running thread is controlled to forward the target compilation request to the compilation thread.
[0138] For example, when the running thread receives the target compilation request, it can be forwarded to the compilation thread. Specifically, the target compilation request can be forwarded to the compilation thread if it is included in the rendering request queue, as in the embodiments of the present application.
[0139] Optionally, in the embodiments of the present application, the rendering request queue refers to a queue for storing rendering requests that need to be executed in the target mini-program. The rendering request can include but is not limited to the target compilation request, which is used to request the compilation thread to perform the shader compilation, that is, to compile the shader code into code that can be directly executed by the GPU.
[0140] In an exemplary embodiment, if the rendering request queue indicates that the program interface of the target mini-program needs to be rendered using the shader, and the shader needs to be compiled before it can be used, the target compilation request corresponding to the shader will be added to the rendering request queue. When the compilation thread receives the target rendering request, the shader compilation will be performed to ensure that the shader can be correctly used during rendering.
[0141] As an optional solution, the response to the running thread starting to generate the rendering instruction, the control of the running thread acquiring the first compilation state message associated with the target compilation request from the compilation thread includes: in response to the running thread starting to generate the rendering instruction, determining whether the first task being executed by the running thread needs to use the first compilation result; in the case where the first task indicates that the first compilation result needs to be used, the running thread is controlled to acquire the first compilation state message from the compilation thread.
[0142] Exemplarily, when the running thread starts to generate the rendering instruction and requests the first compilation state message, the running thread can generate the rendering instruction and check whether the first task needs the first compilation result, and if so, obtain the first compilation state message from the compiling thread.
[0143] Optionally, in the embodiments of the present application, the first task can include, but is not limited to, a rendering production task, indicating that the program interface of the target applet needs to be rendered.
[0144] In an exemplary embodiment, if the first task indicates that the program interface of the target applet needs to be rendered using the first compilation result, the compiling thread can deliver the first compilation state message to the running thread, and after the running thread receives the first compilation state message, the running thread can continue to execute the task and generate the rendering instruction, so that the running thread can use the first compilation result when executing the task.
[0145] According to the embodiments of the present application, when the running thread starts to generate the rendering instruction, it is determined whether the first task being executed by the running thread needs to use the first compilation result, and in the case where the first task indicates that the first compilation result needs to be used, the running thread is controlled to obtain the first compilation state message from the compiling thread, so as to ensure the smooth execution of the rendering instruction and successfully load the program interface.
[0146] As an optional solution, the method further includes: in the case where the first task indicates that the first compilation result does not need to be used, the running thread is controlled to execute the first task.
[0147] In yet another exemplary embodiment, if the first task indicates that the program interface of the target applet does not need to be rendered using the first compilation result, the running thread does not need to request the compiling thread to perform the shader compilation, but directly executes the first task by the running thread, thereby avoiding unnecessary communication between the running thread and the compiling thread and further saving computing resources.
[0148] As an optional solution, in the case that the first compilation state message indicates that the compilation thread has generated the first compilation result, the control of the running thread to obtain the first compilation result and generate the target rendering instruction based on the first compilation result includes: in the case that the first task indicates that the first compilation result is needed and the first compilation state message indicates that the compilation thread has generated the first compilation result, the control of the running thread to obtain the first compilation result and execute the first task based on the first compilation result until the running thread completes all the tasks in the rendering request queue, and the control of the running thread to generate the target rendering instruction; the method further includes: in the case that the first compilation state message indicates that the compilation thread has not generated the first compilation result and the first task indicates that the first compilation result is needed, the control of the running thread to skip the first task, obtain a second task to be executed by the running thread, and determine whether the second task indicates that the first compilation result is needed, where the second task represents a task that is executed after the first task; in the case that the second task indicates that the first compilation result is not needed, the control of the running thread to execute the second task until the running thread completes all the tasks in the rendering request queue, and the control of the running thread to generate the target rendering instruction; in the case that the second task indicates that the first compilation result is needed, the control of the running thread to obtain a third compilation state message from the compilation thread; in the case that the third compilation state message indicates that the compilation thread has generated the first compilation result, the control of the running thread to obtain the first compilation result and execute the second task based on the first compilation result until the running thread completes all the tasks in the rendering request queue, and the control of the running thread to generate the target rendering instruction.
[0149] For example, in the case that the first compilation state message indicates that the first compilation result has been generated, the running thread can be controlled to obtain the first compilation result, execute the first task, and generate the target rendering instruction, or the running thread can be controlled to skip the first task, obtain a second task, execute the second task, and generate the target rendering instruction, or the running thread can be controlled to obtain a third compilation state message, execute the second task, and generate the target rendering instruction.
[0150] Optionally, in the embodiments of the present application, the second task can include, but is not limited to, user interaction logic, business execution logic, shader code compilation, rendering drawing, etc., and the third compilation state message can include, but is not limited to, the same content as the first compilation state message and the second compilation state message, and the third compilation state message can also be used to determine the compilation progress of the shader object.
[0151] In one exemplary embodiment, assuming that the first task is a rendering task requiring the first compilation result, and the first compilation result is a shader code compilation result, if the compilation thread does not generate the shader code compilation result, the running thread will skip the rendering task, obtain a second task to be executed after the rendering task, and if the second task is a texture loading task, the shader code compilation result is not required, and thus the running thread can directly execute the texture loading task until all the tasks in the rendering request queue are completed, and the target rendering instruction is generated.
[0152] In another exemplary embodiment, assuming that the first task and the second task are both rendering tasks requiring the first compilation result, and the first compilation result is a shader code compilation result, if the second task requires the first compilation result, the running thread will obtain a third compilation state message from the compilation thread, for example, if the third compilation state message indicates that the compilation thread has generated the first compilation result, the running thread will obtain the first compilation result and execute the second task based on the first compilation result until all the tasks in the rendering request queue are completed, and finally, the running thread generates the target rendering instruction.
[0153] Through the embodiments of the present application, the first compilation result is determined based on the first compilation state message, the second compilation state message and the third compilation state message, and it is determined whether the first task requires the first compilation result, if not, the first task is directly executed, if yes, while the compilation thread generates the first compilation result, the running thread directly determines whether the second task after the first task requires the first compilation result, if not, the second task is directly executed, if yes, the third compilation state message is waited for, and after the third compilation state message indicates that the first compilation result is generated, the corresponding first task and second task are executed, which ensures the orderly execution of the tasks, effectively avoids unnecessary thread waiting, and achieves the technical effect of improving the execution efficiency of the tasks.
[0154] As an optional solution, the method further comprises: in the case that the first compilation status message indicates that the compilation thread does not generate the first compilation result, and the first task indicates that the first compilation result is required, controlling the running thread to skip the first task, obtaining a third task to be executed by the running thread, and determining whether the third task requires a second compilation result, wherein the third task represents a task that is executed after the first task in the execution sequence, and the second compilation result corresponds to a shader object that is different from the shader object corresponding to the first compilation result; in the case that the third task indicates that the second compilation result is required, controlling the running thread to obtain a fourth compilation status message from the compilation thread; in the case that the fourth compilation status message indicates that the compilation thread has generated the second compilation result, controlling the running thread to obtain the second compilation result, and executing the third task based on the second compilation result, until the running thread completes all the tasks in the rendering request queue, and controlling the running thread to generate the target rendering instruction.
[0155] For example, before the running thread generates the target rendering instruction, when the compilation thread does not generate the first compilation result, and the first task requires the first compilation result, the running thread skips the first task and executes a third task. If the third task requires a second compilation result, the running thread obtains a fourth compilation status message to confirm that the second compilation result has been generated. Then the running thread executes the third task until all the tasks in the rendering request queue are completed, and generates the target rendering instruction.
[0156] Optionally, in the embodiments of the present application, the third task can include, but is not limited to, user interaction logic, business execution logic, shader code compilation, rendering drawing, etc., the fourth compilation status message, the first compilation status message, the second compilation status message, and the third compilation status message can include, but are not limited to, the same content. The fourth compilation status message can also be used to determine the compilation progress of the shader object. The second compilation result can include, but is not limited to, a shader code compilation result. The second compilation result and the first compilation result can correspond to different shader objects, that is, the shader codes corresponding to the two are different.
[0157] For example, the first compilation result can be a result of compiling a shader code for a lighting effect, and the second compilation result can be a result of compiling a shader code for a color filling effect.
[0158] In an example embodiment, assuming that the first task is a rendering production task requiring the first compilation result, the third task is a rendering production task requiring the second compilation result, the first compilation result is a shader A code compilation result, and the second compilation result is another shader B code compilation result, when the compilation thread does not generate the first compilation result, the running thread skips the task requiring the first compilation result and acquires the third task. If the third task requires the second compilation result, the running thread acquires a fourth compilation state message from the compilation thread to ensure that the second compilation result has been generated, then the running thread acquires the second compilation result and executes the third task until all tasks in the rendering request queue are completed to generate the target rendering instruction.
[0159] According to the embodiments of the present application, in the case that the first compilation state message indicates that the compilation thread does not generate the first compilation result and the first task indicates that the first compilation result is required, the running thread is controlled to skip the first task, acquire a third task to be executed by the running thread, and determine whether the third task requires the second compilation result. In the case that the third task indicates that the second compilation result is required, the running thread is controlled to acquire a fourth compilation state message from the compilation thread. In the case that the fourth compilation state message indicates that the compilation thread has generated the second compilation result, the running thread is controlled to acquire the second compilation result and execute the third task based on the second compilation result until the running thread completes all tasks in the rendering request queue, and the running thread is controlled to generate the target rendering instruction. Thus, the correctness of executing the tasks and the accuracy of the corresponding execution results are ensured, and the stability and reliability of the target mini-program are improved.
[0160] As an optional solution, the creating the compilation thread in response to the target mini-program being started includes: in response to the target mini-program being started, pre-acquiring a set of shader objects to be compiled, and in response to acquiring the set of shader objects, creating the compilation thread, wherein the set of shader objects includes at least one shader object to be compiled; and the forwarding the target compilation request to the compilation thread by the running thread in response to receiving the target compilation request includes: in response to receiving the set of shader objects, forwarding each shader object in the set of shader objects to the compilation thread, and controlling the compilation thread to pre-compile the each shader object, wherein the first compilation state message includes a pre-compilation state of a target shader object corresponding to the target compilation request.
[0161] Exemplarily, after starting the target applet and in the case that the client of the target applet creates the compiling thread, the shader object set can be acquired in advance, and then the compiling thread is created. When the running thread receives the target compiling request, the target compiling request is forwarded to the compiling thread, the shader object is precompiled, and after the compilation is completed, the compiling state message of the shader object is returned to the running thread by the compiling thread.
[0162] Optionally, in the embodiment of the present application, the shader object set refers to a plurality of shader codes for processing vertex and pixel data in a graphics rendering pipeline, and the target shader object indicates the shader object that the compiling thread needs to compile according to the target compiling request.
[0163] It should be noted that the precompilation refers to that the shader object is compiled by the compiling thread in advance to obtain the corresponding compilation result when the running thread has not determined whether the shader object needs to be compiled.
[0164] In an exemplary embodiment, assuming that the shader object set is composed of a vertex shader object, a fragment shader object and a geometry shader object, the three shader objects can be passed to the compiling thread, and the compiling thread precompiles each shader object.
[0165] Specifically, after the compiling thread receives the shader object, the vertex shader, the fragment shader and the geometry shader can be precompiled respectively, and each shader object has a corresponding compiling state message to indicate the compiling state of the shader object.
[0166] For example, if the vertex shader is precompiled successfully, a compiling state message is generated to indicate that the vertex shader has been precompiled successfully. Similarly, the fragment shader and the geometry shader also have corresponding compiling state messages. By precompiling the shader object by the compiling thread, the compiling state information of each shader object can be obtained in time, so that the precompiled compilation result of the shader object can be directly used in the subsequent rendering task, the interface loading and running time of the target applet is saved, and better user experience is provided.
[0167] As an optional solution, the above creating the compiling threads in response to the target applet being started comprises: in response to the target applet being started, pre-acquiring the set of shader objects; in response to acquiring the set of shader objects, determining a number of shader objects in the set of shader objects; and creating the compiling threads according to the number of shader objects, wherein each of the compiling threads is allowed to access one or more of the shader objects and to compile code corresponding to the one or more of the shader objects into code executable by the graphics processor.
[0168] For example, when the compiling threads are created, the shader objects in the pre-acquired set of shader objects can be compiled to obtain the code executable by the graphics processor, so that the graphics processor can directly execute the corresponding code.
[0169] Optionally, in the embodiments of the present application, the number of shader objects is not limited, and the code executable by the graphics processor can include but is not limited to binary machine code and the like.
[0170] In an exemplary embodiment, assuming that the target applet is a game, a set of shader objects including a vertex shader and a fragment shader is pre-acquired when the game is started, and then, after the set of shader objects is acquired, it is determined that there are two shader objects in the set, so that two compiling threads can be created according to the number of shader objects, or other number of compiling threads, each of which is responsible for compiling the code of a shader object, and then the compiling threads compile the code of the vertex shader and the fragment shader into code executable by the graphics processor.
[0171] As an optional solution, the above creating the compiling threads in response to the target applet being started comprises: in response to the target applet being started, pre-acquiring the set of shader objects; in response to acquiring the set of shader objects, determining a number of shader objects in the set of shader objects; and creating the compiling threads according to the number of shader objects, wherein each of the compiling threads is allowed to access one or more of the shader objects and to compile code corresponding to the one or more of the shader objects into code executable by the graphics processor.
[0172] For example, when the compiling threads are created, the shader objects in the pre-acquired set of shader objects can be compiled to obtain the code executable by the graphics processor, so that the graphics processor can directly execute the corresponding code.
[0173] In an exemplary embodiment, if the central processor has 4 cores, 4 compiling threads can be created, each of which can access one or more shader objects and compile the code corresponding to the one or more shader objects into code executable by the graphics processor.
[0174] Through the embodiments of the present application, the number of compiled threads is designed and compiled based on the number of shader objects, the number of cores of the central processor, and the like, so as to determine the most appropriate number of compiled threads, avoid unnecessary waste of computing resources, and enable the developer of the target applet to effectively compile the code of multiple shader objects in parallel, thereby improving the compilation efficiency.
[0175] As an optional solution, the above method further includes: in response to the target applet being started, creating M compiled threads according to the number of cores of the central processor of the target device, wherein the target device represents a device loading the target applet, the number of cores of the central processor is M, and M is a positive integer; in response to receiving the target compilation request, controlling the running thread to forward the target compilation request to the M compiled threads, wherein the target compilation request is related to the Nth program interface of the target applet, and N is a positive integer; in response to the running thread starting to generate the rendering instruction corresponding to the Nth program interface, controlling the running thread to obtain the first compilation state message associated with the target compilation request from a target compiled thread in the M compiled threads, wherein the first compilation state message includes whether the target compilation request is compiled by the target compiled thread; in the case that the first compilation state message indicates that the target compiled thread has generated the first compilation result at the N-i th frame, controlling the running thread to obtain the first compilation result and generate the target rendering instruction corresponding to the Nth program interface based on the first compilation result, wherein i is a non-negative integer, and i is less than N.
[0176] Exemplarily, when the target applet is started, M compiled threads can be created according to the number of CPU cores of the target device, if the running thread receives the target compilation request, the target compilation request is forwarded to the M compiled threads, and the target compilation request is related to the Nth program interface, when the running thread starts to generate the rendering instruction of the Nth program interface, the first compilation state message is obtained from the M compiled threads, if the first compilation state message shows that the target compiled thread has generated the first compilation result at the N-i th frame, the first compilation result is obtained, and the rendering instruction corresponding to the Nth program interface is generated.
[0177] Specifically, the target compilation request can be understood as needing the first compilation result to render the Nth program interface, that is, the shader code corresponding to the Nth program interface needs to be compiled into GPU executable code, and then the GPU executable code is used to render the Nth program interface.
[0178] It should be noted that the shader objects required by the program interfaces of different frames can be the same or different, and the application does not limit this, and if the shader objects required by the program interfaces of the two frames in sequence are the same, the second compilation of the shader code by the compilation thread can not be requested in the latter frame, but the already compiled compilation result corresponding to the shader code of the previous frame is directly used, avoiding unnecessary load consumption of the compilation thread.
[0179] In an exemplary embodiment, assuming that the target device has 4 CPU cores, 4 compilation threads can be created when the target applet is started, and when a compilation request arrives, the running thread will distribute the request to one of the 4 compilation threads. Assuming that the rendering instructions for the 10th frame program interface need to be generated, the running thread will obtain the first compilation state message from the 4 compilation threads, and if it is found that one of the compilation threads has generated the first compilation result for the 9th frame, the result will be directly obtained and used to generate the rendering instructions for the 10th frame program interface. By using multi-thread parallel processing of compilation requests, the compilation speed and efficiency are improved.
[0180] Exemplarily, the data processing method proposed in the application can also be applied to the process of shader compilation (shader code compilation). Specifically, a compilation thread can be added on the client side for multi-thread parallel compilation of shaders, and the compilation thread and the running thread of the application program can both access the shader object through the sharing mechanism of the underlying graphics interface. When the application program needs to compile the shader, the compilation thread starts to perform the shader code compilation task, and the running thread of the application program can continue to process the business logic, interaction and rendering at this time, avoiding the application program running, application interface display adapter and delay caused by long time consumption of shader code compilation.
[0181] Further, since the shader code compilation and the game running are asynchronous, the execution of other game operations in the game running will not be blocked due to long time consumption of the shader code compilation. For the game, the interaction, business logic and graphics rendering of the game will continue to be processed normally.
[0182] Through the embodiments of the application, the technical problem of game freezing caused by shader code compilation during game running is solved, the game experience is further improved, the compilation thread is newly added, the advantages of multi-core CPU processors are utilized, the load of the game thread is reduced, and the overall performance of the game is improved. For example, lightweight games made by Unity and other engines can use shader code for pre-compilation, and the shader multi-thread is pre-compiled in parallel to speed up the game startup speed and make the subsequent game running process smoother.
[0183] It can be understood that in the specific embodiments of the present application, data related to user information and the like are involved, and when the above embodiments of the present application are applied to specific products or technologies, the permission or consent of the user needs to be obtained, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of countries and regions.
[0184] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a combination of a series of actions, but those skilled in the art should know that the present application is not limited to the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0185] According to another aspect of the embodiments of the present application, a data processing apparatus for implementing the data processing method described above is also provided. As shown in the Figure 14 The apparatus comprises:
[0186] The creating module 1402 is configured to, in response to the target mini-program being started, create a compiling thread, wherein the running environment of the target mini-program is set to be run by a single thread, and the thread running the target mini-program is a running thread.
[0187] The control module 1404 is configured to, in response to receiving a target compiling request, control the running thread to forward the target compiling request to the compiling thread, wherein the target compiling request is used to access a pre-created shader object to perform a shader compiling work, the compiling thread is set to start processing the target compiling request when the target compiling request is received, and the running thread is set to work in parallel with the compiling thread.
[0188] The obtaining module 1406 is configured to, in response to the running thread starting to generate a rendering instruction, control the running thread to obtain a first compiling state message associated with the target compiling request from the compiling thread.
[0189] The generating module 1408 is configured to, in the case that the first compiling state message indicates that the compiling thread has generated a first compiling result, control the running thread to obtain the first compiling result, and generate a target rendering instruction based on the first compiling result, wherein the target rendering instruction is used to be sent to a graphics processor to control the graphics processor to render a program interface of the target mini-program.
[0190] As an optional solution, the apparatus is further configured to: control the running thread to start generating the rendering instruction, control the running thread to wait for a preset time duration in a case that the first compilation status message indicates that the compilation thread has not generated the first compilation result after the running thread obtains the first compilation status message associated with the target compilation request from the compilation thread; and control the running thread to obtain the second compilation status message from the compilation thread in response to the running time duration waiting for the preset time duration.
[0191] As an optional solution, the apparatus is configured to control the running thread to forward the target compilation request to the compilation thread in response to receiving the target compilation request by: determining whether the target compilation request is included in a rendering request queue in response to receiving the rendering request queue, wherein the rendering request queue includes the target compilation request indicating that the rendering request queue needs to perform a shader compilation; and controlling the running thread to forward the target compilation request to the compilation thread in response to the rendering request queue including the target compilation request.
[0192] As an optional solution, the apparatus is configured to control the running thread to obtain the first compilation status message associated with the target compilation request from the compilation thread in response to the running thread starting to generate the rendering instruction by: determining whether a first task being executed by the running thread needs to use the first compilation result in response to the running thread starting to generate the rendering instruction; and controlling the running thread to obtain the first compilation status message from the compilation thread in a case that the first task indicates that the first compilation result needs to be used.
[0193] As an optional solution, the apparatus is further configured to: control the running thread to execute the first task in a case that the first task indicates that the first compilation result does not need to be used.
[0194] As an optional solution, the apparatus is configured to control the running thread to obtain the first compilation result and generate the target rendering instruction based on the first compilation result in a case that the first compilation status message indicates that the compilation thread has generated the first compilation result by: controlling the running thread to obtain the first compilation result and execute the first task based on the first compilation result in a case that the first task indicates that the first compilation result needs to be used and the first compilation status message indicates that the compilation thread has generated the first compilation result, until the running thread completes each task in the rendering request queue, controlling the running thread to generate the target rendering instruction.
[0195] As an optional solution, the apparatus is further configured to: in a case where the first compilation status message indicates that the compilation thread has not generated the first compilation result and the first task indicates that the first compilation result is required, control the running thread to skip the first task, acquire a second task to be executed by the running thread, and determine whether the second task requires the first compilation result, wherein the second task represents a task that is in an execution sequence after the first task; in a case where the second task indicates that the first compilation result is not required, control the running thread to execute the second task until the running thread completes all the tasks in the rendering request queue, and control the running thread to generate the target rendering instruction; in a case where the second task indicates that the first compilation result is required, control the running thread to acquire a third compilation status message from the compilation thread; in a case where the third compilation status message indicates that the compilation thread has generated the first compilation result, control the running thread to acquire the first compilation result, and execute the second task based on the first compilation result until the running thread completes all the tasks in the rendering request queue, and control the running thread to generate the target rendering instruction.
[0196] As an optional solution, the apparatus is further configured to: in a case where the first compilation status message indicates that the compilation thread has not generated the first compilation result and the first task indicates that the first compilation result is required, control the running thread to skip the first task, acquire a third task to be executed by the running thread, and determine whether the third task requires the second compilation result, wherein the third task represents a task that is in an execution sequence after the first task, and the second compilation result corresponds to a shader object that is different from the shader object corresponding to the first compilation result; in a case where the third task indicates that the second compilation result is required, control the running thread to acquire a fourth compilation status message from the compilation thread; in a case where the fourth compilation status message indicates that the compilation thread has generated the second compilation result, control the running thread to acquire the second compilation result, and execute the third task based on the second compilation result until the running thread completes all the tasks in the rendering request queue, and control the running thread to generate the target rendering instruction.
[0197] As an optional solution, the apparatus is configured to create the compilation thread in response to the target miniprogram being started by: in response to the target miniprogram being started, pre-acquiring a set of shader objects, and in response to acquiring the set of shader objects, creating the compilation thread, wherein the set of shader objects includes at least one shader object to be compiled; in response to receiving a target compilation request, controlling the running thread to forward the target compilation request to the compilation thread, including: in response to receiving the set of shader objects, forwarding each shader object in the set of shader objects to the compilation thread, and controlling the compilation thread to pre-compile each shader object, wherein the first compilation status message includes a pre-compilation status of a target shader object corresponding to the target compilation request.
[0198] As an optional solution, the apparatus is configured to pre-acquire the set of shader objects in response to the target applet being launched, and create the compilation threads in response to acquiring the set of shader objects, by: pre-acquiring the set of shader objects in response to the target applet being launched; determining a number of shader objects in the set of shader objects in response to acquiring the set of shader objects; and creating the compilation threads according to the number of shader objects, wherein each of the compilation threads is allowed to access one or more of the shader objects and to compile code corresponding to the one or more of the shader objects into code executable by the graphics processor.
[0199] As an optional solution, the apparatus is configured to create the compilation threads in response to the target applet being launched, by: acquiring a number of cores of a central processing unit in response to the target applet being launched; and creating the compilation threads according to the number of cores, wherein each of the compilation threads is allowed to access one or more of the shader objects and to compile code corresponding to the one or more of the shader objects into code executable by the graphics processor.
[0200] As an optional solution, the apparatus is further configured to: create M compilation threads according to a number of cores of a central processing unit of a target device in response to the target applet being launched, wherein the target device represents a device on which the target applet is loaded, the number of cores of the central processing unit is M, and M is a positive integer; forward, in response to receiving a target compilation request, the target compilation request to the M compilation threads, wherein the target compilation request is associated with an Nth program interface of the target applet, and N is a positive integer; acquire, in response to the running thread starting to generate a rendering instruction corresponding to the Nth program interface, a first compilation status message associated with the target compilation request from a target compilation thread of the M compilation threads, wherein the first compilation status message comprises whether the target compilation request is compiled by the target compilation thread; and acquire, in a case where the first compilation status message indicates that the target compilation thread has generated a first compilation result at an i-th frame, the first compilation result, and generate a target rendering instruction corresponding to the Nth program interface based on the first compilation result, wherein i is a non-negative integer, and i is less than N.
[0201] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the functions of the module or unit.
[0202] With regard to the apparatus in the above-described embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and thus will not be described in detail here.
[0203] According to an aspect of the present application, there is provided a computer program product comprising a computer program.
[0204] The above-mentioned sequence numbers of the embodiments of the present application are merely for description, and do not represent advantages or disadvantages of the embodiments.
[0205] Figure 15 A block diagram of a computer system structure of an electronic device for implementing the embodiments of the present application is schematically shown.
[0206] It should be noted that, Figure 15 The computer system 1500 of the electronic device shown is merely an example, and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0207] As Figure 15 shown, the computer system 1500 includes a central processing unit 1501 (CPU), which can perform various appropriate actions and processes according to programs stored in a read-only memory 1502 (ROM) or loaded from a storage portion 1508 into a random access memory 1503 (RAM). Various programs and data required for system operation are also stored in the random access memory 1503. The central processing unit 1501, the read-only memory 1502, and the random access memory 1503 are connected to each other through a bus 1504. An input / output interface 1505 (I / O interface) is also connected to the bus 1504.
[0208] The following components are connected to the input / output interface 1505: an input portion 1506 including a keyboard, a mouse, and the like; an output portion 1507 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the like, and a speaker, and the like; a storage portion 1508 including a hard disk, and the like; and a communication portion 1509 including a network adapter, a modem, and the like. The communication portion 1509 performs communication processing via a network such as the Internet. A drive 1510 is also connected to the input / output interface 1505 as necessary. A removable medium 1511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 1510 as necessary, so that a computer program read therefrom is installed in the storage portion 1508 as necessary.
[0209] In particular, according to an embodiment of the present application, the processes described in each method flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 1509, and / or installed from the detachable medium 1511. When the computer program is executed by the central processing unit 1501, various functions defined in the system of the present application are performed.
[0210] In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 1509, and / or installed from the detachable medium 1511. When the computer program is executed by the central processing unit 1501, various functions provided by the embodiments of the present application are performed.
[0211] According to still another aspect of the embodiments of the present application, an electronic device for implementing the above-mentioned data processing method is also provided, which can be the terminal device or the server as shown. Figure 1 As shown in the figure, the electronic device includes a memory 1602 and a processor 1604, the memory 1602 stores a computer program, and the processor 1604 is configured to execute the steps in any of the above-mentioned method embodiments through the computer program. Figure 16
[0212] Optionally, in the present embodiment, the above-mentioned electronic device can be located in at least one of the network devices in the computer network.
[0213] Optionally, in the present embodiment, the above-mentioned processor can be configured to execute the method in each embodiment of the present application through the computer program.
[0214] Optionally, those skilled in the art can understand that the structure shown in the figure is only schematic, Figure 16 and it does not limit the structure of the above-mentioned electronic device. For example, the electronic device can also include more or less components (such as network interfaces, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 16 For example, the electronic device can also include more or less components (such as network interfaces, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 16 Figure 16
[0215] The memory 1602 can be used to store software programs and modules, such as program instructions / modules corresponding to the data processing method and device in the embodiments of the present application. The processor 1604 executes various functions and data processing by running the software programs and modules stored in the memory 1602, that is, implements the data processing method described above. The memory 1602 can include a high-speed random memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 1602 can further include a memory remotely arranged with respect to the processor 1604, which can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. Specifically, the memory 1602 can be used to store, but is not limited to, the first compilation result and other information. As an example, as shown in Figure 16 The memory 1602 can include, but is not limited to, the creation module 1602, the control module 1604, the acquisition module 1606, and the generation module 1608 in the data processing device described above. In addition, other module units in the data processing device described above can also be included, but are not limited to, which will not be described in detail in this example.
[0216] Optionally, the transmission device 1606 described above is used to receive or send data via a network. Specific examples of the above network can include wired networks and wireless networks. In one example, the transmission device 1606 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers through a network cable to communicate with the Internet or a local area network. In one example, the transmission device 1606 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
[0217] In addition, the electronic device described above further includes a display 1608 for displaying the program interface, and a connection bus 1610 for connecting various module components in the electronic device.
[0218] In other embodiments, the terminal device or the server described above can be a node in a distributed system, where the distributed system can be a blockchain system, which can be a distributed system formed by the plurality of nodes communicating through a network. Wherein, the nodes can form a peer-to-peer network, and any form of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the peer-to-peer network.
[0219] According to an aspect of the present application, a computer readable storage medium is provided, and a processor of an electronic device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the electronic device to perform the data processing method provided in the various optional implementation manners of the data processing aspect.
[0220] Optionally, in the embodiment, the computer readable storage medium can be configured to store the program for executing the method in the embodiments of the present application.
[0221] Optionally, in the embodiment, a person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by programs instructing the hardware related to the terminal device, and the programs can be stored in a computer readable storage medium, and the storage medium can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0222] The serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
[0223] The integrated units in the above embodiments can be stored in the computer readable storage medium if they are realized in the form of software function units and sold or used as independent products. Based on such understanding, the technical solutions of the present application or the whole or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of software products, and the computer software products are stored in the storage medium and include a plurality of instructions for enabling one or more electronic devices to execute all or part of the steps of the methods described in the embodiments of the present application.
[0224] In the above embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0225] In the several embodiments provided by the present application, it should be understood that the disclosed application programs can be implemented in other ways. Of course, the above described device embodiments are only schematic. For example, the division of units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between units can be indirect couplings or communication connections through some interfaces, units or modules, and can be electrical or other forms.
[0226] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0227] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0228] The above is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled persons in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.
Claims
1. A method of processing data, characterized by, The method comprises: in response to the target program being started, creating a compilation thread, wherein the running environment of the target program is set to run through single thread, and the thread running the target program is a running thread; in response to receiving a target compilation request, controlling the running thread to forward the target compilation request to the compilation thread, wherein the target compilation request is used to access a pre-created shader object to perform shader compilation work, the compilation thread is set to start processing the target compilation request when the target compilation request is received, and the running thread is set to work in parallel with the compilation thread; in response to the running thread starting to generate rendering instructions, controlling the running thread to obtain a first compilation state message associated with the target compilation request from the compilation thread; in a case where the first compilation state message indicates that the compilation thread has generated a first compilation result, controlling the running thread to obtain the first compilation result and generate target rendering instructions based on the first compilation result, wherein the target rendering instructions are used to be sent to a graphics processor to control the graphics processor to render a program interface of the target program.
2. The method of claim 1, wherein, After the response to the running thread starting to generate rendering instructions, the method further comprises: in a case where the first compilation state message indicates that the compilation thread has not generated the first compilation result, controlling the running thread to wait for a preset time length; in response to the running time length waiting for the preset time length, controlling the running thread to obtain a second compilation state message from the compilation thread; in a case where the second compilation state message indicates that the compilation thread has generated the first compilation result, controlling the running thread to obtain the first compilation result and generate target rendering instructions based on the first compilation result.
3. The method of claim 1, wherein, The response to receiving a target compilation request, controlling the running thread to forward the target compilation request to the compilation thread, comprises: in response to receiving a rendering request queue, determining whether the target compilation request is included in the rendering request queue, wherein the target compilation request indicates that the rendering request queue needs to perform shader compilation; in response to the rendering request queue including the target compilation request, controlling the running thread to forward the target compilation request to the compilation thread.
4. The method of claim 3, wherein, The response to the running thread starting to generate rendering instructions, controlling the running thread to obtain a first compilation state message associated with the target compilation request from the compilation thread, comprises: in response to the running thread starting to generate the rendering instructions, determining whether a first task being executed by the running thread needs to use the first compilation result; in a case where the first task indicates that the first compilation result needs to be used, controlling the running thread to obtain the first compilation state message from the compilation thread.
5. The method of claim 4, wherein, The method further comprises: In a case where the first task indication indicates that the first compilation result is not needed, the running thread is controlled to execute the first task.
6. The method of claim 4, wherein, in a case where the first compilation state message indicates that the first compilation result has been generated by the compiling thread, the running thread is controlled to acquire the first compilation result and generate the target rendering instruction based on the first compilation result, including: in a case where the first task indication indicates that the first compilation result is needed, and the first compilation state message indicates that the first compilation result has been generated by the compiling thread, the running thread is controlled to acquire the first compilation result and execute the first task based on the first compilation result until the running thread completes all the tasks in the rendering request queue, and the running thread is controlled to generate the target rendering instruction; the method further includes: in a case where the first compilation state message indicates that the first compilation result has not been generated by the compiling thread, and the first task indication indicates that the first compilation result is needed, the running thread is controlled to skip the first task, acquire a second task to be executed by the running thread, and determine whether the second task needs to use the first compilation result, wherein the second task represents a task that is executed after the first task in the execution order; in a case where the second task indication indicates that the first compilation result is not needed, the running thread is controlled to execute the second task until the running thread completes all the tasks in the rendering request queue, and the running thread is controlled to generate the target rendering instruction; in a case where the second task indication indicates that the first compilation result is needed, the running thread is controlled to acquire a third compilation state message from the compiling thread; in a case where the third compilation state message indicates that the first compilation result has been generated by the compiling thread, the running thread is controlled to acquire the first compilation result and execute the second task based on the first compilation result until the running thread completes all the tasks in the rendering request queue, and the running thread is controlled to generate the target rendering instruction.
7. The method of claim 4, wherein, the method further includes: in a case where the first compilation state message indicates that the first compilation result has not been generated by the compiling thread, and the first task indication indicates that the first compilation result is needed, the running thread is controlled to skip the first task, acquire a third task to be executed by the running thread, and determine whether the third task needs to use a second compilation result, wherein the third task represents a task that is executed after the first task in the execution order, and the second compilation result corresponds to a shader object that is different from a shader object corresponding to the first compilation result; in a case where the third task indication indicates that the second compilation result is needed, the running thread is controlled to acquire a fourth compilation state message from the compiling thread; in a case where the third task indication indicates that the second compilation result is needed, the running thread is controlled to acquire a fourth compilation state message from the compiling thread; In a case where the fourth compilation status message indicates that the compilation thread has generated the second compilation result, the method further includes: controlling the running thread to acquire the second compilation result, and executing the third task based on the second compilation result until the running thread completes all tasks in the rendering request queue, and controlling the running thread to generate the target rendering instruction.
8. The method of claim 1, wherein, the creating the compilation thread in response to the target miniprogram being started comprises: in response to the target miniprogram being started, pre-acquiring a set of shader objects, and in response to acquiring the set of shader objects, creating the compilation thread, wherein the set of shader objects comprises at least one shader object to be compiled; the forwarding, by the running thread, the target compilation request to the compilation thread in response to receiving the target compilation request comprises: in response to receiving the set of shader objects, forwarding each shader object in the set of shader objects to the compilation thread, and controlling the compilation thread to pre-compile the each shader object, wherein the first compilation status message comprises a pre-compilation status of a target shader object corresponding to the target compilation request.
9. The method of claim 8, wherein, the creating the compilation thread in response to the target miniprogram being started comprises: in response to the target miniprogram being started, pre-acquiring the set of shader objects; in response to acquiring the set of shader objects, determining a number of shader objects in the set of shader objects; creating the compilation thread according to the number of shader objects, wherein each of the compilation threads is allowed to access one or more of the shader objects, and one or more of the shader objects corresponding to the code is compiled into code allowed to be executed by a graphics processing unit.
10. The method of claim 1, wherein, the creating the compilation thread in response to the target miniprogram being started comprises: in response to the target miniprogram being started, acquiring a number of cores of a central processing unit; creating the compilation thread according to the number of cores, wherein each of the compilation threads is allowed to access one or more of the shader objects, and one or more of the shader objects corresponding to the code is compiled into code allowed to be executed by a graphics processing unit.
11. The method of claim 1, wherein, The method further includes: in response to the target miniprogram being started, creating M compilation threads according to a number of cores of a central processing unit of a target device, wherein the target device represents a device on which the target miniprogram is loaded, the number of cores of the central processing unit is M, and M is a positive integer; in response to receiving the target compilation request, forwarding, by the running thread, the target compilation request to the M compilation threads, wherein the target compilation request is related to an Nth program interface of the target miniprogram, and N is a positive integer; In response to the running thread starting to generate the rendering instruction corresponding to the Nth frame of the program interface, the running thread is controlled to acquire the first compilation state message associated with the target compilation request from a target compilation thread in the M compilation threads, where the first compilation state message includes whether the target compilation request is compiled by the target compilation thread. In a case where the first compilation state message indicates that the target compilation thread has generated the first compilation result at the Nth-i frame, the running thread is controlled to acquire the first compilation result and generate the target rendering instruction corresponding to the Nth frame of the program interface based on the first compilation result, where i is a non-negative integer and i is less than N.
12. A data processing apparatus, characterized by comprising: The method comprises: a creating module configured to create a compilation thread in response to a target mini-program being started, where a running environment of the target mini-program is set to be run by a single thread, and a thread running the target mini-program is a running thread; a control module configured to control the running thread to forward a target compilation request to the compilation thread in response to receiving the target compilation request, where the target compilation request is used to access a pre-created shader object to perform a shader compilation task, the compilation thread is set to start processing the target compilation request when the target compilation request is received, and the running thread is set to work in parallel with the compilation thread; an acquisition module configured to control the running thread to acquire a first compilation state message associated with the target compilation request from the compilation thread in response to the running thread starting to generate a rendering instruction; a generation module configured to control the running thread to acquire a first compilation result and generate a target rendering instruction based on the first compilation result in a case where the first compilation state message indicates that the compilation thread has generated the first compilation result, where the target rendering instruction is used to be sent to a graphics processing unit to control the graphics processing unit to render a program interface of the target mini-program.
13. A computer readable storage medium, characterized in that, The computer-readable storage medium comprises a stored computer program, where the computer program can be run by an electronic device to execute the method described in any one of claims 1 to 11.
14. A computer program product comprising a computer program, characterized in that, The computer program is executed by a processor to implement the steps of the method described in any one of claims 1 to 11.
15. An electronic device comprising a memory and a processor, characterized in that The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 11 by using the computer program. The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 11 by using the computer program.