[go: up one dir, main page]

WO2025227883A1 - Graphics rendering method and apparatus and electronic device - Google Patents

Graphics rendering method and apparatus and electronic device

Info

Publication number
WO2025227883A1
WO2025227883A1 PCT/CN2025/077289 CN2025077289W WO2025227883A1 WO 2025227883 A1 WO2025227883 A1 WO 2025227883A1 CN 2025077289 W CN2025077289 W CN 2025077289W WO 2025227883 A1 WO2025227883 A1 WO 2025227883A1
Authority
WO
WIPO (PCT)
Prior art keywords
vertical synchronization
rendering
frame
module
animation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/CN2025/077289
Other languages
French (fr)
Chinese (zh)
Inventor
徐超
付明
吴元培
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of WO2025227883A1 publication Critical patent/WO2025227883A1/en
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • G06F3/147Digital output to display device ; Cooperation and interconnection of the display device with other functional units using display panels
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G3/00Control arrangements or circuits, of interest only in connection with visual indicators other than cathode-ray tubes
    • G09G3/20Control arrangements or circuits, of interest only in connection with visual indicators other than cathode-ray tubes for presentation of an assembly of a number of characters, e.g. a page, by composing the assembly by combination of individual elements arranged in a matrix no fixed position being assigned to or needed to be assigned to the individual characters or partial characters
    • G09G3/2007Display of intermediate tones
    • G09G3/2018Display of intermediate tones by time modulation using two or more time intervals
    • G09G3/2022Display of intermediate tones by time modulation using two or more time intervals using sub-frames
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G2340/00Aspects of display data processing

