Embodiments of this application relate to the cloud computing field, and in particular, to a rendering method in a cloud game scenario.
Cloud games are games based on cloud computing and relying on network transmission. Users click and play cloud games on client terminals without experiencing download and installation processes. 5G features high bandwidth and low latency. It is expected to break, for cloud games, the bottlenecks of limited image quality due to insufficient bandwidth and not being able to meet the requirement of instant gaming due to high latency. Therefore, the era of 5G is bound to boost the development of cloud games. Typical implementation scenarios of cloud game technologies include video cloud games and instruction cloud games.
(1) Video Cloud Games
A cloud server receives operation instructions from a terminal device, and a central processing unit (CPU) or a graphics processing unit (GPU) of the server completes computation. Then, a video stream is transmitted to the terminal (including a laptop computer, a tablet computer, a mobile phone, or the like) through a network for display. In a video cloud game scenario, a player's game terminal does not need to have powerful graphics computing and data processing capabilities, but only needs to have basic streaming playback capabilities and capabilities of obtaining player-input instructions and sending them to a cloud server.
(2) Instruction Cloud Games
All logic is computed by using a cloud server to form rendering instructions of an Open Graphics Library (OpenGL) or a Web Graphics Library (WebGL). Then, the rendering instructions are transmitted to a terminal device through a network. The terminal device parses and executes an instruction stream. In this case, GPU capabilities of the terminal device are fully utilized. For the same image quality, instruction cloud games have lower network bandwidth overheads and lower costs than a video cloud game solution, and do not incur rendering overheads of a GPU of the cloud server and the like. However, an instruction cloud game scenario has low availability under poor network conditions.
This application provides a rendering method and apparatus, applied to the cloud computing field, to resolve the following problem in an instruction cloud game scenario:
According to a first aspect, an embodiment of this application provides a rendering method. The method is applied to a server and includes: Before a network jitter occurs on a network, the server successively receives operation instructions from an electronic device through the network, generates a plurality of first rendering instruction streams based on the operation instructions, and sends the plurality of first rendering instruction streams to the electronic device; and the server generates and stores one or more first rendering contexts for one or more first rendering instruction streams in the plurality of first rendering instruction streams, where the one or more first rendering context one-to-one corresponds to the one or more first rendering instruction streams, and the first rendering context includes a corresponding first rendering instruction stream or information used for restoring a corresponding first rendering instruction stream; when a network jitter occurs, the server continues to generate a second rendering instruction stream based on received operation instructions, and generates and stores a second rendering context based on the second rendering instruction stream, where the second rendering context includes the second rendering instruction stream or information used for restoring the second rendering instruction stream, and the second rendering instruction stream is a rendering instruction stream most recently generated before recovery from the network jitter; and after recovery from the network jitter, the server sends a set of rendering context differences to the electronic device, where the set of rendering context differences includes one or more rendering context differences, wherein the one rendering context difference is the difference between the second rendering context and one of the first rendering contexts, and the electronic device uses the set of rendering context differences to obtain the second rendering instruction streams.
This application may be applied to a scenario in which separate rendering is implemented by using an instruction stream solution, in other words, a server receives operation instructions from an electronic device through a network, generates rendering instruction streams based on the operation instructions, and sends the rendering instruction streams to the electronic device connected to the server, so that the electronic device that receives the rendering instruction streams performs graphics rendering. However, when a network jitter occurs, a large quantity of rendering instruction streams are accumulated because the rendering instruction streams cannot be sent. After recovery from the network jitter, the large quantity of rendering instruction streams are to be sent from the server side to the electronic device. After the sending, the large quantity of rendering instruction streams are to be executed on the electronic device side. This causes high transmission and processing delays of the rendering instruction streams. As a result, rendering consumes much time in the electronic device, the rendering result of the latest frame cannot be presented to a user in time, and the user experiences a high delay. By using the method, the server may send a set of rendering context differences to the electronic device, where the set of rendering context differences includes one or more rendering context differences, wherein the one rendering context difference is a difference between the second rendering context and one first rendering context. Therefore, the electronic device can obtain, based on the set of rendering context differences, a rendering instruction stream most recently generated by the server before recovery from the network jitter, thereby implementing synchronization between the server and the electronic device. Because the quantity of rendering instruction streams corresponding to the set of rendering context differences is greatly reduced compared with the quantity of rendering instruction streams accumulated during the network jitter, network traffic is dramatically reduced in the process of sending the rendering instruction streams to the electronic device, and accordingly, the delay in executing the rendering instruction streams by the electronic device is significantly reduced. In other words, both transmission and processing delays are reduced. Therefore, network transmission traffic is reduced, transmission and processing delays are reduced, and user experience is improved.
In some possible implementations, the operation instructions may alternatively come from another device, or may be generated by the server itself.
In a possible implementation, a rendering context may be generated and stored on the server based on a rendering instruction stream. The rendering context records information required for image rendering, including the rendering instruction stream or information used for restoring the rendering instruction stream. For example, in OpenGL, an OpenGL rendering context records all information required for OpenGL rendering. It is a large structure that records states and state attributes that are set by OpenGL function calling, such as color currently used for rendering, whether there is illumination calculation, and a light source turned on. It may be understood that, in this implementation, the generation and storage of a rendering context may be implemented by a logical entity different from an application program app service end running on the server, for example, a context tracking module. In this scenario, the context tracking module may obtain a rendering instruction stream from the app service end and generate and store a rendering context based on the rendering instruction stream.
In another possible implementation, a rendering context may be alternatively generated and stored on another server or another type of device. This is not limited in this application.
In some possible implementations, before generating and storing any first rendering context in the one or more first rendering contexts, the server determines a generated first rendering instruction stream as a rendering instruction stream corresponding to data of an image frame, or the server determines a first rendering instruction stream as a target rendering instruction stream, where the target rendering instruction stream is prestored on the server, for example, draw instructions or swap instructions.
In a possible implementation, the server may periodically perform an action of generating and storing one or more first rendering contexts.
In another possible implementation, the server may alternatively generate and store the one or more first rendering contexts after generating one or more rendering instruction streams. A quantity of rendering instruction streams are prestored on the server. For example, the server generates and stores the one or more first rendering contexts after generating five rendering instruction streams. The generation and storage of the one or more first rendering contexts is a preparation for subsequent calculation of a set of rendering context differences. The server sends the set of rendering context differences to the electronic device after recovery from the network jitter, so that the electronic device can obtain, based on the set of rendering context differences, a rendering instruction stream most recently generated by the server before recovery from the network jitter, thereby implementing synchronization between the server and the electronic device.
In a possible implementation, the server generates a third rendering instruction stream and generates a third rendering context based on the third rendering instruction stream, where the third rendering context includes the third rendering instruction stream or information used for restoring the third rendering instruction stream, and the third rendering instruction stream is the 1st rendering instruction stream generated after the server receives operation instructions from the electronic device; and the server sets a baseline snapshot, where the baseline snapshot is the third rendering context.
In a possible implementation, the server receives a rendering instruction stream response sent by the electronic device, where the rendering instruction stream response includes an instruction stream number of a rendering instruction stream most recently received by the electronic device; and the server updates the baseline snapshot to a first rendering context corresponding to the received instruction stream number.
In a possible implementation, after receiving the rendering instruction stream response, the server deletes other first rendering contexts stored on the server.
In a possible implementation, any first rendering context in the one or more first rendering contexts may be stored by storing the difference between the any first rendering context and the baseline snapshot. It may be understood that if the difference between the any first rendering context and the baseline snapshot is stored, the storage space of the server can be saved.
In another possible implementation, an entire first rendering context may be directly stored. In this implementation, the baseline snapshot may not be set.
In a possible implementation, after recovery from the network jitter, the server obtains an instruction stream number of the rendering instruction stream last executed by the electronic device before the network jitter occurs. An obtaining manner may be: The server proactively queries the electronic device after detecting that recovery from the network jitter, and the electronic device sends, to the server, the instruction stream number of the rendering instruction stream last executed before the network jitter occurs; or after detecting that recovery from the network jitter, the electronic device proactively reports, to the server, the instruction stream number of the rendering instruction stream last executed before the network jitter occurs. Correspondingly, in this implementation, the sending a set of rendering context differences after recovery from the network jitter includes: sending a difference between the second rendering context and a first rendering context corresponding to the instruction stream number.
After recovery from the network jitter, the server sends the set of rendering context differences to the electronic device. In a possible implementation, the server sends a set of differences between the second rendering context and each first rendering context in the one or more first rendering contexts. In another possible implementation, the server sends a set of differences between a difference between the second rendering context and the baseline snapshot, and a sum of differences between the any first rendering context and the baseline snapshot. Corresponding to this implementation, a manner of storing a first rendering context is the storing a difference between the any first rendering context and the baseline snapshot, as described above.
In a possible implementation, the set of rendering context differences sent by the server after recovery from the network jitter may be in a user-defined message format. It may be understood that if a rendering context difference sent by the server is in the user-defined message format, the electronic device needs to convert the user-defined format of the rendering context difference into a rendering instruction stream format.
In a possible implementation, the set of rendering context differences sent by the server after recovery from the network jitter may be in a rendering instruction stream format.
According to a second aspect, an embodiment of this application provides a rendering method. The method is applied to an electronic device and includes:
Before a network jitter occurs on a network, the electronic device receives a first rendering instruction stream from a server, where the first rendering instruction stream is used for executing image rendering to display an image; the electronic device sends a rendering instruction stream response to the server, where the rendering instruction stream response includes an instruction stream number of a rendering instruction stream most recently received by the electronic device; and after recovery from the network jitter, the electronic device receives a set of rendering context differences from the server, and parses some or all rendering context differences in the set of rendering context differences to obtain a rendering instruction stream most recently generated by the server before recovery from the network jitter.
In some implementations, the method further includes: sending operation instructions to the server, where the operation instructions are used to instruct the server to run an application program.
This application may be applied to a scenario in which separate rendering is implemented by using an instruction stream solution, in other words, an electronic device sends operation instructions to a server through a network, the server generates rendering instruction streams based on the operation instructions and sends the rendering instruction streams to the electronic device, and the electronic device performs graphics rendering. However, when a network jitter occurs, a large quantity of rendering instruction streams are accumulated because the rendering instruction streams cannot be sent. After recovery from the network jitter, the large quantity of rendering instruction streams are to be sent from the server side to the electronic device. After the sending, the large quantity of rendering instruction streams are to be executed on the electronic device side, which causes high transmission and processing delays of the rendering instruction streams. As a result, rendering consumes much time in the electronic device, a rendering result of a latest frame cannot be presented to a user in time, and the user experiences a high delay. By using the method, the server may send a set of rendering context differences to the electronic device, where the set of rendering context differences includes one or more rendering context differences, wherein the one rendering context difference is a difference between the second rendering context and one first rendering context. Therefore, the electronic device can obtain, based on the set of rendering context differences, a rendering instruction stream most recently generated by the server before recovery from the network jitter, thereby implementing synchronization between the server and the electronic device. Because the quantity of rendering instruction streams corresponding to the set of rendering context differences is greatly reduced compared with the quantity of rendering instruction streams accumulated during the network jitter, network traffic is dramatically reduced in a process of sending the rendering instruction streams to the electronic device, and accordingly, a delay in executing the rendering instruction streams by the electronic device is significantly reduced. In other words, both transmission and processing delays are reduced. Therefore, network transmission traffic is reduced, transmission and processing delays are reduced, and user experience is improved.
In some possible implementations, before sending the rendering instruction stream response to the server, the electronic device determines the received first rendering instruction stream as a rendering instruction stream corresponding to data of an image frame, or the electronic device determines the received first rendering instruction stream as a target rendering instruction stream, where the target rendering instruction stream is prestored in the electronic device. For example, the electronic device receives draw instructions or swap instructions and sends a rendering instruction stream response to the server.
In a possible implementation, the electronic device may send a rendering instruction stream response to the server after receiving one or more rendering instruction streams, for example, after receiving five rendering instruction streams. A quantity of rendering instruction streams are prestored in the electronic device.
In a possible implementation, the electronic device periodically performs an action of sending a rendering instruction stream response.
In a possible implementation, one or more rendering context differences in the set of rendering context differences received by the electronic device may be in a user-defined message format. For example, the rendering context difference is in an information format that is used for restoring the rendering instruction stream most recently generated by the server before recovery from the network jitter. If the rendering context difference in the set of rendering context differences received by the electronic device is in the user-defined format, the electronic device converts the user-defined format of the rendering context difference into a rendering instruction stream format. In other words, when the rendering context difference is in the information format that is used for restoring the rendering instruction stream most recently generated by the server before recovery from the network jitter, the electronic device converts the rendering context difference into the rendering instruction stream format.
In a possible implementation, a rendering context difference received by the electronic device may be in a rendering instruction stream format.
In a possible implementation, after recovery from the network jitter, the electronic device proactively reports, to the server, an instruction stream number of the rendering instruction stream last executed before the network jitter occurs.
In a possible implementation, after recovery from the network jitter, the electronic device sends, to the server in response to a query instruction from the server, the instruction stream number of the rendering instruction stream last executed before the network jitter occurs.
After receiving the set of rendering context differences from the server, the electronic device parses some or all rendering context differences in the set of rendering context differences. The parsing some or all rendering context differences in the set of rendering context differences includes: selecting a rendering context difference that is the closest to the rendering instruction stream last executed before the network jitter occurs, and parsing and executing the rendering context difference that is the closest to the rendering instruction stream last executed before the network jitter occurs.
In a possible implementation, after the electronic device receives the set of rendering context differences from the server, if the set of rendering context differences is a difference between the second rendering context obtained after recovery from the network jitter and a first rendering context corresponding to the instruction stream number of the rendering instruction stream last executed by the electronic device before the network jitter occurs, the electronic device determines whether an instruction stream number in the rendering context difference is consistent with the instruction stream number last executed by the electronic device. If they are consistent, the rendering context difference is parsed. In this manner, the server needs to send only one rendering context difference, thereby reducing transmission traffic between the server and the electronic device.
In a possible implementation, after the electronic device receives the set of rendering context differences from the server, if the set of rendering context differences is a set of differences between the second rendering context and each first rendering context in the one or more first rendering contexts, the electronic device needs to select one of the rendering context differences for parsing. In this implementation, the electronic device may search, based on an instruction stream number, whether instruction stream numbers in all rendering context differences on the server include the instruction stream number last executed by the electronic device. If the instruction stream number last executed by the electronic device is included, the electronic device selects a rendering context difference corresponding to the instruction stream number for parsing. In this implementation, to increase a search hit rate, after receiving rendering instruction streams, the electronic device first caches a rendering instruction stream between two first rendering contexts without parsing, and then performs one-time parsing when a next rendering context is obtained, thereby ensuring integrity after recovery from the network jitter. It may be understood that in this implementation, the electronic device needs to record a first rendering context and store a rendering instruction stream between two first rendering contexts. A manner in which the electronic device stores a first rendering context may be consistent with the foregoing manner in which the server stores a first rendering context, may be querying the server for storage of a first rendering context by using a new message, or may be that the server notifies, by using a new message, the electronic device of storage of a first rendering context.
In another possible implementation, after the electronic device receives the set of rendering context differences from the server, if the set of rendering context differences is a set of differences between the second rendering context and each first rendering context in the one or more first rendering contexts, the electronic device needs to select one of the rendering context differences for calculation and parsing. The electronic device finds, based on the instruction stream number of the rendering instruction stream last executed before the network jitter occurs, a first rendering context the closest to the instruction stream number, and calculates a context difference between a rendering context in the electronic device obtained during the network jitter and the first rendering context the closest to the instruction stream number, thereby obtaining a difference between the rendering context in the electronic device obtained during the network jitter and the second rendering context. It may be understood that in this implementation, the electronic device needs to record a first rendering context and the instruction stream number of the rendering instruction stream last executed by the electronic device. A manner in which the electronic device stores a first rendering context may be consistent with the foregoing manner in which the server stores a first rendering context, may be querying the server for storage of a first rendering context by using a new message, or may be that the server notifies, by using a new message, the electronic device of storage of a first rendering context. Different from the foregoing implementation, in this implementation, after receiving a rendering instruction stream, the electronic device may execute the rendering instruction stream in real time and does not need to store a rendering instruction stream between two first rendering contexts. Compared with the foregoing solution, storage space of the electronic device is saved, and the following problem can be avoided: a rendering instruction stream is not executed in real time.
According to a third aspect, an embodiment of this application provides a rendering apparatus. The apparatus includes corresponding modules configured to perform the method/operations/steps/actions described in the first aspect.
The foregoing apparatus may be a server, or may be an apparatus (for example, a chip, or an apparatus that can work together with a server) that is in the server and that is configured to perform graphics rendering.
The module included in the graphics rendering apparatus may be implemented by using a hardware circuit, software, or a combination of a hardware circuit and software.
According to a fourth aspect, an embodiment of this application provides a rendering apparatus. The apparatus includes corresponding modules configured to perform the method/operations/steps/actions described in the second aspect.
The apparatus may be an electronic device, or may be an apparatus (for example, a chip, or an apparatus that can match the electronic device for use) configured to perform graphics rendering in the electronic device.
The module included in the graphics rendering apparatus may be implemented by using a hardware circuit, software, or a combination of a hardware circuit and software.
According to a fifth aspect, an embodiment of this application provides a graphics rendering apparatus. The apparatus includes a processor, where the processor is configured to invoke program code stored in a memory to execute some or all operations in any implementation of the first aspect.
In the foregoing apparatus, the memory storing the program code may be located inside the graphics rendering apparatus (in addition to the processor, the graphics rendering apparatus may further include the memory), or may be located outside the graphics rendering apparatus (which may be a memory of another device). Optionally, the memory is a non-volatile memory.
When the graphics rendering apparatus includes the processor and the memory, the processor and the memory may be coupled together.
According to a sixth aspect, an embodiment of this application provides a graphics rendering apparatus. The apparatus includes a processor, where the processor is configured to invoke program code stored in a memory to execute some or all operations in any implementation of the second aspect.
In the foregoing apparatus, the memory storing the program code may be located inside the graphics rendering apparatus (in addition to the processor, the graphics rendering apparatus may further include the memory), or may be located outside the graphics rendering apparatus (which may be a memory of another device). Optionally, the memory is a non-volatile memory.
When the graphics rendering apparatus includes the processor and the memory, the processor and the memory may be coupled together.
According to a seventh aspect, an embodiment of this application provides a computer-readable storage medium, where the computer-readable storage medium stores program code, and the program code includes instructions used to perform some or all operations in the method described in any one of the foregoing aspects. Optionally, the computer-readable storage medium is located inside an electronic device, and the electronic device may be an apparatus that can perform graphics rendering.
According to an eighth aspect, an embodiment of this application provides a computer program product. When the computer program product runs on a communications apparatus, the communications apparatus is enabled to execute some or all operations of the method described in any one of the foregoing aspects.
According to a ninth aspect, an embodiment of this application provides a chip. The chip includes a processor, and the processor is configured to perform some or all operations in the method described in any one of the foregoing aspects.
According to a tenth aspect, an embodiment of this application provides a system, including the foregoing electronic device and the foregoing server.
To describe the technical solutions in embodiments of this application or in the conventional technology more clearly, the following briefly describes the accompanying drawings required for describing embodiments or the conventional technology. It is clearly that the accompanying drawings in the following description show some embodiments of this application, and a person of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts.
The following clearly describes the technical solutions in embodiments of this application with reference to the accompanying drawings in embodiments of this application. Clearly, the described embodiments are some but not all of embodiments of this application. All other embodiments obtained by a person of ordinary skill in the art based on embodiments of this application without creative efforts shall fall within the protection scope of this application.
In the description of embodiments of this application, unless otherwise stated, “a plurality of” means two or more than two. The term “and/or” or the character “/” in this application is merely an association relationship for describing associated objects, and indicates that three relationships may exist. For example, A and/or, or A/B may indicate the following three cases: Only A exists, both A and B exist, and only B exists. In the description of embodiments of this application, a context and a rendering context have a same meaning, and a context difference and a rendering context difference have a same meaning.
For ease of understanding, the following uses a “restoration point” to represent a “first rendering context” stored on the foregoing server, and uses a “latest rendering context” to represent the “second rendering context”. A terminal in embodiments is one form of the electronic device mentioned above.
The rendering method provided in embodiments of this application is mainly applied to a scenario in which an application program execution environment is separated from a terminal. To better describe embodiments, a cloud game is used as an example for description.
A user starts a game by using an app client on a terminal, and enters operation instructions by using a touch, a mouse, a keyboard, a handle, or the like;
As shown in
It should be understood that the classification of the light-load game, the medium-load game, and the heavy-load game is performed based on the computing resource consumed by the terminal during game running, which is a relative concept. For example, if a resource that is of the terminal and that may be consumed during game running is used as a criterion, a game that needs to consume 30% of the computing resource during game running may be referred to as a light-load game, for example, Angry Birds. A game that needs to consume 80% of the computing resource during game running is referred to as a heavy-load game, for example, Honor of Kings. A game that needs to consume 50% of the computing resource during game running is referred to as a medium-load game, for example, Fruit Ninja.
However, in an existing process described above, upon recovery from a network jitter, the app sends rendering instruction streams accumulated during the network jitter to the app client at the same time, and the data volume of rendering instruction streams increases linearly with jitter duration. As a result, transmission and processing delays of the rendering instruction streams are high, and the user experiences a high delay.
An embodiment of this application provides a rendering method, and optimization is performed on a basis of the system architecture shown in
Context Tracking Module:
The functions of the app and the app client are updated on a basis of the original functions in the following.
App:
It should be noted that in the cloud game scenario, messages are transmitted between the terminal and the server in a form of a “message stream”. The message stream herein is a set carrying a plurality of messages, for example, the foregoing rendering instruction stream and operation instructions.
It should be understood that division of the app and the context tracking module is logical division in the architecture shown in
For ease of understanding, before a detailed process is described, an OpenGL ES is used as an example to illustrate a data structure of a rendering context, a type of a rendering instruction stream, and methods for generating, transferring, and restoring a rendering context difference.
A rendering context is a data structure that stores rendering information. It stores various states, including vertex information, texture information, compiled shader information, and the like, based on which rendering is completed. Specifically, the rendering context includes the following.
(1) One Context State (Context State) and 0 to a Plurality of Context Shared States (Context Shared States)
The context state includes:
The object pool includes various types of objects, such as caches and shader programs. Content and a state of each object are tracked. An object pool instruction specifies creation or deletion of an object.
Object content instruction: changes content of an object. Different types of objects have content in different forms. Therefore, different data structures need to be designed for different types of objects. For example, content of a buffer type is a buffer, and any change to the buffer needs to be tracked. However, tracking some types of objects may be unavailable or tracking costs are comparatively high. In this case, tracking may be lessened. In other words, only a difference is tracked, and content of the difference is not tracked but marked as: content not trackable, and the timestamp of the last change is marked. When difference comparison is performed, if timestamps are the same, it is considered that there is no difference, that is, comparison can be performed; or if timestamps are different, it is considered that comparison cannot be performed, this feature cannot be used, and an original process is used for restoration.
With reference to the schematic diagram of a data structure of a rendering context shown in
Specifically, four instruction examples are provided in the following.
The methods for generating, transferring, and restoring a rendering context difference is described in the following with reference to the foregoing description of a rendering instruction stream and a rendering context.
For calculation of a rendering context difference, comparison may be performed based on the four types of rendering instruction streams described above. Examples are provided in the following.
Configuration of fixed-function stages of the GPU: compares whether a specific configuration is changed.
Bindings of objects: compares whether a specific object is bound to a context.
Object pool instruction: compares whether a specific object is in a pool.
Object content: compares content of an object.
As described above, some types of objects may be marked as: content not comparable (not trackable). Therefore, only timestamps are compared. If the timestamps are the same, it indicates that there is no difference. If the timestamps are different, it indicates that a context difference cannot be generated, and comparison stops.
As described above, there may be three results for a context difference: no difference, different, and not comparable.
For a rendering context difference indicating comparable, a server needs to transfer the rendering context difference to a terminal. A transferred message may be a context difference itself, a rendering instruction stream obtained through conversion, or both, as shown in Table 2.
For example, when object content difference of a specific buffer object is transferred, changed memory information of the object may be transferred, or the object content difference is converted into an instruction glBufferSubData for transfer.
After the context restoration module receives a rendering context difference, if the rendering context difference is an instruction stream, the context restoration module directly forwards the rendering context difference to the app client; or if the rendering context difference is a difference in a user-defined format, the context restoration module converts the rendering context difference into a rendering instruction stream, and then forwards the rendering instruction stream to the app client for parsing and execution.
S601: Start a game and capture user operation instructions.
Specifically, a user starts the game by using a game client, that is, the app client, installed on the terminal. In this case, the app client generates operation instructions. The operation instructions include operation information, such as tapping or dragging by 1 cm to the left, that is entered by the user by using a terminal input device, such as a screen touch, a mouse, a keyboard, or a handle.
S602: The terminal sends the operation instructions to the app.
Data is transmitted between the terminal and the app through TCP/IP. According to a TCP/IP protocol, the terminal and the app first establish a TCP/IP connection through a three-way handshake.
S603: The app parses the operation instructions, starts the game, executes application program logic, and generates a rendering instruction stream.
S604: The app sends the rendering instruction stream to the context tracking module.
S605: The app sends the rendering instruction stream to the context restoration module.
S606: After receiving the rendering instruction stream, the context tracking module updates a local rendering context and sets a restoration point and a baseline snapshot.
Specifically, after the context tracking module receives the rendering instruction stream:
The rules include:
S607: The context restoration module sends the rendering instruction stream to the app client.
S608: The context restoration module sends an instruction stream response message to the context tracking module.
Steps S607 and S608 occur after the context restoration module receives the rendering instruction stream from the app.
After receiving the rendering instruction stream from the app, the context restoration module sends the rendering instruction stream to the app client. Specifically, after receiving the rendering instruction stream from the app, the context restoration module may first cache a rendering instruction between two restoration points without sending it, and then send rendering instructions to the app client at a time when a next restoration point arrives, thereby ensuring integrity upon recovery from a network jitter.
Specifically, when the context restoration module sends the instruction stream response message to the context tracking module, the instruction stream response message includes the rendering instruction stream number last received by the context restoration module. An occasion at which the context restoration module sends an instruction stream response message includes:
S609: After receiving the instruction stream response message from the context restoration module, the context tracking module sets a new baseline snapshot and deletes the existing baseline snapshot and a context difference between each restoration point and the existing baseline snapshot.
Specifically, if the context tracking module stores the context difference between each restoration point and the existing baseline snapshot, the context tracking module recalculates a context difference between each restoration point and the new baseline snapshot, as shown in
S610: After receiving the rendering instruction stream, the app client performs image rendering and display by using a local GPU.
S801: The app detects a network jitter and stops sending a rendering instruction stream to the context restoration module.
S802: The app sends a rendering instruction stream to the context tracking module.
S803: After receiving the rendering instruction stream, the context tracking module sets a restoration point based on rules and updates a local rendering context.
Specifically, the rules for setting a restoration point are consistent with the rules described in step S606.
It should be noted that when the context tracking module detects the network jitter, the server side does not generate a new restoration point anymore, but continues to update the local rendering context.
The foregoing is the basic process and the process that is used when a network jitter occurs according to embodiments of this application. On this basis, a method for restoring a rendering context by using a rendering context difference upon recovery from the network jitter is described in detail in the following by using specific embodiments. Embodiments are distinguished by using different manners of calculating and transferring a rendering context difference.
Embodiment 1: The context restoration module determines whether instruction stream numbers of all restoration points in the context tracking module include the instruction stream number last executed by the context restoration module. If the instruction stream number is included, the context restoration module converts a rendering context difference into a rendering instruction stream and sends the rendering instruction stream to the app client. In this implementation, after receiving a rendering instruction stream, the terminal first caches a rendering instruction stream between two restoration points without parsing and execution, and then performs one-time parsing and execution when a next restoration point arrives, thereby ensuring integrity upon recovery from the network jitter. Therefore, the instruction stream number last executed by the context restoration module is the same as an instruction stream number that is of the last restoration point and that is recorded by the context restoration module.
S901: The context tracking module detects recovery from the network jitter and calculates a rendering context difference.
Specifically, the context tracking module sends rendering context differences between a current rendering context and all restoration points to the context restoration module upon recovery from the network jitter. As shown in
ΔctxN=Ctx_current−Ctx_base−Δctx_rcyN_base
It should be noted that for a type of object that cannot be tracked or whose tracking costs are comparatively high, tracking may be lessened. Only a difference is tracked, and content of the difference is not tracked. In other words, the object type is marked as content not trackable, and the timestamp of the last change is marked. When difference comparison is performed, if timestamps are the same, it is considered that there is no difference; or if timestamps are different, it is considered that comparison cannot be performed, this feature cannot be used, and an original process is used for restoration.
S902: The context tracking module sends the rendering context difference to the context restoration module.
Specifically, the rendering context difference may be transferred by using a user-defined message structure, and the context restoration module converts the rendering context difference into a rendering instruction stream after receiving the rendering context difference. Alternatively, the context tracking module may first convert the rendering context difference into a rendering instruction stream and then send the rendering instruction stream to the context restoration module.
S903: The context restoration module determines whether a restoration point includes an instruction stream number generated when the network jitter occurs.
If the instruction stream number generated when the network jitter occurs is included, proceed to step S904.
If the instruction stream number generated when the network jitter occurs is not included, proceed to step S906.
Specifically, the context restoration module compares, based on rendering instruction stream execution performed by the context restoration module, the last executed rendering instruction stream number with a restoration point that is set by the context tracking module. If a restoration point whose rendering instruction stream number is the same as the last executed rendering instruction stream number can be found, a rendering context difference corresponding to the restoration point is selected for restoration, as shown in
S904: Determine whether the received rendering context difference is in a rendering instruction stream format.
If the received rendering context difference is in the rendering instruction stream format, proceed to step S908.
If the received rendering context difference is not in the rendering instruction stream format, proceed to step S905.
S905: Convert the received rendering context difference into a rendering instruction stream. Then proceed to step S908.
S906: Send a notification message to the context tracking module, indicating that the restoration point does not include the instruction stream number generated when the network jitter occurs. Then proceed to step S907.
S907: Perform restoration in an original manner. In other words, send all rendering instruction streams generated during the network jitter.
S908: Send the rendering instruction stream to the app client. Proceed to step S909.
S909: Perform image rendering and encoding by using a local GPU, to generate video stream information.
In the implementation of Embodiment 1 of this application, after recovery from the network jitter, the context tracking module needs to send only rendering context differences generated before and after the network jitter. In most cases, the quantity of rendering instruction streams corresponding to the rendering context differences is greatly reduced compared with the quantity of rendering instruction streams accumulated during the network jitter. Therefore, network traffic can be reduced and client recovery can be dramatically accelerated, thereby improving user experience.
Embodiment 2: Upon recovery from the network jitter, the context tracking module waits for the context restoration module to report, after the recovery from the network jitter, the instruction stream number last received by the context restoration module before the network jitter occurs; or the context tracking module proactively initiates a message to the context restoration module to query the instruction stream number last received by the context restoration module before the network jitter occurs. After obtaining the specific last instruction stream number, the context tracking module calculates a rendering context difference based on the last instruction stream number and sends the rendering context difference to the context restoration module.
It may be understood that, the context restoration module may send, when detecting the recovery from the network jitter, the instruction stream number last received by the context restoration module before the network jitter occurs, or may report the instruction stream number last received by the context restoration module before the network jitter occurs, when a connection between the context tracking module and the context restoration module is restored. As shown in
S1101: The context restoration module detects the recovery from the network jitter, and returns the last instruction stream number to the context tracking module.
S1102: The context tracking module finds a restoration point that is the closest to the last instruction stream and calculates a context difference between the restoration point and a current rendering context.
S1103: The context tracking module sends the rendering context difference to the context restoration module.
S1104: The context restoration module determines whether the received rendering context difference is in a rendering instruction stream format.
If the received rendering context difference is in the rendering instruction stream format, proceed to step S1106.
If the received rendering context difference is not in the rendering instruction stream format, proceed to step S1105.
S1105: Convert the rendering context difference into a rendering instruction stream. Then proceed to step S1106.
S1106: The context restoration module sends the rendering context difference instruction stream to the app client.
S1107: Perform image rendering and encoding by using a local GPU, to generate video stream information.
It may be understood that the context tracking module may query, upon recovery from the network jitter, the context restoration module for the instruction stream number last received by the context restoration module before the network jitter occurs. As shown in
S1201: The context tracking module detects the network recovery and queries the context restoration module for the last instruction stream number.
S1202: The context restoration module returns the last instruction stream number to the context tracking module.
Steps S1203 to S1208 are the same as steps S1102 to S1107 respectively.
S1203: The context tracking module finds a restoration point that is the closest to the last instruction stream and calculates a context difference between the restoration point and a current rendering context.
S1204: The context tracking module sends the rendering context difference to the context restoration module.
S1205: The context restoration module determines whether the received rendering context difference is in a rendering instruction stream format.
If the received rendering context difference is in the rendering instruction stream format, proceed to step S1207.
If the received rendering context difference is not in the rendering instruction stream format, proceed to step S1206.
S1206: Convert the rendering context difference into a rendering instruction stream. Then proceed to step S1207.
S1207: The context restoration module sends the rendering context difference instruction stream to the app client.
S1208: Perform image rendering and encoding by using a local GPU, to generate video stream information.
In this implementation, the context tracking module does not need to send context differences of all restoration points to the context restoration module, but only needs to find the restoration point the closest to the last instruction stream number and send the context difference corresponding to the closest restoration point to the context restoration module.
Embodiment 2 differs from Embodiment 1 in that a context difference between a corresponding instruction stream number obtained upon network jitter and the closest restoration point can be identified, and only a rendering context difference between a network jitter point and a latest rendering context is sent.
Embodiment 3: The context restoration module queries the context tracking module for restoration point information, or restoration point information is recorded in the context restoration module based on a rule for setting a restoration point. The context restoration module receives rendering context differences of all restoration points sent by the context tracking module, determines the closest restoration point, obtains, based on a rendering instruction stream between a recorded network jitter point and the closest restoration point, a context difference between the network jitter point and the closest restoration point, and then calculates a difference between the network jitter point and a current rendering context.
As shown in
Δctx_client=Δctx2−Δctx_rem
The process of Embodiment 3 is similar to the process of Embodiment 1, and a difference lies in processing of the context restoration module. In some embodiments of this application, the context restoration module needs to record restoration point information and the instruction stream number of the last rendering instruction stream executed by an electronic device. In this implementation, after receiving a rendering instruction stream, the context restoration module may parse and execute the rendering instruction stream in real time, and does not need to store a rendering instruction stream between two restoration points. Compared with the solution of Embodiment 1, storage space is saved, and the following problem is avoided: A rendering instruction stream is not executed in real time. In this implementation, the context restoration module can accurately identify an unexecuted rendering instruction stream each time recovery from a network jitter, and forward the rendering instruction stream to the app client for parsing and execution.
It should be noted that two sending modes are applied to the process of message exchange between the server and the terminal after recovery from the network jitter.
In one sending mode, the context tracking module no longer needs to send a context difference to the context restoration module, and a rendering instruction stream continues to be sent to the context restoration module by the app.
In the other sending mode, the app no longer sends a rendering instruction stream to the context restoration module, and the context tracking module forwards a rendering instruction stream.
The memory 860 may include a read-only memory and a random access memory, and provide instructions and data to the processor 820. The memory 860 may further include a non-volatile random access memory. The memory 860 may be a volatile memory or a non-volatile memory, or may include a volatile memory and a non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (programmable ROM, PROM), an erasable programmable read-only memory (erasable PROM, EPROM), an electrically erasable programmable read-only memory (electrically EPROM, EEPROM), or a flash memory. The volatile memory may be a random access memory ( ), and is used as an external cache. Through example but not limitative description, a plurality of forms of RAMs may be used, for example, a static random access memory (static RAM, SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (synchronous DRAM, SDRAM), a double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), an enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), a synchlink dynamic random access memory (synchlink DRAM, SLDRAM), and a direct rambus random access memory (direct rambus RAM, DR RAM).
The bus 850 may further include a power bus, a control bus, a status signal bus, and the like, in addition to a data bus.
It should be understood that the server 800 shown in
The electronic device 900 in
The electronic device shown in
The following describes each module of the electronic device 900 in
The communications module 910 may include at least one module that can enable the electronic device to communicate with another electronic device. For example, the communications module 910 may include one or more of a wired network interface, a broadcast receiving module, a mobile communications module, a wireless Internet module, a local area communications module, and a location (or positioning) information module. Embodiments of this application set no limitation on a communications generation, for example, the communications generation may be 2G, 3G, 4G, 5G, or another communications generation that emerges with development of technologies.
For example, the communications module 910 can obtain, from a game server end in real time, a rendering instruction required for rendering a game picture.
The sensor 920 may sense some operations of a user, and the sensor 920 may include a distance sensor, a touch sensor, and the like. The sensor 920 may sense an operation such as touching a screen or approaching a screen by the user.
For example, the sensor 920 can sense some operations of the user on a game interface.
The user input module 930 is configured to: receive input digit information, character information, or a contact touch operation/contactless gesture; and receive signal input related to user setting and function control of a system. The user input module 930 includes a touch panel and/or another input device. For example, the user may control a game by using the user input module 3030.
The output module 940 includes a display panel, configured to display information entered by the user, information provided for the user, various menu interfaces of the system, and the like.
Optionally, the display panel may be configured in a form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. In some other embodiments, the touch panel may cover the display panel to form a touch display screen.
In addition, the output module 940 may further include a video output module, an alarm, a tactile module, and the like. The video output module may display a game picture obtained after graphics rendering.
The power supply 980 may receive external power and internal power under control of the processor 950, and provide power required for running the modules in the electronic device.
The processor 950 may include one or more CPUs, and the processor 950 may further include one or more GPUs.
When the processor 950 includes a plurality of CPUs, the plurality of CPUs may be integrated into a same chip, or may be separately integrated into different chips.
When the processor 950 includes a plurality of GPUs, the plurality of GPUs may be integrated into a same chip, or may be separately integrated into different chips.
When the processor 950 includes both a CPU and a GPU, the CPU and the GPU may be integrated into a same chip.
For example, when the electronic device shown in
The memory 970 may store a computer program, and the computer program includes an operating system program 972, an application 971, and the like. A typical operating system is, for example, a system used in a tablet computer or a notebook computer, such as Windows of Microsoft or MacOS of Apple, and for another example, a system used in a mobile terminal, such as a Linux®-based Android (Android®) system developed by Google.
The memory 970 may be one or more of the following types: a flash memory, a memory of a hard disk type, a memory of a micro multimedia card type, a card-type memory (for example, an SD or XD memory), a random access memory (RAM), a static random access memory (static RAM, SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (programmable ROM, PROM), a magnetic memory, a magnetic disk, or an optical disc. In some other embodiments, the memory 970 may be a network storage device on the Internet. The system may perform an operation such as updating or reading on the memory 970 on the Internet.
For example, the memory 970 may store a computer program (the computer program is a program corresponding to the graphics rendering method in embodiments of this application). When the processor 950 executes the computer program, the processor 950 can perform the graphics rendering method in embodiments of this application.
The memory 970 further stores other data 973 in addition to the computer program. For example, the memory 970 may store data in a processing process of the graphics rendering method in this application.
A connection relationship between the modules in
A person of ordinary skill in the art may be aware that, in combination with the examples described in embodiments disclosed in this specification, units and algorithm steps can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by using hardware or software depends on a particular application and a design constraint condition of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.
All or a part of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When the software is used to implement embodiments, all or a part of embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the procedures or functions according to embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or another programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by the computer, or a data storage device, such as a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid state disk (SSD)), or the like.
The apparatus embodiment described above is merely an example. For example, the module division is merely logical function division. The units described as separate parts may or may not be physically separate. Some or all the modules may be selected based on actual needs to achieve the objectives of the solutions of embodiments. In addition, in the accompanying drawings of the apparatus embodiments provided in this application, modules may be communicatively connected by using one or more communications buses or signal lines. A person of ordinary skill in the art may understand and implement embodiments of the present invention without creative efforts.
The foregoing description is merely a specific implementation of this application, but is not intended to limit the protection scope of this application.
Number | Date | Country | Kind |
---|---|---|---|
202010118171.X | Feb 2020 | CN | national |
This application is a continuation of International Application No. PCT/CN2020/113666, filed on Sep. 7, 2020, which claims priority to Chinese Patent Application No. 202010118171.X, filed on Feb. 25, 2020. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.
Number | Name | Date | Kind |
---|---|---|---|
20110263332 | Mizrachi | Oct 2011 | A1 |
20180345140 | Posin | Dec 2018 | A1 |
Number | Date | Country |
---|---|---|
104618733 | May 2015 | CN |
108022286 | May 2018 | CN |
108310766 | Jul 2018 | CN |
110035328 | Jul 2019 | CN |
110083324 | Aug 2019 | CN |
110227259 | Sep 2019 | CN |
110711380 | Jan 2020 | CN |
110740380 | Jan 2020 | CN |
Number | Date | Country | |
---|---|---|---|
20220409999 A1 | Dec 2022 | US |
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2020/113666 | Sep 2020 | WO |
Child | 17895562 | US |