Task scheduling method, electronic equipment and computer readable storage medium
By assigning priority scheduling queues to windows on electronic devices, the problem of uneven GPU resource allocation in multi-window environments is solved, improving the frame rate and smoothness of windows that users are focused on, and enhancing the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2026-03-31
AI Technical Summary
When multiple windows are running simultaneously on an electronic device, the frame rate of the window that the user is more concerned about may decrease due to uneven allocation of GPU resources, resulting in stuttering or lag and affecting the user experience.
By assigning priority scheduling queues to each window, graphics processing tasks for high-priority windows are executed in the high-priority queue first, while tasks for low-priority windows are executed in the low-priority queue, ensuring that GPU resources are prioritized for graphics processing tasks of important windows.
It improved the frame rate and smoothness of the windows that users are focused on, thus enhancing the user experience.
Smart Images

Figure CN121764601A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of terminal technology, and in particular relates to task scheduling methods, electronic devices, and computer-readable storage media. Background Technology
[0002] Electronic devices typically include a graphics processing unit (GPU). The GPU is used for graphics rendering, such as rendering the images needed to display in a window. The shorter the time it takes for the GPU to process a single frame, the higher the frame rate (i.e., the number of frames displayed per second, FPS). A higher frame rate, meaning more frames displayed per second, results in smoother visuals and a better user experience.
[0003] Currently, electronic devices can typically run multiple windows simultaneously. When multiple windows are running concurrently, they generally share the GPU's resources equally for rendering. However, users usually only focus on a few of these windows. In this case, having all windows share the GPU's resources equally reduces the GPU load on the windows that are of greater interest to the user. This leads to a lower frame rate for those windows, causing stuttering or lag, thus negatively impacting the user experience. Summary of the Invention
[0004] This application provides a task scheduling method, an electronic device, and a computer-readable storage medium, which can improve the frame rate of windows that users are concerned about, improve the smoothness of the screen of windows that users are concerned about, and enhance the user experience.
[0005] In a first aspect, embodiments of this application provide a task scheduling method applied to an electronic device, the electronic device including a graphics processing unit (GPU), the method comprising:
[0006] The electronic device operates a first window and a second window;
[0007] The electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution according to the priority of the first scheduling queue and the priority of the second scheduling queue. The first scheduling queue includes graphics processing tasks corresponding to the first window, and the second scheduling queue includes graphics processing tasks corresponding to the second window. The priority of the first scheduling queue is higher than the priority of the second scheduling queue, and the priority of the graphics processing tasks corresponding to the first window is higher than the priority of the graphics processing tasks corresponding to the second window.
[0008] It should be understood that the higher the priority of the graphics processing task corresponding to a window, the higher the user's attention to that window. Conversely, the lower the priority of the graphics processing task corresponding to a window, the lower the user's attention to that window.
[0009] In the task scheduling method described above, when an electronic device runs multiple windows simultaneously, the electronic device can determine the priority of the graphics processing tasks corresponding to each window. Based on the priority of the graphics processing tasks, high-priority graphics processing tasks can be placed in a high-priority scheduling queue, and low-priority graphics processing tasks can be placed in a low-priority scheduling queue. This allows the GPU to prioritize the execution of graphics processing tasks in the high-priority scheduling queue, that is, to prioritize the execution of graphics processing tasks corresponding to windows that the user is more concerned about. This ensures that the GPU utilization rate of high-priority graphics processing tasks is increased, thereby improving the frame rate and smoothness of the screen of the windows that the user is more concerned about, and enhancing the user experience.
[0010] In some embodiments, the priority of the graphics processing task corresponding to the window is determined based on at least one of the area of the first region corresponding to the window, the first proportion corresponding to the window, the area of the window, the second proportion corresponding to the window, the offset distance corresponding to the window, and the offset distance ratio corresponding to the window.
[0011] Wherein, the area of the first region corresponding to the window includes the area of the area currently displayed by the window in the display interface; the first proportion corresponding to the window is the ratio between the area of the first region corresponding to the window and the area of the window; the second proportion corresponding to the window is the ratio between the area of the window and the area of the display interface; the offset distance corresponding to the window is the distance between the center point of the window and the center point of the display interface; and the offset distance ratio corresponding to the window is the ratio between the offset distance corresponding to the window and the diagonal length of the display interface.
[0012] It should be understood that when multiple windows are running simultaneously on an electronic device, users generally pay more attention to the window with the largest or most complete visible area (i.e., the first area). Alternatively, users generally pay more attention to the larger windows. Or, users generally pay more attention to the windows that are closer to the center of the display interface.
[0013] In the task scheduling method provided in this embodiment, the electronic device can determine the user's attention to each window based on one or more of the following: the size of the visible area corresponding to each window (i.e., the area of the first region), the proportion of the visible area (i.e., the first proportion, which can be used to represent the integrity of the visible area), the window size, the screen proportion (i.e., the second proportion, which can be used to represent the size of the window), the offset distance between the center point of the window and the center point of the display interface, and the offset distance ratio. This allows the electronic device to determine the priority of the graphics processing tasks corresponding to each window. Specifically, for windows with high user attention, the graphics processing tasks corresponding to those windows can be determined to have higher priority; for windows with low user attention, the graphics processing tasks corresponding to those windows can be determined to have lower priority. This ensures that the graphics processing tasks corresponding to windows with high user attention can be prioritized for GPU execution, increasing the frame rate of the windows with high user attention and thus improving the smoothness of the screen in those windows.
[0014] In other embodiments, the area of the first region corresponding to the first window is greater than the area of the first region corresponding to the second window, or the first proportion corresponding to the first window is greater than the first proportion corresponding to the second window, or the area of the first window is greater than the area of the second window, or the second proportion corresponding to the first window is greater than the second proportion corresponding to the second window, or the offset distance corresponding to the first window is less than the offset distance corresponding to the second window, or the offset distance ratio corresponding to the first window is less than the offset distance ratio corresponding to the second window.
[0015] In some embodiments, the electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution based on the priorities of the first scheduling queue and the second scheduling queue, including:
[0016] The electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution based on a preset scheduling ratio, the priority of the first scheduling queue, and the priority of the second scheduling queue.
[0017] The preset scheduling ratio is the ratio of the time taken to execute a graphics processing task in the first scheduling queue to the time taken to execute a graphics processing task in the second scheduling queue; or, the preset scheduling ratio is the ratio of scheduling a graphics processing task in the first scheduling queue to scheduling a graphics processing task in the second scheduling queue.
[0018] It should be understood that when the preset scheduling ratio is the ratio of the execution time of graphics processing tasks in each scheduling queue, the higher the priority of the scheduling queue, the longer the execution time of the graphics processing tasks in that scheduling queue will be; the lower the priority of the scheduling queue, the shorter the execution time of the graphics processing tasks in that scheduling queue will be. This increases the execution time of graphics processing tasks in high-priority scheduling queues, allowing the GPU more time to execute high-priority graphics processing tasks. This improves the speed and efficiency of executing graphics processing tasks in high-priority scheduling queues, increases the frame rate and smoothness of windows that users pay close attention to, and enhances the user's viewing experience for these windows.
[0019] Similarly, when the preset scheduling ratio can be the ratio of the number of times graphics processing tasks in each scheduling queue are scheduled, that is, the ratio of the number of times graphics processing tasks in each scheduling queue are scheduled, the higher the priority of the scheduling queue, the more times graphics processing tasks in that scheduling queue will be scheduled; the lower the priority of the scheduling queue, the fewer times graphics processing tasks in that scheduling queue will be scheduled. This increases the number of times the GPU schedules graphics processing tasks in high-priority scheduling queues, which can improve the speed and efficiency of executing graphics processing tasks in high-priority scheduling queues. This can improve the frame rate and smoothness of windows that users pay close attention to, and enhance the user's viewing experience for windows that users pay close attention to.
[0020] In one possible implementation, the GPU includes a first processing core and a second processing core, and the preset scheduling ratio includes a first preset scheduling ratio and a second preset scheduling ratio;
[0021] The first processing core executes the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the first preset scheduling ratio;
[0022] The second processing core executes the graphics processing tasks in the first scheduling queue and the second scheduling queue according to the second preset scheduling ratio.
[0023] It should be understood that the first preset scheduling ratio and the second preset scheduling ratio can be the same or different. That is, when the GPU includes multiple cores, each core of the GPU can execute graphics processing tasks in its respective scheduling queue with the same preset scheduling ratio. Alternatively, each core of the GPU can execute graphics processing tasks in its respective scheduling queue with different preset scheduling ratios.
[0024] In another possible implementation, the GPU includes a first processing core and a second processing core;
[0025] The first processing core executes the graphics processing tasks in the first scheduling queue;
[0026] The second processing core executes the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the preset scheduling ratio.
[0027] In the task scheduling method provided by this implementation, when the GPU includes multiple cores, a portion of the GPU cores can be dedicated to executing graphics processing tasks in higher-priority scheduling queues. Another portion of the GPU cores can execute graphics processing tasks in various scheduling queues according to a preset scheduling ratio, or another portion of the GPU cores can execute graphics processing tasks in other scheduling queues according to a preset scheduling ratio. By having a portion of the GPU cores dedicated to executing graphics processing tasks in higher-priority scheduling queues, it can be ensured that graphics processing tasks in higher-priority scheduling queues are executed in a timely manner, thereby improving the frame rate and smoothness of windows that users pay close attention to, and enhancing the user experience.
[0028] For example, the preset scheduling ratio is either preset or determined based on the current load of the GPU.
[0029] It should be understood that when determining the preset scheduling ratio based on the current GPU load, when the current GPU load is high, the electronic device can determine that the preset scheduling ratio is large. This means that the execution time of graphics processing tasks in the high-priority scheduling queue is longer than the execution time of graphics processing tasks in the low-priority scheduling queue, or that the number of times graphics processing tasks in the high-priority scheduling queue are scheduled is greater than the number of times graphics processing tasks in the low-priority scheduling queue are scheduled. In this way, when the GPU load is high, graphics processing tasks in the high-priority scheduling queue can be executed first, thereby improving the frame rate and smoothness of windows that users pay close attention to, and ensuring the user's viewing experience for windows that users pay close attention to.
[0030] In one possible implementation, the GPU load is greater than or equal to a first preset load.
[0031] It should be noted that the first preset load can be used to indicate whether the GPU is overloaded. It should be understood that when the GPU load is greater than or equal to the first preset load, it can be determined that the GPU is overloaded, meaning the GPU is currently unable to meet the task processing needs of all windows. When the GPU load is less than the first preset load, it can be determined that the GPU is not overloaded, meaning the GPU is currently able to meet the task processing needs of all windows.
[0032] In the task scheduling method provided by this implementation, when GPU overload is determined—that is, when the GPU cannot meet the task processing needs of all current windows—the electronic device can determine the priority of the graphics processing tasks corresponding to each window. Based on the priority of the graphics processing tasks for each window, the device can divide these tasks into scheduling queues of different priorities. For example, high-priority graphics processing tasks can be assigned to high-priority scheduling queues, and low-priority tasks can be assigned to low-priority scheduling queues. This ensures that when the GPU is overloaded, i.e., when GPU resources are scarce, the GPU can prioritize executing graphics processing tasks for windows that are of high user interest, ensuring the frame rate and smoothness of these windows and improving the user's viewing experience.
[0033] In some embodiments, the electronic device also runs a third window, and the method further includes:
[0034] When the GPU load is less than the second preset load, the graphics processing task corresponding to the third window is assigned to the first scheduling queue, and the priority of the graphics processing task corresponding to the first window is higher than the priority of the graphics processing task corresponding to the third window.
[0035] In the task scheduling method provided in this embodiment, the electronic device can allocate graphics processing tasks corresponding to each window to corresponding scheduling queues based on the GPU load. For example, when the GPU load is greater than or equal to a second preset load, the electronic device can allocate high-priority graphics processing tasks to a high-priority scheduling queue and low-priority graphics processing tasks to a low-priority scheduling queue. When the GPU load is less than the second preset load, the electronic device can allocate high-priority graphics processing tasks and a portion of low-priority graphics processing tasks to a high-priority scheduling queue and allocate another portion of low-priority graphics processing tasks to a low-priority scheduling queue. That is, when the GPU load is high, high-priority graphics processing tasks can be prioritized for GPU execution. When the GPU load is low, while prioritizing the scheduling of high-priority graphics processing tasks to the GPU, some low-priority graphics processing tasks can also be prioritized for GPU execution, so that when the GPU load is low, i.e., when GPU resources are sufficient, some low-priority graphics processing tasks can also be prioritized for execution.
[0036] It should be understood that the second preset load may be the same as or different from the first preset load, and the specific choice can be determined according to the actual scenario.
[0037] In some embodiments, the first window and the second window are windows of the same application.
[0038] It should be understood that multiple windows running simultaneously on an electronic device can be windows of the same application or windows of different applications.
[0039] In other embodiments, the first window is the focus window and the second window is the non-focus window.
[0040] In the task scheduling method provided in this embodiment, when an electronic device runs multiple windows, since users generally pay the most attention to the focus window, in order to ensure the frame rate of the focus window and improve the smoothness of the focus window, so as to improve the user's viewing experience of the focus window, the priority of the graphics processing task corresponding to the focus window can be determined to be higher than the priority of the graphics processing task corresponding to the non-focus window, and the priority of the graphics processing task corresponding to the focus window can be put into the highest priority scheduling queue, so that the GPU can execute the graphics processing task corresponding to the focus window first.
[0041] Secondly, embodiments of this application provide a task scheduling device applied to an electronic device, the electronic device including a graphics processing unit (GPU), the device comprising:
[0042] The window execution module is used to run the first and second windows;
[0043] The task scheduling module is used to schedule graphics processing tasks in the first scheduling queue and the second scheduling queue to be executed on the GPU according to the priority of the first scheduling queue and the priority of the second scheduling queue; the first scheduling queue includes graphics processing tasks corresponding to the first window, the second scheduling queue includes graphics processing tasks corresponding to the second window, the priority of the first scheduling queue is higher than the priority of the second scheduling queue, and the priority of the graphics processing tasks corresponding to the first window is higher than the priority of the graphics processing tasks corresponding to the second window.
[0044] In some embodiments, the priority of the graphics processing task corresponding to the window is determined based on at least one of the area of the first region corresponding to the window, the first proportion corresponding to the window, the area of the window, the second proportion corresponding to the window, the offset distance corresponding to the window, and the offset distance ratio corresponding to the window.
[0045] Wherein, the area of the first region corresponding to the window includes the area of the area currently displayed by the window in the display interface; the first proportion corresponding to the window is the ratio between the area of the first region corresponding to the window and the area of the window; the second proportion corresponding to the window is the ratio between the area of the window and the area of the display interface; the offset distance corresponding to the window is the distance between the center point of the window and the center point of the display interface; and the offset distance ratio corresponding to the window is the ratio between the offset distance corresponding to the window and the diagonal length of the display interface.
[0046] In other embodiments, the area of the first region corresponding to the first window is greater than the area of the first region corresponding to the second window, or the first proportion corresponding to the first window is greater than the first proportion corresponding to the second window, or the area of the first window is greater than the area of the second window, or the second proportion corresponding to the first window is greater than the second proportion corresponding to the second window, or the offset distance corresponding to the first window is less than the offset distance corresponding to the second window, or the offset distance ratio corresponding to the first window is less than the offset distance ratio corresponding to the second window.
[0047] In some embodiments, the task scheduling module is specifically used to schedule the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue to be executed by the GPU according to a preset scheduling ratio, the priority of the first scheduling queue and the priority of the second scheduling queue.
[0048] The preset scheduling ratio is the ratio of the time taken to execute a graphics processing task in the first scheduling queue to the time taken to execute a graphics processing task in the second scheduling queue; or, the preset scheduling ratio is the ratio of scheduling a graphics processing task in the first scheduling queue to scheduling a graphics processing task in the second scheduling queue.
[0049] In one possible implementation, the GPU includes a first processing core and a second processing core, and the preset scheduling ratio includes a first preset scheduling ratio and a second preset scheduling ratio;
[0050] The first processing core is used to execute the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the first preset scheduling ratio;
[0051] The second processing core is used to execute the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the second preset scheduling ratio.
[0052] In one example, the first preset scheduling ratio is the same as the second preset scheduling ratio.
[0053] In another possible implementation, the GPU includes a first processing core and a second processing core;
[0054] The first processing core is used to execute the graphics processing tasks in the first scheduling queue;
[0055] The second processing core is used to execute the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the preset scheduling ratio.
[0056] For example, the preset scheduling ratio is either preset or determined based on the current load of the GPU.
[0057] In one possible implementation, the GPU load is greater than or equal to a first preset load.
[0058] In some embodiments, the window running module is further configured to run a third window, and the apparatus further includes:
[0059] The task partitioning module is used to partition the graphics processing task corresponding to the third window into the first scheduling queue when the GPU load is less than the second preset load, wherein the priority of the graphics processing task corresponding to the first window is higher than the priority of the graphics processing task corresponding to the third window.
[0060] In some embodiments, the first window and the second window are windows of the same application.
[0061] In other embodiments, the first window is the focus window and the second window is the non-focus window.
[0062] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the electronic device implements the task scheduling method described in any one of the first aspects above.
[0063] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a computer, causes the computer to implement the task scheduling method described in any one of the first aspects above.
[0064] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the task scheduling method described in any one of the first aspects.
[0065] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0066] Figure 1 This is an example diagram of processing graphics processing tasks corresponding to multiple applications;
[0067] Figure 2 This is a schematic diagram of the structure of the electronic device to which the task scheduling method provided in this application embodiment is applicable;
[0068] Figure 3 This is a schematic diagram of the software architecture to which the task scheduling method provided in the embodiments of this application is applicable;
[0069] Figure 4 This is a flowchart illustrating a task scheduling method provided in an embodiment of this application;
[0070] Figure 5 This is a schematic diagram of the application scenario provided in the embodiments of this application. Figure 1 ;
[0071] Figure 6 This is a schematic diagram of the application scenario provided in the embodiments of this application. Figure 2 ;
[0072] Figure 7 This is an example of task scheduling provided in the embodiments of this application. Figure 1 ;
[0073] Figure 8 This is an example of task scheduling provided in the embodiments of this application. Figure 2 ;
[0074] Figure 9 This is an example of task scheduling provided in the embodiments of this application. Figure 3 ;
[0075] Figure 10 This is an example of task scheduling provided in the embodiments of this application. Figure 4 ;
[0076] Figure 11 This is a flowchart illustrating another task scheduling method provided in an embodiment of this application. Detailed Implementation
[0077] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0078] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0079] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0080] 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, phrases such as "in one example," "in some embodiments," "in another example," "in yet another embodiment," 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.
[0081] Furthermore, the term "multiple" mentioned in the embodiments of this application should be interpreted as two or more.
[0082] The steps involved in the task scheduling method provided in this application are merely examples. Not all steps are mandatory, nor are all information or message contents required. They can be added or removed as needed during use. The same step or step or message with the same function in this application can be referenced and learned from each other in different embodiments.
[0083] The business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0084] Electronic devices typically include a GPU. The GPU is used for graphics rendering, such as rendering the images needed to display in a window. Frame rate refers to the number of frames displayed per second (FPS) in animations or videos. A higher frame rate means more frames are displayed per second, resulting in smoother visuals and a better user experience. Conversely, a lower frame rate means fewer frames are displayed per second, leading to stuttering or lag, negatively impacting the user experience. It's important to understand that GPU processing performance is the key factor affecting frame rate. The shorter the time it takes for the GPU to process a single frame, the higher the frame rate. Conversely, the longer the time it takes for the GPU to process a single frame, the lower the frame rate.
[0085] Generally, electronic devices can run multiple windows simultaneously. When multiple windows are running concurrently, these windows typically require the GPU to render the images. This means the GPU needs to process the graphics processing tasks corresponding to each window individually to produce the desired visuals. It should be understood that the graphics processing tasks corresponding to a window refer to the tasks submitted to the GPU by the application for that window, which require graphics rendering. To manage the processing of these tasks for each window, a unified scheduling queue is typically used. In other words, all graphics processing tasks for each window can be placed in this scheduling queue. The GPU can then sequentially retrieve and process these tasks from the queue.
[0086] For example, please see Figure 1 , Figure 1 An example diagram is shown illustrating the processing of graphics tasks corresponding to multiple applications. This example uses an electronic device running windows A, B, C, and D simultaneously as a case study.
[0087] like Figure 1 As shown, when window A needs to schedule the GPU to execute a graphics processing task, the electronic device can place the graphics processing task corresponding to window A (for example, graphics processing task A) into the scheduling queue. Similarly, when window B needs to schedule the GPU to execute a graphics processing task, the electronic device can place the graphics processing task corresponding to window B (for example, graphics processing task B) into the scheduling queue. When window C needs to schedule the GPU to execute a graphics processing task, the electronic device can place the graphics processing task corresponding to window C (for example, graphics processing task C) into the scheduling queue. When window D needs to schedule the GPU to execute a graphics processing task, the electronic device can place the graphics processing task corresponding to window D (for example, graphics processing task D) into the scheduling queue.
[0088] The GPU can retrieve graphics processing tasks from the scheduling queue in the order they were placed in time and execute them sequentially. That is, it can execute tasks based on the time sequence, using the GPU's processor cores (also called cores or processing cores). Figure 1 This example uses a GPU with core 1 and core 2 as an example to illustrate graphics processing tasks. A GPU can contain multiple processor cores (or computing units), which can execute tasks simultaneously, thus achieving efficient parallel computing and improving the GPU's processing efficiency. It should be understood that... Figure 1 In this context, queue3, queue2, queue1, and queue0 can refer to graphics processing tasks, respectively.
[0089] It should be understood that when multiple windows are running simultaneously on an electronic device, users generally focus on only a portion of them. The method described above, where all windows sequentially access the GPU for graphics processing tasks, reduces the GPU usage of the windows that are of greater interest to the user. This results in a lower frame rate for those windows, causing stuttering or lag, thus negatively impacting the user experience.
[0090] For example, in Figure 1 In the scenario shown, when the user is primarily focused on window C, if the graphics processing task corresponding to window C is not the first task placed in the GPU's scheduling queue, then window C must wait for the GPU to finish processing the graphics processing tasks corresponding to other windows before it can process its own graphics processing task C. In other words, the graphics processing task C corresponding to window C is blocked by the graphics processing tasks of other windows, causing the duration of a single frame for window C to increase, resulting in a decrease in the frame rate of window C's display. This leads to stuttering or lag issues in the displayed image of window C, negatively impacting the user experience.
[0091] To address the aforementioned problems, embodiments of this application provide a task scheduling method, an electronic device, and a computer-readable storage medium. In this method, when an electronic device runs multiple windows simultaneously, the device can determine the priority of the graphics processing tasks corresponding to each window. High-priority graphics processing tasks can be placed in a high-priority scheduling queue, and low-priority tasks can be placed in a low-priority scheduling queue. This allows the GPU to prioritize the execution of graphics processing tasks in the high-priority scheduling queue, ensuring that the GPU utilization of high-priority graphics processing tasks is maintained. This improves the frame rate and smoothness of the screen in the user-focused window, enhancing the user experience and demonstrating strong ease of use and practicality.
[0092] In this application embodiment, the electronic device can be a mobile phone, tablet computer, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), desktop computer, etc. This application embodiment does not impose any restrictions on the specific type of electronic device.
[0093] The following first describes the electronic device involved in the embodiments of this application. Please refer to... Figure 2 , Figure 2 A schematic diagram of an electronic device 200 is shown.
[0094] Electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, antenna 1, antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, a sensor module 280, buttons 290, a camera 291, and a display screen 292, etc. The sensor module 280 may include a pressure sensor 280A, a gyroscope sensor 280B, a barometric pressure sensor 280C, a magnetic sensor 280D, an accelerometer 280E, a proximity sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, etc.
[0095] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 200. In other embodiments of this application, the electronic device 200 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.
[0096] Processor 210 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0097] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0098] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0099] In some embodiments, the processor 210 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0100] 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 200. In other embodiments of this application, the electronic device 200 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0101] The charging management module 240 is used to receive charging input from the charger.
[0102] The power management module 241 is used to connect the battery 242, the charging management module 240, and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240 to power the processor 210, internal memory 221, display 292, camera 291, and wireless communication module 260, etc.
[0103] The wireless communication function of the electronic device 200 can be realized through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor and baseband processor, etc.
[0104] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 200 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0105] The mobile communication module 250 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 200. The mobile communication module 250 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 250 may be housed in the processor 210. In some embodiments, at least some functional modules of the mobile communication module 250 and at least some modules of the processor 210 may be housed in the same device.
[0106] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 270A, receiver 270B, etc.) or displays images or videos through display screen 292. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 210 and may be housed in the same device as the mobile communication module 250 or other functional modules.
[0107] The wireless communication module 260 can provide solutions for wireless communication applications on the electronic device 200, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 210. The wireless communication module 260 can also receive signals to be transmitted from processor 210, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0108] In some embodiments, antenna 1 of electronic device 200 is coupled to mobile communication module 250, and antenna 2 is coupled to wireless communication module 260, enabling electronic device 200 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0109] Electronic device 200 implements display functions through a GPU, display screen 292, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 292 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 210 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0110] Display screen 292 is used to display images, videos, etc. Display screen 292 includes a display panel. The display panel can 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 Mini LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 200 may include one or N displays 292, where N is a positive integer greater than 1.
[0111] Electronic device 200 can perform shooting functions through ISP, camera 291, video codec, GPU, display screen 292 and application processor.
[0112] The ISP is used to process the data fed back by camera 291.
[0113] Camera 291 is used to capture still images or videos. In some embodiments, electronic device 200 may include one or N cameras 291, where N is a positive integer greater than 1.
[0114] A digital signal processor (DSP) is used to process digital signals, including digital image signals and other digital signals. A video codec is used to compress or decompress digital video. Electronic device 200 can support one or more video codecs. Thus, electronic device 200 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0115] An NPU (Neural Processing Unit) is a neural network (NN) computing processor that, by borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, rapidly processes input information and can continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0116] The external storage interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200. The external memory card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0117] Internal memory 221 can be used to store computer executable program code, which includes instructions. Internal memory 221 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program 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 200 (such as audio data, phonebook, etc.). Furthermore, internal memory 221 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. Processor 210 executes various functional applications and data processing of electronic device 200 by running instructions stored in internal memory 221 and / or instructions stored in memory disposed in the processor.
[0118] Electronic device 200 can implement audio functions such as music playback and recording through audio module 270, speaker 270A, receiver 270B, microphone 270C, headphone jack 270D, and application processor.
[0119] Audio module 270 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. Audio module 270 can also be used for audio signal encoding and decoding. Buttons 290 include a power button, volume buttons, etc.
[0120] Button 290 can be a mechanical button or a touch button. Electronic device 200 can receive button input and generate key signal inputs related to user settings and function control of electronic device 200.
[0121] The software system of electronic device 200 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. For example, the software system of electronic device 200 can adopt a layered architecture such as Android operating system (OS), Harmony OS, or iOS. This application embodiment uses a layered architecture as an example to illustrate the software structure of electronic device 200.
[0122] Figure 3This is a software structure block diagram of an electronic device 200 according to an embodiment of this application.
[0123] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom: the application layer, the application framework layer, the runtime and system libraries, and the kernel layer.
[0124] The application layer can include a series of application packages.
[0125] like Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0126] 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.
[0127] like Figure 3 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0128] 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.
[0129] 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.
[0130] 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.
[0131] The phone manager is used to provide communication functions for electronic devices 200. For example, it manages call status (including connection and disconnection).
[0132] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0133] 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.
[0134] Runtime consists of core libraries and a virtual machine. Runtime is responsible for the scheduling and management of the operating system.
[0135] The core library consists of two parts: one part is the functionalities that the Java language needs to call, and the other part is the core library of the operating system.
[0136] 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.
[0137] 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.
[0138] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0139] 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.
[0140] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0141] A 2D graphics engine is a graphics engine for 2D drawing.
[0142] 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.
[0143] The task scheduling method provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings and specific application scenarios.
[0144] Please see Figure 4 , Figure 4 A schematic flowchart illustrating a task scheduling method provided in an embodiment of this application is shown. This method can be applied to the aforementioned electronic device, which may include a GPU. Figure 4 As shown, the method may include:
[0145] S401. When an electronic device is running multiple windows, the electronic device determines the priority of the graphics processing task corresponding to each window.
[0146] In some embodiments, the priority of the graphics processing task corresponding to each window can be determined based on at least one of the following: the area of the visible region corresponding to each window, the proportion of the visible region corresponding to each window, the area of each window, the proportion of the screen corresponding to each window, the offset distance between the center point of each window and the center of the display interface, and the ratio of the offset distances corresponding to each window. For details on how the electronic device determines the priority of the graphics processing task corresponding to each window, please refer to the relevant content in the following section, "The process of determining the priority of the graphics processing task corresponding to each window by the electronic device will be described in detail below."
[0147] S402. The electronic device assigns the graphics processing tasks corresponding to each window to the corresponding scheduling queue according to the priority of the graphics processing tasks corresponding to each window.
[0148] In some embodiments, the electronic device may have N scheduling queues, where N can be a positive integer greater than or equal to 2. Each scheduling queue may have a corresponding priority. For example, the priorities of each scheduling queue may be different, meaning one scheduling queue can correspond to one priority. For example, multiple scheduling queues may have the same priority, meaning two or more scheduling queues can correspond to one priority. The following description will use one scheduling queue corresponding to one priority as an example for illustrative purposes.
[0149] In one example, when an electronic device has two scheduling queues, such as a first scheduling queue and a second scheduling queue, the first scheduling queue can have a higher priority than the second scheduling queue. In this case, the electronic device can assign high-priority graphics processing tasks to the first scheduling queue and low-priority graphics processing tasks to the second scheduling queue, based on the priority of the graphics processing tasks corresponding to each window.
[0150] The details of how the electronic device assigns graphics processing tasks to corresponding scheduling queues based on the priority of each window can be found in the following section, "The process of assigning graphics processing tasks to corresponding scheduling queues based on the priority of each window will be explained in detail below."
[0151] S403: The electronic device schedules graphics processing tasks in each scheduling queue to the GPU for execution based on the priority of each scheduling queue.
[0152] In some embodiments, graphics processing tasks in high-priority scheduling queues can be preferentially scheduled to the GPU for execution; that is, the GPU can preferentially execute graphics processing tasks in high-priority scheduling queues. For example, when an electronic device has two scheduling queues, such as a first scheduling queue and a second scheduling queue, and the first scheduling queue has a higher priority than the second scheduling queue, the electronic device can preferentially schedule graphics processing tasks in the first scheduling queue to the GPU for execution; that is, the GPU can preferentially execute graphics processing tasks in the first scheduling queue.
[0153] The details of how the electronic device schedules graphics processing tasks in each scheduling queue to the GPU for execution based on the priority of each scheduling queue can be found in the following section, "The process of scheduling graphics processing tasks in each scheduling queue to the GPU for execution based on the priority of each scheduling queue will be explained in detail below."
[0154] In this embodiment, when an electronic device runs multiple windows simultaneously, it can determine the priority of the graphics processing tasks corresponding to each window and place high-priority graphics processing tasks into a high-priority scheduling queue and low-priority graphics processing tasks into a low-priority scheduling queue. Specifically, graphics processing tasks corresponding to windows with high user attention can be placed in a high-priority scheduling queue, while those corresponding to windows with low user attention can be placed in a low-priority scheduling queue. This allows the GPU to prioritize the execution of graphics processing tasks in the high-priority scheduling queue, thus prioritizing the execution of graphics processing tasks corresponding to windows with high user attention. This increases the GPU utilization of these windows, reduces their latency, and consequently improves the frame rate and smoothness of the visuals, enhancing the user experience.
[0155] For example, multiple windows running on an electronic device can be windows of different applications, or all or some of the windows can be windows of the same application. Furthermore, any single window running on the electronic device can be a foreground window or a background window.
[0156] In some embodiments, the task scheduling method provided in this application can be an optional function of an electronic device. The electronic device can determine whether to enable this function based on the actual scenario, and thus determine whether to schedule graphics processing tasks to be executed on the GPU using the task scheduling method provided in this application.
[0157] In one example, the electronic device can determine whether to enable the feature based on the GPU load. That is, when the electronic device is running multiple windows, it can determine the GPU load. When the GPU load is determined to be greater than or equal to a preset load (e.g., preset load A), the electronic device can determine that the GPU is overloaded, meaning the GPU cannot currently meet the task processing requirements of these multiple windows. In this case, the electronic device can schedule graphics processing tasks to be executed on the GPU according to the task scheduling method provided in this application embodiment. When the GPU load is determined to be less than the preset load A, the electronic device can determine that the GPU is not overloaded, meaning the GPU can meet the current task processing requirements. In this case, the terminal device can schedule graphics processing tasks to be executed on the GPU using other scheduling methods.
[0158] In other words, when GPU overload is detected, the electronic device can determine the priority of the graphics processing tasks corresponding to each window. Based on this priority, the device can allocate these tasks to corresponding scheduling queues: high-priority tasks to high-priority queues, and low-priority tasks to low-priority queues. Subsequently, the device can schedule these tasks to the GPU for execution, ensuring that the GPU prioritizes high-priority tasks, thus improving the frame rate and smoothness of windows that are of high user interest.
[0159] It should be noted that the preset load A can be determined according to the actual application scenario, and this application embodiment does not impose any restrictions on it.
[0160] The following section will explain in detail the process by which an electronic device determines the priority of the graphics processing tasks corresponding to each window. bright.
[0161] In some embodiments, when an electronic device runs multiple windows simultaneously, the user typically focuses more on the one or more windows with the largest visible area. Therefore, when an electronic device runs multiple windows simultaneously, it can determine the user's focus on each window based on the area of each window displayed on the screen (e.g., the area corresponding to each window's first region), thereby determining the priority of the graphics processing tasks corresponding to each window. In other words, the electronic device can determine the area of the first region corresponding to each window and, based on that area, determine the priority of the graphics processing tasks corresponding to each window. Essentially, the electronic device can determine the priority of the graphics processing tasks corresponding to each window based on the size of its visible area.
[0162] For example, the area of the first region corresponding to each window can be greater than or equal to 0. Specifically, when the area of the first region corresponding to a window is equal to 0, it indicates that the window is not currently displayed in the display interface. When the area of the first region corresponding to a window is greater than 0, it indicates that all or part of the window is displayed in the display interface; that is, the first region corresponding to the window can include all or part of the window.
[0163] For example, a larger first region corresponding to a window (i.e., a larger visible area) indicates more content is currently displayed on the screen, making it more likely for the user to focus on the window. Therefore, the electronic device can determine that the user's attention to the window is higher, and consequently, the priority of the graphics processing task corresponding to that window is higher. Conversely, a smaller first region corresponding to a window (i.e., a smaller visible area) indicates less content is currently displayed on the screen, making it less likely for the user to focus on the window. Therefore, the electronic device can determine that the user's attention to the window is lower, and consequently, the priority of the graphics processing task corresponding to that window is lower.
[0164] In one example, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the ratio between the area of the first region corresponding to each window and the area of the display interface.
[0165] For example, an electronic device can determine the priority of the graphics processing task corresponding to each window by the ratio between the area of the first region corresponding to each window and the area of the display interface.
[0166] For example, when an electronic device operates in windows A, B, C, and D, suppose the electronic device determines that the ratio between the area of the first region corresponding to window A and the area of the display interface is 0.5, the ratio between the area of the first region corresponding to window B and the area of the display interface is 0.3, the ratio between the area of the first region corresponding to window C and the area of the display interface is 0.2, and the ratio between the area of the first region corresponding to window D and the area of the display interface is 0. In this case, the electronic device can determine that the priority of the graphics processing task corresponding to window A is 0.5, the priority of the graphics processing task corresponding to window B is 0.3, the priority of the graphics processing task corresponding to window C is 0.2, and the priority of the graphics processing task corresponding to window D is 0.
[0167] For example, an electronic device may have at least two priorities corresponding to graphics processing tasks and a range corresponding to each priority. After determining the ratio between the area of the first region corresponding to each window and the area of the display interface, the electronic device can determine the range to which the ratio between the area of the first region corresponding to each window and the area of the display interface belongs, and can determine the priority of the graphics processing task corresponding to each window based on the range to which it belongs.
[0168] For example, an electronic device can be configured with a first priority and a second priority for graphics processing tasks, and can be configured with a range corresponding to the first priority (e.g., range A1) and a range corresponding to the second priority (e.g., range A2). The first priority can be higher than the second priority.
[0169] When an electronic device operates within windows A, B, C, and D, assume that the electronic device determines that the ratio between the area of the first region corresponding to window A and the area of the display interface is within interval A1, the ratio between the area of the first region corresponding to window B and the area of the display interface is within interval A2, the ratio between the area of the first region corresponding to window C and the area of the display interface is within interval A1, and the ratio between the area of the first region corresponding to window D and the area of the display interface is within interval A2. In this case, the electronic device can determine that the priority of the graphics processing task corresponding to window A and the graphics processing task corresponding to window C is both first priority, and the priority of the graphics processing task corresponding to window B and the graphics processing task corresponding to window D is both second priority.
[0170] For example, an electronic device can be configured with a first priority, a second priority, and a third priority for graphics processing tasks, and can be configured with a range A1 corresponding to the first priority, a range A2 corresponding to the second priority, and a range (e.g., range A3) corresponding to the third priority. The first priority can be higher than the second priority, and the second priority can be higher than the third priority.
[0171] When an electronic device operates within windows A, B, C, and D, assume that the electronic device determines the ratio between the area of the first region corresponding to window A and the area of the display interface is within interval A1, the ratio is within interval A2, the ratio is within interval A3, and the ratio is within interval A2. In this case, the electronic device can determine that the priority of the graphics processing task corresponding to window A is first priority, the priority of the graphics processing tasks corresponding to window B and D are both second priority, and the priority of the graphics processing task corresponding to window C is third priority.
[0172] For example, an electronic device can be configured with a first priority, a second priority, a third priority, and a fourth priority corresponding to a graphics processing task, and can be configured with a range A1 corresponding to the first priority, a range A2 corresponding to the second priority, a range A3 corresponding to the third priority, and a range (e.g., range A4) corresponding to the fourth priority. The first priority can be higher than the second priority, the second priority can be higher than the third priority, and the third priority can be higher than the fourth priority.
[0173] When an electronic device operates within windows A, B, C, and D, assume that the electronic device determines the ratio between the area of the first region corresponding to window A and the area of the display interface to be within interval A1, the ratio between the area of the first region corresponding to window B and the area of the display interface to be within interval A2, the ratio between the area of the first region corresponding to window C and the area of the display interface to be within interval A3, and the ratio between the area of the first region corresponding to window D and the area of the display interface to be within interval A4. In this case, the electronic device can determine that the priority of the graphics processing task corresponding to window A is the first priority, the priority of the graphics processing task corresponding to window B is the second priority, the priority of the graphics processing task corresponding to window C is the third priority, and the priority of the graphics processing task corresponding to window D is the fourth priority.
[0174] It should be noted that the number of priorities corresponding to graphics processing tasks set in the electronic device can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on this. For example, the number of priorities corresponding to graphics processing tasks can be set according to the number of scheduling queues set in the electronic device.
[0175] For example, when an electronic device has two scheduling queues, the priority of a graphics processing task can be determined to include two priorities, such as first priority and second priority. For example, when an electronic device has three scheduling queues, the priority of a graphics processing task can be determined to include three priorities, such as first priority, second priority, and third priority. For example, when an electronic device has four scheduling queues, the priority of a graphics processing task can be determined to include four priorities, such as first priority, second priority, third priority, and fourth priority. For example, when an electronic device has N scheduling queues, the priority of a graphics processing task can be determined to include N priorities, and so on. Furthermore, the specific value ranges of intervals A1, A2, A3, and A4 can be determined according to the actual scenario, and this application embodiment does not impose any limitations on this.
[0176] In this application, the windows described in the embodiments can all refer to windows running in an electronic device. For any window, the area of the first region corresponding to the window can include the entire area of the first region corresponding to the window, or it can include a portion of the area of the first region corresponding to the window, for example, it can include only the area of the content area in the first region. The content area can be used to display specific content. For example, when the first region corresponding to a window includes a content area, a title bar, a border, a navigation bar, and a toolbar, the area of the first region corresponding to the window can include the area of the content area, the area of the title bar, the area of the border, the area of the navigation bar, and the area of the toolbar. Alternatively, the area of the first region corresponding to the window can include only the area of the content area.
[0177] It should be understood that the area of each window described below may include the entire area of each window, or it may include a portion of the area of each window, such as only the area of the content area of each window. The following examples illustrate this by showing that the area of the first region corresponding to each window includes only the area of the content area within the first region, and that the area of each window includes only the area of the content area within the window.
[0178] For example, please see Figure 5 , Figure 5 This application illustrates an application scenario provided by an embodiment of the present application. Figure 1This application scenario is illustrated by taking an electronic device running windows including window A, window B, window C, and window D, where window A is fully displayed on the display screen, window B is fully displayed on the display screen, window C is partially displayed on the display screen, and window D is not displayed on the display screen (e.g., window D is completely obscured by window A).
[0179] like Figure 5 As shown, the electronic device can determine that the area of the first region 510 corresponding to window A is greater than the area of the first region 520 corresponding to window B, the area of the first region 520 corresponding to window B is greater than the area of the first region 530 corresponding to window C, and the area of the first region 530 corresponding to window C is greater than the area of the first region corresponding to window D.
[0180] At this point, the electronic device can determine that the user's attention is higher for window A than for window B, higher for window B than for window C, and higher for window C than for window D. Therefore, the electronic device can determine that the image processing task corresponding to window A has a higher priority than the graphics processing task corresponding to window B, the image processing task corresponding to window B has a higher priority than the graphics processing task corresponding to window C, and the image processing task corresponding to window C has a higher priority than the graphics processing task corresponding to window D.
[0181] In one possible implementation, the electronic device can also determine the area of each window and, based on the area of the first region corresponding to each window and the area of each window itself, determine the priority of the graphics processing task corresponding to each window. That is, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the size of the visible area of each window and the size of each window itself.
[0182] In one example, for each window, the electronic device can determine the proportion (e.g., visible area proportion) of the first region corresponding to that window within the window, based on the area of that first region and the area of the window itself. Subsequently, the electronic device can determine the priority of the graphics processing tasks corresponding to each window based on the visible area proportions of each window within each window. In other words, the electronic device can determine the priority of the graphics processing tasks corresponding to each window based on the proportion of the visible area of each window within each window.
[0183] For example, a larger visible area of a window indicates less content is obscured, meaning the content displayed is more complete, and the user is more likely to pay attention to the window. Therefore, the electronic device can determine that the user's attention to the window is higher, and thus, the graphics processing task corresponding to that window has a higher priority. Conversely, a smaller visible area of a window indicates more content is obscured, meaning the content displayed is less complete, and the user is less likely to pay attention to the window. Therefore, the electronic device can determine that the user's attention to the window is lower, and thus, the graphics processing task corresponding to that window has a lower priority.
[0184] For example, please see Figure 6 , Figure 6 This application illustrates an application scenario provided by an embodiment of the present application. Figure 2 This application scenario uses an electronic device running windows including window A, window B, window C, and window D, where window A is fully displayed on the display interface, window B is partially displayed on the display interface, window C is partially displayed on the display interface, and window D is not displayed on the display interface as an example for illustration.
[0185] like Figure 6 As shown, the electronic device determines the area of the first region 610 corresponding to window A and the area of window A, and can determine the proportion of the visible area corresponding to window A based on the area of the first region 610 and the area of window A. That is, the electronic device can determine that the proportion of the visible area corresponding to window A is 1.
[0186] The electronic device can determine the area of the first region 620 corresponding to window B and the area of window B, and can determine the proportion of the visible area corresponding to window B based on the area of the first region 620 and the area of window B. Assume that the electronic device determines the proportion of the visible area corresponding to window B to be 0.8.
[0187] The electronic device can determine the area of the first region 630 corresponding to window C and the area of window C, and can determine the proportion of the visible area corresponding to window C based on the area of the first region 630 and the area of window C. Assume that the electronic device determines the proportion of the visible area corresponding to window C to be 0.5.
[0188] The electronic device can determine the area of the first region corresponding to window D and the area of window D itself, and can determine the proportion of the visible area corresponding to window D based on the area of the first region corresponding to window D and the area of window D. That is, the electronic device can determine that the proportion of the visible area corresponding to window D is 0.
[0189] Therefore, the electronic device can determine that the priority of the image processing task corresponding to window A is higher than the priority of the graphics processing task corresponding to window B, the priority of the image processing task corresponding to window B is higher than the priority of the graphics processing task corresponding to window C, and the priority of the image processing task corresponding to window C is higher than the priority of the graphics processing task corresponding to window D.
[0190] In one possible implementation, the electronic device can determine the priority of the graphics processing task corresponding to each window by the proportion of the visible area corresponding to each window. A larger visible area proportion indicates a higher priority, while a smaller visible area proportion indicates a lower priority.
[0191] For example, when an electronic device operates on windows A, B, C, and D, suppose the electronic device determines that the visible area percentage of window A is 1, that of window B is 0.8, that of window C is 0.5, and that of window D is 0. In this case, the electronic device can determine that the priority of the graphics processing task corresponding to window A is 1, the priority of the graphics processing task corresponding to window B is 0.8, the priority of the graphics processing task corresponding to window C is 0.5, and the priority of the graphics processing task corresponding to window D is 0.
[0192] In another possible implementation, the electronic device can set at least two priorities for graphics processing tasks and a range for each priority. The electronic device can determine the priority of the graphics processing task for each window based on the range to which the visible area of each window belongs.
[0193] It should be understood that the specific content of the electronic device determining the priority of the graphics processing task corresponding to each window based on the range of the visible area corresponding to each window can be referred to the aforementioned content of the electronic device determining the priority of the graphics processing task corresponding to each window based on the range of the ratio between the area of the first area corresponding to each window and the area of the display interface. For the sake of simplicity, it will not be repeated here.
[0194] It should be noted that the range of priority levels in the scenario where the priority of graphics processing tasks for each window is determined based on the proportion of the visible area corresponding to each window can be the same as or different from the range of priority levels in the scenario where the priority of graphics processing tasks for each window is determined based on the ratio between the area of the first area corresponding to each window and the area of the display interface. The specific range can be determined according to the actual scenario.
[0195] In other embodiments, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the area of each window.
[0196] For example, a larger window area indicates a higher likelihood of user attention to that window. Therefore, the electronic device can determine that the user's attention to that window is higher, and consequently, the priority of the graphics processing task corresponding to that window is higher. Conversely, a smaller window area indicates a lower likelihood of user attention to that window. Therefore, the electronic device can determine that the user's attention to that window is lower, and consequently, the priority of the graphics processing task corresponding to that window is lower.
[0197] In one example, an electronic device can determine the proportion of each window on the display interface (e.g., the screen proportion of each window) based on the area of each window and the area of the display interface, and can determine the priority of the graphics processing task corresponding to each window based on the screen proportion of each window.
[0198] For example, a larger screen share for a particular window indicates higher user attention to that window, allowing the electronic device to determine a higher priority for the graphics processing task associated with that window. Conversely, a smaller screen share for a particular window indicates lower user attention to that window, allowing the electronic device to determine a lower priority for the graphics processing task associated with that window.
[0199] In one possible implementation, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the screen ratio of each window.
[0200] In another possible implementation, the electronic device can set at least two priorities for graphics processing tasks and a range for each priority. After determining the screen share of each window, the electronic device can determine the range to which the screen share of each window belongs, and can determine the priority of the graphics processing task for each window based on the range to which it belongs.
[0201] Similarly, the specific details of how electronic devices determine the priority of graphics processing tasks for each window based on the range of screen occupancy corresponding to each window can be found in the aforementioned section on how electronic devices determine the priority of graphics processing tasks for each window based on the range of the ratio between the area of the first area corresponding to each window and the area of the display interface. For the sake of simplicity, these details will not be repeated here.
[0202] It should be noted that the range of priority levels in the scenario where the priority of the graphics processing task corresponding to each window is determined based on the screen ratio of each window can be the same as or different from the range of priority levels in the scenario where the priority of the graphics processing task corresponding to each window is determined based on the ratio between the area of the first region corresponding to each window and the area of the display interface. The specific range can be determined according to the actual scenario.
[0203] In other embodiments, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the area of the first region corresponding to each window, the area of each window, and the area of the display interface.
[0204] In one example, the electronic device can obtain the weight corresponding to the visible area ratio (e.g., the first weight) and the weight corresponding to the screen ratio (e.g., the second weight). For each window, the electronic device can perform a weighted calculation based on the first weight, the visible area ratio of the window, the second weight, and the screen ratio of the window to obtain the weighted result for that window. Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the weighted results of each window. Specifically, the larger the weighted result of a window, the higher the priority of the graphics processing task corresponding to that window. The smaller the weighted result of a window, the lower the priority of the graphics processing task corresponding to that window.
[0205] It should be noted that the first weight and the second weight can be determined specifically according to the actual scenario, and the embodiments of this application do not impose any restrictions on this. For example, the first weight can be determined to be 0.7 and the second weight to be 0.3 according to the actual scenario. For example, the first weight can be determined to be 0.8 and the second weight to be 0.2, and so on.
[0206] For example, an electronic device can determine the priority of the graphics processing task corresponding to each window by using the weighted results of each window.
[0207] For example, an electronic device may have at least two priorities for graphics processing tasks and a range for each priority. After determining the weighted result for each window, the electronic device can determine the priority of the graphics processing task for each window based on the range to which the weighted result for each window belongs.
[0208] It should be understood that the specific content of the electronic device determining the priority of the graphics processing task corresponding to each window based on the interval range to which the weighted result of each window belongs can refer to the aforementioned content of the electronic device determining the priority of the graphics processing task corresponding to each window based on the interval range to which the ratio between the area of the first area corresponding to each window and the area of the display interface belongs. For the sake of simplicity, it will not be repeated here.
[0209] In other embodiments, the electronic device can also determine the distance between the center point of each window and the center point of the display interface. Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the distance (or offset distance) between the center point of each window and the center point of the display interface.
[0210] Specifically, the closer the center point of a window is to the center point of the display interface, the closer the window is to the center of the display interface, and the greater the likelihood that the user will pay attention to the window, thus indicating higher user attention to the window. Conversely, the farther the center point of a window is from the center of the display interface, the farther the window is from the center of the display interface, and the less likely the user is to pay attention to the window, thus indicating lower user attention to the window.
[0211] For example, for each window, the electronic device can determine the window offset ratio (or offset distance ratio) based on the distance between the center point of the window and the center point of the display interface, and the display interface (e.g., the diagonal length of the display interface). Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the window offset ratio.
[0212] In one example, an electronic device can determine the priority of the graphics processing task corresponding to each window based on the window offset ratio.
[0213] In another example, the electronic device can set at least two priorities for graphics processing tasks and a range for each priority. After determining the window offset ratio for each window, the electronic device can determine the range to which the window offset ratio for each window belongs, and can determine the priority of the graphics processing task for each window based on the range to which it belongs.
[0214] Similarly, the specific details of how electronic devices determine the priority of graphics processing tasks for each window based on the range of the window offset ratio corresponding to each window can be found in the aforementioned section on how electronic devices determine the priority of graphics processing tasks for each window based on the range of the ratio between the area of the first region corresponding to each window and the area of the display interface. For the sake of simplicity, these details will not be repeated here.
[0215] In one possible implementation, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the proportion of the visible area corresponding to each window and the window offset ratio.
[0216] For example, the electronic device can obtain a first weight corresponding to the visible area proportion and a third weight corresponding to the window offset ratio. For each window, the electronic device can perform a weighted calculation based on the first weight, the visible area proportion corresponding to the window, the third weight, and the window offset ratio corresponding to the window to obtain a weighted result for that window. Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the weighted results for each window. It should be understood that when the weighted result corresponding to a window is larger, the priority of the graphics processing task corresponding to that window is higher. When the weighted result corresponding to a window is smaller, the priority of the graphics processing task corresponding to that window is lower.
[0217] In another possible implementation, the electronic device can determine the priority of the graphics processing tasks corresponding to each window based on the screen occupancy and window offset ratio of each window.
[0218] For example, the electronic device can obtain a second weight corresponding to the screen ratio and a third weight corresponding to the window offset ratio. For each window, the electronic device can perform a weighted calculation based on the second weight, the screen ratio corresponding to the window, the third weight, and the window offset ratio corresponding to the window to obtain a weighted result for that window. Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the weighted results for each window. It should be understood that the larger the weighted result for a window, the higher the priority of the graphics processing task corresponding to that window. The smaller the weighted result for a window, the lower the priority of the graphics processing task corresponding to that window.
[0219] In another possible implementation, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the proportion of the visible area, the screen proportion, and the window offset ratio of each window.
[0220] For example, an electronic device can obtain a first weight corresponding to the visible area ratio, a second weight corresponding to the screen ratio, and a third weight corresponding to the window offset ratio. For each window, the electronic device can perform a weighted calculation based on the first weight, the visible area ratio corresponding to the window, the second weight, the screen ratio corresponding to the window, the third weight, and the window offset ratio corresponding to the window to obtain the weighted result for that window. Subsequently, the electronic device can determine the priority of the graphics processing task corresponding to each window based on the weighted results for each window.
[0221] As described above, the closer the center point of a window is to the center point of the display interface, the closer the window is to the center of the display interface. This indicates higher user attention to the window, and consequently, a higher priority for the graphics processing task corresponding to that window. Conversely, the farther the center point of a window is from the center of the display interface, the farther the window is from the center of the display interface. This indicates lower user attention to the window, and consequently, a lower priority for the graphics processing task corresponding to that window. Therefore, for windows whose center point is closer to the center of the display interface, to ensure a higher priority for the graphics processing task corresponding to that window, the electronic device can perform a weighted calculation based on (1 - window offset ratio) and a third weight when calculating the weighted result for each window, in order to obtain the weighted result for each window.
[0222] In scenarios where the weighted result is determined based on the window offset ratio, for each window, the weighted result = the visible area ratio of the window * first weight + (1 - the window offset ratio) * third weight. Alternatively, the weighted result = the visible area ratio of the window * first weight + the screen ratio of the window * second weight + (1 - the window offset ratio) * third weight, and so on.
[0223] It should be noted that the third weight can be determined according to the specific scenario, and the embodiments of this application do not impose any restrictions on it.
[0224] In one example, after determining the weighted results for each window, the electronic device can use these weighted results to determine the priority of the graphics processing task for each window.
[0225] In another example, the electronic device can set at least two priorities for graphics processing tasks and a range for each priority. After determining the weighted result for each window, the electronic device can determine the priority of the graphics processing task for each window based on the range to which the weighted result for each window belongs.
[0226] In some embodiments, when an electronic device runs multiple windows, the user generally pays the most attention to the focus window. Therefore, to ensure the frame rate of the focus window and improve its smoothness, thereby enhancing the user's viewing experience, the electronic device can determine the focus window based on the other windows, and can determine that the priority of the graphics processing task corresponding to the focus window is higher than the priority of the graphics processing tasks corresponding to non-focus windows. The focus window can be the window located at the top layer of the display interface that is directly interacted with by the user.
[0227] It should be noted that the embodiments of this application do not limit the specific method of determining the focus window, and can be determined according to the actual scenario.
[0228] It should be understood that the priority of graphics processing tasks corresponding to non-focus windows can be determined by referring to the methods used to determine the priority of graphics processing tasks corresponding to the aforementioned windows. For example, it can be determined based on the area of the first region corresponding to each non-focus window, or based on the area of each non-focus window, or based on the area of the first region corresponding to each non-focus window and the area of the window, or based on the area of the first region corresponding to each non-focus window, the area of the window, and the area of the display interface, or based on the distance between the center point of each non-focus window and the center point of the display interface, or based on the area of the first region corresponding to each non-focus window, the area of the non-focus window, the area of the display interface, and the distance between the center point of each non-focus window and the center point of the display interface, and so on.
[0229] For example, when an electronic device operates on windows A, B, C, and D, the device can determine the focus window from these windows. Assuming the device determines window A as the focus window, it can then assign the highest priority to the graphics processing task corresponding to window A. For windows B, C, and D, the device can determine the area of the first region corresponding to window B, the area of the first region corresponding to window C, and the area of the first region corresponding to window D. Based on the area of the first region corresponding to window B and the area of window B, the device can determine the proportion of the visible area corresponding to window B, the proportion of the visible area corresponding to window C, and the proportion of the visible area corresponding to window D.
[0230] Suppose that the electronic device determines that the visible area of window B is greater than that of window C, and the visible area of window C is greater than that of window D. Therefore, the electronic device can determine that the priority of the graphics processing task corresponding to window A is higher than that of the graphics processing task corresponding to window B, the priority of the graphics processing task corresponding to window B is higher than that of the graphics processing task corresponding to window C, and the priority of the graphics processing task corresponding to window C is higher than that of the graphics processing task corresponding to window D.
[0231] The following will describe how electronic devices prioritize the graphics processing tasks corresponding to each window, and then allocate the graphics processing tasks for each window accordingly. The process of allocating shape processing tasks to the corresponding scheduling queues is explained in detail.
[0232] In this embodiment, the electronic device may have at least two scheduling queues. After determining the priority of the graphics processing task corresponding to each window, the electronic device can allocate the graphics processing task corresponding to each window to the corresponding scheduling queue according to the priority of the graphics processing task corresponding to each window.
[0233] In some embodiments, the electronic device may have two scheduling queues, such as a first scheduling queue and a second scheduling queue, and the priority of the first scheduling queue may be higher than that of the second scheduling queue. That is, graphics processing tasks in the first scheduling queue may be executed by the GPU with priority.
[0234] In one example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (such as a ratio, visible area ratio, or weighted result), after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to a certain threshold (for example, it can be called threshold A) to the first scheduling queue, and can assign graphics processing tasks with a priority less than threshold A to the second scheduling queue.
[0235] It should be understood that the specific value of threshold A can be determined based on the actual application scenario, and this application embodiment does not impose any restrictions on it. For example, threshold A can be determined to be 0.8 based on the actual application scenario. That is, after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to 0.8 to the first scheduling queue, and can assign graphics processing tasks with a priority less than 0.8 to the second scheduling queue. For example, threshold A can be determined to be 1 based on the actual application scenario. That is, after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to 1 to the first scheduling queue, and can assign graphics processing tasks with a priority less than 1 to the second scheduling queue.
[0236] For example, please see Figure 7 , Figure 7 An example of task scheduling provided in an embodiment of this application is shown. Figure 1 This example uses Figure 5 The example shown is used to illustrate the application scenario, and this example uses the determination of the proportion of the visible area corresponding to each window as the priority of the graphics processing task corresponding to each window as an example.
[0237] Depend on Figure 5 It can be seen that the electronic device can determine the proportion of the visible area corresponding to window A based on the area of the first region 510 corresponding to window A and the area of window A, thus determining that the proportion of the visible area corresponding to window A is 1. At this time, the electronic device can determine that the priority of the graphics processing task A corresponding to window A is 1.
[0238] The electronic device can determine the proportion of the visible area corresponding to window B based on the area of the first region 520 corresponding to window B and the area of window B itself, thus determining that the proportion of the visible area corresponding to window B is 1. At this time, the electronic device can determine that the priority of the graphics processing task B corresponding to window B is 1.
[0239] The electronic device can determine the proportion of the visible area corresponding to window C based on the area of the first region 530 corresponding to window C and the area of window C itself. Assume the electronic device determines that the proportion of the visible area corresponding to window C is 0.5. In this case, the electronic device can determine that the priority of the graphics processing task C corresponding to window C is 0.5.
[0240] The electronic device can determine the proportion of the visible area corresponding to window D based on the area of the first region corresponding to window D (i.e., 0) and the area of window D, thus determining that the proportion of the visible area corresponding to window D is 0. At this time, the electronic device can determine that the priority of the graphics processing task D corresponding to window D is 0.
[0241] Assuming threshold A is 1, the electronic device can determine that the priority of image processing task A corresponding to window A and the priority of graphics processing task B corresponding to window B are both equal to threshold A (i.e., 1), and can determine that the priority of graphics processing task C corresponding to window C and the priority of graphics processing task D corresponding to window D are both less than threshold A (i.e., 1). Therefore, the electronic device can assign graphics processing task A corresponding to window A and graphics processing task B corresponding to window B to the first scheduling queue, and can assign graphics processing task C corresponding to window C and graphics processing task D corresponding to window D to the second scheduling queue.
[0242] Therefore, as Figure 7 As shown, the electronic device can assign graphics processing tasks A corresponding to an unobstructed window A and B corresponding to an unobstructed window B to a first scheduling queue, and can assign graphics processing tasks C corresponding to a partially obstructed window C and D corresponding to a fully obstructed window D to a second scheduling queue. This allows the graphics processing tasks corresponding to unobstructed windows A and B to be prioritized for GPU execution, increasing the GPU utilization of unobstructed windows, improving the frame rate of unobstructed windows, and thus enhancing the smoothness of unobstructed window visuals and improving the user's viewing experience. For example, the GPU may include two cores, core 1 and core 2, and the GPU can prioritize scheduling graphics processing tasks A and B corresponding to unobstructed windows A and B to cores 1 and 2 for execution.
[0243] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (e.g., ratio, visible area percentage, or weighted result), after determining the priority of the graphics processing tasks for each window, the electronic device can sort the windows according to their priority from highest to lowest, obtaining a sorting result. Subsequently, the electronic device can assign the graphics processing tasks corresponding to the top W windows in the sorting result to a first scheduling queue, and can assign the graphics processing tasks corresponding to the other windows to a second scheduling queue. "Other windows" can refer to windows other than the top W windows in the sorting result.
[0244] It should be understood that the specific value of W can be determined according to the actual scenario, and the embodiments of this application do not impose any restrictions on it. For example, the value of W can be any value such as 1, 2, or 3, depending on the actual scenario.
[0245] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is not a specific numerical value—that is, where the priority of the graphics processing tasks corresponding to each window is either first priority or second priority—the number of priority levels for graphics processing tasks can be the same as the number of scheduling queues. In other words, when the priority of the graphics processing tasks corresponding to each window can be either first priority or second priority, after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign high-priority graphics processing tasks to the first scheduling queue and low-priority graphics processing tasks to the second scheduling queue. For example, when the first priority is higher than the second priority, the electronic device can assign first-priority graphics processing tasks to the first scheduling queue and second-priority graphics processing tasks to the second scheduling queue.
[0246] In one possible implementation, the electronic device can divide the graphics processing tasks corresponding to each window into corresponding scheduling queues based on the GPU load.
[0247] For example, when the GPU load is greater than or equal to a preset load (e.g., preset load B), the electronic device can allocate high-priority graphics processing tasks to a high-priority scheduling queue and low-priority graphics processing tasks to a low-priority scheduling queue. When the GPU load is less than the preset load B, the electronic device can allocate high-priority graphics processing tasks and a portion of low-priority graphics processing tasks to a high-priority scheduling queue and another portion of low-priority graphics processing tasks to a low-priority scheduling queue. In other words, when the GPU load is high, the electronic device can prioritize scheduling high-priority graphics processing tasks to the GPU for execution. When the GPU load is low, the electronic device can prioritize scheduling high-priority graphics processing tasks and a portion of low-priority graphics processing tasks to the GPU for execution.
[0248] It should be noted that the preset load B can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on it. When the GPU load is less than the preset load B, the low-priority graphics processing tasks assigned to the high-priority scheduling queue can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on it.
[0249] For example, in a scenario where an electronic device is running windows A, B, and C, suppose the electronic device determines that the priority of the graphics processing task corresponding to window A is higher than the priority of the graphics processing task corresponding to window B, and the priority of the graphics processing task corresponding to window B is higher than the priority of the graphics processing task corresponding to window C. When the electronic device determines that the GPU load is greater than or equal to a preset load B, the electronic device can allocate the graphics processing task corresponding to window A to the first scheduling queue, and can allocate the graphics processing tasks corresponding to window B and window C to the second scheduling queue.
[0250] When the electronic device determines that the GPU load is less than a preset load B, it can allocate the graphics processing task corresponding to window A to the first scheduling queue, the graphics processing task corresponding to window B to the second scheduling queue, and the graphics processing task corresponding to window C to the first scheduling queue. Alternatively, the electronic device can allocate the graphics processing task corresponding to window A to the first scheduling queue, the graphics processing task corresponding to window B to the first scheduling queue, and the graphics processing task corresponding to window C to the second scheduling queue.
[0251] In other embodiments, the electronic device may be provided with three scheduling queues, such as a first scheduling queue, a second scheduling queue, and a third scheduling queue, and the priority of the first scheduling queue may be higher than the priority of the second scheduling queue, and the priority of the second scheduling queue may be higher than the priority of the third scheduling queue.
[0252] In one example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (such as a ratio, visible area ratio, or weighted result), after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to a certain threshold (such as threshold B) to the first scheduling queue, assign graphics processing tasks with a priority greater than or equal to a certain threshold (such as threshold C) and less than threshold B to the second scheduling queue, and assign graphics processing tasks with a priority less than threshold C to the third scheduling queue.
[0253] It should be understood that the specific values of thresholds B and C can be determined based on the actual application scenario, and this application embodiment does not impose any restrictions on this. For example, threshold B can be determined to be 1 and threshold C to be 0.5 based on the actual application scenario. That is, after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to 1 to the first scheduling queue, assign graphics processing tasks with a priority greater than or equal to 0.5 and less than 1 to the second scheduling queue, and assign graphics processing tasks with a priority less than 0.5 to the third scheduling queue.
[0254] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (e.g., ratio, visible area percentage, or weighted result), after determining the priority of the graphics processing tasks for each window, the electronic device can sort the windows according to their priority from highest to lowest, obtaining a sorting result. Subsequently, the electronic device can assign the graphics processing tasks corresponding to the first M1 windows in the sorting result to a first scheduling queue, the graphics processing tasks corresponding to the M1+1th to M2th windows to a second scheduling queue, and the graphics processing tasks corresponding to the other windows to a third scheduling queue. Here, "other windows" can refer to windows other than the first M2 windows in the sorting result.
[0255] It should be noted that M2 is greater than M1, and the specific values of M1 and M2 can be determined according to the actual scenario. This application embodiment does not impose any restrictions on this. For example, according to the actual scenario, M1 can be determined to be 1 and M2 to be 3. That is, the graphics processing task corresponding to the first window in the sorting result can be assigned to the first scheduling queue, the graphics processing tasks corresponding to the second and third windows in the sorting result can be assigned to the second scheduling queue, and the graphics processing tasks corresponding to the windows other than the first, second, and third windows in the sorting result can be assigned to the third scheduling queue.
[0256] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (such as a ratio, the proportion of the visible area, or a weighted result), the electronic device can also determine the focus window based on each window and assign the graphics processing task corresponding to the focus window to the first scheduling queue.
[0257] For non-focus windows, the electronic device can assign graphics processing tasks with a priority greater than or equal to a certain threshold (e.g., threshold D) to a second scheduling queue, and assign graphics processing tasks with a priority less than threshold D to a third scheduling queue. Alternatively, the electronic device can sort the non-focus windows according to their priority from highest to lowest, obtaining a sorting result. Then, the electronic device can determine that the graphics processing tasks corresponding to the top R non-focus windows in the sorting result are assigned to the second scheduling queue, and assign the graphics processing tasks corresponding to the other non-focus windows to the third scheduling queue.
[0258] It should be noted that the specific values of threshold D and R can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on them.
[0259] For example, please see Figure 8 , Figure 8 An example of task scheduling provided in an embodiment of this application is shown. Figure 2 This example uses Figure 5 The example shown is used to illustrate the application scenario, and this example uses the determination of the proportion of the visible area corresponding to each window as the priority of the graphics processing task corresponding to each window as an example.
[0260] Depend on Figure 5 It can be seen that the electronic device can determine that window A is the focus window. Therefore, the electronic device can assign the graphics processing task A corresponding to window A to the first scheduling queue.
[0261] For window B, the electronic device can determine the proportion of the visible area corresponding to window B based on the area of the first region 520 corresponding to window B and the area of window B itself, thus determining that the proportion of the visible area corresponding to window B is 1. At this time, the electronic device can determine that the priority of the graphics processing task B corresponding to window B is 1.
[0262] For window C, the electronic device can determine the proportion of the visible area corresponding to window C based on the area of the first region 530 corresponding to window C and the area of window C itself. Assume the electronic device determines that the proportion of the visible area corresponding to window C is 0.5. Therefore, the electronic device can determine that the priority of the graphics processing task C corresponding to window C is 0.5.
[0263] For window D, the electronic device can determine the proportion of the visible area corresponding to window D based on the area of the first region corresponding to window D (i.e., 0) and the area of window D itself, thus determining that the proportion of the visible area corresponding to window D is 0. At this time, the electronic device can determine that the priority of the graphics processing task D corresponding to window D is 0.
[0264] Assuming threshold D is 1, the electronic device can determine that the priority of graphics processing task B corresponding to window B is equal to threshold D, and can also determine that the priorities of graphics processing tasks corresponding to window C and window D are both less than threshold D. Therefore, the electronic device can assign graphics processing task B corresponding to window B to the second scheduling queue, and can assign graphics processing tasks C corresponding to window C and D corresponding to window D to the third scheduling queue.
[0265] Therefore, as Figure 8 As shown, the electronic device can allocate graphics processing task A corresponding to the focused window A to the first scheduling queue, graphics processing task B corresponding to the non-focused and unobstructed window B to the second scheduling queue, and graphics processing task C corresponding to the non-focused and partially obstructed window C and graphics processing task D corresponding to the non-focused and fully obstructed window D to the third scheduling queue. This allows graphics processing task A corresponding to the focused window A to be prioritized for GPU execution, ensuring the GPU utilization ratio of the focused window is prioritized, increasing the frame rate of the focused window, thereby improving the smoothness of the focused window's display and enhancing the user's viewing experience. For example, the GPU may include two cores, core 1 and core 2, and the GPU can prioritize scheduling graphics processing task A corresponding to the focused window A to cores 1 and 2 for execution.
[0266] In another example, when the priority of the graphics processing task corresponding to each window is not a specific value, i.e., the priority of the graphics processing task corresponding to each window is the first priority or the second priority, the number of priorities corresponding to the graphics processing task can be the same as the number of scheduling queues. That is, the priority of the graphics processing task corresponding to each window is the first priority, the second priority, or the third priority. After determining the priority of the graphics processing task corresponding to each window, the electronic device can assign the highest priority graphics processing task to the first scheduling queue, the lowest priority graphics processing task to the third scheduling queue, and the intermediate priority graphics processing task to the second scheduling queue.
[0267] For example, when the first priority is higher than the second priority, and the second priority is higher than the third priority, the electronic device can assign the graphics processing task with the first priority to the first scheduling queue, the graphics processing task with the second priority to the second scheduling queue, and the graphics processing task with the third priority to the third scheduling queue.
[0268] In another possible implementation, the electronic device may be equipped with four scheduling queues, such as a first scheduling queue, a second scheduling queue, a third scheduling queue, and a fourth scheduling queue, wherein the priority of the first scheduling queue may be higher than the priority of the second scheduling queue, the priority of the second scheduling queue may be higher than the priority of the third scheduling queue, and the priority of the third scheduling queue may be higher than the priority of the fourth scheduling queue.
[0269] In one example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (such as a ratio, visible area ratio, or weighted result), after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to a certain threshold (such as threshold E) to the first scheduling queue, assign graphics processing tasks with a priority greater than or equal to a certain threshold (such as threshold F) and less than threshold E to the second scheduling queue, assign graphics processing tasks with a priority greater than or equal to a certain threshold (such as threshold G) and less than threshold F to the third scheduling queue, and assign graphics processing tasks with a priority less than threshold G to the fourth scheduling queue.
[0270] It should be understood that the specific values of thresholds E, F, and G can be determined according to the actual application scenario, and this application embodiment does not impose any restrictions on this. For example, threshold E can be determined to be 1, threshold F to be 0.8, and threshold G to be 0.5 according to the actual application scenario. That is, after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can assign graphics processing tasks with a priority greater than or equal to 1 to the first scheduling queue, assign graphics processing tasks with a priority greater than or equal to 0.8 and less than 1 to the second scheduling queue, assign graphics processing tasks with a priority greater than or equal to 0.5 and less than 0.8 to the third scheduling queue, and assign graphics processing tasks with a priority less than 0.5 to the fourth scheduling queue.
[0271] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (e.g., ratio, visible area percentage, or weighted result), after determining the priority of the graphics processing tasks corresponding to each window, the electronic device can sort the windows according to the order of priority from largest to smallest, obtaining a sorting result. Subsequently, the electronic device can assign the graphics processing tasks corresponding to the first M1 windows in the sorting result to the first scheduling queue, the graphics processing tasks corresponding to the M1+1 to M2 windows in the sorting result to the second scheduling queue, the graphics processing tasks corresponding to the M2+1 to M3 windows in the sorting result to the third scheduling queue, and the graphics processing tasks corresponding to the remaining windows in the sorting result to the fourth scheduling queue. Here, "remaining windows" can refer to windows other than the first M3 windows in the sorting result.
[0272] It should be noted that the specific values of M1, M2, and M3 can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on this.
[0273] In another example, in a scenario where the priority of the graphics processing tasks corresponding to each window is a specific numerical value (such as a ratio, the proportion of the visible area, or a weighted result), the electronic device can also determine the focus window based on each window and assign the graphics processing task corresponding to the focus window to the first scheduling queue.
[0274] For non-focus windows, the electronic device can assign graphics processing tasks with a priority greater than or equal to a certain threshold (e.g., threshold H) to the second scheduling queue, assign graphics processing tasks with a priority greater than or equal to a certain threshold (e.g., threshold J) and less than threshold H to the third scheduling queue, and assign graphics processing tasks with a priority less than threshold J to the fourth scheduling queue. Alternatively, the electronic device can sort the non-focus windows according to their priority from highest to lowest, obtaining a sorting result. Then, the electronic device can assign the graphics processing tasks corresponding to the first S1 non-focus windows in the sorting result to the second scheduling queue, assign the graphics processing tasks corresponding to the S1+1th to S2th non-focus windows to the third scheduling queue, and assign the graphics processing tasks corresponding to the remaining non-focus windows to the fourth scheduling queue. Here, "remaining non-focus windows" refers to non-focus windows other than the first S2 non-focus windows in the sorting result.
[0275] It should be noted that the specific values of threshold H, threshold J, S1 and S2 can be determined according to the actual scenario, and this application embodiment does not impose any restrictions on them.
[0276] For example, please see Figure 9 , Figure 9 An example of task scheduling provided in an embodiment of this application is shown. Figure 3 This example uses Figure 5 The example shown is used to illustrate the application scenario, and this example uses the determination of the proportion of the visible area corresponding to each window as the priority of the graphics processing task corresponding to each window as an example.
[0277] Depend on Figure 5 It can be seen that the electronic device can determine that window A is the focus window. Therefore, the electronic device can assign the graphics processing task A corresponding to window A to the first scheduling queue.
[0278] For window B, the electronic device can determine the proportion of the visible area corresponding to window B based on the area of the first region 520 corresponding to window B and the area of window B itself, thus determining that the proportion of the visible area corresponding to window B is 1. At this time, the electronic device can determine that the priority of the graphics processing task B corresponding to window B is 1.
[0279] For window C, the electronic device can determine the proportion of the visible area corresponding to window C based on the area of the first region 530 corresponding to window C and the area of window C itself. Assume the electronic device determines that the proportion of the visible area corresponding to window C is 0.5. Therefore, the electronic device can determine that the priority of the graphics processing task C corresponding to window C is 0.5.
[0280] For window D, the electronic device can determine the proportion of the visible area corresponding to window D based on the area of the first region corresponding to window D (i.e., 0) and the area of window D itself, thus determining that the proportion of the visible area corresponding to window D is 0. At this time, the electronic device can determine that the priority of the graphics processing task D corresponding to window D is 0.
[0281] Assuming threshold H is 1 and threshold J is 0.3, the electronic device can determine that the priority of graphics processing task B corresponding to window B is equal to threshold H, the priority of graphics processing task C corresponding to window C is greater than threshold J and less than threshold H, and the priority of graphics processing task D corresponding to window D is less than threshold J. Therefore, the electronic device can assign graphics processing task B corresponding to window B to the second scheduling queue, graphics processing task C corresponding to window C to the third scheduling queue, and graphics processing task D corresponding to window D to the fourth scheduling queue.
[0282] Therefore, as Figure 9 As shown, the electronic device can allocate graphics processing task A corresponding to the focused window A to the first scheduling queue, graphics processing task B corresponding to the non-focused and unobstructed window B to the second scheduling queue, graphics processing task C corresponding to the non-focused and partially obstructed window C to the third scheduling queue, and graphics processing task D corresponding to the non-focused and fully obstructed window D to the fourth scheduling queue, so that graphics processing task A corresponding to the focused window A can be preferentially executed by the GPU. For example, the GPU may include four cores: core 1, core 2, core 3, and core 4. The GPU can preferentially schedule graphics processing task A corresponding to the focused window A to cores 1, 2, 3, and 4 for execution.
[0283] In another example, in a scenario where the priority of the graphics processing task corresponding to each window is not a specific numerical value, i.e., the priority of the graphics processing task corresponding to each window is first priority or second priority, the number of priorities corresponding to the graphics processing task can be the same as the number of scheduling queues. That is, the priority of the graphics processing task corresponding to each window is first priority, second priority, third priority or fourth priority. After determining the priority of the graphics processing task corresponding to each window, the electronic device can assign the highest priority graphics processing task to the first scheduling queue, the second highest priority graphics processing task to the second scheduling queue, the third highest priority graphics processing task to the third scheduling queue, and the lowest priority graphics processing task to the fourth scheduling queue.
[0284] For example, when the first priority is higher than the second priority, the second priority is higher than the third priority, and the third priority is higher than the fourth priority, the electronic device can assign the graphics processing task with the first priority to the first scheduling queue, the graphics processing task with the second priority to the second scheduling queue, the graphics processing task with the third priority to the third scheduling queue, and the graphics processing task with the fourth priority to the fourth scheduling queue.
[0285] It should be noted that electronic devices can have five, six, seven, or eight scheduling queues. The specific details of how an electronic device allocates graphics processing tasks for each window to five, six, seven, or eight scheduling queues are similar to those of allocating them to three or four scheduling queues. For details, please refer to the section on allocating graphics processing tasks for each window to three or four scheduling queues; it will not be repeated here.
[0286] The following will describe how the electronic device will schedule graphics processing tasks in each scheduling queue according to their priority. The process of execution on the GPU will be explained in detail.
[0287] In this embodiment, after dividing the graphics processing tasks corresponding to each window into their respective scheduling queues, the electronic device can schedule the graphics processing tasks according to the priority of each scheduling queue. That is, graphics processing tasks in high-priority scheduling queues can be prioritized for execution on the GPU.
[0288] In some embodiments, the electronic device may schedule graphics processing tasks in each scheduling queue to be executed on the GPU based on a preset scheduling ratio and the priority of each scheduling queue.
[0289] In one possible implementation, the preset scheduling ratio can refer to the ratio between the scheduling times of each scheduling queue. The scheduling time of a scheduling queue can refer to the time that the graphics processing tasks in that scheduling queue are executed on the GPU. The preset scheduling ratio can be determined according to the actual scenario, and this application embodiment does not impose any limitations on it. It should be understood that when the priority of a scheduling queue is higher, the scheduling time of that queue will be longer; when the priority of a scheduling queue is lower, the scheduling time of that queue will be shorter. That is, by increasing the scheduling time of high-priority scheduling queues, the execution time of high-priority graphics processing tasks on the GPU can be increased, thereby increasing the execution time of graphics processing tasks corresponding to windows that are of high user attention. This can improve the frame rate of windows that are of high user attention, enhance the smoothness of the screen in windows that are of high user attention, and improve the user experience.
[0290] In another possible implementation, the preset scheduling ratio can refer to the ratio between the scheduling frequencies of each scheduling queue. The scheduling frequency of a scheduling queue can refer to the number of times the GPU executes the graphics processing tasks in that scheduling queue. The preset scheduling ratio can be determined according to the actual scenario, and this application embodiment does not impose any limitations on it. It should be understood that when the priority of a scheduling queue is higher, the scheduling frequency of that scheduling queue will be higher; when the priority of a scheduling queue is lower, the scheduling frequency of that scheduling queue will be lower. That is, by increasing the scheduling frequency of high-priority scheduling queues, the number of times the GPU executes high-priority graphics processing tasks can be increased, thereby increasing the number of times the GPU executes graphics processing tasks corresponding to windows that are of high user attention. This can improve the frame rate of windows that are of high user attention, enhance the smoothness of the screen in windows that are of high user attention, and improve the user experience.
[0291] For example, when an electronic device has a first scheduling queue and a second scheduling queue, and the priority of the first scheduling queue is higher than that of the second scheduling queue, a preset scheduling ratio can be determined according to the actual scenario. Suppose the preset scheduling ratio is determined to be 3:1 according to the actual scenario. The GPU can first execute the graphics processing tasks in the first scheduling queue three times, and then execute the graphics processing tasks in the second scheduling queue once. For example, the GPU can first execute the three graphics processing tasks in the first scheduling queue, and then execute the one graphics processing task in the second scheduling queue.
[0292] For example, the preset scheduling ratio can be a scheduling ratio pre-set in the electronic device. Alternatively, the preset scheduling ratio can be a scheduling ratio determined by the electronic device based on the GPU load. For instance, when the GPU load is high, the electronic device can determine that the preset scheduling ratio is large, so that the scheduling time of the high-priority scheduling queue is higher than that of the low-priority scheduling queue, or the scheduling frequency of the high-priority scheduling queue is higher than that of the low-priority scheduling queue, thereby causing the GPU to prioritize the execution of graphics processing tasks in the high-priority scheduling queue. For instance, when the GPU load is low, the electronic device can determine that the preset scheduling ratio is small, such as setting the preset scheduling ratio to 1:1.
[0293] In one example, when a GPU comprises multiple cores, each core can execute graphics processing tasks in its respective scheduling queue at the same preset scheduling ratio. Alternatively, the cores can execute graphics processing tasks in their respective scheduling queues at different preset scheduling ratios. For instance, some cores in the GPU can execute graphics processing tasks in their respective scheduling queues at preset scheduling ratio A, while other cores can execute them at preset scheduling ratio B. Preset scheduling ratios A and B can be different.
[0294] For example, in an electronic device with a first scheduling queue and a second scheduling queue, where the first scheduling queue has a higher priority than the second scheduling queue, a preset scheduling ratio can be determined based on the actual scenario. Each core of the GPU can then process graphics processing tasks in the first and second scheduling queues sequentially based on this preset ratio. Taking a preset scheduling ratio of 3:1 as an example (where the GPU's scheduling time is 100ms), the scheduling time for the first scheduling queue can be determined to be 100ms*3 / (3+1) = 75ms, and the scheduling time for the second scheduling queue can be determined to be 100ms*3 / (3+1) = 25ms. That is, when the GPU's scheduling time is 100ms, each core of the GPU can execute graphics processing tasks in the first scheduling queue within the first 75ms and execute graphics processing tasks in the second scheduling queue within the remaining 25ms.
[0295] For example, when an electronic device has a first scheduling queue and a second scheduling queue, and the priority of the first scheduling queue is higher than that of the second scheduling queue, a preset scheduling ratio A and a preset scheduling ratio B can be determined according to the actual scenario. A portion of the cores in the GPU (e.g., core 1) can process the graphics processing tasks in the first scheduling queue and the second scheduling queue in sequence based on the preset scheduling ratio A, while another portion of the cores in the GPU (e.g., core 2) can process the graphics processing tasks in the first scheduling queue and the second scheduling queue in sequence based on the preset scheduling ratio B.
[0296] Taking a preset scheduling ratio as the ratio of the scheduling times of each scheduling queue, with preset scheduling ratio A being 3:1 and preset scheduling ratio B being 4:1 as an example, when the GPU scheduling time is 100ms, for core 1, the scheduling time corresponding to the first scheduling queue can be determined to be 100ms*3 / (3+1) = 75ms, and the scheduling time corresponding to the second scheduling queue can be determined to be 100ms*3 / (3+1) = 25ms; for core 2, the scheduling time corresponding to the first scheduling queue can be determined to be 100ms*4 / (4+1) = 80ms, and the scheduling time corresponding to the second scheduling queue can be determined to be 100ms*1 / (4+1) = 20ms. That is, when the GPU scheduling time is 100ms, GPU core 1 can execute the graphics processing tasks in the first scheduling queue in the first 75ms and execute the graphics processing tasks in the second scheduling queue in the remaining 25ms. GPU core 2 can execute the graphics processing tasks in the first scheduling queue in the first 80ms and execute the graphics processing tasks in the second scheduling queue in the remaining 20ms.
[0297] In one possible implementation, when the GPU includes multiple cores, a portion of the GPU's cores can be dedicated to executing graphics processing tasks in higher-priority scheduling queues, while another portion of the GPU's cores can execute graphics processing tasks in all or other scheduling queues according to a preset scheduling ratio.
[0298] For example, in an electronic device with a first scheduling queue and a second scheduling queue, where the first scheduling queue has a higher priority than the second scheduling queue, assuming the GPU includes core 1 and core 2, core 1 of the GPU can be dedicated to executing graphics processing tasks in the first scheduling queue, while core 2 of the GPU can execute graphics processing tasks in the first scheduling queue and graphics processing tasks in the second scheduling queue according to a preset scheduling ratio.
[0299] Taking a preset scheduling ratio of 4:1 as an example, when the GPU's scheduling time is 100ms, for core 2, the scheduling time corresponding to the first scheduling queue can be determined to be 100ms*4 / (4+1) = 80ms, and the scheduling time corresponding to the second scheduling queue can be determined to be 100ms*1 / (4+1) = 20ms. That is, when the GPU's scheduling time is 100ms, GPU core 1 can dedicate 100ms to executing graphics processing tasks in the first scheduling queue. GPU core 2 can execute graphics processing tasks in the first scheduling queue for the first 80ms and execute graphics processing tasks in the second scheduling queue for the remaining 20ms.
[0300] It should be noted that when an electronic device is running multiple windows, the task scheduling method provided in this application embodiment can rationally allocate GPU resources, thereby improving GPU utilization. This not only increases the frame rate of windows that receive high user attention but also improves the overall frame rate of the electronic device. The overall frame rate of the electronic device can refer to the number of frames displayed per second, that is, the sum of the number of frames displayed by all windows per second.
[0301] For example, in a scenario where ten windows and drop-down menus are swiped through the task center, and in multi-round scheduling of graphics processing tasks using other task scheduling methods, the overall frame rate and average frame rate of the electronic device can be as shown in Table 1 below. Additionally, in multi-round scheduling of graphics processing tasks using the task scheduling method provided in this application embodiment, the overall frame rate and average frame rate of the electronic device can also be as shown in Table 1 below.
[0302] Table 1
[0303]
[0304] As shown in Table 1, in scenarios where an electronic device runs multiple windows, the overall average frame rate of the electronic device can reach 108.1 fps when scheduling graphics processing tasks using other task scheduling methods. However, when scheduling graphics processing tasks using the task scheduling method provided in this embodiment, the overall average frame rate of the electronic device can reach 113.6 fps, the average time per frame can be reduced by 0.6 ms, and the overall average frame rate can be increased by 5.5 frames. That is, with a fixed amount of GPU resources, the task scheduling method provided in this embodiment can utilize GPU resources more rationally, thereby improving the overall frame rate of the electronic device, the frame rate of each window, the smoothness of the screen, and the user experience.
[0305] In other embodiments, when the electronic device includes multiple GPUs, some of these GPUs can be dedicated to executing graphics processing tasks in higher-priority scheduling queues. Therefore, after allocating the graphics processing tasks corresponding to each window to their respective scheduling queues, the electronic device can use these dedicated GPUs to execute graphics processing tasks in higher-priority scheduling queues. This ensures that graphics processing tasks for windows of high user attention can be executed by the GPUs in a timely manner, reducing latency for these windows, increasing their frame rate, improving their smoothness, and ultimately enhancing the user's viewing experience.
[0306] In this embodiment of the application, the window running on the electronic device can be any window in the electronic device that needs to perform graphics rendering. For example, it can include a window that uses the system's common rendering mechanism (e.g., a unified rendering mechanism), or it can include a window that does not use the system's common rendering mechanism (i.e., a window that uses its own independent rendering mechanism for graphics rendering).
[0307] In one example, when the render service (RS) in an electronic device renders each window using the system's common rendering mechanism, the RS can determine the priority of the graphics processing task corresponding to each window according to the aforementioned priority determination method, and then render each window according to the priority of the graphics processing task corresponding to each window. For example, high-priority graphics processing tasks can be placed in the high-priority rendering queue of the RS, and low-priority graphics processing tasks can be placed in the low-priority rendering queue of the RS.
[0308] In one implementation, high-priority graphics processing tasks can be rendered by the main thread, while low-priority graphics processing tasks can be rendered by a child thread.
[0309] It should be noted that the number of rendering queues in RS can be determined based on the actual scenario. For example, the number of rendering queues in RS can be determined based on the number of scheduling queues set up in the electronic device. For instance, when the electronic device has two scheduling queues, RS can include two rendering queues. Similarly, when the electronic device has four scheduling queues, RS can include four rendering queues. And when the electronic device has N scheduling queues, RS can include N rendering queues, where N is a positive integer, and so on.
[0310] Therefore, since all windows running on electronic devices use the system's common rendering mechanism, when the GPU is invoked to execute the graphics processing tasks corresponding to each window, the graphics processing tasks for each window can be divided into different priority scheduling queues of the GPU according to the priority of the rendering queues in the Rendering Server (RS). This allows the GPU to execute graphics processing tasks according to the priority of each scheduling queue. For example, graphics processing tasks in high-priority rendering queues can be placed in high-priority scheduling queues of the GPU, and graphics processing tasks in low-priority rendering queues can be placed in low-priority scheduling queues of the GPU.
[0311] For example, when the windows running on the electronic device include windows that use the system's common rendering mechanism and windows that do not use the system's common rendering mechanism (e.g., self-drawn windows), the electronic device can also determine the priority of the graphics processing tasks corresponding to each drawing window according to the priority determination method described above. Subsequently, the electronic device can perform comprehensive scheduling based on the priority of the graphics processing tasks assigned by the RS and the priority of the graphics processing tasks corresponding to each drawing window, so as to divide the graphics processing tasks corresponding to each window into different priority scheduling queues of the GPU.
[0312] For example, if an electronic device has a first scheduling queue and a second scheduling queue, and the priority of the first scheduling queue is higher than that of the second scheduling queue, then graphics processing tasks in the high-priority rendering queue of RS and graphics processing tasks corresponding to high-priority self-drawn windows can be assigned to the first scheduling queue, and graphics processing tasks in the low-priority rendering queue of RS and graphics processing tasks corresponding to low-priority self-drawn windows can be assigned to the second scheduling queue.
[0313] For example, please see Figure 10 , Figure 10 An example of task scheduling provided in an embodiment of this application is shown. Figure 4 This example illustrates an electronic device running with four windows using the system's common rendering mechanism (e.g., unified drawing window B1, unified drawing window B2, unified drawing window B3, and unified drawing window B4) and two self-drawn windows (e.g., self-drawn window A1 and self-drawn window A2). Additionally, this example also shows the GPU including a first scheduling queue and a second scheduling queue, where the first scheduling queue may have a higher priority than the second scheduling queue, and the RS includes a high-priority rendering queue (…). Figure 9 The middle part can be shown as a high-priority rendering queue and a low-priority rendering queue. Figure 10 The following example, which can be shown as a low-rendering queue, is provided for illustration.
[0314] Suppose that RS determines the priority of the graphics processing task corresponding to unified drawing window B1 as high priority based on the first region corresponding to each unified drawing window, and determines the priorities of the graphics processing tasks corresponding to unified drawing windows B2, B3, and B4 as low priority. Therefore, RS can place the graphics processing task corresponding to unified drawing window B1 into the high-priority rendering queue, and can place the graphics processing tasks corresponding to unified drawing windows B2, B3, and B4 into the low-priority rendering queue.
[0315] Suppose that the electronic device determines the priority of the graphics processing task corresponding to the self-drawn window A1 as high priority and the priority of the graphics processing task corresponding to the self-drawn window A2 as low priority based on the first area corresponding to each drawing window.
[0316] Therefore, as Figure 10 As shown, the electronic device can place graphics processing tasks (i.e., graphics processing tasks corresponding to unified drawing window B1) and high-priority self-drawing window A1 from the high-priority rendering queue of RS into the first scheduling queue of the GPU, and can place graphics processing tasks (i.e., graphics processing tasks corresponding to unified drawing window B2, unified drawing window B3, and unified drawing window B4) and low-priority self-drawing window A2 from the low-priority rendering queue of RS into the second scheduling queue of the GPU. The GPU can execute the graphics processing tasks in the first scheduling queue and the second scheduling queue according to the priorities of the first and second scheduling queues. For example, the GPU may include core 1 and core 2, and the GPU can preferentially schedule the graphics processing tasks in the first scheduling queue to core 1 and core 2 for execution.
[0317] The following will provide an exemplary description of another task scheduling method provided in the embodiments of this application, based on the above description. Please refer to... Figure 11 , Figure 11 A schematic flowchart of another task scheduling method provided in an embodiment of this application is shown. This method can be applied to the electronic device described above, which may include a GPU. Figure 11 As shown, the method may include:
[0318] S1101, the electronic device runs the first window and the second window.
[0319] For example, the first window and the second window can be windows of the same application, or they can be windows of different applications.
[0320] For example, the first window can be a window running in the foreground or a window running in the background. Similarly, the second window can be a window running in the foreground or a window running in the background.
[0321] S1102. The electronic device schedules the graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution according to the priority of the first scheduling queue and the priority of the second scheduling queue. The first scheduling queue includes the graphics processing tasks corresponding to the first window, and the second scheduling queue includes the graphics processing tasks corresponding to the second window. The priority of the first scheduling queue is higher than the priority of the second scheduling queue, and the priority of the graphics processing tasks corresponding to the first window is higher than the priority of the graphics processing tasks corresponding to the second window.
[0322] In this embodiment, when the electronic device is running a first window and a second window, the electronic device can determine the priority of the graphics processing task corresponding to the first window and the priority of the graphics processing task corresponding to the second window. Based on the priorities of the graphics processing tasks corresponding to the first and second windows, the electronic device can allocate the graphics processing task corresponding to the first window to a first scheduling queue and the graphics processing task corresponding to the second window to a second scheduling queue. In allocating graphics processing tasks to the first and second scheduling queues, the electronic device can schedule the graphics processing tasks in the first scheduling queue (e.g., the graphics processing task corresponding to the first window) and the graphics processing tasks in the second scheduling queue (e.g., the graphics processing task corresponding to the second window) to the GPU for execution based on the priorities of the first and second scheduling queues.
[0323] It should be noted that the specific details of how the electronic device determines the priority of the graphics processing tasks corresponding to the first window and the second window can be found in the aforementioned section "The process of the electronic device determining the priority of the graphics processing tasks corresponding to each window will be explained in detail below." The specific details of how the electronic device allocates the graphics processing tasks corresponding to the first window to the first scheduling queue and the graphics processing tasks corresponding to the second window to the second scheduling queue can also be found in the aforementioned section "The process of the electronic device allocating the graphics processing tasks corresponding to each window to the corresponding scheduling queue based on their priorities can be explained in detail below." The specific details of how the electronic device schedules the graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution can also be found in the aforementioned section "The process of the electronic device scheduling the graphics processing tasks in each scheduling queue to the GPU for execution based on their priorities can be explained in detail below." For the sake of simplicity, these details will not be repeated here.
[0324] In this embodiment, when the electronic device runs a first window and a second window simultaneously, the electronic device can determine the priority of the graphics processing task corresponding to the first window and the priority of the graphics processing task corresponding to the second window. It can place high-priority graphics processing tasks into a high-priority first scheduling queue and low-priority graphics processing tasks into a low-priority second scheduling queue. This allows the GPU to prioritize the execution of graphics processing tasks in the high-priority first scheduling queue, thus prioritizing the execution of graphics processing tasks corresponding to windows that the user is more interested in. This ensures that high-priority graphics processing tasks occupy a certain proportion of the GPU, thereby increasing the frame rate and smoothness of the screen in the windows that the user is more interested in, and improving the user experience.
[0325] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0326] Corresponding to the task scheduling method described in the above embodiments, this application also provides a task scheduling device, the various modules of which can implement the various steps of the task scheduling method.
[0327] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0328] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments 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 integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0329] This application also provides an electronic device, which includes at least one memory, at least one processor, and a computer program stored in the at least one memory and executable on the at least one processor. When the processor executes the computer program, it causes the electronic device to perform the steps in any of the above-described method embodiments. Exemplarily, the structure of the electronic device can be as follows: Figure 2 As shown.
[0330] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a computer, causes the computer to perform the steps in any of the above method embodiments.
[0331] This application provides a computer program product that, when run on an electronic device, causes the electronic device to perform the steps in any of the above method embodiments.
[0332] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate form. The computer-readable storage medium can include at least: any entity or device capable of carrying computer program code to a device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0333] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0334] 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.
[0335] In the embodiments provided in this application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For instance, the division of modules or 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 displayed or discussed mutual couplings or direct couplings or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0336] 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.
[0337] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A task scheduling method, characterized in that, Applied to an electronic device, the electronic device including a graphics processing unit (GPU), the method includes: The electronic device operates a first window and a second window; The electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution according to the priority of the first scheduling queue and the priority of the second scheduling queue. The first scheduling queue includes graphics processing tasks corresponding to the first window, and the second scheduling queue includes graphics processing tasks corresponding to the second window. The priority of the first scheduling queue is higher than the priority of the second scheduling queue, and the priority of the graphics processing tasks corresponding to the first window is higher than the priority of the graphics processing tasks corresponding to the second window.
2. The method according to claim 1, characterized in that, The priority of the graphics processing task corresponding to the window is determined based on at least one of the area of the first region corresponding to the window, the first proportion corresponding to the window, the area of the window, the second proportion corresponding to the window, the offset distance corresponding to the window, and the offset distance ratio corresponding to the window. Wherein, the area of the first region corresponding to the window includes the area of the area currently displayed by the window in the display interface; the first proportion corresponding to the window is the ratio between the area of the first region corresponding to the window and the area of the window; the second proportion corresponding to the window is the ratio between the area of the window and the area of the display interface; the offset distance corresponding to the window is the distance between the center point of the window and the center point of the display interface; and the offset distance ratio corresponding to the window is the ratio between the offset distance corresponding to the window and the diagonal length of the display interface.
3. The method according to claim 1 or 2, characterized in that, The area of the first region corresponding to the first window is greater than the area of the first region corresponding to the second window, or the first proportion corresponding to the first window is greater than the first proportion corresponding to the second window, or the area of the first window is greater than the area of the second window, or the second proportion corresponding to the first window is greater than the second proportion corresponding to the second window, or the offset distance corresponding to the first window is less than the offset distance corresponding to the second window, or the offset distance ratio corresponding to the first window is less than the offset distance ratio corresponding to the second window.
4. The method according to any one of claims 1 to 3, characterized in that, The electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution based on the priorities of the first scheduling queue and the second scheduling queue, including: The electronic device schedules graphics processing tasks in the first scheduling queue and the second scheduling queue to the GPU for execution based on a preset scheduling ratio, the priority of the first scheduling queue, and the priority of the second scheduling queue. The preset scheduling ratio is the ratio of the time taken to execute a graphics processing task in the first scheduling queue to the time taken to execute a graphics processing task in the second scheduling queue; or, the preset scheduling ratio is the ratio of scheduling a graphics processing task in the first scheduling queue to scheduling a graphics processing task in the second scheduling queue.
5. The method according to claim 4, characterized in that, The GPU includes a first processing core and a second processing core, and the preset scheduling ratio includes a first preset scheduling ratio and a second preset scheduling ratio. The first processing core executes the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the first preset scheduling ratio; The second processing core executes the graphics processing tasks in the first scheduling queue and the second scheduling queue according to the second preset scheduling ratio.
6. The method according to claim 5, characterized in that, The first preset scheduling ratio is the same as the second preset scheduling ratio.
7. The method according to claim 4, characterized in that, The GPU includes a first processing core and a second processing core; The first processing core executes the graphics processing tasks in the first scheduling queue; The second processing core executes the graphics processing tasks in the first scheduling queue and the graphics processing tasks in the second scheduling queue according to the preset scheduling ratio.
8. The method according to any one of claims 4 to 7, characterized in that, The preset scheduling ratio is either preset or determined based on the current load of the GPU.
9. The method according to any one of claims 1 to 8, characterized in that, The GPU load is greater than or equal to a first preset load.
10. The method according to any one of claims 1 to 9, characterized in that, The electronic device also runs a third window, and the method further includes: When the GPU load is less than the second preset load, the graphics processing task corresponding to the third window is assigned to the first scheduling queue, and the priority of the graphics processing task corresponding to the first window is higher than the priority of the graphics processing task corresponding to the third window.
11. The method according to any one of claims 1 to 10, characterized in that, The first window and the second window are windows of the same application.
12. The method according to any one of claims 1 to 11, characterized in that, The first window is the focus window, and the second window is the non-focus window.
13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it causes the electronic device to implement the task scheduling method as described in any one of claims 1 to 12.
14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the computer, it causes the computer to implement the task scheduling method as described in any one of claims 1 to 12.