Definitions

  • This application relates to the field of graphics rendering, and more specifically, to a method, apparatus, and electronic device for graphics rendering.
  • VSYNC vertical synchronization
  • VSYNC works by establishing a synchronization signal between the graphics processor (GPU) and the monitor.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the number of first events input within a vertical synchronization cycle is not limited; it can be one or more.
  • the number of frames rendered by the rendering module within a vertical synchronization cycle can be zero, one, or more.
  • the decoupled vertical synchronization module 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.
  • the decoupled vertical synchronization module 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.
  • 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.
  • 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.
  • Virtual timestamps refer to a virtual future time.
  • the vertical synchronization signal is used to indicate the next frame to be displayed.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.
  • This implementation method can also be described as:
  • the decoupled vertical synchronization module sends the first instruction to the rendering module upon receiving the first request message.
  • 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...
  • a first instruction is sent to the rendering module.
  • 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.
  • 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".
  • 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.
  • 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.
  • 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.
  • 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.
  • 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
  • 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.
  • the display time of the next frame can be a virtual timestamp.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the rendering module adds the next frame of the rendered current frame to the buffer queue in a first-in-first-out order.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the number of pre-rendered frames in the buffer queue 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.
  • the device further includes an event state prediction module.
  • 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.
  • 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.
  • 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.
  • the first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.
  • 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.
  • 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.
  • the device further includes a vertical synchronization module
  • 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.
  • the decoupled vertical synchronization process 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.
  • 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.
  • a graphics rendering apparatus comprising a decoupled vertical synchronization module and a rendering module.
  • the decoupled vertical synchronization module includes a pre-execution module.
  • 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
  • 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.
  • 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.
  • 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.
  • the number of first events input within a vertical synchronization cycle is not limited; it can be one or more.
  • the number of frames rendered by the rendering module within a vertical synchronization cycle can be zero, one, or more.
  • 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.
  • 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.
  • 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.
  • 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.
  • Virtual timestamps refer to a virtual future time.
  • the vertical synchronization signal is used to indicate that the next frame of the current display frame will be displayed.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.
  • 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".
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the display time of the next frame can be a virtual timestamp.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the rendering module adds the next frame of the rendered current frame to the buffer queue in a first-in-first-out order.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the number of pre-rendered frames in the buffer queue 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.
  • 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.
  • 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.
  • 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.
  • the decoupled vertical synchronization process is turned off, and the graphics rendering process is executed by the vertical synchronization module.
  • 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.
  • an electronic device 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.
  • a computer-readable storage medium which stores a computer program or instructions that, when executed, implement the method described in the first aspect or any possible implementation thereof.
  • 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.
  • a computer program product 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.
  • Figure 1 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application.
  • Figure 2 is a software structure block diagram of an electronic device provided in an embodiment of this application.
  • Figure 3 is a schematic diagram of a VSYNC architecture
  • Figure 4 is a schematic diagram of the rendering architecture corresponding to the VSYNC architecture
  • Figure 5 is a schematic diagram of the rendering architecture corresponding to another VSYNC architecture
  • Figure 6 is a schematic flowchart of a graphics rendering method provided in an embodiment of this application.
  • Figure 7 is a schematic interactive diagram of a graphics rendering method provided in an embodiment of this application.
  • Figure 8 is a schematic interactive diagram of another graphics rendering method provided in an embodiment of this application.
  • Figure 9 is a schematic diagram of a graphics rendering system architecture provided in an embodiment of this application.
  • FIG. 10 is a schematic diagram of another graphics rendering system architecture provided in an embodiment of this application.
  • Figure 11 is a schematic diagram illustrating the principle of controller control of decoupled vertical synchronous opening and closing provided in an embodiment of this application;
  • Figure 12 is a schematic diagram illustrating the principle of a pre-executor sending a first instruction to a rendering module according to an embodiment of this application;
  • Figure 13 is a schematic diagram illustrating the principle of a virtual timer determining a virtual timestamp according to an embodiment of this application;
  • Figure 14 is a schematic diagram illustrating the principle of an input event prediction module predicting the state of an input event according to an embodiment of this application;
  • Figure 15 is a comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in an embodiment of this application;
  • Figure 16 is a test result diagram 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.
  • 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.
  • a feature defined as “first” or “second” may explicitly or implicitly include one or more of that feature.
  • a plurality of means two or more.
  • 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.
  • 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.
  • 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.
  • AR augmented reality
  • VR virtual reality
  • laptops laptops
  • UMPCs ultra-mobile personal computers
  • PDAs personal digital assistants
  • smart home devices and other electronic devices.
  • Figure 1 shows a schematic diagram of the structure of an electronic device 100.
  • the 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, an antenna 1, an 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.
  • SIM subscriber identification module
  • 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.
  • the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100.
  • 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.
  • Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.
  • AP application processor
  • GPU graphics processing unit
  • ISP image signal processor
  • DSP digital signal processor
  • NPU neural network processing unit
  • 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.
  • the processor 110 may also include a memory for storing instructions and data.
  • 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.
  • 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.
  • I2C inter-integrated circuit
  • UART universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • USB universal serial bus
  • USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, or USB Type-C port.
  • 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.
  • 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.
  • the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
  • 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.
  • 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.
  • electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
  • 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.
  • 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.).
  • 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.
  • 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.
  • Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
  • 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.
  • FIG. 2 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.
  • 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.
  • the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
  • the application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer.
  • APIs application programming interfaces
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
  • 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.
  • 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.
  • 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.
  • the phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
  • the file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • surface manager e.g., media libraries
  • 3D graphics processing libraries e.g., OpenGL ES
  • 2D graphics engines e.g., SGL
  • the Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
  • 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.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
  • a 2D graphics engine is a graphics engine for 2D drawing.
  • 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.
  • 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.
  • 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).
  • PLMNs public land mobile networks
  • V-Sync Vertical sync
  • 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.
  • D-VSYNC Decoupled Vertical Synchronization
  • 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.
  • VSYNC vertical synchronization
  • Figure 3 shows a schematic diagram of a VSYNC architecture.
  • the UI thread maintains frame synchronization with the rendering thread.
  • the VSYNC signal wakes up Choreographer to trigger the UI thread to perform the drawing operation of the first frame; after the drawing of the first frame is completed, the rendering thread immediately enters to render the first frame; then at the beginning of the second VSYNC cycle of compositing display (i.e., VSYNC-sf shown in Figure 3), the compositing display thread is triggered to composite and display the first frame, and at the beginning of the third VSYNC cycle of display (i.e., HW-VSYNC shown in Figure 3), the first frame is displayed on the screen of the electronic device.
  • 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.
  • 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.
  • 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.
  • Figure 4 shows a schematic diagram of the rendering architecture corresponding to the VSYNC architecture.
  • the system adopts a separate rendering architecture, with the UI thread and the compositing and display thread running according to the VSYNC beat.
  • VSYNC-sf can drive the compositing and display thread to compose the N+1th frame
  • VSYNC-app can drive the UI thread to execute the N+2th frame.
  • 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.
  • SurfaceFlinger retrieves the rendered frames from the frame buffer queue, performs compositing and other processing, and then displays them.
  • Figure 5 shows a schematic diagram of another rendering architecture corresponding to the VSYNC architecture.
  • the system adopts a unified rendering architecture, with the UI thread and rendering thread running according to the VSYNC timing.
  • VSYNC-rs can drive the rendering thread to render frame N+1
  • VSYNC-app can drive the UI thread to execute frame N+2.
  • 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
  • VSYNC-app refers to the vertical synchronization signal received by the UI thread, used to indicate the execution of the next frame.
  • VSYNC works by establishing a synchronization signal (VSYNC signal) between the graphics processor (GPU) and the monitor.
  • the monitor begins its next refresh, it sends a VSYNC signal to the GPU.
  • the GPU Upon receiving the VSYNC signal, the GPU begins rendering the next frame.
  • 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.
  • 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.
  • the main loop of VSYNC blocks and waits for the VSYNC signal.
  • the VSYNC signal it sends a trigger command to the rendering thread, which instructs the rendering thread to start rendering the next frame.
  • the rendering thread cannot complete the rendering of the long frame within one VSYNC cycle, resulting in a dropped frame.
  • 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.
  • 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.
  • animate sends a signal to VSYNC to request the execution of the next frame's animation.
  • visualization tests were conducted on the responsiveness of swiping scenarios.
  • a red ball was constructed to follow the finger's touch, and its rendering trajectory was tested.
  • the red ball should strictly follow the touch position and be covered by the fingertip.
  • the red ball clearly appears to fall behind the fingertip.
  • 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.
  • 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.
  • FIG6 shows a schematic flowchart of a graphics rendering method 600 provided in an embodiment of this application.
  • the method 600 includes:
  • D-VSYNC Decoupled Vertical Synchronization
  • 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
  • the first scenario may include, for example, a list scrolling scenario, an app opening scenario, a folder opening scenario, a map zooming scenario, etc.
  • the decoupled vertical synchronization process is not enabled, and graphics rendering is performed based on the VSYNC architecture.
  • the rendering module renders the (i+1)-th frame, and the application module executes the (i+2)-th frame.
  • 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.
  • 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.
  • 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.
  • 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.
  • the decoupled vertical synchronization module 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.
  • the first request message 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.
  • an animation request i.e., a rendering thread property animation, which can be regarded as a self-call request
  • 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.
  • 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.
  • the first virtual timestamp is determined based on the current time and the VSYNC period.
  • 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.
  • 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).
  • 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.
  • 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.
  • the specific method for determining the scenario is as follows:
  • 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.
  • determining a first timing based on a first parameter carried in a first request message includes:
  • the decoupled vertical synchronization module 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.
  • 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.
  • determining the first timing based on the first parameter carried in the first request message includes:
  • the decoupled vertical synchronization module 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.
  • 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.
  • determining the first timing based on the first parameter carried in the first request message includes:
  • the decoupled vertical synchronization module 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.
  • 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.
  • 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.
  • D-VSYNC upon receiving a non-animation request from the application module, immediately sends a first instruction to the rendering module to pre-execute the current frame if it is a non-animation scene.
  • D-VSYNC 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.
  • the decoupled vertical synchronization module 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.
  • 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.
  • 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.
  • the decoupled vertical synchronization module 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.
  • the next VSYNC cycle i.e., when the VSYNC signal is received
  • 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.
  • the rendering module 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.
  • 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.
  • FIG7 shows a schematic interactive diagram of a graphics rendering method 700 provided in an embodiment of this application.
  • the method 700 includes:
  • the decoupling vertical synchronization module includes a controller that controls the activation and deactivation of the decoupling vertical synchronization based on the scenario.
  • the decoupled vertical synchronization module 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.
  • the current scene (animated scene, non-animated scene, or mixed 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.
  • the current scene is determined based on the first parameter and how the first timing is determined based on the current scene, please refer to the description of S602 in the embodiment shown in Figure 6; for brevity, it will not be repeated here.
  • the decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment.
  • 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.
  • the decoupling vertical synchronization module before sending the first instruction to the rendering 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.
  • 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.
  • each pre-rendered frame has a corresponding virtual timestamp.
  • 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.
  • the rendering module 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.
  • 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.
  • the rendering module may request a buffer from the frame buffer queue before sending the first target frame to the frame buffer queue.
  • the frame buffer queue 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.
  • 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.
  • 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.
  • the frame rendering time recorded by the choreographer (VSYNC-app timestamp) 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.
  • 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.
  • the virtual timer calculates when the currently rendered 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.
  • FIG8 shows a schematic interactive diagram of another graphics rendering method 800 provided in an embodiment of this application.
  • the method 800 includes:
  • S801 to S803 are the same as S701 to S703 in the embodiment shown in Figure 7, and will not be described again here for the sake of simplicity.
  • the decoupled vertical synchronization module sends a first query message to the frame buffer queue. This first query message is used to query the number of frames currently existing 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.
  • the number of frames included in the frame buffer queue must be less than or equal to M.
  • 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.
  • the frame buffer queue 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.
  • 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.
  • S807 to S811 are the same as S704 to S708 in the embodiment shown in FIG7, and will not be described again here for the sake of simplicity.
  • the compositing and display module 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.
  • S804 to S806 are an alternative implementation of the "controlling the difference between the first virtual timestamp and the current real timestamp to be less than or equal to X VSYNC cycles" described in the embodiment shown in Figure 6.
  • S804 to S806 are not executed; when the decoupled vertical synchronization module executes 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 needs to be executed.
  • the decoupled vertical synchronization process is turned off, and a vertical synchronization architecture is used for graphics rendering.
  • the composite display module retrieves the next frame of the current display frame from the frame buffer queue.
  • the composite display module After completing the display of the next frame of the current display frame, the composite display module sends a release command to the frame buffer queue, which is used to instruct the frame buffer queue to release the next frame of the current display frame.
  • the frame buffer queue After receiving a release command, the frame buffer queue removes the next frame from the frame buffer queue of the currently displayed frame.
  • 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.
  • Figure 9 shows a schematic diagram of a system architecture for graphics rendering provided in an embodiment of this application.
  • 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:
  • 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.
  • the rendering module renders the (i+1)-th frame
  • the application module executes the (i+2)-th frame.
  • 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.
  • 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.
  • 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.
  • 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.
  • the frame buffer queue 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.
  • 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.
  • D-VSYNC can be partially or completely turned off when the rendering process depends on unpredictable data or incompatible applications.
  • Figure 10 shows a schematic diagram of another system architecture for graphics rendering provided in an embodiment of this application.
  • 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.
  • 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:
  • 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.
  • the rendering module renders the (i+1)-th frame
  • the application module executes the (i+2)-th frame.
  • the embodiment shown in Figure 10 adds an input event prediction module 1000 to the embodiment shown in Figure 9, so that the state of the input event is the event state corresponding to the virtual time calculated by the virtual timer. That is, the state of the input event is updated 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 can avoid rendering errors caused by the loss of the latest event state between rendering and display due to the frame being executed before some VSYNC cycles in the D-VSYNC pre-rendering architecture, and can improve the accuracy of real-time rendering.
  • the embodiment shown in Figure 10 differs from the embodiment shown in Figure 9 in steps S1001 to S1003, specifically:
  • 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.
  • a predictor list sliding predictor 1100, zoom event predictor 1200, or other predictor
  • 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.
  • 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.
  • the input event prediction module 1000 updates the status of the first predicted event to the application module.
  • 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).
  • ESPL event state prediction layer
  • LSPP list scrolling position predictor
  • S1004 to S1012 are the same as S902 to S910 in the embodiment shown in Figure 9, and will not be described again here for the sake of simplicity.
  • controller 921, pre-executor 922, virtual timer 923, and input event prediction module 1000 in the decoupled vertical synchronization module 900 will be described in detail below with reference to Figures 11 to 14.
  • Figure 11 shows a schematic diagram of the principle of controller control of decoupled vertical synchronization on and off according to an embodiment of this application.
  • the controller is used to control the start and stop of D-VSYNC.
  • the controller is also used to configure D-VSYNC parameters.
  • the D-VSYNC parameters may include the maximum number of buffers in the frame buffer queue, and may also include other VSYNC configuration parameters, such as the VSYNC period.
  • the controller in D-VSYNC exposes API interfaces for starting, stopping, and configuring to the APP layer.
  • the APP layer (or OS) instructs the controller to start D-VSYNC through these API interfaces.
  • the controller can be instructed to disable D-VSYNC via this API interface.
  • This implementation method can take full advantage of the APP's familiarity with the scene and avoid dropping frames in the first frame.
  • the rendering module's performance monitoring module performs rendering frame rate and per-frame execution time statistics.
  • D-VSYNC is enabled through the controller.
  • the performance monitoring module can disable D-VSYNC via the controller when the scene changes to a different scenario.
  • This implementation method enables automatic start and stop of D-VSYNC without requiring any changes at the APP level.
  • Figure 12 shows a schematic diagram of the principle of a pre-executor sending a first instruction to a rendering module according to an embodiment of this application.
  • 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 a first instruction to the rendering module at the first timing to instruct the rendering module to execute the next frame, and uses a first virtual timestamp to represent the display time of the rendered frame.
  • 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.
  • the pre-executor determines the first timing based on the first parameter.
  • 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.
  • 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.
  • the pre-executor determines a first timing based on a first parameter, including:
  • 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.
  • the current scene is an animation scene (which can be understood as a continuous animation scene).
  • the pre-executor sends the first instruction to the rendering module immediately after receiving the first request message.
  • the current scene is a mixed scene, specifically, an animation-to-non-animation scene within a mixed scene.
  • 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.
  • 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.
  • the current scene is a mixed scene, specifically a non-animation-to-animation scene within a mixed scene.
  • 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.
  • the pre-executor 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.
  • the rendering module 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.
  • 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.
  • Figure 13 shows a schematic diagram of the principle of a virtual timer for determining a virtual timestamp according to an embodiment of this application.
  • 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 be displayed on the screen in the future, which is virtualized based on the timestamp of the previous frame and the VSYNC period.
  • the first request message carries a second parameter, which is used to carry the timestamp of the current frame (i.e., the previous frame of the current pre-rendered frame).
  • This second parameter can be lastVSyncTS.
  • 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 first request message is a non-animation request
  • the second parameter has a default value of 0.
  • 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 a traditional VSYNC, where lastVSyncTS represents the timestamp of the current frame (i.e., the previous frame of the current pre-rendered frame).
  • 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.
  • 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.
  • the first VSYNC timestamp expected after the current time is used as the virtual timestamp of the next frame.
  • 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 case of frame stacking, time rollback will not occur due to a sudden receipt of a non-animation request.
  • the real VSYNC signal records the real timestamp (realVSyncTS) and the real VSYNC period (realPeriod) for each VSYNC period.
  • 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.
  • This calibration helps prevent the accumulation of errors in virtual timestamps.
  • 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.
  • Figure 14 shows a schematic diagram of the principle of an input event prediction module predicting the state of an input event according to an embodiment of this application.
  • 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.
  • LSPP List Scroll Position Predictor
  • LSPP when the application component displays a scrollable list of items (i.e., the input event is a list scrolling event), LSPP is activated and takes effect. After LSPP is activated, a model is selected based on the scrolling of the item list. Specifically, when the item list scrolls upwards quickly, the upward curve model shown in Figure 14(a) is selected; when the item list scrolls downwards quickly, the downward curve model shown in Figure 14(a) is selected; and when the item list scrolls slowly, the straight line model shown in Figure 14(a) is selected.
  • 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.
  • 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.
  • Figure 14(b) shows a schematic diagram of the principle of the Map Zoom Distance Predictor (MZDP) in the input event prediction module predicting the state of zoom events.
  • MZDP Map Zoom Distance Predictor
  • MZDP is activated and takes effect.
  • 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...
  • the model is updated based on the calculated distance between the two touch points.
  • 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.
  • 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.
  • 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.
  • the D-VSYNC architecture provides rollback and fault tolerance mechanisms for the frame buffer queue, specifically:
  • the input event prediction module records the event state prediction data.
  • 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.
  • 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.
  • 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.
  • rollback and fault tolerance mechanisms set up for the frame buffer queue in the D-VSYNC architecture are optional.
  • application logic can determine the inaccuracy of the prediction and explicitly call the API interface for discarding buffered frames.
  • an API interface for discarding buffered frames may not be configured.
  • Figure 15 shows a comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in an embodiment of this application.
  • the VSYNC rendering pipeline maintains frame synchronization between the UI thread and the rendering thread.
  • the VSYNC signal triggers the UI thread to draw the first frame.
  • the rendering thread immediately follows to render the first frame.
  • the compositing and display thread is triggered to composite and display the first frame.
  • 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.
  • the D-VSYNC rendering pipeline pre-renders frames and adds them to the frame buffer queue, accumulating frames to be displayed—this is the accumulation stage in the D-VSYNC rendering pipeline shown in Figure 15.
  • D-VSYNC uses a frame synchronization method between the UI thread and the rendering thread for pre-rendering—this is the synchronization stage in the D-VSYNC rendering pipeline shown in Figure 15.
  • the UI thread draws the 11th frame, since the 11th frame is a very long frame, drawing the 11th frame takes more than 3 VSYNC cycles.
  • the compositing and display thread consumes the pre-rendered frames in the frame buffer queue in a first-in-first-out order. In this way, even if the rendering thread cannot perform rendering operations within 3 cycles, frames can still be displayed on the screen during those 3 cycles, thus avoiding frame drops.
  • D-VSYNC After the 11th frame is rendered, since the number of buffers in the frame buffer queue is less than the maximum allowed number of buffers, D-VSYNC will start pre-rendering frames again to accumulate the frames to be displayed, which is the long frame & accumulation stage in the D-VSYNC rendering pipeline in Figure 15; when the number of buffers in the frame buffer queue reaches the maximum allowed number of buffers, D-VSYNC switches to pre-rendering by keeping the UI thread and the rendering thread synchronized, which is the synchronization stage in the D-VSYNC rendering pipeline in Figure 15.
  • the execution entity of the UI thread can be the application module
  • the execution entity of the rendering thread can be the rendering module
  • the execution entity of the compositing and display thread can be the compositing and display module.
  • D-VSYNC extends the VSYNC framework, dividing the rendering framework into an accumulation phase and a synchronization phase.
  • D-VSYNC decouples rendering time from display time.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • the number of buffers in the D-VSYNC frame buffer queue was 5, it eliminated 87.7% of frame drops, and the average FDPS for 25 applications decreased from 2.04 to 0.25.
  • Figure 16 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.
  • D-VSYNC with 5 buffers has higher responsiveness. For continuous fast scrolling scenes, it can reduce the average pixel difference (APD) by 61.6%, and for slow scrolling scenes, it can reduce the APD by 55.9%.
  • APD average pixel difference
  • 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.
  • 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.
  • 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.
  • One or more modules or units described herein can be implemented in software, hardware, or a combination of both.
  • 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.
  • SoC System-on-a-Chip
  • ASIC application-specific integrated circuit
  • the processor 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.
  • FPGAs field-programmable gate arrays
  • PLDs programmable logic devices
  • 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.
  • the modules or units described herein When the modules or units described herein are implemented using software, they can be implemented, in whole or in part, in the form of a computer program product.
  • the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, 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.
  • 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)).
  • the disclosed systems, apparatuses, and methods can be implemented in other ways.
  • 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.
  • multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Human Computer Interaction (AREA)
  • General Engineering & Computer Science (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The present application provides a graphics rendering method applied to a graphics rendering apparatus. The apparatus comprises a decoupling vertical synchronization module and a rendering module, and the method comprises: in a vertical synchronization period, in response to the input of a first event, the decoupling vertical synchronization module sends a first instruction to the rendering module at a first opportunity, to instruct the rendering module to render a frame following a current rendered frame, wherein the first opportunity is previous to the moment when a following vertical synchronization signal is received, and the first instruction is also used for representing a display time of the frame following the current rendered frame; and upon receiving the first instruction, the rendering module starts rendering the frame following the current rendered frame. The method can decouple the vertical synchronization dependence between rendering and display, and subsequent frames can be pre-rendered by using the residual execution time of a short frame, without waiting the execution of a vertical synchronization signal triggering frame, realizing asynchronous parallelism of rendering and sending for display, and reducing the frame loss rate and the rendering delay.

Description

图形渲染的方法、装置和电子设备Methods, apparatus and electronic devices for graphics rendering

本申请要求于2024年04月30日提交中国专利局、申请号为202410539029.0、申请名称为“图形渲染的方法、装置和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 202410539029.0, filed on April 30, 2024, entitled "Method, Apparatus and Electronic Device for Graphic Rendering", the entire contents of which are incorporated herein by reference.

技术领域Technical Field

本申请实施例涉及图形渲染领域,并且更具体地,涉及一种图形渲染的方法、装置和电子设备。This application relates to the field of graphics rendering, and more specifically, to a method, apparatus, and electronic device for graphics rendering.

背景技术Background Technology

目前,电子设备通过采用垂直同步(vertical synchronization,VSYNC)技术,避免电子设备的屏幕在显示的过程中出现画面撕裂的情况,以提高屏幕显示的流畅度和稳定性。Currently, electronic devices use vertical synchronization (VSYNC) technology to avoid screen tearing during display, thereby improving the smoothness and stability of the screen display.

然而,VSYNC的工作原理是通过在图形处理器和显示器之间建立一个同步信号来实现的,当显示器开始进行下一次刷新时,发送VSYNC信号到图形处理器,图形处理器在接收到VSYNC信号后开始渲染下一帧。也就是说,图像处理器必须等待显示器完成刷新后,才能渲染下一帧,这很可能会导致渲染帧率的降低和渲染的延迟,尤其是在负载波动较大的时候,容易导致丢帧和渲染延迟。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

本申请提供一种图形渲染的方法、装置和电子设备。通过该方法、装置和电子设备,能够解耦渲染和显示的垂直同步依赖,不需要等待垂直同步信号触发帧的执行,而是可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

第一方面,提供一种图形渲染的方法,该方法应用于图形渲染装置,该装置包括解耦垂直同步模块和渲染模块,该方法包括:在一个垂直同步周期内,响应于第一事件的输入,该解耦垂直同步模块在第一时机向该渲染模块发送第一指令,该第一请求消息用于请求渲染当前渲染帧的下一帧,该第一指令用于指示该渲染模块渲染当前渲染帧的下一帧,其中,该第一时机在接收到下一个垂直同步信号的时刻之前,该第一指令还用于表示当前渲染帧的下一帧的显示时间;该渲染模块在接收到该第一指令后,开始渲染当前渲染帧的下一帧。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.

在一些实施例中,垂直同步周期为两个相邻的帧显示的时间间隔;垂直同步周期还可以理解为显示屏连续两次刷新的时间间隔;垂直同步周期还可以理解为连续接收到两个垂直同步信号的时间间隔。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.

其中,当前渲染帧的下一帧可以指渲染模块当前完成渲染的帧的下一帧,该当前渲染帧可以是当前显示帧的下一帧,还可以是上一个预渲染的帧;该当前渲染帧还未显示在设备的屏幕上。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.

在一些实施例中,第一事件可以是应用层面上的用户输入事件,例如用户滑动事件、打开APP的事件等;该第一事件还可以是渲染模块渲染完成当前帧,请求渲染下一帧的事件。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.

应注意:在一个垂直同步周期内,所输入的第一事件的数量不限定,可以是1个,也可以是多个,对应地,渲染模块在一个垂直同步周期内渲染的帧的数量可以是0个或1个,也可以是多个。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.

在一个示例中,在一个垂直同步周期内:In one example, within one vertical synchronization cycle:

响应于第1个第一事件的输入,解耦垂直同步模块在该垂直同步周期内的第一时刻向渲染模块发送第1个第一指令,其中,假设渲染模块当前刚完成第1帧的渲染,则该第一个第一指令用于指示渲染模块渲染第2帧,该第1个第一指令还用于表示该第2帧的显示时间;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.

响应于第2个第一事件的输入,解耦垂直同步模块在该垂直同步周期内的第二时刻向渲染模块发送第2个第一指令,该第2个第一指令用于指示渲染模块渲染第3帧,该第2个第一指令还用于表示该第3帧的显示时间。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.

类似地,在一个垂直同步周期内,只会完成一帧的显示,但渲染模块却可以完成多帧的渲染,即能够实现帧的预渲染,其中,在一个垂直同步周期内所渲染的帧的数量不固定,会受帧的长短、垂直同步周期的长短等因素的影响,也可以理解为:本申请实施例提供的方案中,对帧的渲染过程不受垂直同步周期和垂直同步信号约束。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.

在一些实施例中,第一指令表示当前渲染帧的下一帧的显示时间的方式为:第一指令携带第一虚拟时间戳,该第一虚拟时间戳用于表示当前渲染帧的下一帧的显示时间。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.

其中,虚拟时间戳是指虚拟出来的一个未来的时间。Virtual timestamps refer to a virtual future time.

其中,垂直同步信号用于指示即将显示当前显示帧的下一帧。本申请实施例中,通过对帧进行预渲染,并为预渲染的帧赋予一个虚拟的显示时间,能够解耦渲染和显示之间的垂直同步依赖,不需要等待垂直同步信号触发帧的执行,可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块在第一时机向所述渲染模块发送第一指令,包括:该解耦垂直同步模块接收第一请求消息,该第一请求消息用于请求渲染当前渲染帧的下一帧;该解耦垂直同步模块根据当前场景,在第一时机向该渲染模块发送该第一指令。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.

其中,当前场景包括动画场景(也可描述为连续动画场景)、非动画场景(也可描述为连续非动画场景)、动画转非动画场景、非动画转动画场景中的一项。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块根据当前场景,在第一时机向该渲染模块发送第一指令,包括:当当前场景为动画场景或非动画场景时,该解耦垂直同步模块向该渲染模块发送该第一指令。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块根据当前场景,在第一时机向该渲染模块发送第一指令,包括:当当前场景为动画转非动画场景时,该解耦垂直同步模块等待接收非动画请求,若在m个垂直同步周期内接收到非动画请求,则该解耦垂直同步模块在接收到非动画请求时,向渲染模块发送第一指令,若在该m个垂直同步周期内未接收到非动画请求,则解耦垂直同步模块在该m个垂直同步周期结束时向该渲染模块发送第一指令,其中,m个垂直同步周期的计时起点为该解耦垂直同步模块接收到第一请求消息的时刻,m为大于1,且小于等于2的任意数值。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块根据当前场景,在第一时机向该渲染模块发送第一指令,包括:当当前场景为非动画转动画场景时,该解耦垂直同步模块等待接收动画请求,若在该m个垂直同步周期内接收到动画请求,则该解耦垂直同步模块在接收到该动画请求时,向渲染模块发送第一指令,若在该m个垂直同步周期内未接收到动画请求,则该解耦垂直同步模块在该m个垂直同步周期结束时向渲染模块发送第一指令。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.

在一些示例中,m的值为1.1、1.2、1.3、1.5、1.8中的任意一个。In some examples, the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.

该实现方式还可以描述为:This implementation method can also be described as:

当当前场景为动画场景或非动画场景时,该解耦垂直同步模块在接收到该第一请求消息时向该渲染模块发送该第一指令;当当前场景为动画转非动画场景时,该解耦垂直同步模块在接收到该第一请求消息时开始等待,最大等待时长设置为m个垂直同步周期,若在当前等待时长小于m个垂直同步周期时接收到非动画请求,则该解耦垂直同步模块在接收到该非动画请求时,向渲染模块发送第一指令;若在当前等待时长达到m个垂直同步周期时仍未接收到非动画请求,则该解耦垂直同步模块在当前等待时长达到m个垂直同步周期时,向渲染模块发送第一指令;当当前场景为非动画转动画场景时,该解耦垂直同步模块在接收到该第一请求消息时开始等待,最大等待时长设置为m个垂直同步周期,若在当前等待时长小于m个垂直同步周期时接收到动画请求,则该解耦垂直同步模块在接收到该动画请求时,向渲染模块发送第一指令;若在当前等待时长达到m个垂直同步周期时仍未接收到动画请求,则该解耦垂直同步模块在当前等待时长达到m个垂直同步周期时,向渲染模块发送第一指令。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.

可以理解:若当前场景为动画场景或非动画场景,则该解耦垂直同步模块立即向该渲染模块发送该第一指令,可以将确定当前场景为动画场景或非动画场景理解为向该渲染模块发送该第一指令的触发条件,在确定满足该触发条件时,向该渲染模块发送该第一指令的触发条件,在“确定当前场景为动画场景或非动画场景”和“向该渲染模块发送该第一指令”这两个动作之间没有时间间隔或时间间隔极短。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".

本申请实施例中,在不同的场景下,解耦垂直同步模块向渲染模块发送第一指令的时机可能不同,不需要等待垂直同步信号触发帧的执行,可以利用短帧剩余的执行时间对后续的帧进行预渲染,并为预渲染的帧赋予一个虚拟时间戳,用于表示其显示时间,能够解耦渲染和显示之间的垂直同步依赖,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第一方面,在一种可能的实现方式中,该方法还包括:该解耦垂直同步模块根据该第一请求消息携带的第一参数确定当前场景,该第一参数用于指示该第一请求消息的类型,该第一请求消息的类型包括动画请求或非动画请求,动画请求来自渲染模块,非动画请求来自应用模块。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.

具体地,该解耦垂直同步模块根据该第一请求消息携带的该第一参数和在上一个垂直同步周期内接收的请求消息携带的参数确定当前场景。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.

本申请实施例中,用于请求执行下一帧的请求消息携带用于指示该请求消息的类型的参数,使得解耦垂直同步模块能够基于该参数确定向渲染模块发送第一指令的第一时机,为帧的预渲染提供基础。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块根据该第一请求消息携带的第一参数确定当前场景,包括:当该第一请求消息为动画请求,且在上一个垂直同步周期没有收到非动画请求时,该解耦垂直同步模块确定当前场景为动画场景,该垂直同步周期为两个相邻的帧显示的时间间隔;当该第一请求消息为动画请求,且在上一个垂直同步周期内有收到非动画请求时,该解耦垂直同步模块确定当前场景为动画转非动画场景;当该第一请求消息为非动画请求,且在上一个垂直同步周期收到的请求消息均为非动画请求时,或者当该第一请求消息为非动画请求,且在上一个垂直同步周期内没有收到任何请求消息时,该解耦垂直同步模块确定当前场景为非动画场景;当该第一请求消息为非动画请求,且在上一个垂直同步周期内有收到动画请求时,该解耦垂直同步模块确定当前场景为非动画转动画场景。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.

结合第一方面,在一种可能的实现方式中,该方法还包括:该解耦垂直同步模块根据当前显示帧的显示时间和垂直同步周期确定当前渲染帧的下一帧的显示时间。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.

其中,下一帧的显示时间可以是一个虚拟时间戳。The display time of the next frame can be a virtual timestamp.

本申请实施例中,通过为预渲染的帧赋予一个虚拟时间戳,用于表示其显示时间,能够解耦渲染和显示之间的垂直同步依赖,使得不需要等待垂直同步信号就能够触发帧的执行。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.

结合第一方面,在一种可能的实现方式中,该解耦垂直同步模块在第一时机向该渲染模块发送第一指令,包括:当当前渲染帧的下一帧的显示时间和当前的真实时间之间的差值小于或等于X个垂直同步周期时,该解耦垂直同步模块在第一时机向该渲染模块发送该第一指令,该X为大于或等于1的正整数。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.

在一些实施例中,当该第一虚拟时间戳和当前的真实时间戳之间的差值大于X个垂直同步周期时,等待来自合成送显模块的下一个垂直同步信号,在接收到该下一个垂直同步信号后,向渲染模块发送第一指令。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.

本申请实施例中,通过控制预渲染的帧对应的虚拟时间戳和当前的真实时间戳之间的差值小于预设值,可以实现控制预渲染的帧的数量小于预设数量,这样,能够避免由于预渲染的帧的数量过多而造成的存储资源浪费,并且,预渲染的帧的数量过多时,预渲染的帧的准确度可能会下降,控制预渲染的帧的数量小于预设数量,也能够提高预渲染的帧的准确度。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.

结合第一方面,在一种可能的实现方式中,该方法还包括:该渲染模块将渲染完成的该当前渲染帧的下一帧加入缓冲队列,作为该缓冲队列中的缓冲帧,以使得合成送显模块在每个垂直同步周期内从该缓冲队列中的多个缓冲帧中获取当前显示帧的下一帧。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.

在一些实施例中,该渲染模块将渲染完成的该当前渲染帧的下一帧按照先进先出的顺序加入该缓冲队列,对应地,合成送显模块在每个垂直同步周期内,例如在每个垂直同步周期开始时,按照先进先出的顺序从该缓冲队列中的多个缓冲帧中获取当前显示帧的下一帧。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.

结合第一方面,在一种可能的实现方式中,该解耦垂直同步模块在第一时机向该渲染模块发送第一指令,包括:该解耦垂直同步模块查询该缓冲队列中的缓冲数量;当该缓冲队列中的缓冲数量小于最大缓冲数量时,该解耦垂直同步模块在该第一时机向该渲染模块发送该第一指令。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.

在一些实施例中,该解耦垂直同步模块向该缓冲队列发送第一查询消息,该第一查询消息用于查询该缓冲队列中的缓冲数量。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.

结合第一方面,在一种可能的实现方式中,该方法还包括:当该缓冲队列中的缓冲数量大于或等于该最大缓冲数量时,该解耦垂直同步模块在接收到下一个垂直同步信号时,向该渲染模块发送该第一指令。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.

具体地,当该缓冲队列中的缓冲数量大于或等于该最大缓冲数量时,该解耦垂直同步模块等待来自该合成送显模块的下一个垂直同步信号;该解耦垂直同步模块在接收到该下一个垂直同步信号时,向该渲染模块发送该第一指令。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.

本申请实施例中,通过控制缓冲队列中的预渲染的帧的数量小于预设数量,这样,能够避免由于预渲染的帧的数量过多而造成的存储资源浪费,并且,预渲染的帧的数量过多时,预渲染的帧的准确度可能会下降,控制预渲染的帧的数量小于预设数量,也能够提高预渲染的帧的准确度。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.

结合第一方面,在一种可能的实现方式中,该装置还包括事件状态预测模块,在第一事件输入之后,该方法还包括:该事件状态预测模块对该第一事件的状态进行预测,以将该第一事件的状态更新为与下一帧的显示时间对应的事件状态。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.

本申请实施例中,当响应于事件进行帧的预渲染时,在事件传递之前,对事件状态进行预测,将事件的当前状态修改为与预渲染的帧的显示时间对应的状态,能够提高帧的预渲染的正确性。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.

结合第一方面,在一种可能的实现方式中,解耦垂直同步模块在第一时机向该渲染模块发送第一指令,包括:当该第一事件对应的场景为第一场景时,该解耦垂直同步模块启动解耦垂直同步流程;在该解耦垂直同步流程启动的情况下,该解耦垂直同步模块在第一时机向该渲染模块发送第一指令。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.

其中,第一场景是指存在负载波动的场景,或是存在重负载的场景。The first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.

在一些实施例中,该第一场景包括列表滑动的场景、打开应用程序的场景、打开文件夹的场景、打开控制中心的场景、打开通知中心的场景、解锁的场景、横竖屏旋转的场景、应用间转场的场景中的一项或者多项。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.

本申请实施例中,在当前场景为存在负载波动的场景或者存在重负载的场景时,才会启动解耦垂直同步模块执行图形渲染流程。可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第一方面,在一种可能的实现方式中,该装置还包括垂直同步模块,该方法还包括:在当前场景变化为非第一场景时,该解耦垂直同步模块关闭解耦垂直同步流程;在该解耦垂直同步流程关闭的情况下,该垂直同步模块在接收到该下一个垂直同步信号时,向该渲染模块发送第二指令,该第二指令用于指示该渲染模块渲染当前显示帧的下一帧;该渲染模块在接收到该第二指令后,开始渲染当前显示帧的下一帧。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.

本申请实施例中,在当前场景为不需要进行帧的预渲染的场景(即不存在负载波动或者重负载)时,解耦垂直同步流程关闭,由垂直同步模块执行图形渲染流程,垂直同步模块在每次接收到合成显示线程发送的垂直同步信号后,指示渲染模块开始渲染下一帧,不对帧进行预渲染。这样,能够实现解耦垂直同步模块和垂直同步模块之间基于场景的配合,能够使得本申请方案应用于更多的场景。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.

第二方面,提供一种图形渲染的装置,该装置包括解耦垂直同步模块和渲染模块,该解耦垂直同步模块包括预执行模块,具体地:该预执行模块,用于在一个垂直同步周期内,响应于第一事件的输入,在第一时机向该渲染模块发送第一指令,该第一请求消息用于请求渲染当前渲染帧的下一帧,该第一指令用于指示该渲染模块渲染当前渲染帧的下一帧,其中,该第一时机在接收到下一个垂直同步信号的时刻之前,该第一指令还用于表示当前渲染帧的下一帧的显示时间;该渲染模块,用于在接收到该第一指令后开始渲染当前渲染帧的下一帧。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.

其中,当前渲染帧的下一帧可以指渲染模块当前完成渲染的帧的下一帧,该当前渲染帧可以是当前显示帧的下一帧,还可以是上一个预渲染的帧;该当前渲染帧还未显示在设备的屏幕上。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.

在一些实施例中,第一事件可以是应用层面上的用户输入事件,例如用户滑动事件、打开APP的事件等;该第一事件还可以是渲染模块渲染完成当前帧,请求渲染下一帧的事件。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.

应注意:在一个垂直同步周期内,所输入的第一事件的数量不限定,可以是1个,也可以是多个,对应地,渲染模块在一个垂直同步周期内渲染的帧的数量可以是0个或1个,也可以是多个。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.

在一个示例中,在一个垂直同步周期内:In one example, within one vertical synchronization cycle:

响应于第1个第一事件的输入,预执行模块在该垂直同步周期内的第一时刻向渲染模块发送第1个第一指令,其中,假设渲染模块当前刚完成第1帧的渲染,则该第一个第一指令用于指示渲染模块渲染第2帧,该第1个第一指令还用于表示该第2帧的显示时间;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.

响应于第2个第一事件的输入,预执行模块在该垂直同步周期内的第二时刻向渲染模块发送第2个第一指令,该第2个第一指令用于指示渲染模块渲染第3帧,该第2个第一指令还用于表示该第3帧的显示时间。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.

类似地,在一个垂直同步周期内,只会完成一帧的显示,但渲染模块却可以完成多帧的渲染,即能够实现帧的预渲染,其中,在一个垂直同步周期内所渲染的帧的数量不固定,会受帧的长短、垂直同步周期的长短等因素的影响,也可以理解为:本申请实施例提供的方案中,对帧的渲染过程不受垂直同步周期和垂直同步信号约束。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.

在一些实施例中,第一指令表示当前渲染帧的下一帧的显示时间的方式为:第一指令携带第一虚拟时间戳,该第一虚拟时间戳用于表示当前渲染帧的下一帧的显示时间。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.

其中,虚拟时间戳是指虚拟出来的一个未来的时间。Virtual timestamps refer to a virtual future time.

其中,垂直同步信号用于指示即将显示当前显示帧的下一帧。The vertical synchronization signal is used to indicate that the next frame of the current display frame will be displayed.

本申请实施例中,通过对帧进行预渲染,并为预渲染的帧赋予一个虚拟的显示时间,能够解耦渲染和显示之间的垂直同步依赖,不需要等待垂直同步信号触发帧的执行,可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第二方面,在一种可能的实现方式中,预执行模块具体用于:接收第一请求消息,该第一请求消息用于请求渲染当前渲染帧的下一帧;根据当前场景,在第一时机向该渲染模块发送该第一指令。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.

其中,当前场景包括动画场景(也可描述为连续动画场景)、非动画场景(也可描述为连续非动画场景)、动画转非动画场景、非动画转动画场景中的一项。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.

结合第二方面,在一种可能的实现方式中,预执行模块还具体用于:当当前场景为动画场景或非动画场景时,向该渲染模块发送该第一指令。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.

结合第二方面,在一种可能的实现方式中,预执行模块还具体用于:当当前场景为动画转非动画场景时,等待接收非动画请求,若在m个垂直同步周期内接收到非动画请求,则在接收到非动画请求时,向渲染模块发送第一指令,若在该m个垂直同步周期内未接收到非动画请求,则在该m个垂直同步周期结束时向该渲染模块发送第一指令,其中,m个垂直同步周期的计时起点为接收到第一请求消息的时刻,m为大于1,且小于等于2的任意数值。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.

结合第二方面,在一种可能的实现方式中,预执行模块还具体用于:当当前场景为非动画转动画场景时,等待接收动画请求,若在该m个垂直同步周期内接收到动画请求,则在接收到该动画请求时,向渲染模块发送第一指令,若在该m个垂直同步周期内未接收到动画请求,则在该m个垂直同步周期结束时向渲染模块发送第一指令。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.

在一些示例中,m的值为1.1、1.2、1.3、1.5、1.8中的任意一个。In some examples, the value of m is any one of 1.1, 1.2, 1.3, 1.5, and 1.8.

可以理解:若当前场景为动画场景或非动画场景,则预执行模块立即向该渲染模块发送该第一指令,可以将确定当前场景为动画场景或非动画场景理解为向该渲染模块发送该第一指令的触发条件,在确定满足该触发条件时,向该渲染模块发送该第一指令的触发条件,在“确定当前场景为动画场景或非动画场景”和“向该渲染模块发送该第一指令”这两个动作之间没有时间间隔。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".

本申请实施例中,在不同的场景下,解耦垂直同步模块向渲染模块发送第一指令的时机可能不同,不需要等待垂直同步信号触发帧的执行,可以利用短帧剩余的执行时间对后续的帧进行预渲染,并为预渲染的帧赋予一个虚拟时间戳,用于表示其显示时间,能够解耦渲染和显示之间的垂直同步依赖,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第二方面,在一种可能的实现方式中,预执行模块还具体用于:根据该第一请求消息携带的第一参数确定当前场景,该第一参数用于指示该第一请求消息的类型,该第一请求消息的类型包括动画请求或非动画请求,动画请求来自渲染模块,非动画请求来自应用模块。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.

具体地,该解耦垂直同步模块根据该第一请求消息携带的该第一参数和在上一个垂直同步周期内接收的请求消息携带的参数确定当前场景。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.

本申请实施例中,用于请求执行下一帧的请求消息携带用于指示该请求消息的类型的参数,使得解耦垂直同步模块能够基于该参数确定向渲染模块发送第一指令的第一时机,为帧的预渲染提供基础。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.

结合第二方面,在一种可能的实现方式中,该预执行模块具体用于:当该第一请求消息为动画请求,且在上一个垂直同步周期没有收到非动画请求时,确定当前场景为动画场景,该垂直同步周期为两个相邻的帧显示的时间间隔;当该第一请求消息为动画请求,且在上一个垂直同步周期内有收到非动画请求时,确定当前场景为动画转非动画场景;当该第一请求消息为非动画请求,且在上一个垂直同步周期收到的请求消息均为非动画请求时,或者当该第一请求消息为非动画请求,且在上一个垂直同步周期内没有收到任何请求消息时,确定当前场景为非动画场景;当该第一请求消息为非动画请求,且在上一个垂直同步周期内有收到动画请求时,确定当前场景为非动画转动画场景。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.

结合第二方面,在一种可能的实现方式中,该解耦垂直同步模块还包括:虚拟时间模块,用于根据当前显示帧的显示时间和垂直同步周期确定当前渲染帧的下一帧的显示时间。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.

其中,下一帧的显示时间可以是一个虚拟时间戳。The display time of the next frame can be a virtual timestamp.

本申请实施例中,通过为预渲染的帧赋予一个虚拟时间戳,用于表示其显示时间,能够解耦渲染和显示之间的垂直同步依赖,使得不需要等待垂直同步信号就能够触发帧的执行。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.

结合第二方面,在一种可能的实现方式中,该预执行模块还具体用于:当当前渲染帧的显示时间和当前的真实时间之间的差值小于或等于X个垂直同步周期时,在第一时机向该渲染模块发送该第一指令,该X为大于或等于1的正整数。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.

在一些实施例中,该预执行模块还具体用于:当当前渲染帧的下一帧的显示时间和当前的真实时间之间的差值大于X个垂直同步周期时,等待来自合成送显模块的下一个垂直同步信号,在接收到该下一个垂直同步信号后,向渲染模块发送第一指令。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.

本申请实施例中,通过控制预渲染的帧对应的虚拟时间戳和当前的真实时间戳之间的差值小于预设值,可以实现控制预渲染的帧的数量小于预设数量,这样,能够避免由于预渲染的帧的数量过多而造成的存储资源浪费,并且,预渲染的帧的数量过多时,预渲染的帧的准确度可能会下降,控制预渲染的帧的数量小于预设数量,也能够提高预渲染的帧的准确度。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.

结合第二方面,在一种可能的实现方式中,该渲染模块还用于:将渲染完成的该当前渲染帧的下一帧加入缓冲队列,作为该缓冲队列中的缓冲帧,以使得合成送显模块在每个垂直同步周期内从该缓冲队列中的多个缓冲帧中获取当前显示帧的下一帧。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.

在一些实施例中,该渲染模块将渲染完成的该当前渲染帧的下一帧按照先进先出的顺序加入该缓冲队列,对应地,合成送显模块在每个垂直同步周期内,例如在每个垂直同步周期开始时按照先进先出的顺序从该缓冲队列中的多个缓冲帧中获取当前显示帧的下一帧。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.

结合第二方面,在一种可能的实现方式中,该预执行模块还具体用于:查询该缓冲队列中的缓冲数量;当该缓冲队列中的缓冲数量小于最大缓冲数量时,在该第一时机向该渲染模块发送该第一指令。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.

在一些实施例中,该预执行模块向该缓冲队列发送第一查询消息,该第一查询消息用于查询该缓冲队列中的缓冲数量。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.

结合第二方面,在一种可能的实现方式中,该预执行模块还用于:当该缓冲队列中的缓冲数量大于或等于该最大缓冲数量时,在接收到该下一个垂直同步信号时,向该渲染模块发送该第一指令。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.

具体地,当该缓冲队列中的缓冲数量大于或等于该最大缓冲数量时,预执行模块等待来自该合成送显模块的下一个垂直同步信号;预执行模块在接收到该下一个垂直同步信号时,向该渲染模块发送该第一指令。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.

本申请实施例中,通过控制缓冲队列中的预渲染的帧的数量小于预设数量,这样,能够避免由于预渲染的帧的数量过多而造成的存储资源浪费,并且,预渲染的帧的数量过多时,预渲染的帧的准确度可能会下降,控制预渲染的帧的数量小于预设数量,也能够提高预渲染的帧的准确度。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.

结合第二方面,在一种可能的实现方式中,该装置还包括:事件状态预测模块,用于在该第一事件输入之后,对该第一事件的状态进行预测,以将该第一事件的状态更新为与下一帧的显示时间对应的事件状态。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.

本申请实施例中,当响应于事件进行帧的预渲染时,在事件传递之前,对事件状态进行预测,将事件的当前状态修改为与预渲染的帧的显示时间对应的状态,能够提高帧的预渲染的正确性。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.

结合第二方面,在一种可能的实现方式中,该解耦垂直同步模块还包括控制模块,该控制模块,用于在该第一事件对应的场景为第一场景时,启动解耦垂直同步流程;该预执行模块具体用于:在该解耦垂直同步流程启动的情况下,在第一时机向该渲染模块发送第一指令。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.

其中,第一场景是指存在负载波动的场景,或是存在重负载的场景。The first scenario refers to a scenario with load fluctuations or a scenario with heavy loads.

在一些实施例中,该第一场景包括列表滑动的场景、打开应用程序的场景、打开文件夹的场景、打开控制中心的场景、打开通知中心的场景、解锁的场景、横竖屏旋转的场景、应用间转场的场景中的一项或者多项。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.

本申请实施例中,在当前场景为存在负载波动的场景或者存在重负载的场景时,才会启动解耦垂直同步模块执行图形渲染流程,可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

结合第二方面,在一种可能的实现方式中,该控制模块还用于:在当前场景变化为非第一场景时,关闭解耦垂直同步流程;该装置还包括:垂直同步模块,用于在该解耦垂直同步流程关闭的情况下,在接收到该垂直同步信号时,向该渲染模块发送第二指令,该第二指令用于指示该渲染模块渲染当前显示帧的下一帧;该渲染模块还用于:在接收到该第二指令后,开始渲染当前显示帧的下一帧。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.

本申请实施例中,在当前场景为不需要进行帧的预渲染的场景(即不存在负载波动或者重负载)时,解耦垂直同步流程关闭,由垂直同步模块执行图形渲染流程,垂直同步模块在每次接收到合成显示线程发送的垂直同步信号后,指示渲染模块开始渲染下一帧,不对帧进行预渲染。这样,能够实现解耦垂直同步模块和垂直同步模块之间基于场景的配合,能够使得本申请提供的图形渲染的装置应用于更多的场景。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.

第三方面,提供一种电子设备,该电子设备包括存储器和处理器,其中,存储器用于存储计算机程序代码,处理器用于执行存储于存储器中的计算机程序代码,以实现上述第一方面或第一方面中任一种可能实现方式中的方法。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.

第四方面,提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序或指令,当该计算机程序或指令被执行时,实现上述第一方面或第一方面中任一种可能实现方式中的方法。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.

第五方面,提供了一种芯片,其中存储有指令,当其在设备上运行时,使得所述芯片执行上述第一方面或第一方面中任一种可能实现方式中的方法。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.

第六方面,提供了一种计算机程序产品,该计算机程序产品中存储有计算机程序或指令,当该计算机程序或指令被执行时,实现上述第一方面或第一方面中任一种可能实现方式中的方法。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

图1是本申请实施例提供的电子设备的结构示意图;Figure 1 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application;

图2是本申请实施例提供的一种电子设备的软件结构框图;Figure 2 is a software structure block diagram of an electronic device provided in an embodiment of this application;

图3是一种VSYNC架构的示意图;Figure 3 is a schematic diagram of a VSYNC architecture;

图4是一种VSYNC架构对应的渲染架构示意图;Figure 4 is a schematic diagram of the rendering architecture corresponding to the VSYNC architecture;

图5是又一种VSYNC架构对应的渲染架构示意图;Figure 5 is a schematic diagram of the rendering architecture corresponding to another VSYNC architecture;

图6是本申请实施例提供的一种图形渲染的方法的示意性流程图;Figure 6 is a schematic flowchart of a graphics rendering method provided in an embodiment of this application;

图7是本申请实施例提供的一种图形渲染的方法的示意性交互图;Figure 7 is a schematic interactive diagram of a graphics rendering method provided in an embodiment of this application;

图8是本申请实施例提供的又一种图形渲染的方法的示意性交互图;Figure 8 is a schematic interactive diagram of another graphics rendering method provided in an embodiment of this application;

图9是本申请实施例提供的一种图形渲染的系统架构示意图;Figure 9 is a schematic diagram of a graphics rendering system architecture provided in an embodiment of this application;

图10是本申请实施例提供的又一种图形渲染的系统架构示意图;Figure 10 is a schematic diagram of another graphics rendering system architecture provided in an embodiment of this application;

图11是本申请实施例提供的一种控制器控制解耦垂直同步开启和关闭的原理示意图;Figure 11 is a schematic diagram illustrating the principle of controller control of decoupled vertical synchronous opening and closing provided in an embodiment of this application;

图12是本申请实施例提供的一种预执行器向渲染模块发送第一指令的原理示意图;Figure 12 is a schematic diagram illustrating the principle of a pre-executor sending a first instruction to a rendering module according to an embodiment of this application;

图13是本申请实施例提供的一种虚拟时间器确定虚拟时间戳的原理示意图;Figure 13 is a schematic diagram illustrating the principle of a virtual timer determining a virtual timestamp according to an embodiment of this application;

图14是本申请实施例提供的一种输入事件预测模块预测输入事件的状态的原理示意图;Figure 14 is a schematic diagram illustrating the principle of an input event prediction module predicting the state of an input event according to an embodiment of this application;

图15是本申请实施例提供的一种VSYNC渲染管线和D-VSYNC渲染管线的对比图;Figure 15 is a comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in an embodiment of this application;

图16是本申请实施例提供的一种第一场景分别为持续快速滚动、交替快速滚动和低速滚动时,平均像素差的测试结果图。Figure 16 is a test result diagram 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

下面将结合附图,对本申请中的技术方案进行描述。显然,所描述的实施例仅仅是本申请的一部分实施例,而不是全部的实施例。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.

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,在本申请实施例的描述中,“复数个”或者“多个”是指两个或多于两个。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.

以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。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.

以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个、两个或两个以上。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。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.

在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“一个实施例”、“一些实施例”、“另一个实施例”、“另外一些实施例”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。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.

本申请实施例提供的方法可以应用于具有显示功能的电子设备,例如可以应用于手机、平板电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)、智能家居设备等电子设备上,本申请实施例对电子设备的具体类型不作任何限制。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.

