Method, apparatus and electronic device for graphics rendering
By decoupling the vertical synchronization dependency between rendering and display, pre-rendering is performed using the remaining time of short frames and assigned a virtual timestamp, thus solving the rendering latency and frame dropping issues caused by VSYNC, achieving an increase in frame rate and efficient utilization of CPU time.
Patent Information
- Application Number
- CN202510107877.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2044-04-30
AI Technical Summary
In existing technologies, vertical synchronization (VSYNC) forces the graphics processor to wait for the display to refresh before rendering the next frame, resulting in a reduced rendering frame rate and rendering latency, especially prone to frame drops when the load fluctuates.
By decoupling the vertical synchronization dependency between rendering and display, pre-rendering is performed using the remaining execution time of short frames, and virtual timestamps are assigned to the pre-rendered frames, thus achieving asynchronous parallelism between frame rendering and display.
It reduces frame drop rate and rendering latency, improves frame rate utilization, and reduces CPU time waste.
Smart Images

Figure CN120144081B_ABST
Abstract
Description
[0001] This application is a divisional application. The original application has the application number 202410539029.0 and the original application date is April 30, 2024. The entire contents of the original application are incorporated herein by reference. Technical Field
[0002] This application relates to the field of graphics rendering, and more specifically, to a method, apparatus, and electronic device for graphics rendering. Background Technology
[0003] Currently, electronic devices use vertical synchronization (VSYNC) technology to avoid screen tearing during display, thereby improving the smoothness and stability of the screen display.
[0004] However, VSYNC works by establishing a synchronization signal between the graphics processor (GPU) and the monitor. When the monitor begins its next refresh, it sends a VSYNC signal to the GPU, which then begins rendering the next frame upon receiving the signal. In other words, the GPU must wait for the monitor to finish refreshing before it can render the next frame. This can potentially lead to a lower frame rate and rendering delays, especially under heavy load, which can result in dropped frames and rendering latency. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for graphics rendering. This method, apparatus, and electronic device decouple the vertical synchronization dependency between rendering and display. Instead of waiting for the vertical synchronization signal to trigger frame execution, the remaining execution time of short frames can be used to pre-render subsequent frames, achieving asynchronous parallelism between frame rendering and display. This allows for the reuse of CPU time that would otherwise be wasted rendering short frames, reducing frame drop rate and rendering latency.
[0006] A first aspect provides a method for graphics rendering, applied to a graphics rendering apparatus including a decoupled vertical synchronization module and a rendering module. The method includes: within a vertical synchronization cycle, in response to the input of a first event, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, the first request message being used to request rendering of the next frame of the current rendering frame, the first instruction being used to instruct the rendering module to render the next frame of the current rendering frame, wherein the first opportune moment is before the moment of receiving the next vertical synchronization signal, and the first instruction is also used to indicate the display time of the next frame of the current rendering frame; after receiving the first instruction, the rendering module begins rendering the next frame of the current rendering frame.
[0007] In some embodiments, the vertical synchronization period is the time interval between the display of two adjacent frames; the vertical synchronization period can also be understood as the time interval between two consecutive refreshes of the display screen; the vertical synchronization period can also be understood as the time interval between the consecutive reception of two vertical synchronization signals.
[0008] The next frame of the current rendering frame can refer to the next frame of the frame that the rendering module has completed rendering. The current rendering frame can be the next frame of the current display frame or the previous pre-rendered frame; the current rendering frame has not yet been displayed on the device screen.
[0009] In some embodiments, the first event may be a user input event at the application layer, such as a user swipe event or an event of opening the APP; the first event may also be an event in which the rendering module finishes rendering the current frame and requests to render the next frame.
[0010] It should be noted that the number of first events input within a vertical synchronization cycle is not limited; it can be one or more. Correspondingly, the number of frames rendered by the rendering module within a vertical synchronization cycle can be zero, one, or more.
[0011] In one example, within one vertical synchronization cycle:
[0012] In response to the input of the first first event, the decoupled vertical synchronization module sends the first first instruction to the rendering module at the first moment within the vertical synchronization cycle. Assuming that the rendering module has just finished rendering the first frame, the first first instruction is used to instruct the rendering module to render the second frame. The first first instruction is also used to indicate the display time of the second frame.
[0013] In response to the input of the second first event, the decoupled vertical synchronization module sends a second first instruction to the rendering module at the second moment within the vertical synchronization cycle. The second first instruction is used to instruct the rendering module to render the third frame, and the second first instruction is also used to indicate the display time of the third frame.
[0014] Similarly, only one frame can be displayed within a vertical synchronization cycle, but the rendering module can render multiple frames, i.e., it can pre-render frames. The number of frames rendered within a vertical synchronization cycle is not fixed and is affected by factors such as the length of the frame and the length of the vertical synchronization cycle. It can also be understood that the frame rendering process in the solution provided in this application embodiment is not constrained by the vertical synchronization cycle and the vertical synchronization signal.
[0015] In some embodiments, the first instruction indicates the display time of the next frame of the current rendered frame in the following way: the first instruction carries a first virtual timestamp, which is used to indicate the display time of the next frame of the current rendered frame.
[0016] Virtual timestamps refer to a virtual future time.
[0017] The vertical synchronization signal is used to indicate the next frame to be displayed. In this embodiment, by pre-rendering the frame and assigning a virtual display time to the pre-rendered frame, the vertical synchronization dependency between rendering and display can be decoupled. It is not necessary to wait for the vertical synchronization signal to trigger the frame execution. The remaining execution time of the short frame can be used to pre-render subsequent frames, realizing asynchronous parallelism between frame rendering and display. The CPU time that would otherwise be wasted rendering short frames can be reused, reducing frame drop rate and rendering latency.
[0018] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, including: the decoupled vertical synchronization module receiving a first request message, the first request message being used to request rendering the next frame of the current rendering frame; the decoupled vertical synchronization module sending the first instruction to the rendering module at a first opportune moment according to the current scene.
[0019] The current scene includes one of the following: an animated scene (which can also be described as a continuous animated scene), a non-animated scene (which can also be described as a continuous non-animated scene), an animated-to-non-animated scene, or a non-animated-to-animated scene.
[0020] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment based on the current scene, including: when the current scene is an animated scene or a non-animated scene, the decoupled vertical synchronization module sends the first instruction to the rendering module.
[0021] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment based on the current scene. This includes: when the current scene is transitioning from an animation to a non-animation scene, the decoupled vertical synchronization module waits to receive a non-animation request; if a non-animation request is received within m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module upon receiving the non-animation request; if no non-animation request is received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module at the end of the m vertical synchronization cycles. Here, the starting point of the m vertical synchronization cycles is the moment when the decoupled vertical synchronization module receives the first request message, and m is any value greater than 1 and less than or equal to 2.
[0022] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment based on the current scene. This includes: when the current scene is a non-animation-to-animation scene, the decoupled vertical synchronization module waits to receive an animation request; if an animation request is received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module upon receiving the animation request; if no animation request is received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module at the end of the m vertical synchronization cycles.
[0023] In some examples, the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.
[0024] This implementation method can also be described as:
[0025] When the current scene is either an animated or non-animated scene, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the first request message. When the current scene transitions from an animated to a non-animated scene, the decoupled vertical synchronization module starts waiting upon receiving the first request message, with a maximum waiting time set to m vertical synchronization cycles. If a non-animated request is received before the current waiting time is less than m vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the non-animated request. If no non-animated request is received before the current waiting time reaches m vertical synchronization cycles, the decoupled vertical synchronization module... When the waiting time reaches m vertical synchronization cycles, a first instruction is sent to the rendering module. When the current scene is a non-animation to animation transition scene, the decoupled vertical synchronization module starts waiting upon receiving the first request message, with a maximum waiting time set to m vertical synchronization cycles. If an animation request is received before the current waiting time is less than m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module upon receiving the animation request. If no animation request is received before the current waiting time reaches m vertical synchronization cycles, the decoupled vertical synchronization module sends a first instruction to the rendering module after the current waiting time reaches m vertical synchronization cycles.
[0026] It can be understood that if the current scene is an animated scene or a non-animated scene, the decoupled vertical synchronization module immediately sends the first instruction to the rendering module. Determining whether the current scene is an animated scene or a non-animated scene can be understood as the trigger condition for sending the first instruction to the rendering module. When the trigger condition is met, the first instruction is sent to the rendering module. There is no time interval or the time interval is extremely short between the two actions of "determining whether the current scene is an animated scene or a non-animated scene" and "sending the first instruction to the rendering module".
[0027] In this embodiment, the timing of the decoupled vertical synchronization module sending the first instruction to the rendering module may differ in different scenarios. It does not require waiting for the vertical synchronization signal to trigger frame execution; the remaining execution time of the short frame can be used to pre-render subsequent frames, and a virtual timestamp can be assigned to each pre-rendered frame to represent its display time. This decouples the vertical synchronization dependency between rendering and display, enabling asynchronous parallelism between frame rendering and display. It also allows for the reuse of CPU time that would otherwise be wasted rendering short frames, reducing frame drop rate and rendering latency.
[0028] In conjunction with the first aspect, in one possible implementation, the method further includes: the decoupled vertical synchronization module determines the current scene based on a first parameter carried by the first request message, the first parameter being used to indicate the type of the first request message, the type of the first request message including an animation request or a non-animation request, the animation request coming from the rendering module, and the non-animation request coming from the application module.
[0029] Specifically, the decoupled vertical synchronization module determines the current scenario based on the first parameter carried in the first request message and the parameter carried in the request message received in the previous vertical synchronization cycle.
[0030] In this embodiment of the application, the request message for requesting the execution of the next frame carries a parameter indicating the type of the request message, so that the decoupled vertical synchronization module can determine the first timing for sending the first instruction to the rendering module based on the parameter, thus providing a basis for the pre-rendering of the frame.
[0031] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module determines the current scene based on the first parameter carried by the first request message, including: when the first request message is an animation request and no non-animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines the current scene as an animation scene, where the vertical synchronization cycle is the time interval between the display of two adjacent frames; when the first request message is an animation request and a non-animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines the current scene as an animation-to-non-animation scene; when the first request message is a non-animation request and all request messages received in the previous vertical synchronization cycle are non-animation requests, or when the first request message is a non-animation request and no request message was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines the current scene as a non-animation scene; when the first request message is a non-animation request and an animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines the current scene as a non-animation-to-animation scene.
[0032] In conjunction with the first aspect, in one possible implementation, the method further includes: the decoupled vertical synchronization module determines the display time of the next frame of the current rendering frame based on the display time of the current display frame and the vertical synchronization period.
[0033] The display time of the next frame can be a virtual timestamp.
[0034] In this embodiment of the application, by assigning a virtual timestamp to the pre-rendered frame to represent its display time, the vertical synchronization dependency between rendering and display can be decoupled, so that the execution of the frame can be triggered without waiting for the vertical synchronization signal.
[0035] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, including: when the difference between the display time of the next frame of the current rendered frame and the current real time is less than or equal to X vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment, where X is a positive integer greater than or equal to 1.
[0036] In some embodiments, when the difference between the first virtual timestamp and the current real timestamp is greater than X vertical synchronization cycles, the system waits for the next vertical synchronization signal from the compositing and display module, and after receiving the next vertical synchronization signal, sends a first instruction to the rendering module.
[0037] In this embodiment of the application, by controlling the difference between the virtual timestamp corresponding to the pre-rendered frame and the current real timestamp to be less than a preset value, the number of pre-rendered frames can be controlled to be less than a preset number. In this way, the waste of storage resources caused by too many pre-rendered frames can be avoided. Furthermore, when the number of pre-rendered frames is too large, the accuracy of the pre-rendered frames may decrease. Controlling the number of pre-rendered frames to be less than a preset number can also improve the accuracy of the pre-rendered frames.
[0038] In conjunction with the first aspect, in one possible implementation, the method further includes: the rendering module adding the next frame of the currently rendered frame to a buffer queue as a buffer frame in the buffer queue, so that the compositing and display module obtains the next frame of the current display frame from multiple buffer frames in the buffer queue in each vertical synchronization cycle.
[0039] In some embodiments, the rendering module adds the next frame of the rendered current frame to the buffer queue in a first-in-first-out order. Correspondingly, the compositing and display module retrieves the next frame of the current display frame from multiple buffer frames in the buffer queue in a first-in-first-out order during each vertical synchronization cycle, for example, at the beginning of each vertical synchronization cycle.
[0040] In conjunction with the first aspect, in one possible implementation, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, including: the decoupled vertical synchronization module queries the number of buffers in the buffer queue; when the number of buffers in the buffer queue is less than the maximum number of buffers, the decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment.
[0041] In some embodiments, the decoupled vertical synchronization module sends a first query message to the buffer queue, the first query message being used to query the number of buffers in the buffer queue.
[0042] In conjunction with the first aspect, in one possible implementation, the method further includes: when the number of buffers in the buffer queue is greater than or equal to the maximum number of buffers, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the next vertical synchronization signal.
[0043] Specifically, when the number of buffers in the buffer queue is greater than or equal to the maximum number of buffers, the decoupled vertical synchronization module waits for the next vertical synchronization signal from the compositing and display module; when the decoupled vertical synchronization module receives the next vertical synchronization signal, it sends the first instruction to the rendering module.
[0044] In this embodiment of the application, by controlling the number of pre-rendered frames in the buffer queue to be less than a preset number, the waste of storage resources caused by too many pre-rendered frames can be avoided. Furthermore, when the number of pre-rendered frames is too large, the accuracy of the pre-rendered frames may decrease. Controlling the number of pre-rendered frames to be less than a preset number can also improve the accuracy of the pre-rendered frames.
[0045] In conjunction with the first aspect, in one possible implementation, the device further includes an event state prediction module. After the first event is input, the method further includes: the event state prediction module predicts the state of the first event to update the state of the first event to an event state corresponding to the display time of the next frame.
[0046] In this embodiment of the application, when pre-rendering a frame in response to an event, the event state is predicted before the event is transmitted, and the current state of the event is modified to the state corresponding to the display time of the pre-rendered frame, which can improve the accuracy of the frame pre-rendering.
[0047] In conjunction with the first aspect, in one possible implementation, the decoupling vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, including: when the scene corresponding to the first event is a first scene, the decoupling vertical synchronization module starts the decoupling vertical synchronization process; when the decoupling vertical synchronization process is started, the decoupling vertical synchronization module sends a first instruction to the rendering module at the first opportune moment.
[0048] The first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.
[0049] In some embodiments, the first scenario includes one or more of the following: list scrolling, opening an application, opening a folder, opening the control center, opening the notification center, unlocking, screen rotation, and transitions between applications.
[0050] In this embodiment, the decoupled vertical synchronization module is activated to execute the graphics rendering process only when the current scenario involves load fluctuations or heavy loads. The remaining execution time of short frames can be used to pre-render subsequent frames, achieving asynchronous parallelism between frame rendering and display delivery. This reuses the CPU time that would otherwise be wasted rendering short frames, reducing frame drop rate and rendering latency.
[0051] In conjunction with the first aspect, in one possible implementation, the device further includes a vertical synchronization module, and the method further includes: when the current scene changes to a non-first scene, the decoupling vertical synchronization module shuts down the decoupling vertical synchronization process; when the decoupling vertical synchronization process is shut down, the vertical synchronization module sends a second instruction to the rendering module upon receiving the next vertical synchronization signal, the second instruction being used to instruct the rendering module to render the next frame of the current display frame; after receiving the second instruction, the rendering module begins rendering the next frame of the current display frame.
[0052] In this embodiment, when the current scene does not require frame pre-rendering (i.e., there is no load fluctuation or heavy load), the decoupled vertical synchronization process is turned off, and the graphics rendering process is executed by the vertical synchronization module. Each time the vertical synchronization module receives a vertical synchronization signal from the compositing and display thread, it instructs the rendering module to start rendering the next frame, without pre-rendering the frame. This enables the decoupling of the vertical synchronization module and scene-based cooperation between them, allowing the solution to be applied to more scenarios.
[0053] Secondly, a graphics rendering apparatus is provided, comprising a decoupled vertical synchronization module and a rendering module. The decoupled vertical synchronization module includes a pre-execution module. Specifically, the pre-execution module is configured to, within a vertical synchronization cycle, in response to the input of a first event, send a first instruction to the rendering module at a first opportune moment. The first request message is used to request the rendering of the next frame of the current rendering frame, and the first instruction is used to instruct the rendering module to render the next frame of the current rendering frame. The first opportune moment is before the moment when the next vertical synchronization signal is received, and the first instruction is also used to indicate the display time of the next frame of the current rendering frame. The rendering module is configured to start rendering the next frame of the current rendering frame after receiving the first instruction.
[0054] The next frame of the current rendering frame can refer to the next frame of the frame that the rendering module has completed rendering. The current rendering frame can be the next frame of the current display frame or the previous pre-rendered frame; the current rendering frame has not yet been displayed on the device screen.
[0055] In some embodiments, the first event may be a user input event at the application layer, such as a user swipe event or an event of opening the APP; the first event may also be an event in which the rendering module finishes rendering the current frame and requests to render the next frame.
[0056] It should be noted that the number of first events input within a vertical synchronization cycle is not limited; it can be one or more. Correspondingly, the number of frames rendered by the rendering module within a vertical synchronization cycle can be zero, one, or more.
[0057] In one example, within one vertical synchronization cycle:
[0058] In response to the input of the first first event, the pre-execution module sends the first first instruction to the rendering module at the first moment within the vertical synchronization cycle. Assuming that the rendering module has just finished rendering the first frame, the first first instruction is used to instruct the rendering module to render the second frame. The first first instruction is also used to indicate the display time of the second frame.
[0059] In response to the input of the second first event, the pre-execution module sends a second first instruction to the rendering module at the second moment within the vertical synchronization cycle. The second first instruction is used to instruct the rendering module to render the third frame, and the second first instruction is also used to indicate the display time of the third frame.
[0060] Similarly, only one frame can be displayed within a vertical synchronization cycle, but the rendering module can render multiple frames, i.e., it can pre-render frames. The number of frames rendered within a vertical synchronization cycle is not fixed and is affected by factors such as the length of the frame and the length of the vertical synchronization cycle. It can also be understood that the frame rendering process in the solution provided in this application embodiment is not constrained by the vertical synchronization cycle and the vertical synchronization signal.
[0061] In some embodiments, the first instruction indicates the display time of the next frame of the current rendered frame in the following way: the first instruction carries a first virtual timestamp, which is used to indicate the display time of the next frame of the current rendered frame.
[0062] Virtual timestamps refer to a virtual future time.
[0063] The vertical synchronization signal is used to indicate that the next frame of the current display frame will be displayed.
[0064] In this embodiment, by pre-rendering the frame and assigning a virtual display time to the pre-rendered frame, the vertical synchronization dependency between rendering and display can be decoupled. There is no need to wait for the vertical synchronization signal to trigger the execution of the frame. The remaining execution time of the short frame can be used to pre-render subsequent frames, realizing asynchronous parallelism between frame rendering and display. The CPU time that was originally wasted on rendering short frames can be reused, reducing the frame drop rate and rendering latency.
[0065] In conjunction with the second aspect, in one possible implementation, the pre-execution module is specifically used to: receive a first request message, which requests the rendering of the next frame of the current rendering frame; and send the first instruction to the rendering module at a first opportune moment, based on the current scene.
[0066] The current scene includes one of the following: an animated scene (which can also be described as a continuous animated scene), a non-animated scene (which can also be described as a continuous non-animated scene), an animated-to-non-animated scene, or a non-animated-to-animated scene.
[0067] In conjunction with the second aspect, in one possible implementation, the pre-execution module is also specifically used to send the first instruction to the rendering module when the current scene is an animated scene or a non-animated scene.
[0068] In conjunction with the second aspect, in one possible implementation, the pre-execution module is further specifically used for: when the current scene is transitioning from animation to non-animation, waiting to receive a non-animation request; if a non-animation request is received within m vertical synchronization cycles, then a first instruction is sent to the rendering module upon receiving the non-animation request; if no non-animation request is received within the m vertical synchronization cycles, then a first instruction is sent to the rendering module at the end of the m vertical synchronization cycles, wherein the timing start point of the m vertical synchronization cycles is the moment when the first request message is received, and m is any value greater than 1 and less than or equal to 2.
[0069] In conjunction with the second aspect, in one possible implementation, the pre-execution module is also specifically used for: when the current scene is a non-animation to animation scene, waiting to receive an animation request; if an animation request is received within the m vertical synchronization cycles, then sending a first instruction to the rendering module upon receiving the animation request; if no animation request is received within the m vertical synchronization cycles, then sending a first instruction to the rendering module at the end of the m vertical synchronization cycles.
[0070] In some examples, the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.
[0071] It can be understood that if the current scene is an animated scene or a non-animated scene, the pre-execution module immediately sends the first instruction to the rendering module. Determining whether the current scene is an animated scene or a non-animated scene can be understood as the trigger condition for sending the first instruction to the rendering module. When the trigger condition is met, the first instruction is sent to the rendering module. There is no time interval between the two actions of "determining whether the current scene is an animated scene or a non-animated scene" and "sending the first instruction to the rendering module".
[0072] In this embodiment, the timing of the decoupled vertical synchronization module sending the first instruction to the rendering module may differ in different scenarios. It is not necessary to wait for the vertical synchronization signal to trigger the execution of the frame. The remaining execution time of the short frame can be used to pre-render subsequent frames, and a virtual timestamp can be assigned to the pre-rendered frame to indicate its display time. This can decouple the vertical synchronization dependency between rendering and display, realize asynchronous parallelism between frame rendering and display, and reuse the CPU time that was originally wasted on rendering short frames, thereby reducing frame drop rate and rendering latency.
[0073] In conjunction with the second aspect, in one possible implementation, the pre-execution module is further specifically used to: determine the current scene based on the first parameter carried by the first request message, the first parameter being used to indicate the type of the first request message, the type of the first request message including animation request or non-animation request, animation request coming from the rendering module, and non-animation request coming from the application module.
[0074] Specifically, the decoupled vertical synchronization module determines the current scenario based on the first parameter carried in the first request message and the parameter carried in the request message received in the previous vertical synchronization cycle.
[0075] In this embodiment of the application, the request message for requesting the execution of the next frame carries a parameter indicating the type of the request message, so that the decoupled vertical synchronization module can determine the first timing for sending the first instruction to the rendering module based on the parameter, thus providing a basis for the pre-rendering of the frame.
[0076] In conjunction with the second aspect, in one possible implementation, the pre-execution module is specifically used to: determine that the current scene is an animation scene when the first request message is an animation request and no non-animation request was received in the previous vertical synchronization cycle, where the vertical synchronization cycle is the time interval between the display of two adjacent frames; determine that the current scene is an animation-to-non-animation scene when the first request message is an animation request and a non-animation request was received in the previous vertical synchronization cycle; determine that the current scene is a non-animation scene when the first request message is a non-animation request and all request messages received in the previous vertical synchronization cycle are non-animation requests, or when the first request message is a non-animation request and no request message was received in the previous vertical synchronization cycle; and determine that the current scene is a non-animation-to-animation scene when the first request message is a non-animation request and an animation request was received in the previous vertical synchronization cycle.
[0077] In conjunction with the second aspect, in one possible implementation, the decoupled vertical synchronization module further includes a virtual time module, used to determine the display time of the next frame of the current rendering frame based on the display time of the current display frame and the vertical synchronization period.
[0078] The display time of the next frame can be a virtual timestamp.
[0079] In this embodiment of the application, by assigning a virtual timestamp to the pre-rendered frame to represent its display time, the vertical synchronization dependency between rendering and display can be decoupled, so that the execution of the frame can be triggered without waiting for the vertical synchronization signal.
[0080] In conjunction with the second aspect, in one possible implementation, the pre-execution module is further specifically used to: send the first instruction to the rendering module at a first opportune moment when the difference between the display time of the current rendered frame and the current real time is less than or equal to X vertical synchronization cycles, where X is a positive integer greater than or equal to 1.
[0081] In some embodiments, the pre-execution module is further configured to: wait for the next vertical synchronization signal from the compositing and display module when the difference between the display time of the next frame of the current rendered frame and the current real time is greater than X vertical synchronization cycles, and send a first instruction to the rendering module after receiving the next vertical synchronization signal.
[0082] In this embodiment of the application, by controlling the difference between the virtual timestamp corresponding to the pre-rendered frame and the current real timestamp to be less than a preset value, the number of pre-rendered frames can be controlled to be less than a preset number. In this way, the waste of storage resources caused by too many pre-rendered frames can be avoided. Furthermore, when the number of pre-rendered frames is too large, the accuracy of the pre-rendered frames may decrease. Controlling the number of pre-rendered frames to be less than a preset number can also improve the accuracy of the pre-rendered frames.
[0083] In conjunction with the second aspect, in one possible implementation, the rendering module is further configured to: add the next frame of the currently rendered frame that has been rendered to a buffer queue as a buffer frame in the buffer queue, so that the compositing and display module can obtain the next frame of the current display frame from multiple buffer frames in the buffer queue in each vertical synchronization cycle.
[0084] In some embodiments, the rendering module adds the next frame of the rendered current frame to the buffer queue in a first-in-first-out order. Correspondingly, the compositing and display module retrieves the next frame of the current display frame from multiple buffer frames in the buffer queue in a first-in-first-out order during each vertical synchronization cycle, for example, at the beginning of each vertical synchronization cycle.
[0085] In conjunction with the second aspect, in one possible implementation, the pre-execution module is further specifically used to: query the number of buffers in the buffer queue; and when the number of buffers in the buffer queue is less than the maximum number of buffers, send the first instruction to the rendering module at the first opportune moment.
[0086] In some embodiments, the pre-execution module sends a first query message to the buffer queue, the first query message being used to query the number of buffers in the buffer queue.
[0087] In conjunction with the second aspect, in one possible implementation, the pre-execution module is further configured to: send the first instruction to the rendering module upon receiving the next vertical synchronization signal when the number of buffers in the buffer queue is greater than or equal to the maximum number of buffers.
[0088] Specifically, when the number of buffers in the buffer queue is greater than or equal to the maximum number of buffers, the pre-execution module waits for the next vertical synchronization signal from the compositing and display module; when the pre-execution module receives the next vertical synchronization signal, it sends the first instruction to the rendering module.
[0089] In this embodiment of the application, by controlling the number of pre-rendered frames in the buffer queue to be less than a preset number, the waste of storage resources caused by too many pre-rendered frames can be avoided. Furthermore, when the number of pre-rendered frames is too large, the accuracy of the pre-rendered frames may decrease. Controlling the number of pre-rendered frames to be less than a preset number can also improve the accuracy of the pre-rendered frames.
[0090] In conjunction with the second aspect, in one possible implementation, the device further includes: an event state prediction module, used to predict the state of the first event after the first event is input, so as to update the state of the first event to the event state corresponding to the display time of the next frame.
[0091] In this embodiment of the application, when pre-rendering a frame in response to an event, the event state is predicted before the event is transmitted, and the current state of the event is modified to the state corresponding to the display time of the pre-rendered frame, which can improve the accuracy of the frame pre-rendering.
[0092] In conjunction with the second aspect, in one possible implementation, the decoupled vertical synchronization module further includes a control module, which is used to initiate the decoupled vertical synchronization process when the scene corresponding to the first event is the first scene; the pre-execution module is specifically used to send a first instruction to the rendering module at a first opportune moment when the decoupled vertical synchronization process is initiated.
[0093] The first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.
[0094] In some embodiments, the first scenario includes one or more of the following: list scrolling, opening an application, opening a folder, opening the control center, opening the notification center, unlocking, screen rotation, and transitions between applications.
[0095] In this embodiment, the decoupled vertical synchronization module is activated to execute the graphics rendering process only when the current scenario is a scenario with load fluctuations or a scenario with heavy load. It can use the remaining execution time of the short frame to pre-render subsequent frames, realize asynchronous parallelism of frame rendering and display, and reuse the CPU time that was originally wasted on rendering short frames, thereby reducing frame drop rate and rendering latency.
[0096] In conjunction with the second aspect, in one possible implementation, the control module is further configured to: shut down the decoupled vertical synchronization process when the current scene changes to a non-first scene; the device further includes: a vertical synchronization module, configured to send a second instruction to the rendering module upon receiving the vertical synchronization signal when the decoupled vertical synchronization process is shut down, the second instruction being used to instruct the rendering module to render the next frame of the current display frame; the rendering module is further configured to: start rendering the next frame of the current display frame after receiving the second instruction.
[0097] In this embodiment, when the current scene does not require frame pre-rendering (i.e., there is no load fluctuation or heavy load), the decoupled vertical synchronization process is turned off, and the graphics rendering process is executed by the vertical synchronization module. Each time the vertical synchronization module receives a vertical synchronization signal from the compositing and display thread, it instructs the rendering module to start rendering the next frame, without pre-rendering the frame. This decouples the vertical synchronization module and the scene-based cooperation between them, enabling the graphics rendering apparatus provided in this application to be used in more scenarios.
[0098] Thirdly, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store computer program code, and the processor is used to execute the computer program code stored in the memory to implement the method in the first aspect or any possible implementation thereof.
[0099] Fourthly, a computer-readable storage medium is provided, which stores a computer program or instructions that, when executed, implement the method described in the first aspect or any possible implementation thereof.
[0100] Fifthly, a chip is provided, wherein instructions are stored that, when executed on a device, cause the chip to perform the methods of the first aspect or any possible implementation thereof.
[0101] In a sixth aspect, a computer program product is provided, which stores a computer program or instructions that, when executed, implement the method in the first aspect or any possible implementation of the first aspect. Attached Figure Description
[0102] Figure 1 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;
[0103] Figure 2 This is a software structure block diagram of an electronic device provided in an embodiment of this application;
[0104] Figure 3This is a schematic diagram of a VSYNC architecture;
[0105] Figure 4 This is a schematic diagram of the rendering architecture corresponding to the VSYNC architecture;
[0106] Figure 5 This is a schematic diagram of another rendering architecture corresponding to the VSYNC architecture;
[0107] Figure 6 This is a schematic flowchart illustrating a graphics rendering method provided in an embodiment of this application;
[0108] Figure 7 This is a schematic interactive diagram illustrating a graphics rendering method provided in an embodiment of this application;
[0109] Figure 8 This is a schematic interactive diagram illustrating yet another graphics rendering method provided in an embodiment of this application;
[0110] Figure 9 This is a schematic diagram of a graphics rendering system architecture provided in an embodiment of this application;
[0111] Figure 10 This is a schematic diagram of another graphics rendering system architecture provided in the embodiments of this application;
[0112] Figure 11 This is a schematic diagram illustrating the principle of controller control of decoupled vertical synchronous opening and closing provided in an embodiment of this application;
[0113] Figure 12 This is a schematic diagram illustrating the principle of a pre-executor sending a first instruction to a rendering module, as provided in an embodiment of this application.
[0114] Figure 13 This is a schematic diagram illustrating the principle of a virtual timer determining a virtual timestamp, as provided in an embodiment of this application.
[0115] Figure 14 This is a schematic diagram illustrating the principle of an input event prediction module predicting the state of an input event, as provided in an embodiment of this application.
[0116] Figure 15 This is a comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in the embodiments of this application;
[0117] Figure 16 This is a test result image of the average pixel difference in a first scenario provided by an embodiment of this application, namely continuous fast scrolling, alternating fast scrolling, and slow scrolling. Detailed Implementation
[0118] The technical solutions of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments.
[0119] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "plural" or "multiple" refers to two or more than two.
[0120] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.
[0121] The terminology used in the following embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to also include expressions such as “one or more,” unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, “at least one” and “one or more” refer to one, two, or more than two. The term “and / or” is used to describe the relationship between related objects, indicating that three relationships may exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship.
[0122] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "one embodiment," "some embodiments," "another embodiment," "other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0123] The method provided in this application can be applied to electronic devices with display functions, such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), smart home devices, and other electronic devices. This application does not impose any restrictions on the specific type of electronic device.
[0124] For example, Figure 1 A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0125] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0126] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0127] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0128] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0129] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, and / or a universal serial bus (USB) interface, etc.
[0130] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0131] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0132] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0133] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0134] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0135] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0136] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0137] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0138] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0139] Figure 2 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.
[0140] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0141] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0142] like Figure 2 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0143] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0144] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0145] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0146] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0147] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0148] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0149] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0150] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0151] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0152] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0153] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0154] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0155] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0156] A 2D graphics engine is a graphics engine for 2D drawing.
[0157] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0158] It should be understood that the technical solutions in the embodiments of this application can be used in systems such as Android, iOS, and HarmonyOS.
[0159] The technical solutions of this application embodiment can be applied to the graphics rendering process of electronic devices to improve the smoothness and stability of the screen display of electronic devices.
[0160] Among them, electronic devices can be televisions, desktop computers, laptops, or portable electronic devices such as mobile phones, foldable screens, tablets, cameras, camcorders, and video recorders. They can also be smart home devices such as refrigerators, washing machines, robot vacuums, and any other electronic devices with display functions. They can also be electronic devices in 5G networks or in future evolved public land mobile networks (PLMNs).
[0161] The following section will introduce the relevant terms used in the embodiments of this application.
[0162] 1. Vertical Synchronization (VSYNC)
[0163] Vertical sync (V-Sync) is a graphics card setting used in games to address the "screen tearing" issue. Screen tearing occurs when a game's frame rate exceeds the monitor's refresh rate, causing the monitor to display only a portion of the frames at a time, resulting in a discontinuous vertical display that appears as if the image is "ripped." When V-Sync is enabled, the graphics card limits the game's frame rate based on the monitor's refresh rate. For example, if the monitor's refresh rate is 60Hz, the graphics card will limit the game's frame rate to no more than 60 frames per second. This ensures that the graphics card outputs a complete frame each time the monitor refreshes, thus preventing screen tearing.
[0164] 2. Decoupled Vertical Synchronization (D-VSYNC)
[0165] Decoupling vertical synchronization decouples the VSYNC dependency between frame rendering and display. For example, it can decouple the VSYNC dependency between the rendering thread and the compositing / display thread, or between the rendering thread and the UI thread. Currently, electronic devices use vertical synchronization (VSYNC) technology to avoid screen tearing during use, thereby improving the smoothness and stability of screen display.
[0166] For example, Figure 3 A schematic diagram of a VSYNC architecture is shown.
[0167] like Figure 3 As shown, in the VSYNC architecture, the UI thread maintains frame synchronization with the rendering thread. This occurs during the first VSYNC cycle of the app's rendering (i.e.,...). Figure 3 When the VSYNC-app shown in the diagram begins, the VSYNC signal wakes up the Choreographer, triggering the UI thread to draw the first frame; after the first frame is drawn, the rendering thread immediately begins rendering the first frame; then, in the second VSYNC cycle of the composite display (i.e., Figure 3 The compositing display thread is triggered to composite the first frame at the start of the VSYNC-sf shown in the diagram, and in the third VSYNC cycle of the display (i.e., Figure 3 When HW-VSYNC (as shown in the diagram) begins, the first frame is displayed on the screen of the electronic device.
[0168] One crucial point to note is that when the compositing thread is triggered to composite the second frame at the start of the third VSYNC cycle of the compositing display, the rendering thread has not yet completed rendering the second frame. Since the rendering thread for the second frame occupies two VSYNC cycles, the second frame cannot be composited during the third VSYNC cycle. It must wait until the second frame is rendered before the compositing thread can composite it at the start of the fourth VSYNC cycle. Consequently, the second frame only appears on the electronic device screen at the start of the fifth VSYNC cycle, resulting in no frame being displayed during the fourth VSYNC cycle. In other words, because the second frame is a long frame, a frame drop occurs in the fourth VSYNC cycle. And this pattern continues, with the third frame only appearing on the screen at the start of the sixth VSYNC cycle. If multiple long frames like the second frame subsequently appear, it will exacerbate the rendering frame drops and latency.
[0169] Choreographer's primary role is to work in conjunction with VSYNC to provide a stable information processing opportunity for the upper-layer app's rendering. Specifically, when VSYNC arrives, the system controls the timing of each frame's rendering operation by adjusting the VSYNC signal period. For example, if the phone's refresh rate is 60Hz (16.6ms), the system can set the VSYNC period to 16.6ms to match the screen's refresh rate. Every 16.6ms, the VSYNC signal wakes up Choreographer to perform the app's rendering operations; this is the main function of introducing Choreographer.
[0170] For example, taking the Android system as an example, Figure 4 A schematic diagram of the rendering architecture corresponding to the VSYNC architecture is shown.
[0171] like Figure 4 As shown, the system adopts a separate rendering architecture, with the UI thread and the compositing and display thread running according to the VSYNC beat. When frame N is displayed on the screen, VSYNC-sf can drive the compositing and display thread to compose frame N+1, and VSYNC-app can drive the UI thread to execute frame N+2.
[0172] For example, the compositing and display thread can be SurfaceFlinger. SurfaceFlinger performs compositing, scaling, or blending on the rendered image and then hands it over to the CPU or GPU for rendering. In other words, after receiving the vertical synchronization signal, SurfaceFlinger retrieves the rendered frames from the frame buffer queue, performs compositing and other processing, and then displays them.
[0173] For example, Figure 5 This shows a schematic diagram of another rendering architecture corresponding to the VSYNC architecture.
[0174] like Figure 5 As shown, the system adopts a unified rendering architecture, with the UI thread and rendering thread running according to the VSYNC timing. When frame N is displayed on the screen, VSYNC-rs can drive the rendering thread to render frame N+1, and VSYNC-app can drive the UI thread to execute frame N+2. Here, VSYNC-rs refers to the vertical synchronization signal received by the rendering thread, used to indicate the rendering of the next frame; VSYNC-sf refers to the vertical synchronization signal received by the compositing and display thread, used to indicate the compositing of the next frame; and VSYNC-app refers to the vertical synchronization signal received by the UI thread, used to indicate the execution of the next frame.
[0175] VSYNC works by establishing a synchronization signal (VSYNC signal) between the graphics processor (GPU) and the monitor. When the monitor begins its next refresh, it sends a VSYNC signal to the GPU. Upon receiving the VSYNC signal, the GPU begins rendering the next frame. In other words, the GPU must wait for the monitor to finish refreshing before it can render the next frame. This can potentially lead to a decrease in the rendering frame rate and rendering delays, especially under conditions of high load fluctuations, which can easily result in dropped frames and rendering latency.
[0176] In order to clearly understand the solution of this application, the rendering and display trajectories of several scenarios will be analyzed below.
[0177] (1) For swipe reading scenarios, after adopting the VSYNC architecture, the rendering thread needs to wait for the next VSYNC signal to arrive before starting to render the next frame. That is: when the i-th VSYNC signal is generated, the i-th frame is displayed on the screen of the electronic device, the rendering thread renders the i+1-th frame, and the UI thread executes the i+2-th frame.
[0178] In this process, after the UI thread sends a signal to VSYNC requesting the execution of the next frame, the main loop of VSYNC blocks and waits for the VSYNC signal. Upon receiving the VSYNC signal, it sends a trigger command to the rendering thread, which instructs the rendering thread to start rendering the next frame. When the first frame of the slide is a long frame, the rendering thread cannot complete the rendering of the long frame within one VSYNC cycle, resulting in a dropped frame.
[0179] (2) For the scenario of opening a large folder on the desktop, the specific operation process is as follows: the user clicks the large folder icon, the large folder expands, and then clicks any non-icon location on the expanded page, the large folder collapses.
[0180] During this process, the UI thread is idle, and the rendering thread executes the animation. The animation (animate) in the main loop of the rendering thread updates the state of the unified rendering tree. At the same time, animate sends a signal to VSYNC to request the execution of the next frame's animation.
[0181] When the workload of each frame is uneven, some short frames may not be able to fill the entire VSYNC cycle, while some long frames may take too long to execute, which can easily lead to frame drops.
[0182] In some examples, visualization tests were conducted on the responsiveness of swiping scenarios. Using the VSYNC architecture, a red ball was constructed to follow the finger's touch, and its rendering trajectory was tested. Ideally, without any latency, the red ball should strictly follow the touch position and be covered by the fingertip. However, when swiping upwards, the red ball clearly appears to fall behind the fingertip. When the latency reaches 45ms, with rapid finger swiping, the maximum distance difference between the fingertip and the red ball reaches approximately 400 pixels, with an average distance difference of around 200 pixels.
[0183] Therefore, under the current VSYNC architecture, due to the fluctuating load of applications, long frames are often not rendered within a single VSYNC cycle, easily resulting in dropped frames. Furthermore, since the VSYNC signals of the rendering thread and the compositing and display thread are forcibly aligned and synchronized, there is at least a rendering delay of two VSYNC cycles from the start of frame rendering to its display on the screen. In addition, since short frames cannot fill the entire VSYNC cycle, the CPU / GPU computing power of electronic devices cannot be fully utilized, leading to a waste of CPU / GPU computing power.
[0184] While current graphics rendering methods can solve image tearing and other adverse effects, they suffer from problems such as frame dropping, rendering latency, and low parallelism between rendering and display.
[0185] In view of this, embodiments of this application provide a graphics rendering method that can decouple the vertical synchronization dependency between rendering and display. Instead of waiting for the vertical synchronization signal to trigger the execution of the frame, it can use the remaining execution time of the short frame to pre-render subsequent frames, realizing asynchronous parallelism between frame rendering and display. This can reuse the CPU time that was originally wasted on rendering short frames, reducing frame drop rate and rendering latency.
[0186] For example, Figure 6 A schematic flowchart of a graphics rendering method 600 provided in an embodiment of this application is shown. Figure 6 As shown, the method 600 includes:
[0187] S601: In the first scenario, the Decoupled Vertical Synchronization (D-VSYNC) module initiates the decoupled vertical synchronization process.
[0188] In some embodiments, the first scenario is the scenario corresponding to the input event, the first scenario is the scenario where load fluctuations or large loads may occur, and the first scenario may include, for example, a list scrolling scenario, an app opening scenario, a folder opening scenario, a map zooming scenario, etc.
[0189] In some embodiments, when not in the first scenario, the decoupled vertical synchronization process is not enabled, and graphics rendering is performed based on the VSYNC architecture. When the i-th VSYNC signal is generated, the rendering module renders the (i+1)-th frame, and the application module executes the (i+2)-th frame.
[0190] In some embodiments, the application layer monitors changes in the current scene and then notifies the controller in the decoupling vertical synchronization module via an API interface. The controller then controls the start and stop of the decoupling vertical synchronization process according to the current scene.
[0191] In some embodiments, when there is no event input (i.e. when the application module is not involved), the performance monitoring module in the rendering module monitors the changes in the current scene based on the rendering frame rate and the rendering duration per frame, and then notifies the controller in the decoupling vertical synchronization module, which controls the opening and closing of the decoupling vertical synchronization process according to the current scene.
[0192] For example, when the current rendering frame rate is lower than the first frame rate threshold, and the rendering duration of each or part of the consecutive frames is greater than the first time threshold, the current scene is determined to be the first scene, and the controller starts the decoupled vertical synchronization process.
[0193] Optionally, after the decoupled vertical synchronization process is initiated, changes in the current scene are continuously monitored. If the current scene changes to a different scenario than the first scenario, the controller shuts down the decoupled vertical synchronization process. The rendering duration of each frame in a series of consecutive frames corresponding to the non-first scenario is less than a second time threshold, which is less than a first time threshold. In this way, the decoupled vertical synchronization process can be turned on and off in a timely manner according to the scene.
[0194] S602: After receiving the first request message, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment. The first instruction is used to instruct the rendering module to start rendering the next frame of the current rendering frame. The first instruction carries a first virtual timestamp. The first opportune moment is determined according to the first parameter carried in the first request message.
[0195] In some embodiments, when the first request message is a non-animation request (a request initiated in response to an input event, i.e., a user interface animation, which can be regarded as an external call request), the first request message comes from the application module; when the first request message is an animation request (i.e., a rendering thread property animation, which can be regarded as a self-call request), the first request message comes from the rendering module (the current rendering frame of the rendering module requests to render the next frame), and the first request message is used to request to render the next frame of the current rendering frame. The first request message may be, for example, RequestNextVSync; the first parameter carried by the first request message may be, for example, fromWhom, where RequestNextVSync is used to indicate that the request is to execute the next frame; fromWhom is used to indicate the source of the first request message, i.e., whether it comes from the application module or the rendering module.
[0196] The first virtual timestamp is determined based on the display time of the current frame and the VSYNC period. The VSYNC period is the time interval between two adjacent frames displayed on the screen, which can also be understood as the time interval of the display refresh. Alternatively, the first virtual timestamp is determined based on the current time and the VSYNC period.
[0197] In some embodiments, the first parameter can be used to distinguish whether the first request message is an animation request from the rendering module or a non-animation request from the application module. An animation request refers to the rendering module requesting rendering of the next frame after rendering the previous frame; scenarios involving animation requests include opening a folder, opening an app, expanding the notification bar, expanding the status bar, etc. A non-animation request refers to a rendering request from the app, typically involving user input processing or application logic; scenarios involving non-animation requests include swiping the desktop, swiping a list, etc.
[0198] Based on the type of the first request message received in the previous VSYNC cycle (whether it is an animation request or a non-animation request, which is determined by the first parameter carried by the first request message received in the previous VSYNC cycle) and the type of the first request message received in the current VSYNC cycle (whether it is an animation request or a non-animation request, which is determined by the first parameter carried by the first request message received in the current VSYNC cycle), it can be determined whether the current scene is an animation scene, a non-animation scene, or a mixed scene (including animation and events).
[0199] In some embodiments, the hybrid scenario could be, for example, an app opening scenario where the pop-up window receives continuous animation requests from the rendering module, while the application module might synchronize the rendered app data to the rendering module during the window pop-up and request the next frame via RequestNextVSync. In this case, the user might see a white screen for the first half of the app opening, with content appearing only in the second half. Another example is a sliding list scenario where the first half is a non-animation request when the finger is on the screen, with the app synchronizing data to the rendering module in each frame. When the finger leaves the screen, an inertial animation occurs, and the rendering module makes continuous auto-draw requests.
[0200] In some embodiments, the specific method for determining the scenario is as follows:
[0201] Non-animation scene (can be understood as continuous non-animation scene): If a first request message of type non-animation is received in the current VSYNC cycle, and the first request message of type non-animation was received in the previous VSYNC cycle, or if no first request message was received in the previous VSYNC cycle (the situation that will occur at the beginning of rendering), then the current scene is a non-animation scene.
[0202] In some embodiments, determining a first timing based on a first parameter carried in a first request message includes:
[0203] When the current scene is a non-animation scene, the decoupled vertical synchronization module immediately sends the first instruction to the rendering module after receiving the first request message. In other words, in a non-animation scene, the rendering module can immediately respond to the drawing request from the application module, avoiding the occurrence of dropped frames in the first frame and reducing rendering latency.
[0204] Animated scene (which can be understood as a continuous animation scene): If a first request message of type animation is received in the current VSYNC cycle, and no first request message of type non-animation was received in the previous VSYNC cycle, then the current scene is an animated scene.
[0205] In some other embodiments, determining the first timing based on the first parameter carried in the first request message includes:
[0206] When the current scene is an animation scene, the decoupled vertical synchronization module immediately sends the first instruction to the rendering module after receiving the first request message. In other words, in the animation scene, frames will be piled up, achieving the effect of pre-rendering frames.
[0207] Hybrid Scene (which can be understood as including animation-to-non-animation scenes and non-animation-to-animation scenes): If a first request message of type animation is received in the current VSYNC cycle, and a first request message of type non-animation was received in the previous VSYNC cycle, then the current scene is a hybrid scene; or, if a first request message of type non-animation is received in the current VSYNC cycle, and a first request message of type animation was received in the previous VSYNC cycle, then the current scene is a hybrid scene.
[0208] In some other embodiments, determining the first timing based on the first parameter carried in the first request message includes:
[0209] When the current scene transitions from animation to non-animation, the decoupled vertical synchronization module, upon receiving a first request message of type animation request, waits for the corresponding non-animation request for that frame. Upon receiving the non-animation request, it immediately sends a first instruction to the rendering module. The waiting time can be 1.2 VSYNC cycles. If the wait times out, it indicates the input event stream has ended. In response to the animation request, the decoupled vertical synchronization module immediately sends the first instruction to the rendering module after the timeout.
[0210] When the current scene is transitioning from non-animation to animation, after receiving a first request message of type non-animation, the decoupled vertical synchronization module waits for the animation request corresponding to that frame. Upon receiving the animation request, it immediately sends a first instruction to the rendering module. The waiting time can be 1.2 VSYNC cycles. If the wait times out, it indicates that the property animation has ended, and in response to the non-animation request, the decoupled vertical synchronization module immediately sends a first instruction to the rendering module.
[0211] In animated scenes, where the current frame does not involve APP event responses, D-VSYNC, upon receiving an animation request from the rendering module, immediately sends a first instruction to the rendering module to pre-execute the current frame if it is an animated scene. Similarly, upon receiving a non-animation request from the application module, D-VSYNC, upon receiving a non-animation request, immediately sends a first instruction to the rendering module to pre-execute the current frame if it is a non-animation scene. In mixed scenes, upon receiving both a non-animation request from the application module and an animation request from the rendering module, D-VSYNC immediately sends a first instruction to the rendering module to execute the current frame.
[0212] In some embodiments, after receiving the first request message, the decoupled vertical synchronization module first determines a first virtual timestamp. When the difference between the first virtual timestamp and the current real timestamp is less than or equal to X VSYNC cycles, it sends a first instruction to the rendering module at a first opportune moment.
[0213] In some embodiments, the number of pre-rendered frames buffered in the frame buffer queue may have an upper limit X, which can be configured by the controller in the decoupled vertical synchronization module; for example, X can be 1, 2, 3, 4, or 5, etc. Based on this, the electronic device can control the difference between the first virtual timestamp and the current real timestamp to be less than or equal to X VSYNC cycles.
[0214] In some examples, the number of frames buffered in the frame buffer queue can have an upper limit of X+2 (i.e., the maximum allowed number of buffers in the frame buffer queue), which can be configured by the controller in the decoupled vertical synchronization module; for example, X can be 1, 2, 3, 4, or 5, etc. Based on this, the electronic device can control the difference between the first virtual timestamp and the current real timestamp to be less than or equal to X VSYNC cycles.
[0215] In some embodiments, after receiving the first request message, the decoupled vertical synchronization module first determines a first virtual timestamp. If the difference between the first virtual timestamp and the current real timestamp is greater than X VSYNC cycles, it indicates that if the first instruction is sent to the rendering module in the current VSYNC cycle in response to the first request message, the number of pre-rendered frames buffered in the frame buffer queue will exceed the upper limit X. In this case, after receiving the first request message, the decoupled vertical synchronization module will wait until the next VSYNC cycle (i.e., when the VSYNC signal is received) before sending the first instruction to the rendering module.
[0216] Another implementation method is as follows: After receiving the first request message, the decoupled vertical synchronization module queries the number of frames buffered in the frame buffer queue. If the number of frames buffered in the frame buffer queue is less than X+2, the decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment.
[0217] S603: After receiving the first instruction, the rendering module begins to render the next frame of the current rendering frame and uses the first virtual timestamp to represent the display time corresponding to the next frame of the current rendering frame.
[0218] In this embodiment, a virtual timestamp is used to represent the future display time of the pre-rendered frame, thereby decoupling the VSYNC dependency between the rendering module and the compositing and display module. Utilizing the CPU idle time of the electronic device to pre-render subsequent frames enables asynchronous parallel fast display of the two stages of frame rendering and display. This reuses the CPU time that would otherwise be wasted rendering short frames, reducing frame drop rate, reducing rendering latency, and improving responsiveness.
[0219] For example, Figure 7 This diagram illustrates a schematic interactive representation of a graphics rendering method 700 provided in an embodiment of this application. Figure 7As shown, the method 700 includes:
[0220] S701 to S703: After the first event is input, if the scenario corresponding to the first event is the first scenario, the decoupling vertical synchronization module starts the decoupling vertical synchronization process and receives the first request message.
[0221] Among them, the explanation of the first scenario and the first request message is in Figure 6 The embodiments shown are described in detail, and for the sake of brevity, they will not be repeated here.
[0222] Note: Figure 7 There are two S703s: one indicating the first request message comes from the application module, and the other indicating it comes from the rendering module. When the application layer receives an event input, the application module sends a first request message, i.e., a non-animation request. Additionally, the rendering module can also request the rendering of the next frame from the current frame, i.e., an animation request. In the same scene, there may only be animation requests (i.e., an animated scene), only non-animation requests (i.e., a non-animation scene), or a mixture of both (i.e., a mixed scene). Specifically, in... Figure 6 The illustrated embodiments are described in detail.
[0223] In one implementation, the decoupling vertical synchronization module includes a controller that controls the activation and deactivation of the decoupling vertical synchronization based on the scenario.
[0224] S704: After receiving the first request message, the decoupled vertical synchronization module determines the first timing based on the first parameter carried in the first request message.
[0225] The explanation of the first parameter is as follows: Figure 6 The embodiments shown are described in detail, and for the sake of brevity, they will not be repeated here.
[0226] In some embodiments, the current scene (animated scene, non-animated scene, or hybrid scene) is determined based on the first parameter carried in the first request message received in the previous VSYNC cycle and the first parameter carried in the first request message received in the current VSYNC cycle, and then the first timing is determined based on the current scene. For a description of how to determine the current scene based on the first parameter and how to determine the first timing based on the current scene, please refer to [link to relevant documentation]. Figure 6 The description of S602 in the illustrated embodiment will not be repeated here for the sake of brevity.
[0227] S705: The decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment.
[0228] In one implementation, the decoupled vertical synchronization module includes a pre-executor that receives a first request message and sends a first instruction to the rendering module at a first opportune moment based on the first parameters carried in the first request message.
[0229] In some embodiments, before sending the first instruction to the rendering module, the decoupling vertical synchronization module determines the first virtual timestamp based on the display time of the current display frame and the VSYNC period, or the decoupling vertical synchronization module determines the first virtual timestamp based on the current time and the VSYNC period.
[0230] In one implementation, the decoupled vertical synchronization module includes a virtual timer. This virtual timer determines a first virtual timestamp based on the display time of the current display frame and the VSYNC period, or based on the current time and the VSYNC period.
[0231] It should be understood that each pre-rendered frame has a corresponding virtual timestamp. In one example, if the pre-rendered frame is the second pre-rendered frame, and the frame just before the one before the one before the one before the one is displayed, then the virtual timestamp corresponding to the pre-rendered frame can be the sum of the display time of the frame before the one before the one before the one and two VSYNC cycles.
[0232] Among them, the interpretation of the first instruction is in Figure 6 The embodiments shown are described in detail, and for the sake of brevity, they will not be repeated here.
[0233] S706: After receiving the first instruction, the rendering module begins rendering the first target frame. The first target frame refers to the frame following the current frame.
[0234] Specifically, after rendering the first target frame, the rendering module associates the first virtual timestamp carried by the first instruction with the first target frame. That is, the first virtual timestamp represents the display time of the first target frame.
[0235] S707: After the rendering module finishes rendering the first target frame, it sends the first target frame to the frame buffer queue.
[0236] In some embodiments, the rendering module may request a buffer from the frame buffer queue before sending the first target frame to the frame buffer queue.
[0237] S708: After receiving the first target frame, the frame buffer queue adds the first target frame to the frame buffer queue in a first-in-first-out order.
[0238] The composite display module can retrieve the frame to be displayed from the frame buffer queue at the beginning of each VSYNC cycle, that is, the next frame after the current display frame, and display it on the screen of the electronic device.
[0239] In this embodiment, a virtual timestamp is used to represent the future display time of the pre-rendered frame, thereby decoupling the VSYNC dependency between the rendering module and the compositing and display module. Utilizing the CPU idle time of the electronic device to pre-render subsequent frames enables asynchronous parallel fast display of the two stages of frame rendering and display. This reuses the CPU time that would otherwise be wasted rendering short frames, reducing frame drop rate, reducing rendering latency, and improving responsiveness.
[0240] Specifically, in the VSYNC architecture, the frame rendering time (VSYNC-app timestamp) recorded by the choreographer and other system clocks are used to represent the frame display time. Therefore, in the VSYNC architecture, frame rendering must be performed shortly before the frame is displayed. However, in the D-VSYNC architecture provided in this application embodiment, since the state and behavior of the graphics system are deterministic, the virtual timer is merged into the modified choreographer, enabling the display time of the pre-rendered frame to be represented by a virtual timestamp instead of the current time. This allows the D-VSYNC architecture to support frame pre-rendering. In other words, the virtual timer calculates when the currently rendering frame will be displayed and associates the calculated virtual timestamp with the rendered frame, ensuring that the rendered frame is displayed at the time corresponding to the virtual timestamp. Therefore, by applying the virtual timer, D-VSYNC can decouple the frame content display time from the frame rendering code execution time, achieving frame pre-rendering and thus improving the performance of electronic devices.
[0241] For example, Figure 8 This diagram illustrates a schematic interactive representation of another graphics rendering method 800 provided in an embodiment of this application. Figure 8 As shown, the method 800 includes:
[0242] S801 to S803 and Figure 7 S701 to S703 in the illustrated embodiment are the same, and will not be described again here for the sake of simplicity.
[0243] S804: The decoupled vertical synchronization module sends a first query message to the frame buffer queue, which is used to query the number of frames currently existing in the frame buffer queue.
[0244] In some embodiments, of all frames in the frame buffer queue, two are buffer frames used for frame caching and frame acquisition between the rendering module and the composition and display module, and are non-pre-rendered frames. All other frames are pre-rendered frames.
[0245] In some embodiments, the number of frames included in the frame buffer queue must be less than or equal to M. The value of M can be any one of 3, 4, or 5, and can also be other values greater than or equal to 3. This application does not limit the value of M, where M can be understood as the maximum number of buffered frames allowed.
[0246] S805: After receiving the first query message, the frame buffer queue sends a first number N to the decoupled vertical synchronization module. The first number N represents the number of frames currently existing in the frame buffer queue.
[0247] S806: Determine if the number N of frames currently existing in the frame buffer queue is less than M. If so, it means that the frame buffer queue can still hold more pre-rendered frames, and further execute S807.
[0248] S807 to S811 and Figure 7 S704 to S708 in the illustrated embodiment are the same, and will not be described again here for the sake of simplicity.
[0249] Specifically, when the number of frames N currently existing in the frame buffer queue is greater than or equal to M, it waits for the VSYNC signal from the compositing and display module, and sends the first instruction to the rendering module after receiving the VSYNC signal.
[0250] It can be understood that S804 to S806 are... Figure 6 The illustrated embodiment provides an alternative implementation of "controlling the difference between the first virtual timestamp and the current real timestamp to be less than or equal to X VSYNC cycles". When the decoupling vertical synchronization module performs the judgment of "whether the difference between the first virtual timestamp and the current real timestamp is less than or equal to X VSYNC cycles", steps S804 to S806 are not executed; conversely, when the decoupling vertical synchronization module executes steps S804 to S806, the judgment of "whether the difference between the first virtual timestamp and the current real timestamp is less than or equal to X VSYNC cycles" is not executed. The purpose of both is the same. Therefore, if it is necessary to control the number of pre-rendered frames in the buffer to not exceed a preset number, only one of the two methods needs to be executed.
[0251] S812: After the decoupling vertical synchronization module receives a second request message from the application module or the rendering module, it repeats the above steps S804 to S811, wherein the second request message is used to request the execution of the next frame. Similarly, in the first scenario, each time the decoupling vertical synchronization module receives a request message from the application module or the rendering module to request the execution of the next frame, it repeats the above steps S804 to S811.
[0252] Optionally, when the current scene changes to a different scene than the first scene, the decoupled vertical synchronization process is turned off, and a vertical synchronization architecture is used for graphics rendering.
[0253] The following sections S813 to S817 describe the process by which the composite display module retrieves and displays frames from the frame buffer queue in a first-in-first-out (FIFO) order at the beginning of each VSYNC cycle. This process can be considered a relatively independent flow and is not directly related to the execution logic of the above-mentioned S802 to S812.
[0254] S813: The composite display module retrieves the next frame of the current display frame from the frame buffer queue.
[0255] S814: When the next VSYNC cycle begins, the composite display module composites and displays the next frame of the current display frame.
[0256] S815: After completing the display of the next frame of the current display frame, the composite display module sends a VSYNC signal to the decoupled vertical synchronization module.
[0257] S816: After the composite display module completes the display of the next frame of the current display frame, it sends a release command to the frame buffer queue to instruct the frame buffer queue to release the next frame of the current display frame.
[0258] S817: After receiving a release command, the frame buffer queue removes the next frame from the frame buffer queue of the currently displayed frame.
[0259] In some embodiments, the composite display module consumes the frame buffer queue in FIFO order during each VSYNC cycle; and the number of buffers queued in the frame buffer queue and other VSYNC configuration parameters (such as VSYNC cycle or phase) are always available for querying, for example, through the first query message mentioned above.
[0260] For example, Figure 9 A schematic diagram of a graphics rendering system architecture provided in an embodiment of this application is shown.
[0261] like Figure 9 As shown, the system architecture includes an application module, a rendering module, a frame buffer queue, a compositing and display module, and a frame rendering timing control module 900. The frame rendering timing control module 900 includes a vertical synchronization module 910 and a decoupled vertical synchronization module 920. The decoupled vertical synchronization module 920 includes a controller 921, a pre-executor 922, and a virtual timer 923. Specifically:
[0262] The vertical synchronization module 910 in the frame rendering timing control module 900 is used to control the graphics rendering according to the rules of vertical synchronization when the decoupled vertical synchronization module 920 is in the off state. That is: after receiving the first request message, it waits for the VSYNC signal sent by the composite display module; after receiving the VSYNC signal, it sends a first instruction to the rendering module to instruct the rendering module to start rendering the next frame. Thus, when the i-th VSYNC signal is generated, the i-th frame is displayed, the rendering module renders the (i+1)-th frame, and the application module executes the (i+2)-th frame.
[0263] The following focuses on describing the coordination process between the modules when the decoupling vertical synchronization module 920 is in the enabled state.
[0264] S901 to S902: After the first event is input, when the application module detects that the scene corresponding to the first event is the first scene, it sends an enable command to the controller 921 through the API interface configured on the controller 921, so that the controller 921 enables decoupled vertical synchronization. Furthermore, the application module sends a first request message to the pre-executor 922, which is used to request the execution of the next frame.
[0265] In some embodiments, after the graphics rendering begins, the performance monitoring module in the rendering module monitors the rendering frame rate and the duration of each frame. When it detects that the current scene is the first scene, it directly enables decoupled vertical synchronization through the controller 921. Furthermore, the rendering module sends a first request message to the pre-executor 922, which requests the execution of the next frame.
[0266] In some other embodiments, the first request message may be sent by the rendering module to the pre-executor 922 after rendering the current frame, to request the execution of the next frame.
[0267] S903: The decoupled vertical synchronization module 920 sends a first query message to the frame buffer queue, which is used to query the number of frames currently existing in the frame buffer queue.
[0268] The explanation of this step and Figure 8 The explanation of S804 in the illustrated embodiment is the same, and for the sake of brevity, it will not be repeated here.
[0269] S904: After receiving the first query message, the frame buffer queue sends a first quantity N to the decoupled vertical synchronization module 920. The first quantity N represents the number of frames currently existing in the frame buffer queue.
[0270] S905: When N is less than M, the decoupled vertical synchronization module 920 sends the first instruction to the rendering module at the first opportune moment.
[0271] For an explanation of this step, please refer to [link / reference]. Figure 8 The explanations of S806 to S808 in the illustrated embodiment will not be repeated here for the sake of brevity.
[0272] S906: In response to a request from the rendering module, the framebuffer queue allocates a buffer to the rendering module.
[0273] Explanation of S907 to S910 Figure 8 The explanations of S808 to S817 in the illustrated embodiments are similar, and for the sake of brevity, they will not be repeated here.
[0274] In some embodiments, to ensure compatibility with existing applications, D-VSYNC is developed based on the traditional VSYNC framework. D-VSYNC adds new API interfaces while retaining the semantics of the original API interfaces.
[0275] In some embodiments, D-VSYNC can be partially or completely turned off when the rendering process depends on unpredictable data or incompatible applications.
[0276] For example, Figure 10 This illustration shows a schematic diagram of another graphics rendering system architecture provided in an embodiment of this application.
[0277] like Figure 10 As shown, the system architecture includes an application module, a rendering module, a frame buffer queue, a compositing and display module, and a frame rendering timing control module 900. The frame rendering timing control module 900 includes a vertical synchronization module 910 and a decoupled vertical synchronization module 920. The decoupled vertical synchronization module 920 includes a controller 921, a pre-executor 922, and a virtual timer 923. Additionally, the system architecture also includes an input event prediction module 1000, which may include, for example, a list sliding predictor 1100, a zoom event predictor 1200, and other predictors. Specifically:
[0278] The vertical synchronization module 910 in the frame rendering timing control module 900 is used to control the graphics rendering to proceed according to the rules of vertical synchronization when the decoupled vertical synchronization module 920 is in the off state. That is: after receiving the first request message, it waits for the VSYNC signal sent by the composite display module; after receiving the VSYNC signal, it sends a first instruction to the rendering module to instruct the rendering module to start rendering the next frame. Thus, when the i-th VSYNC signal is generated, the i-th frame is displayed, the rendering module renders the (i+1)-th frame, and the application module executes the (i+2)-th frame.
[0279] The following focuses on describing the coordination process between the modules when the decoupling vertical synchronization module 920 is in the enabled state.
[0280] It is understandable: Figure 10 The illustrated embodiment is in Figure 9 Based on the illustrated embodiment, an input event prediction module 1000 is added, ensuring that the state of the input event corresponds to the event state at the virtual time calculated by the virtual timer. This updates the state of the input event to the event state corresponding to the display time of the pre-rendered frame (e.g., the display position of the pre-rendered frame). This avoids rendering errors caused by the loss of the latest event state between rendering and display due to frames being executed some VSYNC cycles before the pre-rendering architecture of D-VSYNC, thus improving the accuracy of real-time rendering.
[0281] Figure 10 The illustrated embodiments and Figure 9 The illustrated embodiment differs in steps S1001 to S1003, specifically:
[0282] S1001 to S1002: After the first event is input, the input event prediction module 1000 obtains the first virtual timestamp from the virtual timer 923. This first timestamp is the expected display time corresponding to the next frame. Based on the input first event, a predictor (list sliding predictor 1100, zoom event predictor 1200, or other predictor) is determined. The determined predictor corresponding to the first event predicts the state of the first event and modifies the state of the first event to the expected state corresponding to the first virtual timestamp, thereby improving the accuracy of the pre-rendering of the next frame.
[0283] In one example, when the application component displays a list of items that the user can scroll through (the first input event is the list scroll event), the list scroll predictor 1100 built into the input event prediction module 1000 will be activated and take effect. The list scroll predictor 110 uses an internal heuristic model and a virtual timestamp output by the virtual timer 923 to modify the current coordinates of the touch to the expected coordinates corresponding to the virtual timestamp.
[0284] In some embodiments, the input event prediction module 1000 provides an API interface to the application for registering / unregistering predictors, which allows custom predictors to be registered to the input event prediction module 1000 so that the input event prediction module 1000 can be applied to more scenarios.
[0285] S1003: The input event prediction module 1000 updates the status of the first predicted event to the application module.
[0286] The input event prediction module 1000 can also be described as an event state prediction layer (ESPL), and the list scrolling predictor 1100 can also be described as a list scrolling position predictor (LSPP).
[0287] S1004 to S1012 and Figure 9 S902 to S910 in the illustrated embodiment are the same, and will not be described again here for the sake of simplicity.
[0288] To better understand the architecture of graphics rendering provided in the embodiments of this application, the following will be combined with... Figures 11 to 14 The controller 921, pre-executor 922, virtual timer 923, and input event prediction module 1000 in the decoupled vertical synchronization module 920 are described in detail.
[0289] For example, Figure 11 This illustration shows a schematic diagram of the principle of a controller controlling the decoupled vertical synchronization on and off according to an embodiment of this application.
[0290] like Figure 11 As shown, the controller is used to control the start and stop of D-VSYNC. In addition, the controller is also used to configure D-VSYNC parameters. These parameters can include the maximum number of frames in the frame buffer queue, as well as other VSYNC configuration parameters, such as the VSYNC period.
[0291] There are two ways to control the D-VSYNC to turn on and off:
[0292] 1. The controller in D-VSYNC exposes API interfaces for starting, stopping, and configuring to the APP layer. In the first scenario, the APP layer (or OS) instructs the controller to start D-VSYNC through these API interfaces.
[0293] Optionally, when the scene changes to a different scene than the first scene, the controller can be instructed to disable D-VSYNC via this API interface.
[0294] This implementation method can take full advantage of the APP's familiarity with the scene and avoid dropping frames in the first frame.
[0295] 2. After the graphics start rendering, the rendering module's performance monitoring module performs rendering frame rate and per-frame execution time statistics. When the current scene is determined to be the first scene based on the rendering frame rate and per-frame execution time statistics, D-VSYNC is enabled through the controller.
[0296] Optionally, the performance monitoring module can disable D-VSYNC via the controller when the scene changes to a different scenario.
[0297] This implementation method enables automatic start and stop of D-VSYNC without requiring any changes at the APP level.
[0298] For example, Figure 12 This illustration shows a schematic diagram of a pre-executor sending a first instruction to a rendering module, according to an embodiment of this application.
[0299] like Figure 12 As shown in (a), after receiving the first request message requesting the execution of the next frame, the frame rendering timing control module uses the VSYNC architecture to execute the frame rendering logic if D-VSYNC is not enabled. That is, it continues to wait for the VSYNC signal sent by the compositing and display module. After receiving the VSYNC signal, it sends a first instruction to the rendering module to instruct the rendering module to execute the next frame. If D-VSYNC is enabled, the pre-executor determines the first timing based on the first parameter carried in the first request message, and sends the first instruction to the rendering module at the first timing to instruct the rendering module to execute the next frame, and uses the first virtual timestamp to represent the display time of the rendered frame.
[0300] Figure 12 (b) shows a schematic diagram of a rule for a pre-executor to determine a first timing based on a first parameter, according to an embodiment of this application.
[0301] like Figure 12 As shown in (b), after receiving the first request message for requesting the execution of the next frame, if D-VSYNC is enabled, the pre-executor determines the first timing based on the first parameter.
[0302] During the graphics rendering process, four scenarios may occur: continuous animated scenes, continuous non-animated scenes, animated scene transitioning to non-animated scenes, and non-animated scene transitioning to animated scenes. The transition from animated to non-animated scenes and from non-animated to animated scenes involves alternating animation and non-animation requests. Based on the first parameter, it can be determined which of the four scenarios the current scene falls into, and based on this determination, the first timing is identified.
[0303] In some embodiments, the pre-executor determines the current scene (animated scene, non-animated scene, or mixed scene) based on the first parameter carried by the first request message received in the previous VSYNC cycle and the first parameter carried by the first request message received in the current VSYNC cycle, and then determines the first timing based on the current scene.
[0304] In some embodiments, the pre-executor determines a first timing based on a first parameter, including:
[0305] If a first request message of type non-animation is received in the current VSYNC cycle, and the first request messages received in the previous VSYNC cycle were all of type non-animation, or no first request message was received in the previous VSYNC cycle (the situation that occurs at the very beginning of rendering), then the current scene is a non-animation scene (which can be understood as a continuous non-animation scene); when the current scene is a non-animation scene, the pre-executor immediately sends the first instruction to the rendering module after receiving the first request message.
[0306] If a first request message of type animation is received in the current VSYNC cycle, and no first request message of type non-animation was received in the previous VSYNC cycle, then the current scene is an animation scene (which can be understood as a continuous animation scene). When the current scene is an animation scene, the pre-executor sends the first instruction to the rendering module immediately after receiving the first request message.
[0307] When a first request message of type "animation request" is received within the current VSYNC cycle, if a first request message of type "non-animation request" was received in the previous VSYNC cycle, then the current scene is a mixed scene, specifically, an animation-to-non-animation scene within a mixed scene. When the current scene is an animation-to-non-animation scene, after receiving a first request message of type "animation request," the pre-executor waits for the corresponding non-animation request for that frame. Upon receiving the corresponding non-animation request, it immediately sends a first instruction to the rendering module. The waiting time can be m VSYNC cycles. If the wait times out, it indicates the end of the input event stream. In response to the animation request, the pre-executor immediately sends a first instruction to the rendering module, where m is any value greater than 1 and less than or equal to 2, such as 1.1, 1.2, 1.3, 1.5, or 1.8.
[0308] Alternatively, if a first request message of type non-animation is received within the current VSYNC cycle, and a first request message of type animation was received in the previous VSYNC cycle, then the current scene is a mixed scene, specifically a non-animation-to-animation scene within a mixed scene. When the current scene is a non-animation-to-animation scene, after receiving a first request message of type non-animation, the pre-executor waits for the animation request corresponding to that frame. Upon receiving the animation request, it immediately sends a first instruction to the rendering module. The waiting time can be m VSYNC cycles. If the wait times out, it indicates that the property animation has ended. In response to the non-animation request, the pre-executor immediately sends a first instruction to the rendering module. This first instruction carries a first virtual timestamp. After receiving the first instruction, the rendering module begins executing the next frame and uses the first virtual timestamp to represent the display time of the next frame.
[0309] In this embodiment, the pre-executor enables the frame rendering module to perform frame rendering in advance without having to align with the VSYNC signal from the composite display module, and assigns a virtual timestamp to the frame to represent the future display time of the frame.
[0310] For example, Figure 13 This illustration shows a schematic diagram illustrating the principle of a virtual timer for determining a virtual timestamp, as provided in an embodiment of this application.
[0311] like Figure 13 As shown, the virtual timer provides a corresponding virtual timestamp for each pre-rendered frame. The virtual timestamp can be the time when the pre-rendered frame will actually be displayed on the screen in the future, which is virtualized based on the timestamp of the previous frame and the VSYNC period.
[0312] Specifically, the first request message carries a second parameter, which is used to carry the timestamp of the current frame (i.e., the frame preceding the current pre-rendered frame). This second parameter can be `lastVSyncTS`. When the first request message is a request from the rendering module to execute the autodraw request for the next frame, this second parameter carries the timestamp of the previous frame; when the first request message is a non-animation request, this second parameter has a default value of 0. Combined with... Figure 13 As can be seen, when the first request message is a request from the rendering module to execute the autodraw request for the next frame, the second parameter carries the timestamp of the previous frame. The calculated virtual timestamp of the next frame is the sum of the timestamp of the previous frame (lastVSyncTS) and one VSYNC cycle. Therefore, in the frame stacking state, the animation can be executed as smoothly as the traditional VSYNC, where lastVSyncTS is used to represent the timestamp of the current frame (i.e., the previous frame of the current pre-rendered frame).
[0313] Note that the virtual timestamp for the next frame calculated here must be greater than the current time (now). If it is less than the current time, it means that a frame drop has occurred even though D-VSYNC was used. In this case, the first expected VSYNC timestamp after the current time is used as the virtual timestamp for the next frame. For example, the sum of the actual timestamp of the current VSYNC cycle and one VSYNC cycle can be used as the virtual timestamp for the next frame.
[0314] Combination Figure 13Furthermore, when the first request message is a non-animation request, the first VSYNC timestamp expected after the current time (now) is used as the virtual timestamp of the next frame. For example, the sum of the actual timestamp of the current VSYNC cycle and one VSYNC cycle is used as the virtual timestamp of the next frame. The virtual timestamp of the next frame must be greater than or equal to the virtual timestamp of the previous event. If the virtual timestamp of the next frame is less than the virtual timestamp of the previous event, the virtual timestamp of the previous event is used as the virtual timestamp of the next frame. This ensures that in the event of frame backlog, time rollback will not occur due to a sudden receipt of a non-animation request.
[0315] The real VSYNC signal records the real timestamp (realVSyncTS) and the real VSYNC period (realPeriod) for each VSYNC period.
[0316] In some embodiments, after calculating the virtual timestamp, each frame calibrates the virtual timestamp using the real timestamp (realVSyncTS) and the real VSYNC period (realPeriod) recorded by the real VSYNC signal. The virtual timestamp (expectedVSyncTS) is calibrated to realVSyncTS + k * realPeriod, where k is an integer.
[0317] This calibration helps prevent the accumulation of errors in virtual timestamps.
[0318] In some embodiments, the virtual timer also provides an API interface for obtaining the display time, which the application can use in its own frame logic when needed.
[0319] For example, Figure 14 This illustration shows a schematic diagram illustrating the principle of an input event prediction module predicting the state of an input event, as provided in an embodiment of this application.
[0320] Figure 14 (a) shows a schematic diagram of the principle of the List Scroll Position Predictor (LSPP) in the input event prediction module predicting the state of the sliding event.
[0321] like Figure 14 As shown in (a), LSPP is activated and takes effect when the application component displays a scrollable list of items (i.e., the input event is a list scroll event). After LSPP is activated, the model is selected based on the scrolling of the item list. Specifically, when the item list scrolls up quickly, the model is selected. Figure 14 The upward curve model shown in (a) is selected when the item list is scrolled down quickly. Figure 14The downward curve model shown in (a) indicates that when the item list scrolls slowly, select... Figure 14 The linear model is shown in (a) above. After model selection, the model is updated, that is, the current model is modified to the latest selected model; then, based on the updated model and the virtual timestamp from the virtual timer, the current coordinates of the touch are modified to the coordinates corresponding to the virtual timestamp, and the coordinates corresponding to the virtual timestamp are output. In this way, the current state of the input event can be modified and corrected to the expected state corresponding to the expected display time of the frame calculated by the virtual timer.
[0322] Figure 14 (b) shows a schematic diagram illustrating the principle of the Map Zoom Distance Predictor (MZDP) in the input event prediction module predicting the state of zoom events.
[0323] like Figure 14 As shown in (b), after an input event, when two touch points are detected (i.e., the input event is a zoom event), MZDP is activated and takes effect. After MZDP is activated, the distance between the two touch points is calculated. The coordinates of the two touch points are (x1, y1) and (x2, y2), and the distance between the two touch points is... Then, the model is updated based on the calculated distance between the two touch points. Following this, the distance between the two touch points is modified to match the distance between the two touch points corresponding to the virtual timestamp, based on the updated model and the virtual timestamp from the virtual timer. The distance between the two touch points corresponding to the virtual timestamp is then output. This allows the current state of the input event to be modified and corrected to the expected state corresponding to the expected display time of the frame calculated by the virtual timer.
[0324] In addition, the input event prediction module may also include a drawing point predictor or a game angle predictor, as well as other custom predictors, to predict the state of different events.
[0325] In some embodiments, since almost all applications use some form of list to display pages such as news, contacts, or settings, the input event prediction module includes LSPP by default for list scrolling prediction. LSPP and D-VSYNC are activated when an application uses a list and detects dropped frames, providing a default performance boost for most applications.
[0326] In some embodiments, the D-VSYNC architecture provides rollback and fault tolerance mechanisms for the frame buffer queue, specifically:
[0327] During the pre-rendering of frames in the D-VSYNC architecture, when an input event passes through the corresponding predictor in the input event prediction module, the input event prediction module records the event state prediction data. In other words, the input event prediction module records the most recent historical event state prediction data. This historical data can be used to evaluate the pixel difference between the predicted state and the actual data, thus determining the accuracy of the event state prediction.
[0328] D-VSYNC provides an API interface for discarding buffered frames. For any pre-rendered frame in the framebuffer queue, if its content is inaccurate due to incorrect prediction, and the inaccuracy exceeds a set threshold, the buffered pre-rendered data can be discarded through this API interface.
[0329] In some embodiments, when discarding pre-rendered data in the buffer via this API interface, the specific discarding method is as follows: release all buffered frames in the frame buffer queue before the currently rendered frame, and release all buffered frames after the last frame synthesized by the compositing and display module. The currently rendered frame will be the next frame to be displayed.
[0330] It should be understood that the rollback and fault tolerance mechanisms set up for the frame buffer queue in the D-VSYNC architecture are optional. In some embodiments, application logic can determine the inaccuracy of the prediction and explicitly call the API interface for discarding buffered frames.
[0331] Since incorrect predictions of event states only result in minor pixel differences, in some embodiments, an API interface for discarding buffered frames may not be configured.
[0332] To more intuitively demonstrate the beneficial effects of D-VSYNC pre-rendering in reducing frame drops and lowering rendering latency, for example, Figure 15 A comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in an embodiment of this application is shown.
[0333] like Figure 15 The VSYNC rendering pipeline shown in the diagram maintains frame synchronization between the UI thread and the rendering thread within the VSYNC architecture. This occurs during the app's first VSYNC cycle (i.e.,...). Figure 15 As shown in the diagram, at the start of the VSYNC-app, the VSYNC signal triggers the UI thread to perform the drawing operation for the first frame; after the UI thread finishes drawing the first frame, it immediately enters the rendering thread to render the first frame; then, in the second VSYNC cycle of the composite display (i.e., Figure 15 The compositing display thread is triggered to composite the first frame at the start of the VSYNC-sf shown in the diagram, and in the third VSYNC cycle of the display (i.e., Figure 15When HW-VSYNC (as shown in the diagram) starts, the first frame is displayed on the screen of the electronic device. That is, when the i-th VSYNC signal is generated, the i-th frame is displayed, the rendering thread renders the (i+1)-th frame, and the UI thread executes the (i+2)-th frame.
[0334] One point to note is that when the UI thread draws the 11th frame, because the 11th frame is an extremely long frame, drawing the 11th frame takes more than 3 VSYNC cycles. This means that the rendering thread cannot perform rendering operations within 3 cycles. Consequently, no frame is displayed on the screen within 3 cycles, which results in dropped frames.
[0335] like Figure 15 The D-VSYNC rendering pipeline shown in the diagram, within the D-VSYNC architecture, allows for pre-rendering of frames and adding these pre-rendered frames to the frame buffer queue, thus accumulating frames to be displayed. Figure 15 In the D-VSYNC rendering pipeline, during the accumulation phase, when the number of buffers in the framebuffer queue reaches the maximum allowed number of buffers, D-VSYNC uses a method that maintains frame synchronization between the UI thread and the rendering thread for pre-rendering. Figure 15 In the D-VSYNC rendering pipeline, during the synchronization phase, when the UI thread draws frame 11, because frame 11 is a very long frame, drawing it takes more than three VSYNC cycles. At this time, the compositing and display thread consumes the pre-rendered frames in the frame buffer queue in a first-in, first-out (FIFO) order. This ensures that even if the rendering thread cannot perform rendering operations for three cycles, frames are still displayed on the screen during those three cycles, thus avoiding dropped frames. After frame 11 is drawn, because the number of frames in the frame buffer queue is less than the maximum allowed number, D-VSYNC starts pre-rendering frames again, accumulating the frames to be displayed. Figure 15 In the D-VSYNC rendering pipeline, during the long frame & accumulation phase, when the number of buffers in the frame buffer queue reaches the maximum allowed number, D-VSYNC switches to a pre-rendering method that maintains frame synchronization between the UI thread and the rendering thread. Figure 15 The synchronization phase in the D-VSYNC rendering pipeline.
[0336] Among them, the execution entity of the UI thread can be the application module, the execution entity of the rendering thread can be the rendering module, and the execution entity of the compositing and display thread can be the compositing and display module.
[0337] In this embodiment, D-VSYNC extends the VSYNC framework, dividing the rendering framework into an accumulation phase and a synchronization phase. During the accumulation phase, D-VSYNC decouples rendering time from display time. When there are still spare frame buffers, some frames can be executed ahead of schedule based on an abstraction of the calculated display time, without waiting for the VSYNC signal. Therefore, D-VSYNC can fully utilize the time and computing power saved by short frames during load fluctuations, allowing time for the execution of long frames, thereby avoiding dropped frames.
[0338] In addition, in order to clearly demonstrate the beneficial effects of the embodiments of this application, based on the above-mentioned sliding reading scenario (1) and the scenario of opening a large folder on the desktop (2), the rendering display trajectory of these two scenarios after using the graphics rendering method provided in the embodiments of this application is analyzed as follows.
[0339] (1) For sliding reading scenarios, after adopting the D-VSYNC architecture, D-VSYNC can immediately instruct the rendering module to execute the next frame when it receives a request to execute the next frame. The display time of the frame executed in the rendering module is represented by a virtual timestamp from the virtual timer. The rendering module does not need to wait for the next VSYNC signal to arrive before it starts rendering the next frame, which can avoid the waiting caused by VSYNC signal alignment, thus having more rendering time and avoiding frame drops.
[0340] (2) For scenarios where a large folder is opened on the desktop, after adopting the D-VSYNC architecture, after the current frame requests the execution of the next frame, D-VSYNC can instruct the rendering module to render the next frame in advance according to the virtual timestamp corresponding to the next frame from the virtual timer. In this way, short frames will be executed one after another, and when a long frame appears, the execution time of the long frame can occupy the time saved by the short frames, avoiding frame drops and rendering delays.
[0341] In some examples, in short-frame scenarios, compared to the rendering latency of VSYNC (at least 2 VSYNC cycles), D-VSYNC allows the UI thread and the rendering thread to complete within the same VSYNC cycle, reducing the rendering latency to 1 VSYNC cycle.
[0342] In one example, when the first scene was a fast, continuous sliding scene, the D-VSYNC architecture was used to test frame drop performance. The frame drop situation for different applications was tested with different numbers of buffers set in the frame buffer queue. When the number of buffers in the D-VSYNC frame buffer queue was set to 4, it eliminated 71.6% of frame drops, and the average frame drops per second (FDPS) for 25 applications decreased from 2.04 to 0.58. When the number of buffers in the D-VSYNC frame buffer queue was set to 5, it eliminated 87.7% of frame drops, and the average FDPS for 25 applications decreased from 2.04 to 0.25.
[0343] In one example Figure 16 The diagram shows the test results of the average pixel difference in a first scenario provided by an embodiment of this application, namely continuous fast scrolling, alternating fast scrolling, and slow scrolling.
[0344] like Figure 16 As shown, D-VSYNC with 5 buffers has higher responsiveness, reducing the average pixel difference (APD) by 61.6% for continuous fast scrolling scenes and by 55.9% for slow scrolling scenes.
[0345] In some other examples, performance model verification was performed based on SkiaGL. As shown in Table 1 below, SkiaGL improved the frame rate by 4.9 frames in scenes with less than full frames and achieved full frames in 10 scenes.
[0346] Table 1
[0347]
[0348] Similarly, in some other examples, performance model verification was performed based on Skia VK. As shown in Table 2 below, Skia VK improved the frame rate by an average of 3.1 frames in scenarios with less than full frames, and achieved full frames in 20 scenarios with the same load as the baseline.
[0349] Table 2
[0350]
[0351]
[0352] The graphics rendering method provided in this application can be applied not only to the operating system graphics field, but also to other VSYNC-driven scenarios, such as web scenarios based on VSYNC.
[0353] One or more modules or units described herein can be implemented in software, hardware, or a combination of both. When any of the above modules or units are implemented in software, the software exists as computer program instructions and is stored in memory. A processor can be used to execute the program instructions and implement the above method flow. The processor can include, but is not limited to, at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor, etc., and various computing devices that run software. Each computing device may include one or more cores for executing software instructions to perform calculations or processing. The processor can be built into a SoC (System-on-a-Chip) or an application-specific integrated circuit (ASIC), or it can be a separate semiconductor chip. In addition to the cores within the processor for executing software instructions to perform calculations or processing, it may further include necessary hardware accelerators, such as field-programmable gate arrays (FPGAs), PLDs (programmable logic devices), or logic circuits that implement dedicated logic operations.
[0354] When the modules or units described herein are implemented in hardware, the hardware may be any one or any combination of a CPU, microprocessor, DSP, MCU, artificial intelligence processor, ASIC, SoC, FPGA, PLD, application-specific digital circuit, hardware accelerator, or non-integrated discrete device, which may run the necessary software or perform the above method flow independently of software.
[0355] When the modules or units described herein are implemented using software, they can be implemented in whole or in part as 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, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0356] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0357] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0358] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0359] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0360] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0361] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0362] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for graphics rendering, characterized in that, The method is applied to a graphics rendering device, and the method includes: Within a vertical synchronization cycle, in response to the input of the first event, the decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal; wherein, the first instruction is used to instruct the rendering module to render the next frame of the current rendering frame, the current rendering frame has not yet been displayed on the screen of the graphics rendering device, and the first instruction is also used to indicate the display time of the next frame of the current rendering frame. After receiving the first instruction, the rendering module begins rendering the next frame of the current rendering frame.
2. The method according to claim 1, characterized in that, The first instruction carries a first virtual timestamp, which is used to indicate the display time of the next frame of the current rendering frame.
3. The method according to claim 1 or 2, characterized in that, The decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal, including: The decoupled vertical synchronization module receives a first request message, which is used to request the rendering of the next frame of the current rendering frame; The decoupled vertical synchronization module sends the first instruction to the rendering module before the next vertical synchronization signal according to the current scene. The current scene includes one of the following: an animated scene, a non-animated scene, an animated-to-non-animated scene, and a non-animated-to-animated scene.
4. The method according to claim 3, characterized in that, The decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal, based on the current scene, including: When the current scene is an animated scene or a non-animated scene, the decoupled vertical synchronization module sends the first instruction to the rendering module; When the current scene transitions from animation to non-animation, the decoupled vertical synchronization module waits to receive a non-animation request. If the non-animation request is received within m vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the non-animation request; or, if the non-animation request is not received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module at the end of the m vertical synchronization cycles. The starting point of the m vertical synchronization cycles is the moment when the decoupled vertical synchronization module receives the first request message, and m is any value greater than 1 and less than or equal to 2. When the current scene is a non-animation to animation scene, the decoupled vertical synchronization module waits to receive an animation request. If the animation request is received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the animation request. If the animation request is not received within the m vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module at the end of the m vertical synchronization cycles.
5. The method according to claim 3, characterized in that, The method further includes: The decoupled vertical synchronization module determines the current scene based on the first parameter carried in the first request message. The first parameter is used to indicate the type of the first request message. The type of the first request message includes an animation request or a non-animation request. The animation request comes from the rendering module, and the non-animation request comes from the application module.
6. The method according to claim 5, characterized in that, The decoupled vertical synchronization module determines the current scenario based on the first parameter carried in the first request message, including: When the first request message is an animation request, and no non-animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines that the current scene is an animation scene, and the vertical synchronization cycle is the time interval between the display of two adjacent frames. When the first request message is an animation request, and a non-animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines that the current scene is an animation-to-non-animation scene. When the first request message is a non-animation request, and all request messages received in the previous vertical synchronization cycle are non-animation requests, the decoupled vertical synchronization module determines that the current scene is a non-animation scene. When the first request message is a non-animation request, and no request message was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines that the current scene is a non-animation scene; or When the first request message is a non-animation request, and an animation request was received in the previous vertical synchronization cycle, the decoupled vertical synchronization module determines that the current scene is a non-animation to animation scene.
7. The method according to claim 1 or 2, characterized in that, The method further includes: The decoupled vertical synchronization module determines the display time of the next frame of the current rendering frame based on the display time of the current display frame and the vertical synchronization period.
8. The method according to claim 1 or 2, characterized in that, The decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal, including: When the difference between the display time of the next frame of the current rendered frame and the current real time is less than or equal to X vertical synchronization cycles, the decoupled vertical synchronization module sends the first instruction to the rendering module before the next vertical synchronization signal, where X is a positive integer greater than or equal to 1.
9. The method according to claim 1 or 2, characterized in that, The method further includes: The rendering module adds the next frame of the rendered current frame to the buffer queue as a buffer frame in the buffer queue, so that the compositing and display module can obtain the next frame of the current display frame from multiple buffer frames in the buffer queue in each vertical synchronization cycle.
10. The method according to claim 9, characterized in that, The decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal, including: The decoupled vertical synchronization module queries the number of buffers in the buffer queue; When the number of buffers in the buffer queue is less than the maximum number of buffers, the decoupled vertical synchronization module sends the first instruction to the rendering module before the next vertical synchronization signal.
11. The method according to claim 10, characterized in that, The method further includes: When the number of buffers in the buffer queue is greater than or equal to the maximum number of buffers, the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the next vertical synchronization signal.
12. The method according to claim 1 or 2, characterized in that, The device further includes an event state prediction module, and after the first event input, the method further includes: The event state prediction module predicts the state of the first event and updates the state of the first event to the event state corresponding to the display time of the next frame of the current rendering frame.
13. The method according to claim 1 or 2, characterized in that, The decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal, including: When the scenario corresponding to the first event is the first scenario, the decoupling vertical synchronization module starts the decoupling vertical synchronization process. The first scenario includes one or more of the following: list scrolling scenario, application opening scenario, folder opening scenario, control center opening scenario, notification center opening scenario, unlocking scenario, screen rotation scenario, and application transition scenario. When the decoupled vertical synchronization process is initiated, the decoupled vertical synchronization module sends a first instruction to the rendering module before the next vertical synchronization signal.
14. The method according to claim 13, characterized in that, The method further includes: When the current scenario changes to a different scenario than the first scenario, the decoupling vertical synchronization module shuts down the decoupling vertical synchronization process; When the decoupled vertical synchronization process is turned off, the vertical synchronization module sends a second instruction to the rendering module when it receives the next vertical synchronization signal. The second instruction is used to instruct the rendering module to render the next frame of the current display frame. After receiving the second instruction, the rendering module begins rendering the next frame of the currently displayed frame.
15. An electronic device, characterized in that, include: One or more processors; One or more memory units; And one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, the one or more computer programs including instructions that, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 14.
Citation Information
Patent Citations
Data processing method and device in application program starting and storage medium
CN115904563A