示例性的,图1示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户身份识别(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。For example, Figure 1 shows a schematic diagram of the structure of an electronic device 100. The 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, an antenna 1, an 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.

可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。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.

处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。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.

处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。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.

在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,和/或通用串行总线(universal serial bus,USB)接口等。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.

USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, or USB Type-C port. 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.

可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。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.

电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。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.

显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。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.

外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。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.

内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的App(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。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.

按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。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.

指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.

电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。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.

图2是本申请实施例的电子设备100的软件结构框图。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。应用程序层可以包括一系列应用程序包。Figure 2 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.

如图2所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in Figure 2, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.

应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。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.

如图2所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in Figure 2, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。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.

内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。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.

视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。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.

电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).

资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。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.

Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。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.

核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。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.

应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。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.

系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(media libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。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.

表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。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.

三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

2D图形引擎是2D绘图的绘图引擎。A 2D graphics engine is a graphics engine for 2D drawing.

内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。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.

应理解,本申请实施例中的技术方案可以用于Android、IOS、鸿蒙等系统中。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.

本申请实施例的技术方案可以应用于电子设备的图形渲染过程中,用于提升电子设备的屏幕显示的流畅度和稳定性。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.

其中,电子设备可以是电视机、台式电脑、笔记本电脑,还可以是便携式电子设备,诸如手机、折叠屏、平板电脑、照相机、摄影机、录像机,还可以是智能家居设备,例如冰箱、洗衣机、扫地机等任何具有显示功能的电子设备,还可以是5G网络中的电子设备或者未来演进的公用陆地移动通信网络(public land mobile network,PLMN)中的电子设备等。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).

以下,先对本申请实施例中涉及到的相关术语进行介绍。The following section will introduce the relevant terms used in the embodiments of this application.

1.垂直同步(VSYNC)1. Vertical Synchronization (VSYNC)

垂直同步是一种显卡设置,以游戏场景为例,垂直同步用于解决游戏中出现的“画面撕裂”问题。画面撕裂是指当游戏的帧率超过显示器的刷新率时,显示器一次只能显示一部分帧,导致画面在垂直方向上不连续,看起来就像画面被“撕裂”了一样。当开启垂直同步后,显卡会根据显示器的刷新率来限制游戏的帧率。例如,如果显示器的刷新率是60Hz,那么显卡就会限制游戏的帧率不超过60帧/秒。这样,每次显示器刷新时,显卡都会输出一个完整的帧,从而避免了画面撕裂。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.

2.解耦垂直同步(D-VSYNC)2. Decoupled Vertical Synchronization (D-VSYNC)

解耦垂直同步是解耦帧的渲染和送显之间的VSYNC依赖。例如,可以让渲染线程和合成送显之间的VSYNC依赖解耦,也可以让渲染线程和UI线程之间的VSYNC依赖解耦。目前,电子设备通过采用垂直同步(vertical synchronization,VSYNC)技术,避免电子设备的屏幕在使用的过程中出现画面撕裂的情况,以提高屏幕显示的流畅度和稳定性。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.

示例性地,图3示出了一种VSYNC架构的示意图。For example, Figure 3 shows a schematic diagram of a VSYNC architecture.

如图3所示,在VSYNC架构中,UI线程会与渲染线程之间保持帧同步。在app绘制的第一个VSYNC周期(即图3中示出的VSYNC-app)开始时,VSYNC信号唤醒Choreographer触发UI线程做第1帧的绘制操作;第1帧的绘制结束后,紧接着进入渲染线程,进行第1帧的渲染;然后在合成显示的第二个VSYNC周期(即图3中示出的VSYNC-sf)开始时触发合成显示线程对第1帧合成显示,并且在显示的第三个VSYNC周期(即图3中示出的HW-VSYNC)开始时,在电子设备的屏幕上显示第1帧。As shown in Figure 3, in the VSYNC architecture, the UI thread maintains frame synchronization with the rendering thread. At the beginning of the first VSYNC cycle of app rendering (i.e., VSYNC-app shown in Figure 3), the VSYNC signal wakes up Choreographer to trigger the UI thread to perform the drawing operation of the first frame; after the drawing of the first frame is completed, the rendering thread immediately enters to render the first frame; then at the beginning of the second VSYNC cycle of compositing display (i.e., VSYNC-sf shown in Figure 3), the compositing display thread is triggered to composite and display the first frame, and at the beginning of the third VSYNC cycle of display (i.e., HW-VSYNC shown in Figure 3), the first frame is displayed on the screen of the electronic device.

其中,应特别注意的是:在合成显示的第三个VSYNC周期开始时触发合成显示线程对第2帧合成显示时,由于渲染线程还未对该第2帧完成渲染,第2帧的渲染线程占用了两个VSYNC周期,因此,在合成显示的第三个V SYNC周期内无法对第2帧合成显示,需要等待至第2帧渲染完成后,在合成显示的第四个VSYNC周期开始时合成显示线程才能对第2帧合成显示。这样,在显示的第五个VSYNC周期开始才能在电子设备的屏幕上显示第2帧,这导致显示的第四个VSYNC周期没有帧显示。也就是说,由于第2帧为长帧,导致在显示的第四个VSYNC周期发生了掉帧,并且,以此类推,在显示的第六个VSYNC周期开始才能在电子设备的屏幕上显示第3帧,若后续出现多个如第2帧一样的长帧,则会加剧渲染丢帧和渲染延迟。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.

其中,Choreographer的作用主要是配合VSYNC,给上层app的渲染提供一个稳定的信息处理的时机,也就是VSYNC到来的时候,系统通过对VSYNC信号周期的调整,来控制每一帧绘制操作的时机。例如:若手机的刷新率为60Hz,也就是16.6ms刷新一次,系统为了配合屏幕的刷新频率,可以将VSYNC的周期也设置为16.6ms。每隔16.6ms,VSYNC信号唤醒Choreographer来做app的绘制操作,这就是引入Choreographer的主要作用。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.

示例性地,以安卓系统为例,图4示出了一种VSYNC架构对应的渲染架构示意图。For example, taking the Android system as an example, Figure 4 shows a schematic diagram of the rendering architecture corresponding to the VSYNC architecture.

如图4所示,系统采用分离渲染架构,UI线程和合成送显线程按照VSYNC节拍运行。第N帧在屏幕上显示时,VSYNC-sf可以驱动合成送显线程合成第N+1帧,VSYNC-app可以驱动UI线程执行第N+2帧。As shown in Figure 4, the system adopts a separate rendering architecture, with the UI thread and the compositing and display thread running according to the VSYNC beat. When the Nth frame is displayed on the screen, VSYNC-sf can drive the compositing and display thread to compose the N+1th frame, and VSYNC-app can drive the UI thread to execute the N+2th frame.

示例的,合成送显线程可以是SurfaceFlinger,SurfaceFlinger对渲染后的图像进行合成、缩放或混合等处理后,将其交给CPU或GPU绘制;也就是说,SurfaceFlinger在接收到垂直同步信号后,从帧缓冲队列中获取已渲染的帧进行合成等处理,并将其送显。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.

示例性地,图5示出了又一种VSYNC架构对应的渲染架构示意图。For example, Figure 5 shows a schematic diagram of another rendering architecture corresponding to the VSYNC architecture.

如图5所示,系统采用统一渲染架构,UI线程和渲染线程按照VSYNC节拍运行。当第N帧在屏幕上显示时,VSYNC-rs可以驱动渲染线程渲染第N+1帧,VSYNC-app可以驱动UI线程执行第N+2帧,其中,VSYNC-rs是指渲染线程接收到的垂直同步信号,用于指示渲染下一帧,VSYNC-sf是指合成送显线程接收到的垂直同步信号,用于指示合成下一帧,VSYNC-app是指UI线程接收到的垂直同步信号,用于指示执行下一帧。As shown in Figure 5, 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.

VSYNC的工作原理是通过在图形处理器和显示器之间建立同步信号(VSYNC信号)来实现的,当显示器开始进行下一次刷新时,发送VSYNC信号到图形处理器,图形处理器在接收到VSYNC信号后开始渲染下一帧。也就是说,图像处理器必须等待显示器完成刷新后,才能渲染下一帧,这很可能会导致渲染帧率的降低和渲染的延迟,尤其是在负载波动较大的时候,很容易导致丢帧和渲染延迟。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.

以下,为了清楚地理解本申请的方案,先分别对几种场景的渲染显示轨迹进行分析。In order to clearly understand the solution of this application, the rendering and display trajectories of several scenarios will be analyzed below.

(1)对于滑动阅读场景,在采用了VSYNC架构后,渲染线程需要等待下一个VSYNC信号到来才开始渲染下一帧。即:在生成第i个VSYNC信号时,在电子设备的屏幕上显示第i帧,渲染线程渲染第i+1帧,UI线程执行第i+2帧。(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.

其中,UI线程在向VSYNC发送请求执行下一帧的信号之后,VSYNC的主循环阻塞等待VSYNC信号,在收到VSYNC信号后向渲染线程发送触发指令,该触发指令用于指示渲染线程开始渲染下一帧。当滑动的第一帧为长帧时,渲染线程无法在一个VSYNC周期内完成该长帧的渲染,导致掉帧。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.

(2)对于在桌面打开大文件夹的场景,具体操作过程为:用户点击大文件夹图标位置,大文件夹展开,再点击展开页面中的任意非图标位置,大文件夹收起。(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.

在该过程中,UI线程处于闲置状态,由渲染线程执行动画,渲染线程的主循环中的动画(animate)更新统一渲染树的状态,同时animate向VSYNC发送请求执行下一帧的信号,请求执行下一帧的动画。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.

其中,当每帧工作量的负载不均衡时,会导致有些短帧无法占满全部的VSYNC周期,而有些长帧则执行时间过长,容易导致掉帧。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.

在一些示例中,对滑动场景进行可视化跟手性测试,在采用了VSYNC架构后,通过构建一个红色小球跟随手指触摸移动进行渲染显示轨迹测试,在没有任何延迟的理想情况下,红色小球应该严格跟随触摸位置,并被指尖覆盖。然而,当向上滑动手指时,可以清楚地看到落在指尖后面的红色小球,当延迟达到45ms时,随着指尖的快速滑动,指尖与红色小球之间的最大距离差达到400像素左右,其平均距离差也在200像素左右。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.

因此,在当前的VSYNC架构下,由于应用程序的负载往往存在波动,往往无法在一个VSYNC周期内完成长帧的渲染,很容易产生丢帧;并且,由于渲染线程和合成送显线程的VSYNC信号是强制对齐同步的,因此从帧开始渲染到在屏幕上显示,至少存在两个VSYNC周期的渲染延迟;另外,由于短帧无法占满全部的VSYNC周期,不能充分利用电子设备的CPU/GPU算力,这会导致CPU/GPU算力的浪费。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.

即当前的图形渲染方法虽然可以解决图像撕裂和其他不良影响,但存在渲染丢帧、渲染延迟以及渲染和送显的并行度低的问题。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.

有鉴于此,本申请实施例提供了一种图形渲染的方法,该方法能够解耦渲染和显示的垂直同步依赖,不需要等待垂直同步信号触发帧的执行,而是可以利用短帧剩余的执行时间对后续的帧进行预渲染,实现帧渲染与送显的异步并行,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率和渲染延迟。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.

示例性地,图6示出了本申请实施例提供的一种图形渲染的方法600的示意性流程图。如图6所示,该方法600包括:For example, FIG6 shows a schematic flowchart of a graphics rendering method 600 provided in an embodiment of this application. As shown in FIG6, the method 600 includes:

S601:在第一场景下,解耦垂直同步(D-VSYNC)模块启动解耦垂直同步流程。S601: In the first scenario, the Decoupled Vertical Synchronization (D-VSYNC) module initiates the decoupled vertical synchronization process.

在一些实施例中,第一场景为输入事件对应的场景,第一场景为可能出现负载波动或负载较大的场景,第一场景例如可以包括列表滑动场景、打开APP场景、打开文件夹场景、地图缩放场景等。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.

在一些实施例中,在非第一场景时,解耦垂直同步流程不开启,图形渲染基于VSYNC架构执行。在产生第i个VSYNC信号时,渲染模块渲染第i+1帧,应用模块执行第i+2帧。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.

在一些实施例中,由应用程序层监测当前场景变化,然后通过API接口通知解耦垂直同步模块中的控制器,由控制器根据当前场景控制解耦垂直同步流程的开启和关闭。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.

在一些实施例中,在没有事件输入时(即应用模块不参与时),由渲染模块中的性能监测模块基于渲染帧率和每帧渲染时长监测当前场景变化,然后通知解耦垂直同步模块中的控制器,由控制器根据当前场景控制解耦垂直同步流程的开启和关闭。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.

示例性地,当当前渲染帧率低于第一帧率阈值,且连续多帧中的每帧或者部分帧渲染时长大于第一时间阈值时,确定当前场景为第一场景,控制器开启解耦垂直同步流程。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.

可选地,在解耦垂直同步流程被启动后,持续监测当前场景变化,当前场景变化为非第一场景时,控制器关闭解耦垂直同步流程,非第一场景对应的连续多帧中的每帧渲染时长小于第二时间阈值,该第二时间阈值小于第一时间阈值。这样,就能够实现根据场景对解耦垂直同步流程的及时关闭和及时开启。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.

S602:解耦垂直同步模块在接收到第一请求消息后,在第一时机向渲染模块发送第一指令,该第一指令用于指示渲染模块开始渲染当前渲染帧的下一帧,该第一指令携带第一虚拟时间戳,其中,第一时机是根据第一请求消息携带的第一参数确定的。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.

在一些实施例中,当第一请求消息为非动画请求(响应于输入的事件发起的请求,即用户界面动画,可视为外部调用请求)时,第一请求消息来自应用模块;当第一请求消息为动画请求(即渲染线程属性动画,可视为自我调用请求)时,第一请求消息来自渲染模块(渲染模块的当前渲染帧请求渲染下一帧),第一请求消息用于请求渲染当前渲染帧的下一帧,第一请求消息例如可以是RequestNextVSync;第一请求消息携带的第一参数例如可以是fromWhom,其中,RequestNextVSync用于表示请求执行下一帧;fromWhom用于表示第一请求消息的来源,即来自应用模块还是来自渲染模块。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.

其中,第一虚拟时间戳是根据当前显示帧的显示时间和VSYNC周期确定的,VSYNC周期是指两个相邻的帧在屏幕上显示的时间间隔,也可以理解为显示器刷新的时间间隔;或者,第一虚拟时间戳是根据当前时间和VSYNC周期确定的。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.

在一些实施例中,通过第一参数,可以区分第一请求消息是来自渲染模块的动画请求(animate),还是来自应用模块的非动画请求(non-animate)。其中,动画请求是指渲染模块在前一帧渲染后,自我请求后一帧渲染,出现动画请求的场景包括打开文件夹、打开app、展开通知栏、展开状态栏等;非动画请求是指来自app的绘制请求,通常涉及到用户输入处理,或者应用逻辑,出现非动画请求的场景可以包括滑动桌面、滑动列表等。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.

可以根据上一个VSYNC周期收到的第一请求消息的类型(动画请求还是非动画请求,是基于上一个VSYNC周期收到的第一请求消息携带的第一参数确定的)和当前VSYNC周期内收到的第一请求消息的类型(动画请求还是非动画请求,是基于当前VSYNC周期内收到的第一请求消息携带的第一参数确定的),判断当前场景为动画场景、非动画场景还是混合场景(包含动画和事件)。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).

在一些实施例中,混合场景例如可以是:打开app场景,窗口弹开来自于渲染模块的连续的动画请求,而应用模块可能在窗口弹开期间将绘制完的app数据同步到渲染模块,并通过RequestNextVSync请求执行下一帧,此时用户会看到打开app的前半段可能是白屏,在后半段才可能出现内容;再比如,滑动列表场景,前半段当手指在显示屏上时为非动画请求,app在每一帧同步数据给渲染模块,当手指离开屏幕时,发生惯性动画,渲染模块进行连续的自动画请求。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.

在一些实施例中,场景的具体判断方法为:In some embodiments, the specific method for determining the scenario is as follows:

非动画场景(可理解为连续非动画场景):在当前VSYNC周期内收到一个类型为非动画请求的第一请求消息时,在上一个VSYNC周期收到的第一请求消息的类型均为非动画请求,或者在上一个VSYNC周期内没有收到任何第一请求消息(渲染最开始会出现的情况),则当前场景为非动画场景。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.

在一些实施例中,根据第一请求消息携带的第一参数确定第一时机,包括:In some embodiments, determining a first timing based on a first parameter carried in a first request message includes:

在当前场景为非动画场景时,解耦垂直同步模块在接收到第一请求消息后,立即向渲染模块发送第一指令,也就是说,在非动画场景中,渲染模块可以立即响应来自应用模块的绘制请求,避免出现首帧掉帧的情况,以及降低渲染时延。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.

动画场景(可理解为连续动画场景):在当前VSYNC周期内收到一个类型为动画请求的第一请求消息时,若在上一个VSYNC周期没有收到类型为非动画请求的第一请求消息,则当前场景为动画场景。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.

在又一些实施例中,根据第一请求消息携带的第一参数确定第一时机,包括:In some other embodiments, determining the first timing based on the first parameter carried in the first request message includes:

在当前场景为动画场景时,解耦垂直同步模块在接收到第一请求消息后,立即向渲染模块发送第一指令,也就是说,在动画场景中,会发生帧的堆积,达到帧的预渲染的效果。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.

混合场景(可理解为包括动画转非动画场景和非动画转动画场景):在当前VSYNC周期内收到一个类型为动画请求的第一请求消息时,若在上一个VSYNC周期内有收到类型为非动画请求的第一请求消息,则当前场景为混合场景;或者,在当前VSYNC周期内收到一个类型为非动画请求的第一请求消息时,若在上一个VSYNC周期内有收到类型为动画请求的第一请求消息,则当前场景为混合场景。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.

在又一些实施例中,根据第一请求消息携带的第一参数确定第一时机,包括:In some other embodiments, determining the first timing based on the first parameter carried in the first request message includes:

在当前场景为动画转非动画场景时,解耦垂直同步模块在接收到一个类型为动画请求的第一请求消息后,等待该帧对应的非动画请求,在接收到该帧对应的非动画请求后,立即向渲染模块发送第一指令,其中,等待时间可以是1.2个VSYNC周期。若等待超时,则表示输入事件流结束,响应于该动画请求,解耦垂直同步模块在超时后立即向渲染模块发送第一指令。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.

在当前场景为非动画转动画场景时,解耦垂直同步模块在接收到一个类型为非动画请求的第一请求消息后,等待该帧对应的动画请求,在接收到该帧对应的动画请求后,立即向渲染模块发送第一指令,其中,等待时间可以是1.2个VSYNC周期。若等待超时,则表示属性动画结束,响应于该非动画请求,解耦垂直同步模块立即向渲染模块发送第一指令。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.

在动画场景中,当前帧不涉及APP事件响应,D-VSYNC在收到来自渲染模块的动画请求后,若是动画场景,则立即向渲染模块发送第一指令,以预执行当前帧;D-VSYNC在收到来自应用模块的非动画请求后,若是非动画场景,则立即向渲染模块发送第一指令,以预执行当前帧;D-VSYNC在收到来自应用模块的非动画请求或在收到来自渲染模块的动画请求后,若是混合场景,则在收到来自U应用模块的非动画请求和来自渲染模块的动画请求后,立即向渲染模块发送第一指令,以执行当前帧。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.

在一些实施例中,解耦垂直同步模块在接收到第一请求消息后,先确定第一虚拟时间戳。当该第一虚拟时间戳和当前的真实时间戳之间的差值小于或等于X个VSYNC周期时,在第一时机向渲染模块发送第一指令。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.

在一些实施例中,帧缓冲队列中的缓冲的预渲染的帧的数量可以存在上限X,该上限值可以由解耦垂直同步模块中的控制器配置;例如,X可以为1、2、3、4或者5等。基于此,电子设备可以控制该第一虚拟时间戳和当前的真实时间戳之间的差值小于或等于X个VSYNC周期。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.

在一些示例中,帧缓冲队列中的缓冲的帧的数量可以存在上限X+2(即帧缓冲队列中的允许的最大缓冲数),该上限值可以由解耦垂直同步模块中的控制器配置;例如,X可以为1、2、3、4或者5等。基于此,电子设备可以控制该第一虚拟时间戳和当前的真实时间戳之间的差值小于或等于X个VSYNC周期。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.

在一些实施例中,若解耦垂直同步模块在接收到第一请求消息后,先确定第一虚拟时间戳。当该第一虚拟时间戳和当前的真实时间戳之间的差值大于X个VSYNC周期时,说明若响应于第一请求消息,在当前VSYNC周期向渲染模块发送第一指令,则会导致帧缓冲队列中的缓冲的预渲染的帧的数量超出上限X。此时,解耦垂直同步模块在接收到第一请求消息后,会等待至下一个VSYNC周期(即接收到VSYNC信号时),才会向渲染模块发送第一指令。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.

另一种实现方式可以是:解耦垂直同步模块在接收到第一请求消息后,查询帧缓冲队列中缓冲的帧的数量。若帧缓冲队列中缓冲的帧的数量小于X+2,则解耦垂直同步模块在第一时机向渲染模块发送第一指令。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.

S603:渲染模块在接收到该第一指令后,开始渲染当前渲染帧的下一帧,并使用该第一虚拟时间戳表示该当前渲染帧的下一帧对应的显示时间。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.

本申请实施例中,用虚拟时间戳表示预渲染的帧的未来显示时间,以实现解耦渲染模块和合成送显模块之间的VSYNC依赖。利用电子设备的CPU空闲对后续的帧进行预渲染,实现帧渲染与送显两阶段异步并行快速送显,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率,降低渲染延迟,提升跟手性。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.

示例性地,图7示出了本申请实施例提供的一种图形渲染的方法700的示意性交互图。如图7所示,该方法700包括:For example, FIG7 shows a schematic interactive diagram of a graphics rendering method 700 provided in an embodiment of this application. As shown in FIG7, the method 700 includes:

S701至S703:第一事件输入后,若第一事件对应的场景为第一场景,则解耦垂直同步模块开启解耦垂直同步流程,并接收第一请求消息。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.

其中,关于对第一场景、第一请求消息的解释在图6所示实施例中作了详细说明,为了简洁,在此不再赘述。The explanation of the first scenario and the first request message is described in detail in the embodiment shown in Figure 6, and will not be repeated here for the sake of brevity.

应注意:图7中有两个S703,一个是表示第一请求消息来自应用模块,一个是表示第一请求消息来自渲染模块。当应用层有事件输入时,应用模块会发出第一请求消息,即非动画请求;此外,渲染模块中,也可以由当前帧请求渲染下一帧,即动画请求。在同一场景中,可能只有动画请求(即动画场景),也可能只有非动画请求(即非动画场景),也可能存在动画请求和非动画请求(即混合场景),具体地,在图6所示实施例中有详细描述。Note that there are two S703s in Figure 7: one indicating that the first request message comes from the application module, and the other indicating that the first request message comes from the rendering module. When there is an event input at the application layer, the application module will issue a first request message, i.e., a non-animation request. In addition, in the rendering module, the current frame can also request the rendering of the next frame, i.e., an animation request. In the same scene, there may only be animation requests (i.e., an animated scene), there may only be non-animation requests (i.e., a non-animation scene), or there may be both animation requests and non-animation requests (i.e., a mixed scene). Specifically, this is described in detail in the embodiment shown in Figure 6.

在一种实现方式中,解耦垂直同步模块中包括控制器,由该控制器基于场景控制解耦垂直同步的开启和关闭。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.

S704:解耦垂直同步模块在接收到第一请求消息后,根据该第一请求消息携带的第一参数确定第一时机。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.

其中,关于对第一参数的解释在图6所示实施例中作了详细说明,为了简洁,在此不再赘述。The explanation of the first parameter is detailed in the embodiment shown in Figure 6, and will not be repeated here for the sake of brevity.

在一些实施例中,根据上一个VSYNC周期内接收到的第一请求消息携带的第一参数和本VSYNC周期内接收到的第一请求消息携带的第一参数确定当前场景(动画场景、非动画场景或者混合场景),再根据当前场景确定第一时机。其中,关于如何根据第一参数确定当前场景的描述以及关于如何根据当前场景确定第一时机的描述参见图6所示实施例中对S602的描述,为了简洁,在此不再赘述。In some embodiments, the current scene (animated scene, non-animated scene, or mixed 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 the current scene is determined based on the first parameter and how the first timing is determined based on the current scene, please refer to the description of S602 in the embodiment shown in Figure 6; for brevity, it will not be repeated here.

S705:解耦垂直同步模块在第一时机向渲染模块发送第一指令。S705: The decoupled vertical synchronization module sends the first instruction to the rendering module at the first opportune moment.

在一种实现方式中,解耦垂直同步模块中包括预执行器,由该预执行器接收第一请求消息,并根据第一请求消息携带的第一参数在第一时机向渲染模块发送第一指令。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.

在一些实施例中,解耦垂直同步模块在向渲染模块发送第一指令之前,解耦垂直同步模块根据当前显示帧的显示时间和VSYNC周期确定第一虚拟时间戳,或者,解耦垂直同步模块根据当前时间和VSYNC周期确定第一虚拟时间戳。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.

在一种实现方式中,解耦垂直同步模块中包括虚拟时间器。由该虚拟时间器根据当前显示帧的显示时间和VSYNC周期确定第一虚拟时间戳,或根据当前时间和VSYNC周期确定第一虚拟时间戳。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.

应理解:每一个预渲染的帧都有与其对应的虚拟时间戳。在一个示例中,若该预渲染的帧为第二个预渲染的帧,此时刚显示到该预渲染的帧的上上帧,则该预渲染的帧对应的虚拟时间戳可以为该预渲染的帧的上上帧的显示时间与两个VSYNC周期之和。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.

其中,关于对第一指令的解释在图6所示实施例中作了详细说明,为了简洁,在此不再赘述。The explanation of the first instruction is detailed in the embodiment shown in Figure 6, and will not be repeated here for the sake of brevity.

S706:渲染模块在接到第一指令后,开始渲染第一目标帧。其中,该第一目标帧是指当前帧的下一帧。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.

其中,渲染模块在渲染第一目标帧后,将第一指令携带的第一虚拟时间戳与第一目标帧关联。即:用该第一虚拟时间戳表示该第一目标帧的显示时间。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.

S707:渲染模块渲染完成第一目标帧后,向帧缓冲队列发送该第一目标帧。S707: After the rendering module finishes rendering the first target frame, it sends the first target frame to the frame buffer queue.

在一些实施例中,渲染模块在向帧缓冲队列发送该第一目标帧之前,可以向帧缓冲队列请求buffer。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.

S708:帧缓冲队列在接收到第一目标帧后,按照先进先出的顺序,将该第一目标帧加入帧缓冲队列。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.

合成送显模块可以在每个VSYNC周期开始时从帧缓冲队列中获取要显示的帧,即当前显示帧的下一帧,并显示在电子设备的屏幕上。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.

本申请实施例中,用虚拟时间戳表示预渲染的帧的未来显示时间,以实现解耦渲染模块和合成送显模块之间的VSYNC依赖。利用电子设备的CPU空闲对后续的帧进行预渲染,实现帧渲染与送显两阶段异步并行快速送显,可以将原本浪费掉的渲染短帧剩余的CPU时间再利用,降低丢帧率,降低渲染延迟,提升跟手性。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.

具体地,在VSYNC架构中,使用choreographer记录的帧渲染时间(VSYNC-app时间戳)以及其他系统时钟来表示帧的显示时间,因此,VSYNC架构中,帧渲染必须在帧被显示前不久执行。而在本申请实施例提供的D-VSYNC架构中,由于图形系统的状态和行为是确定性的,将虚拟时间器合并到修改后的choreographer中,实现用虚拟时间戳表示预渲染的帧的显示时间,而不是用当前的时间表示预渲染的帧的显示时间,这使得D-VSYNC架构支持帧的预渲染。也就是说,虚拟时间器会计算正在渲染的当前帧将在何时显示,并将计算得到的虚拟时间戳与该渲染的帧关联起来,使得该渲染的帧在虚拟时间戳对应的时间显示。因此,应用虚拟时间器,D-VSYNC可以将帧内容显示的时间与帧渲染的代码执行时间解耦,实现帧的预渲染,进而提升电子设备的性能。Specifically, in the VSYNC architecture, the frame rendering time recorded by the choreographer (VSYNC-app timestamp) 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 rendered 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.

示例性地,图8示出了本申请实施例提供的又一种图形渲染的方法800的示意性交互图。如图8所示,该方法800包括:For example, FIG8 shows a schematic interactive diagram of another graphics rendering method 800 provided in an embodiment of this application. As shown in FIG8, the method 800 includes:

S801至S803与图7所示实施例中的S701至S703相同,为了简洁,在此不再赘述。S801 to S803 are the same as S701 to S703 in the embodiment shown in Figure 7, and will not be described again here for the sake of simplicity.

S804:解耦垂直同步模块向帧缓冲队列发送第一查询消息,该第一查询消息用于查询帧缓冲队列中当前存在的帧的数量。S804: The decoupled vertical synchronization module sends a first query message to the frame buffer queue. This first query message is used to query the number of frames currently existing in the frame buffer queue.

在一些实施例中,帧缓冲队列中存在的所有帧中,有两帧为渲染模块和合成送显模块之间进行帧缓存和帧获取的缓冲帧,为非预渲染的帧,除此之外,其他的帧均为预渲染的帧。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.

在一些实施例中,帧缓冲队列中所包括的帧的数量需小于等于M。该M的值例如可以是3、4、5中的任一个,此外,该M的值还可以是大于等于3的其他数值,本申请对此不做限定,其中,M可以理解为所允许的最大缓冲帧的数量。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.

S805:帧缓冲队列在接收到第一查询消息后,向解耦垂直同步模块发送第一数量N,该第一数量N表示帧缓冲队列中当前存在的帧的数量为N。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.

S806:判断帧缓冲队列中当前存在的帧的数量N是否小于M。若是,则说明帧缓冲队列中还能存放更多的预渲染的帧,进一步执行S807。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.

S807至S811与图7所示实施例中的S704至S708相同,为了简洁,在此不再赘述。S807 to S811 are the same as S704 to S708 in the embodiment shown in FIG7, and will not be described again here for the sake of simplicity.

其中,当帧缓冲队列中当前存在的帧的数量N大于或等于M时,则等待来自合成送显模块的VSYNC信号,并在接收到VSYNC信号后向渲染模块发送第一指令。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.

可以理解:S804至S806为图6所示实施例中所述的“控制该第一虚拟时间戳和当前的真实时间戳之间的差值小于或等于X个VSYNC周期”的一种可替代的实现方式。当解耦垂直同步模块执行判断“该第一虚拟时间戳和当前的真实时间戳之间的差值是否小于或等于X个VSYNC周期”时,就不执行S804至S806;当解耦垂直同步模块执行S804至S806时,就不执行判断“该第一虚拟时间戳和当前的真实时间戳之间的差值是否小于或等于X个VSYNC周期”,二者的目的是一致的。因此,若需要控制缓冲的预渲染的帧的数量不超过预设数量,只需二者择其一执行。It can be understood that S804 to S806 are an alternative implementation of the "controlling the difference between the first virtual timestamp and the current real timestamp to be less than or equal to X VSYNC cycles" described in the embodiment shown in Figure 6. When the decoupled 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", S804 to S806 are not executed; when the decoupled vertical synchronization module executes 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 needs to be executed.

S812:当解耦垂直同步模块接收到来自应用模块或者来自渲染模块的第二请求消息后,重复执行上述S804至S811,其中,第二请求消息用于请求执行下一帧。类似地,在第一场景下,当解耦垂直同步模块每次接收到来自应用模块或者来自渲染模块的用于请求执行下一帧的请求消息后,均重复执行上述S804至S811。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.

可选地,当前场景变化为非第一场景时,解耦垂直同步流程关闭,采用垂直同步架构进行图形渲染。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.

以下,S813至S817为合成送显模块在每个VSYNC周期开始时,按先进先出(FIFO)的顺序从帧缓冲队列中获取并送显帧的过程,该过程可以视为相对独立的流程,与上述S802至S812的执行逻辑没有直接关联。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.

S813:合成送显模块从帧缓冲队列中获取当前显示帧的下一帧。S813: The composite display module retrieves the next frame of the current display frame from the frame buffer queue.

S814:合成送显模块在下一个VSYNC周期开始时,合成送显当前显示帧的下一帧。S814: When the next VSYNC cycle begins, the composite display module composites and displays the next frame of the current display frame.

S815:合成送显模块在完成当前显示帧的下一帧的送显后,向解耦垂直同步模块发送VSYNC信号。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.

S816:合成送显模块在完成当前显示帧的下一帧的送显后,向帧缓冲队列发送释放指令,用于指示帧缓冲队列释放该当前显示帧的下一帧。S816: After completing the display of the next frame of the current display frame, the composite display module sends a release command to the frame buffer queue, which is used to instruct the frame buffer queue to release the next frame of the current display frame.

S817:帧缓冲队列在接收到释放指令后,从帧缓冲队列中移出该当前显示帧的下一帧。S817: After receiving a release command, the frame buffer queue removes the next frame from the frame buffer queue of the currently displayed frame.

在一些实施例中,合成送显模块在每个VSYNC周期按FIFO顺序消耗帧缓冲队列;并且,帧缓冲队列中排队的缓冲数量和其他VSYNC配置参数(例如VSYNC周期或相位等)始终可供查询,例如可以通过上述第一查询消息查询。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.

示例性地,图9示出了本申请实施例提供的一种图形渲染的系统架构示意图。For example, Figure 9 shows a schematic diagram of a system architecture for graphics rendering provided in an embodiment of this application.

如图9所示,该系统架构包括应用模块、渲染模块、帧缓冲队列、合成送显模块、帧渲染时序控制模块900。其中,帧渲染时序控制模块900中包括垂直同步模块910和解耦垂直同步模块920,解耦垂直同步模块920包括控制器921、预执行器922和虚拟时间器923。具体地:As shown in Figure 9, 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:

帧渲染时序控制模块900中的垂直同步模块910,用于在解耦垂直同步模块920处于关闭状态时,控制图形渲染以垂直同步的规则进行。即:在接收到第一请求消息后,等待合成送显模块发送的VSYNC信号;在接收到VSYNC信号后,向渲染模块发送第一指令,以指示渲染模块开始渲染下一帧。这样,生成第i个VSYNC信号时,显示第i帧,渲染模块渲染第i+1帧,应用模块执行第i+2帧。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.

以下着重描述解耦垂直同步模块920处于开启状态时,各模块之间的配合过程。The following focuses on describing the coordination process between the modules when the decoupling vertical synchronization module 920 is in the enabled state.

S901至S902:第一事件输入后,应用模块在监测到第一事件对应的场景为第一场景时,通过控制器921上配置的API接口向控制器921发送开启指令,以使得控制器921开启解耦垂直同步。并且,应用模块向预执行器922发送第一请求消息,该第一请求消息用于请求执行下一帧。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.

在一些实施例中,在图形开始渲染后,渲染模块中的性能监测模块通过监测渲染帧率和每帧渲染的时长,监测到当前场景为第一场景时,直接通过控制器921开启解耦垂直同步。并且,渲染模块向预执行器922发送第一请求消息,该第一请求消息用于请求执行下一帧。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.

在又一些实施例中,该第一请求消息可以是渲染模块在渲染完成当前帧后,向预执行器922发送的,用于请求执行下一帧。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.

S903:解耦垂直同步模块920向帧缓冲队列发送第一查询消息,该第一查询消息用于查询帧缓冲队列中当前存在的帧的数量。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.

其中,对该步骤的解释与图8所示实施例中对S804的解释相同,为了简洁,在此不再赘述。The explanation of this step is the same as that of S804 in the embodiment shown in Figure 8, and will not be repeated here for the sake of brevity.

S904:帧缓冲队列在接收到第一查询消息后,向解耦垂直同步模块920发送第一数量N,该第一数量N表示帧缓冲队列中当前存在的帧的数量为N。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.

S905:在N小于M时,解耦垂直同步模块920在第一时机向渲染模块发送第一指令。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.

其中,对于该步骤的解释参见图8所示实施例中对S806至S808的解释,为了简洁,在此不再赘述。For an explanation of this step, please refer to the explanation of S806 to S808 in the embodiment shown in Figure 8. For the sake of brevity, it will not be repeated here.

S906:响应于渲染模块的请求,帧缓冲队列向渲染模块分配buffer。S906: In response to a request from the rendering module, the framebuffer queue allocates a buffer to the rendering module.

对S907至S910的解释与图8所示实施例中对S808至S817的解释类似,为了简洁,在此不再赘述。The explanations of S907 to S910 are similar to those of S808 to S817 in the embodiment shown in Figure 8, and will not be repeated here for the sake of brevity.

其中,在一些实施例中,为了确保与现有应用程序的兼容性,D-VSYNC基于传统VSYNC框架开发,D-VSYNC添加了新的API接口,并保留了原始API接口的语义。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.

在一些实施例中,当渲染过程依赖于不可预测的数据或输入的不兼容应用程序时,D-VSYNC可以部分或全部关闭。In some embodiments, D-VSYNC can be partially or completely turned off when the rendering process depends on unpredictable data or incompatible applications.

示例性地,图10示出了本申请实施例提供的又一种图形渲染的系统架构示意图。For example, Figure 10 shows a schematic diagram of another system architecture for graphics rendering provided in an embodiment of this application.

如图10所示,该系统架构包括应用模块、渲染模块、帧缓冲队列、合成送显模块、帧渲染时序控制模块900。其中,帧渲染时序控制模块900中包括垂直同步模块910和解耦垂直同步模块920,解耦垂直同步模块920包括控制器921、预执行器922和虚拟时间器923;另外,该系统架构还包括输入事件预测模块1000,该输入事件预测模块1000例如可以包括列表滑动预测器1100、缩放事件预测器1200和其他预测器,具体地:As shown in Figure 10, 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:

帧渲染时序控制模块900中的垂直同步模块910,用于在解耦垂直同步模块920处于关闭状态时,控制图形渲染以垂直同步的规则进行。即:在接收到第一请求消息后,等待合成送显模块发送的VSYNC信号;在接收到VSYNC信号后,向渲染模块发送第一指令,以指示渲染模块开始渲染下一帧,这样,生成第i个VSYNC信号时,显示第i帧,渲染模块渲染第i+1帧,应用模块执行第i+2帧。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.

以下着重描述解耦垂直同步模块920处于开启状态时,各模块之间的配合过程。The following focuses on describing the coordination process between the modules when the decoupling vertical synchronization module 920 is in the enabled state.

可以理解:图10所示实施例是在图9所示实施例的基础上增加了输入事件预测模块1000,使得输入事件的状态为虚拟时间器所计算的虚拟时间对应的事件状态。即将输入事件的状态更新为预渲染的帧的显示时间对应的事件状态(例如:预渲染的帧的显示位置等状态),能够避免由于在D-VSYNC的预渲染架构中,帧在一些VSYNC周期之前执行,渲染和显示之间的事件最新状态丢失引起的渲染错误,能够提高实时性渲染的准确性。It can be understood that the embodiment shown in Figure 10 adds an input event prediction module 1000 to the embodiment shown in Figure 9, so that the state of the input event is the event state corresponding to the virtual time calculated by the virtual timer. That is, the state of the input event is updated 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 can avoid rendering errors caused by the loss of the latest event state between rendering and display due to the frame being executed before some VSYNC cycles in the D-VSYNC pre-rendering architecture, and can improve the accuracy of real-time rendering.

图10所示实施例与图9所示实施例区别在于S1001至S1003,具体地:The embodiment shown in Figure 10 differs from the embodiment shown in Figure 9 in steps S1001 to S1003, specifically:

S1001至S1002:在第一事件输入后,输入事件预测模块1000从虚拟时间器923中获取第一虚拟时间戳,该第一时间戳为下一帧对应的预期显示时间。根据输入的第一事件确定与其对应的预测器(列表滑动预测器1100、缩放事件预测器1200或者其他预测器),并由确定的与第一事件对应的预测器对第一事件的状态进行预测,将第一事件的状态修改为第一虚拟时间戳对应的预期状态,以提高下一帧预渲染的准确度。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.

在一个示例中,当应用组件显示用户可以滚动的项目列表时(输入的第一事件为列表滚动事件),输入事件预测模块1000中内置的列表滑动预测器1100将被激活并生效。列表滑动预测器110利用内部启发式模型和虚拟时间器923输出的虚拟时间戳来将触摸的当前坐标修改为与该虚拟时间戳对应的预期坐标。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.

在一些实施例中,输入事件预测模块1000向应用程序提供了用于注册/注销预测器的API接口,这使得可以将自定义预测器注册到输入事件预测模块1000中,以使得输入事件预测模块1000可以应用于更多的场景。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.

S1003:输入事件预测模块1000将预测后的第一事件的状态更新至应用模块。S1003: The input event prediction module 1000 updates the status of the first predicted event to the application module.

其中,输入事件预测模块1000还可以描述为事件状态预测层(event state prediction layer,ESPL),列表滑动预测器1100还可以描述为列表滚动位置预测器(list scrolling position predictor,LSPP)。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).

S1004至S1012与图9所示实施例中的S902至S910相同,为了简洁,在此不再赘述。S1004 to S1012 are the same as S902 to S910 in the embodiment shown in Figure 9, and will not be described again here for the sake of simplicity.

为了更加清楚地理解本申请实施例提供的图形渲染的架构,以下,结合图11至图14,对解耦垂直同步模块900中的控制器921、预执行器922、虚拟时间器923,以及输入事件预测模块1000进行详细介绍。To better understand the architecture of graphics rendering provided in this application embodiment, the controller 921, pre-executor 922, virtual timer 923, and input event prediction module 1000 in the decoupled vertical synchronization module 900 will be described in detail below with reference to Figures 11 to 14.

示例性地,图11示出了本申请实施例提供的一种控制器控制解耦垂直同步开启和关闭的原理示意图。For example, Figure 11 shows a schematic diagram of the principle of controller control of decoupled vertical synchronization on and off according to an embodiment of this application.

如图11所示,控制器用于控制D-VSYNC的启动和停止,此外,控制器还用于配置D-VSYNC参数。其中,D-VSYNC参数可以包括帧缓冲队列中的最大缓冲数量,还可以包括其他VSYNC配置参数,例如VSYNC周期等。As shown in Figure 11, 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. The D-VSYNC parameters may include the maximum number of buffers in the frame buffer queue, and may also include other VSYNC configuration parameters, such as the VSYNC period.

其中,控制器控制D-VSYNC的开启和关闭的实现方式有以下两种:There are two ways to control the D-VSYNC to turn on and off:

1.D-VSYNC中的控制器向APP层暴露开启、关闭、配置的API接口,APP层(或者OS)在第一场景下通过该API接口指示控制器启动D-VSYNC。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.

可选地,在场景变化为非第一场景时,通过该API接口指示控制器关闭D-VSYNC。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.

该实现方式可以充分利用APP对场景熟悉的优势,能够避免首帧掉帧。This implementation method can take full advantage of the APP's familiarity with the scene and avoid dropping frames in the first frame.

2.在图形开始渲染后,渲染模块的性能监测模块进行渲染帧率和每帧执行时间统计,根据渲染帧率和每帧执行时间统计情况确定当前场景为第一场景时通过控制器开启D-VSYNC。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.

可选地,性能监测模块在场景变化为非第一场景时通过控制器关闭D-VSYNC。Optionally, the performance monitoring module can disable D-VSYNC via the controller when the scene changes to a different scenario.

该实现方式可以实现D-VSYNC的自动启停,不需要在APP层做出改动。This implementation method enables automatic start and stop of D-VSYNC without requiring any changes at the APP level.

示例性地,图12示出了本申请实施例提供的一种预执行器向渲染模块发送第一指令的原理示意图。For example, Figure 12 shows a schematic diagram of the principle of a pre-executor sending a first instruction to a rendering module according to an embodiment of this application.

如图12中的(a)所示,帧渲染时序控制模块在接收到用于请求执行下一帧的第一请求消息后,若D-VSYNC未开启,则使用VSYNC架构执行帧的渲染逻辑。即:继续等待合成送显模块发送的VSYNC信号,在接收到该VSYNC信号后,向渲染模块发送第一指令,以指示渲染模块执行下一帧;若D-VSYNC处于开启状态,则预执行器根据第一请求消息携带的第一参数确定第一时机,并在第一时机向渲染模块发送第一指令,以指示渲染模块执行下一帧,并用第一虚拟时间戳表示渲染帧的显示时间。As shown in Figure 12(a), after receiving the first request message for 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 a first instruction to the rendering module at the first timing to instruct the rendering module to execute the next frame, and uses a first virtual timestamp to represent the display time of the rendered frame.

图12中的(b)示出了本申请实施例提供的一种预执行器根据第一参数确定第一时机的规则示意图。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.

如图12中的(b)所示,帧渲染时序控制模块在接收到用于请求执行下一帧的第一请求消息后,若D-VSYNC处于开启状态,则预执行器根据第一参数确定第一时机。As shown in Figure 12(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.

其中,在图形渲染过程中,可能会出现连续动画场景、连续非动画场景、动画场景转非动画场景、非动画场景转动画场景这4种情况。其中,动画场景转非动画场景和非动画场景转动画场景存在动画请求和非动画请求的交替,根据第一参数可以确定当前场景为上述4种场景中的那种场景,并基于对场景的判断,确定第一时机。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.

在一些实施例中,预执行器根据上一个VSYNC周期内接收到的第一请求消息携带的第一参数和本VSYNC周期内接收到的第一请求消息携带的第一参数确定当前场景(动画场景、非动画场景或者混合场景),再根据当前场景确定第一时机。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.

在一些实施例中,预执行器根据第一参数确定第一时机,包括:In some embodiments, the pre-executor determines a first timing based on a first parameter, including:

在当前VSYNC周期内收到一个类型为非动画请求的第一请求消息时,在上一个VSYNC周期收到的第一请求消息的类型均为非动画请求,或者在上一个VSYNC周期内没有收到任何第一请求消息(渲染最开始会出现的情况),则当前场景为非动画场景(可理解为连续非动画场景);在当前场景为非动画场景时,预执行器在接收到第一请求消息后,立即向渲染模块发送第一指令。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.

在当前VSYNC周期内收到一个类型为动画请求的第一请求消息时,若在上一个VSYNC周期没有收到类型为非动画请求的第一请求消息,则当前场景为动画场景(可理解为连续动画场景);在当前场景为动画场景时,预执行器在接收到第一请求消息后,立即向渲染模块发送第一指令。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.

在当前VSYNC周期内收到一个类型为动画请求的第一请求消息时,若在上一个VSYNC周期内有收到类型为非动画请求的第一请求消息,则当前场景为混合场景,具体地,为混合场景中的动画转非动画场景;在当前场景为动画转非动画场景时,预执行器在接收到一个类型为动画请求的第一请求消息后,等待该帧对应的非动画请求,在接收到该帧对应的非动画请求后,立即向渲染模块发送第一指令,其中,等待时间可以是m个VSYNC周期。若等待超时,则表示输入事件流结束,响应于该动画请求,预执行器立即向渲染模块发送第一指令,其中,m为大于1且小于等于2的任意数值,m例如可以是1.1、1.2、1.3、1.5或1.8等。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.

或者,在当前VSYNC周期内收到一个类型为非动画请求的第一请求消息时,若在上一个VSYNC周期内有收到类型为动画请求的第一请求消息,则当前场景为混合场景,具体地,为混合场景中的非动画转动画场景;在当前场景为非动画转动画场景时,预执行器在接收到一个类型为非动画请求的第一请求消息后,等待该帧对应的动画请求,在接收到该帧对应的动画请求后,立即向渲染模块发送第一指令,其中,等待时间可以是m个VSYNC周期。若等待超时,则表示属性动画结束,响应于该非动画请求,预执行器立即向渲染模块发送第一指令。其中,第一指令携带第一虚拟时间戳,渲染模块在接收到第一指令后,开始执行下一帧,并用第一虚拟时间戳表示下一帧的显示时间。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.

本申请实施例中,预执行器使得帧的渲染模块可以不必与来自合成送显模块的VSYNC信号对齐,能够提前执行帧的渲染,并赋予该帧一个虚拟时间戳来表示该帧的未来显示时间。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.

示例性地,图13示出了本申请实施例提供的一种虚拟时间器确定虚拟时间戳的原理示意图。For example, Figure 13 shows a schematic diagram of the principle of a virtual timer for determining a virtual timestamp according to an embodiment of this application.

如图13所示,虚拟时间器为每一个预渲染的帧提供对应的虚拟时间戳,虚拟时间戳可以是根据预渲染的帧的上一帧的时间戳和VSYNC周期为预渲染的帧虚拟出来的未来真实上屏显示的时间。As shown in Figure 13, 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 be displayed on the screen in the future, which is virtualized based on the timestamp of the previous frame and the VSYNC period.

具体的,第一请求消息携带第二参数,该第二参数用于携带当前帧(即当前预渲染的帧的上一帧)的时间戳,该第二参数可以是lastVSyncTS。当第一请求消息为渲染模块的上一帧请求执行下一帧的自动画请求时,该第二参数携带上一帧的时间戳;当第一请求消息为非动画请求时,该第二参数为默认值0。结合图13可知,当第一请求消息为渲染模块的上一帧请求执行下一帧的自动画请求时,该第二参数携带该上一帧的时间戳,计算出的下一帧的虚拟时间戳为上一帧的时间戳(lastVSyncTS)与一个VSYNC周期之和。因此在帧堆积状态中,动画可以如同传统的VSYNC一样流畅的执行,其中,lastVSyncTS用于表示当前帧(即当前预渲染的帧的上一帧)的时间戳。Specifically, the first request message carries a second parameter, which is used to carry the timestamp of the current frame (i.e., the previous frame of 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, the second parameter carries the timestamp of the previous frame; when the first request message is a non-animation request, the second parameter has a default value of 0. Referring to Figure 13, 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 a traditional VSYNC, where lastVSyncTS represents the timestamp of the current frame (i.e., the previous frame of the current pre-rendered frame).

应注意:这里所计算出的下一帧的虚拟时间戳必须比当前时间(now)大。若小于当前时间,意味着即使使用了D-VSYNC也发生了掉帧,则使用大于当前时间以后预计的第一个VSYNC时间戳作为下一帧的虚拟时间戳,例如使用当前VSYNC周期的真实的时间戳与一个VSYNC周期之和作为下一帧的虚拟时间戳。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.

结合图13还可知,当第一请求消息为非动画请求时,使用大于当前时间(now)以后预计的第一个VSYNC时间戳作为下一帧的虚拟时间戳,例如使用当前VSYNC周期的真实的时间戳与一个VSYNC周期之和作为下一帧的虚拟时间戳。且该下一帧的虚拟时间戳必须大于或等于上一个事件的虚拟时间戳,若该下一帧的虚拟时间戳小于上一个事件的虚拟时间戳,则使用上一个事件的虚拟时间戳作为该下一帧的虚拟时间戳,以确保在帧堆积情况下,不会发生由于突然收到非动画请求而导致的时间回退。As shown in Figure 13, 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. Furthermore, 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 case of frame stacking, time rollback will not occur due to a sudden receipt of a non-animation request.

真实的VSYNC信号会在每个VSYNC周期记录该VSYNC周期的真实的时间戳(realVSyncTS)和真实的VSYNC周期(realPeriod)。The real VSYNC signal records the real timestamp (realVSyncTS) and the real VSYNC period (realPeriod) for each VSYNC period.

在一些实施例中,每帧在计算完虚拟时间戳后会用真实的VSYNC信号记录的该VSYNC周期的真实的时间戳(realVSyncTS)和真实的VSYNC周期(realPeriod)对虚拟时间戳进行校准,虚拟的时间戳(expectedVSyncTS)会被校准为realVSyncTS+k*realPeriod,其中k是整数。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.

通过该校准,能够避免虚拟时间戳的误差累积。This calibration helps prevent the accumulation of errors in virtual timestamps.

在一些实施例中,虚拟时间器还提供用于获得显示时间的API接口,以供应用程序在需要时在其自己的帧逻辑中使用。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.

示例性地,图14示出了本申请实施例提供的一种输入事件预测模块预测输入事件的状态的原理示意图。For example, Figure 14 shows a schematic diagram of the principle of an input event prediction module predicting the state of an input event according to an embodiment of this application.

图14中的(a)示出的是输入事件预测模块中的列表滚动位置预测器(LSPP)预测滑动事件的状态的原理示意图。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.

如图14中的(a)所示,当应用组件显示用户可以滚动的项目列表时(即输入事件为列表滚动事件),LSPP被激活并生效。LSPP被激活后,根据项目列表的滚动情况选择模型。具体地,当项目列表快速向上滚动时,选择图14中的(a)中所示出的曲线向上模型;当项目列表快速向下滚动时,选择图14中的(a)中所示出的曲线向下模型;当项目列表低速滚动时,选择图14中的(a)中所示出的直线模型。在模型选择完成后,进行模型更新,即将当前的模型修改为最新选择的模型;然后根据更新后的模型和来自虚拟时间器的虚拟时间戳,将触摸的当前坐标修改为虚拟时间戳对应的坐标,并输出虚拟时间戳对应的坐标。这样,就能够实现将输入事件的当前状态修改并纠正为虚拟时间器计算的帧的预期显示时间对应的预期状态。As shown in Figure 14(a), when the application component displays a scrollable list of items (i.e., the input event is a list scrolling event), LSPP is activated and takes effect. After LSPP is activated, a model is selected based on the scrolling of the item list. Specifically, when the item list scrolls upwards quickly, the upward curve model shown in Figure 14(a) is selected; when the item list scrolls downwards quickly, the downward curve model shown in Figure 14(a) is selected; and when the item list scrolls slowly, the straight line model shown in Figure 14(a) is selected. After the model selection is completed, 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.

图14中的(b)示出的是输入事件预测模块中的地图缩放距离预测器(MZDP)预测缩放事件的状态的原理示意图。Figure 14(b) shows a schematic diagram of the principle of the Map Zoom Distance Predictor (MZDP) in the input event prediction module predicting the state of zoom events.

如图14中的(b)所示,在输入事件后,当识别到两个触摸点时(即输入事件为缩放事件),MZDP被激活并生效,MZDP被激活后,计算该两个触摸点之间的距离,该两个触摸点的坐标记为(x1,y1)、(x2,y2),该两个触摸点之间的距离为然后根据所计算出的该两个触摸点之间的距离进行模型更新,进而根据更新后的模型和来自虚拟时间器的虚拟时间戳,将两个触摸点之间的距离修改为虚拟时间戳对应的两个触摸点之间的距离,并输出虚拟时间戳对应的两个触摸点之间的距离。这样,就能够实现将输入事件的当前状态修改并纠正为虚拟时间器计算的帧的预期显示时间对应的预期状态。As shown in Figure 14(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.

此外,输入事件预测模块还可以包括绘画报点预测器或游戏角度预测器,还可以包括其他自定义预测器,以实现对不同事件的状态的预测。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.

在一些实施例中,由于几乎所有应用程序都会使用某种形式的列表来显示新闻、联系人或设置等页面,输入事件预测模块默认包含LSPP,以用于列表滚动预测。当应用使用列表并检测到丢帧时,LSPP和D-VSYNC将被激活,为大多数应用程序带来默认的性能提升。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.

在一些实施例中,D-VSYNC架构为帧缓冲队列设置了回滚和容错机制,具体地:In some embodiments, the D-VSYNC architecture provides rollback and fault tolerance mechanisms for the frame buffer queue, specifically:

在D-VSYNC架构对帧进行预渲染的过程中,输入事件经过输入事件预测模块中的对应的预测器时,输入事件预测模块会记录事件状态预测数据。也就是说,输入事件预测模块会记录最近的事件状态预测历史数据,该事件状态预测历史数据可用于评估预测状态与真实数据之间的像素差,即可以判断事件状态预测的准确性。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.

D-VSYNC可以提供用于舍弃缓冲帧的API接口。对于帧缓冲队列中的任何预渲染帧,如果由于错误的预测而导致其内容不准确,并且不准确度超过设定的阈值,可以通过该API接口丢弃缓冲区预渲染的数据。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.

在一些实施例中,在通过该API接口丢弃缓冲区预渲染的数据时,具体舍弃方法为:释放帧缓冲队列中的当前渲染的帧之前的所有缓冲帧,并且释放合成送显模块最后合成的帧之后的所有缓冲帧。其中,当前渲染的帧将是下一个要显示的帧。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.

应理解:D-VSYNC架构为帧缓冲队列设置的回滚和容错机制为可选设置。在一些实施例中,应用程序逻辑可以自行判断预测的不准确性并显式调用用于舍弃缓冲帧的API接口。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.

由于事件状态的错误预测只会导致较小的像素差异,因此,在一些实施例中,可以不配置用于舍弃缓冲帧的API接口。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.

为了更加直观地体现通过D-VSYNC进行预渲染所能够起到的减少掉帧和降低渲染延迟的有益效果,示例性地,图15示出了本申请实施例提供的一种VSYNC渲染管线和D-VSYNC渲染管线的对比图。To more intuitively demonstrate the beneficial effects of D-VSYNC pre-rendering in reducing frame drops and lowering rendering latency, Figure 15 shows a comparison diagram of a VSYNC rendering pipeline and a D-VSYNC rendering pipeline provided in an embodiment of this application.

如图15所示出的VSYNC渲染管线,在VSYNC架构中,UI线程会与渲染线程之间保持帧同步。在app的第一个VSYNC周期(即图15中示出的VSYNC-app)开始时,VSYNC信号触发UI线程做第1帧的绘制操作;第1帧的UI线程结束后,紧接着进入渲染线程,进行第1帧的渲染;然后在合成显示的第二个VSYNC周期(即图15中示出的VSYNC-sf)开始时触发合成显示线程对第1帧合成显示,并且在显示的第三个VSYNC周期(即图15中示出的HW-VSYNC)开始时,在电子设备的屏幕上显示第1帧。即生成第i个VSYNC信号时,显示第i帧,渲染线程渲染第i+1帧,UI线程执行第i+2帧。As shown in Figure 15, the VSYNC rendering pipeline maintains frame synchronization between the UI thread and the rendering thread. At the start of the first VSYNC cycle of the app (i.e., VSYNC-app as shown in Figure 15), the VSYNC signal triggers the UI thread to draw the first frame. After the UI thread finishes rendering the first frame, the rendering thread immediately follows to render the first frame. Then, at the start of the second VSYNC cycle for compositing and display (i.e., VSYNC-sf as shown in Figure 15), the compositing and display thread is triggered to composite and display the first frame. Finally, at the start of the third VSYNC cycle for display (i.e., HW-VSYNC as shown in Figure 15), 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.

其中,应特别注意的是:在UI线程绘制第11帧时,由于第11帧为超长帧,UI线程绘制第11帧占用了超过3个VSYNC周期,这使得渲染线程在3个周期内都无法执行渲染操作,对应地,在3个周期内显示屏上没有帧显示,这就导致了掉帧。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.

如图15所示出的D-VSYNC渲染管线,在D-VSYNC架构中,D-VSYNC能够对帧进行预渲染,将预渲染的帧加入帧缓冲队列,实现待显示帧的累积,即图15中的D-VSYNC渲染管线中的累积阶段;当帧缓冲队列中的缓冲数量达到允许的最大缓冲数量时,D-VSYNC采用UI线程与渲染线程之间保持帧同步的方式进行预渲染,即图15中的D-VSYNC渲染管线中的同步阶段;当UI线程绘制第11帧时,由于第11帧为超长帧,UI线程绘制第11帧占用了超过3个VSYNC周期,此时,合成送显线程以先进先出的顺序消耗帧缓冲队列中的预渲染的帧。这样,即使渲染线程在3个周期内都无法执行渲染操作,也能够使得在该3个周期内显示屏上也有帧显示,从而避免了掉帧。在第11帧绘制结束后,由于帧缓冲队列中的缓冲数量小于允许的最大缓冲数量,D-VSYNC又会开始预渲染帧,实现待显示帧的累积,即图15中的D-VSYNC渲染管线中的长帧&累积阶段;当帧缓冲队列中的缓冲数量达到允许的最大缓冲数量时,D-VSYNC又切换为采用UI线程与渲染线程之间保持帧同步的方式进行预渲染,即图15中的D-VSYNC渲染管线中的同步阶段。As shown in Figure 15, the D-VSYNC rendering pipeline pre-renders frames and adds them to the frame buffer queue, accumulating frames to be displayed—this is the accumulation stage in the D-VSYNC rendering pipeline shown in Figure 15. When the number of frames in the frame buffer queue reaches the maximum allowed number, D-VSYNC uses a frame synchronization method between the UI thread and the rendering thread for pre-rendering—this is the synchronization stage in the D-VSYNC rendering pipeline shown in Figure 15. When the UI thread draws the 11th frame, since the 11th frame is a very long frame, drawing the 11th frame takes more than 3 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 order. In this way, even if the rendering thread cannot perform rendering operations within 3 cycles, frames can still be displayed on the screen during those 3 cycles, thus avoiding frame drops. After the 11th frame is rendered, since the number of buffers in the frame buffer queue is less than the maximum allowed number of buffers, D-VSYNC will start pre-rendering frames again to accumulate the frames to be displayed, which is the long frame & accumulation stage in the D-VSYNC rendering pipeline in Figure 15; when the number of buffers in the frame buffer queue reaches the maximum allowed number of buffers, D-VSYNC switches to pre-rendering by keeping the UI thread and the rendering thread synchronized, which is the synchronization stage in the D-VSYNC rendering pipeline in Figure 15.

其中,UI线程的执行主体可以是应用模块,渲染线程的执行主体可以是渲染模块,合成送显线程的执行主体可以是合成送显模块。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.

本申请实施例中,D-VSYNC扩展了VSYNC框架,将渲染框架分为累积阶段和同步阶段。对于累积阶段,D-VSYNC将渲染时间和显示时间解耦,在仍有空余的帧缓冲时,允许一些帧根据计算出的显示时间的抽象获得提前执行,不必等待VSYNC信号。因此,D-VSYNC能够充分利用负载波动时短帧节省的时间和算力,为长帧的执行留出时间,从而避免产生掉帧。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.

此外,为了清楚地体现本申请实施例的有益效果,基于上述滑动阅读场景(1)和在桌面打开大文件夹的场景(2),分别对这两种场景在使用本申请实施例提供的图形渲染方法后的渲染显示轨迹进行如下分析。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.

(1)对于滑动阅读场景,在采用了D-VSYNC架构后,D-VSYNC在接收到请求执行下一帧的请求时,能够立即指示渲染模块执行下一帧。渲染模块中所执行的帧的显示时间用来自虚拟时间器的虚拟时间戳表示,渲染模块不需要等待下一个VSYNC信号到来才开始渲染下一帧,能够避免VSYNC信号对齐带来的等待,从而拥有更多的渲染时间,从而避免了掉帧。(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.

(2)对于在桌面打开大文件夹的场景,在采用了D-VSYNC架构后,当前帧请求执行下一帧之后,D-VSYNC能够指示渲染模块根据来自虚拟时间器的下一帧对应的虚拟时间戳提前渲染下一帧。这样,短帧会一帧接着一帧堆积执行,之后出现长帧时,长帧的执行时间可以占用短帧省下来的时间,避免掉帧和渲染延迟。(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.

在一些示例中,短帧场景下,相比较于VSYNC的渲染时延(至少为2个VSYNC周期),D-VSYNC可以使得UI线程和渲染线程在同一个VSYNC周期内完成,使渲染时延变成1个VSYNC周期。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.

在一个示例中,当第一场景为快速连续滑动的场景时,采用D-VSYNC结构进行掉帧的性能测试,在帧缓冲队列中设置不同数量的缓存buffer时,对不同应用对应的掉帧情况进行了测试。D-VSYNC设置帧缓冲队列中的缓存buffer的数量为4时,能够消除71.6%的丢帧,25个应用的每秒掉帧数(frame drops per second,FDPS)的均值由2.04降至0.58;D-VSYNC帧缓冲队列中的缓存buffer的数量为5时,能够消除87.7%的丢帧,25个应用的FDPS均值由2.04降至0.25。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 5, it eliminated 87.7% of frame drops, and the average FDPS for 25 applications decreased from 2.04 to 0.25.

在一个示例中,图16示出了本申请实施例提供的一种第一场景分别为持续快速滚动、交替快速滚动和低速滚动时,平均像素差的测试结果图。In one example, Figure 16 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.

如图16所示,具有5个缓存buffer的D-VSYNC响应能力更高,对于持续快速滚动场景,能够将平均像素差(average pixel difference,APD)减少61.6%,对于低速滚动场景,能够将APD减少55.9%。As shown in Figure 16, D-VSYNC with 5 buffers has higher responsiveness. For continuous fast scrolling scenes, it can reduce the average pixel difference (APD) by 61.6%, and for slow scrolling scenes, it can reduce the APD by 55.9%.

在又一些示例中,基于skiaGL进行性能模型验证,如下表1所示,在未满帧场景,skiaGL提升4.9帧,10个场景满帧。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.

表1
Table 1

类似地,在又一些示例中,基于skia vk进行性能模型验证,如下表2所示,在未满帧场景,skia vk平均提升3.1帧,20个场景满帧,负载与基线持平。Similarly, in some other examples, performance models were validated 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.

表2

Table 2

本申请实施例提供的图形渲染方法除了可以应用于操作系统图形领域之外,还可以应用于其他的由VSYNC驱动的场景,比如可以应用于基于VSYNC驱动的网页(web)场景。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.

本文中所描述的模块或单元的一个或多个可以软件、硬件或二者结合来实现。当以上任一模块或单元以软件实现的时候,所述软件以计算机程序指令的方式存在,并被存储在存储器中,处理器可以用于执行所述程序指令并实现以上方法流程。所述处理器可以包括但不限于以下至少一种:中央处理单元(central processing unit,CPU)、微处理器、数字信号处理器(DSP)、微控制器(microcontroller unit,MCU)、或人工智能处理器等各类运行软件的计算设备,每种计算设备可包括一个或多个用于执行软件指令以进行运算或处理的核。该处理器可以内置于SoC(片上系统)或专用集成电路(application specificintegrated circuit,ASIC),也可是一个独立的半导体芯片。该处理器内处理用于执行软件指令以进行运算或处理的核外,还可进一步包括必要的硬件加速器,如现场可编程门阵列(field programmable gate array,FPGA)、PLD(可编程逻辑器件)、或者实现专用逻辑运算的逻辑电路。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 for executing software instructions to perform calculations or processing, the processor 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.

当本文中所描述的模块或单元以硬件实现的时候,该硬件可以是CPU、微处理器、DSP、MCU、人工智能处理器、ASIC、SoC、FPGA、PLD、专用数字电路、硬件加速器或非集成的分立器件中的任一个或任一组合,其可以运行必要的软件或不依赖于软件以执行以上方法流程。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.

当本文中所描述的模块或单元使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。When the modules or units described herein are implemented using software, they can be implemented, in whole or in part, in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, 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)).

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。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.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art will 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.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。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.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。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.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。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.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。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.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。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 scope of the technology 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 (18)

一种图形渲染的方法,其特征在于,所述方法应用于图形渲染装置,所述装置包括解耦垂直同步模块和渲染模块,所述方法包括:A method for graphics rendering, characterized in that the method is applied to a graphics rendering apparatus, the apparatus comprising a decoupled vertical synchronization module and a rendering module, the method comprising: 在一个垂直同步周期内,响应于第一事件的输入,所述解耦垂直同步模块在第一时机向所述渲染模块发送第一指令;其中,所述第一指令用于指示所述渲染模块渲染当前渲染帧的下一帧,所述第一时机在接收到下一个垂直同步信号的时刻之前,所述第一指令还用于表示所述当前渲染帧的下一帧的显示时间;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; wherein, the first instruction is used to instruct the rendering module to render the next frame of the current rendering frame, and the first opportune moment is before the moment of receiving the next vertical synchronization signal, 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. 根据权利要求1所述的方法,其特征在于,所述第一指令携带第一虚拟时间戳,所述第一虚拟时间戳用于表示所述当前渲染帧的下一帧的显示时间。According to the method of claim 1, 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. 根据权利要求1或2所述的方法,其特征在于,所述解耦垂直同步模块在第一时机向所述渲染模块发送第一指令,包括:According to the method of claim 1 or 2, the decoupled vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, comprising: 所述解耦垂直同步模块接收第一请求消息,所述第一请求消息用于请求渲染所述当前渲染帧的下一帧;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 at a first opportune moment based on 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. 根据权利要求3所述的方法,其特征在于,所述解耦垂直同步模块根据当前场景,在第一时机向所述渲染模块发送第一指令,包括:According to the method of claim 3, 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; 当当前场景为动画转非动画场景时,所述解耦垂直同步模块等待接收非动画请求,若在m个垂直同步周期内接收到所述非动画请求,则所述解耦垂直同步模块在接收到所述非动画请求时,向所述渲染模块发送所述第一指令;或,若在所述m个垂直同步周期内未接收到所述非动画请求,则所述解耦垂直同步模块在所述m个垂直同步周期结束时向所述渲染模块发送所述第一指令,其中,所述m个垂直同步周期的计时起点为所述解耦垂直同步模块接收到所述第一请求消息的时刻,m为大于1,且小于等于2的任意数值;或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. 当当前场景为非动画转动画场景时,所述解耦垂直同步模块等待接收动画请求,若在所述m个垂直同步周期内接收到所述动画请求,则所述解耦垂直同步模块在接收到所述动画请求时,向所述渲染模块发送所述第一指令,若在所述m个垂直同步周期内未接收到所述动画请求,则所述解耦垂直同步模块在所述m个垂直同步周期结束时向所述渲染模块发送所述第一指令。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. 根据权利要求3或4所述的方法,其特征在于,所述方法还包括:The method according to claim 3 or 4, characterized in that the method further comprises: 所述解耦垂直同步模块根据所述第一请求消息携带的第一参数确定当前场景,所述第一参数用于指示所述第一请求消息的类型,所述第一请求消息的类型包括动画请求或非动画请求,所述动画请求来自所述渲染模块,所述非动画请求来自应用模块。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. 根据权利要求5所述的方法,其特征在于,所述解耦垂直同步模块根据所述第一请求消息携带的第一参数确定当前场景,包括:According to the method of claim 5, the decoupling vertical synchronization module determines the current scene 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. 根据权利要求1至6中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 6, characterized in that the method further comprises: 所述解耦垂直同步模块根据当前显示帧的显示时间和垂直同步周期确定所述当前渲染帧的下一帧的显示时间。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. 根据权利要求1至7中任一项所述的方法,其特征在于,所述解耦垂直同步模块在第一时机向所述渲染模块发送第一指令,包括:The method according to any one of claims 1 to 7, characterized in that, the decoupling vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, comprising: 当所述当前渲染帧的下一帧的显示时间和当前的真实时间之间的差值小于或等于X个垂直同步周期时,所述解耦垂直同步模块在第一时机向所述渲染模块发送所述第一指令,所述X为大于或等于1的正整数。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. 根据权利要求1至8中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 8, characterized in that the method further comprises: 所述渲染模块将渲染完成的所述当前渲染帧的下一帧加入缓冲队列,作为所述缓冲队列中的缓冲帧,以使得合成送显模块在每个垂直同步周期内从所述缓冲队列中的多个缓冲帧中获取当前显示帧的下一帧。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. 根据权利要求9所述的方法,其特征在于,所述解耦垂直同步模块在第一时机向所述渲染模块发送第一指令,包括:According to the method of claim 9, the decoupling vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, comprising: 所述解耦垂直同步模块查询所述缓冲队列中的缓冲数量;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. 根据权利要求10所述的方法,其特征在于,所述方法还包括:The method according to claim 10, characterized in that the method further comprises: 当所述缓冲队列中的缓冲数量大于或等于所述最大缓冲数量时,所述解耦垂直同步模块在接收到所述下一个垂直同步信号时,向所述渲染模块发送所述第一指令。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. 根据权利要求1至11中任一项所述的方法,其特征在于,所述装置还包括事件状态预测模块,在所述第一事件输入之后,所述方法还包括:The method according to any one of claims 1 to 11, characterized in that the apparatus further comprises an event state prediction module, and after the first event input, the method further comprises: 所述事件状态预测模块对所述第一事件的状态进行预测,以将所述第一事件的状态更新为与所述当前渲染帧的下一帧的显示时间对应的事件状态。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. 根据权利要求1至12中任一项所述的方法,其特征在于,所述解耦垂直同步模块在第一时机向所述渲染模块发送第一指令,包括:The method according to any one of claims 1 to 12, characterized in that, the decoupling vertical synchronization module sends a first instruction to the rendering module at a first opportune moment, comprising: 当所述第一事件对应的场景为第一场景时,所述解耦垂直同步模块启动解耦垂直同步流程,所述第一场景包括列表滑动的场景、打开应用程序的场景、打开文件夹的场景、打开控制中心的场景、打开通知中心的场景、解锁的场景、横竖屏旋转的场景、应用间转场的场景中的一项或者多项;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 at the first opportune moment. 根据权利要求13所述的方法,其特征在于,所述装置还包括垂直同步模块,所述方法还包括:The method according to claim 13, wherein the device further comprises a vertical synchronization module, and the method further comprises: 在当前场景变化为非第一场景时,所述解耦垂直同步模块关闭解耦垂直同步流程;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. 一种电子设备,其特征在于,包括:An electronic device, characterized in that it comprises: 一个或多个处理器;One or more processors; 一个或多个存储器;One or more memory units; 以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述一个或多个存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行如权利要求1至14中任一项所述的方法。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. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有程序或指令,当所述程序或指令被运行时,实现如权利要求1至14中任一项所述的方法。A computer-readable storage medium, characterized in that the storage medium stores a program or instructions that, when the program or instructions are executed, implement the method as described in any one of claims 1 to 14. 一种芯片,其特征在于,所述芯片中存储有指令,当所述指令被运行时,实现如权利要求1至14中任一项所述的方法。A chip, characterized in that the chip stores instructions that, when executed, implement the method as described in any one of claims 1 to 14. 一种计算机程序产品,其特征在于,所述计算机程序产品中存储有程序或指令,当所述程序或指令被运行时,实现如权利要求1至14中任一项所述的方法。A computer program product, characterized in that the computer program product stores a program or instructions, which, when the program or instructions are run, implement the method as described in any one of claims 1 to 14.
PCT/CN2025/077289 2024-04-30 2025-02-14 Graphics rendering method and apparatus and electronic device Pending WO2025227883A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202410539029.0A CN120872275A (en) 2024-04-30 2024-04-30 Method and device for graphic rendering and electronic equipment
CN202410539029.0 2024-04-30

Publications (1)

Publication Number Publication Date
WO2025227883A1 true WO2025227883A1 (en) 2025-11-06

Family

ID=95981716

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2025/077289 Pending WO2025227883A1 (en) 2024-04-30 2025-02-14 Graphics rendering method and apparatus and electronic device

Country Status (2)

Country Link
CN (2) CN120144081A (en)
WO (1) WO2025227883A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107220019A (en) * 2017-05-15 2017-09-29 努比亚技术有限公司 A kind of rendering intent, mobile terminal and storage medium based on dynamic VSYNC signals
CN110503708A (en) * 2019-07-03 2019-11-26 华为技术有限公司 A kind of image processing method and electronic equipment based on vertical synchronizing signal
CN111627116A (en) * 2020-05-29 2020-09-04 联想(北京)有限公司 Image rendering control method and device and server
CN115904563A (en) * 2021-09-30 2023-04-04 荣耀终端有限公司 Data processing method and device in application program starting and storage medium
WO2024055904A1 (en) * 2022-09-14 2024-03-21 荣耀终端有限公司 Method for requesting vsync signal, and electronic device

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10957020B2 (en) * 2017-12-04 2021-03-23 Nvidia Corporation Systems and methods for frame time smoothing based on modified animation advancement and use of post render queues
CN108769815B (en) * 2018-06-21 2021-02-26 威盛电子股份有限公司 Video processing method and device
WO2021232328A1 (en) * 2020-05-21 2021-11-25 Qualcomm Incorporated Methods and apparatus for tickless pre-rendering
CN111652962B (en) * 2020-06-08 2024-04-23 北京联想软件有限公司 Image rendering method, head-mounted display device and storage medium
CN116627301A (en) * 2021-09-30 2023-08-22 荣耀终端有限公司 Data processing method and related device
CN114579075B (en) * 2022-01-30 2023-01-17 荣耀终端有限公司 Data processing method and related device
CN116991354A (en) * 2022-01-30 2023-11-03 荣耀终端有限公司 Data processing methods and related devices
CN117909000A (en) * 2022-10-19 2024-04-19 华为技术有限公司 Interface generation method and electronic equipment
CN115883921A (en) * 2022-12-30 2023-03-31 新华智云科技有限公司 A data visualization video synthesis method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107220019A (en) * 2017-05-15 2017-09-29 努比亚技术有限公司 A kind of rendering intent, mobile terminal and storage medium based on dynamic VSYNC signals
CN110503708A (en) * 2019-07-03 2019-11-26 华为技术有限公司 A kind of image processing method and electronic equipment based on vertical synchronizing signal
CN111627116A (en) * 2020-05-29 2020-09-04 联想(北京)有限公司 Image rendering control method and device and server
CN115904563A (en) * 2021-09-30 2023-04-04 荣耀终端有限公司 Data processing method and device in application program starting and storage medium
WO2024055904A1 (en) * 2022-09-14 2024-03-21 荣耀终端有限公司 Method for requesting vsync signal, and electronic device

Also Published As

Publication number Publication date
CN120144081A (en) 2025-06-13
CN120872275A (en) 2025-10-31

Similar Documents

Publication Publication Date Title
CN116501210B (en) Display method, electronic equipment and storage medium
CN114648951B (en) Method for controlling dynamic change of screen refresh rate and electronic equipment
CN113805743B (en) Method and electronic device for switching display windows
WO2024041047A1 (en) Screen refresh rate switching method and electronic device
CN118276722A (en) Window display method and electronic device
US20240348869A1 (en) Refresh rate setting method and related device
US20250363677A1 (en) Image display method and related apparatus
WO2023001163A1 (en) Screen refreshing method and device capable of improving dynamic effect performance
CN117707406B (en) Bright screen display method, electronic device and storage medium
CN118626201A (en) Operation frame rate control method, electronic device, chip system and readable storage medium
CN117094876B (en) Data processing method, electronic device and readable storage medium
WO2025227883A1 (en) Graphics rendering method and apparatus and electronic device
WO2024234818A1 (en) Method for adjusting cpu frequency, and terminal device
CN120510057A (en) Image processing method and electronic equipment
WO2024109220A1 (en) Widget display method, electronic device, and readable storage medium
WO2022188667A1 (en) Screen rotation processing method and apparatus, medium and electronic device
US20250363701A1 (en) Interface processing method and electronic device
CN118426892B (en) Interface switching method, electronic equipment and storage medium
CN120215772A (en) Application function response method, electronic device and readable storage medium
US20250391062A1 (en) Image Processing Method and Electronic Device
EP4538852A1 (en) Image processing method and electronic device
WO2025179808A1 (en) Long interface rendering method, application interface display method and electronic device
WO2025148991A1 (en) Frame delivery method and apparatus, electronic device, and readable storage medium
CN121170085A (en) Dynamic effect processing method, electronic device, and computer-readable storage medium
WO2025130055A1 (en) Image processing method and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 25797061

Country of ref document: EP

Kind code of ref document: A1