Method and apparatus for determining rendering time consumption, electronic device, storage medium and program product
By recording the start and completion timestamps of rendering commands in the rendering queue, the CPU blocking problem caused by traditional rendering time statistics is solved, and rendering time can be accurately calculated without affecting performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-12-09
- Publication Date
- 2026-06-09
AI Technical Summary
Traditional methods for calculating rendering time result in the CPU waiting for rendering to finish, blocking subsequent code execution and affecting video playback frame rate and encoding time.
By storing the queue address in the rendering queue, querying the execution status of rendering commands, recording start and finish timestamps, and calculating rendering time, CPU blocking can be avoided.
Accurately calculate rendering time without affecting video playback frame rate and encoding time, thus improving rendering performance.
Smart Images

Figure CN122179616A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of video rendering technology, and in particular to a method, apparatus, electronic device, storage medium, and program product for determining rendering time. Background Technology
[0002] In the field of video playback and editing, using a Graphics Processing Unit (GPU) for video rendering is a common practice to improve the frame rate. Therefore, analyzing the time taken by the GPU during a single rendering process is essential for identifying bottlenecks and improving rendering performance.
[0003] Since the rendering process is handled by the GPU, and the statistics and reporting of rendering time depend on the Central Processing Unit (CPU), the traditional method for calculating rendering time involves the CPU marking a GPU rendering start timestamp at the beginning of rendering, submitting rendering commands, waiting for rendering to finish, and marking a GPU rendering end timestamp after all rendering commands have been executed. The difference between the two timestamps is then calculated and converted into CPU time to obtain the GPU rendering time.
[0004] However, the aforementioned method of waiting for the CPU to finish rendering will block the execution of subsequent CPU code, resulting in a decrease in the overall video playback frame rate and an increase in encoding time. Summary of the Invention
[0005] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a method, apparatus, electronic device, storage medium, and program product for determining rendering time.
[0006] A first aspect of this disclosure provides a method for determining rendering time. The method includes: in response to inserting a first rendering command into a rendering queue, saving a first queue address of the rendering queue, the rendering queue being used to store rendering commands corresponding to video frames to be rendered; in response to querying based on the first queue address that the first rendering command in the rendering queue has started execution, saving a first timestamp of the first rendering command, the first timestamp being used to indicate the time when the first rendering command started execution; in response to querying that the first rendering command has finished execution, saving a second timestamp of the first rendering command, the second timestamp being used to indicate the time when the first rendering command finished execution; and determining the rendering time for executing the first rendering command based on the difference between the second timestamp and the first timestamp.
[0007] In some embodiments of this disclosure, before the method responds to a query based on the first queue address indicating that a first rendering command in the rendering queue has started execution and saves the first timestamp of the first rendering command, the method further includes: after a first query cycle, querying the rendering queue based on the first queue address whether there is a rendering command that has started execution; or, after inserting a second rendering command into the rendering queue, querying the rendering queue based on the first queue address whether there is a rendering command that has started execution.
[0008] In some embodiments of this disclosure, before saving the second timestamp of the first rendering command in response to the query that the first rendering command has been completed, the method further includes: inserting the first rendering command into a CPU query queue and saving the second queue address of the CPU query queue, the CPU query queue being used to store rendering commands that have started execution; the method of saving the second timestamp of the first rendering command in response to the query that the first rendering command has been completed includes: saving the second timestamp in response to the query that the first rendering command in the CPU query queue has been completed based on the second queue address.
[0009] In some embodiments of this disclosure, before saving the second timestamp after querying the CPU query queue based on the second queue address and finding that the first rendering command in the CPU query queue has been executed, the method further includes: after the second query cycle, querying the CPU query queue based on the second queue address whether there is a rendering command that has been executed; or, after inserting a second rendering command into the rendering queue, querying the CPU query queue based on the second queue address whether there is a rendering command that has been executed.
[0010] In some embodiments of this disclosure, after the method responds to inserting a first rendering command into a rendering queue and saving a first queue address of the rendering queue, the method further includes: responding to inserting a third rendering command into the rendering queue, determining a third timestamp of the third rendering command, wherein the rendering queue includes at least one rendering command between the first rendering command and the third rendering command; the third timestamp is used to indicate the time when the third rendering command begins execution, or the third timestamp is used to indicate the time when the third rendering command completes execution; and determining a target rendering time based on the difference between the third timestamp and a fourth timestamp, wherein the fourth timestamp is either the first timestamp or the second timestamp, and the target rendering time includes the rendering time for executing the at least one rendering command.
[0011] In some embodiments of this disclosure, the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command and the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the second timestamp, and the target rendering time is the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command, the rendering time of executing the at least one rendering command, and the rendering time of executing the third rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the second timestamp, and the target rendering time is the sum of the rendering time of executing the at least one rendering command and the rendering time of executing the third rendering command.
[0012] In some embodiments of this disclosure, the first rendering command is a rendering command for an empty task; and / or, the third rendering command is a rendering command for an empty task.
[0013] A second aspect of this disclosure provides a rendering time determination apparatus, comprising: a storage module, configured to, in response to inserting a first rendering command into a rendering queue, store a first queue address of the rendering queue, the rendering queue being used to store rendering commands corresponding to video frames to be rendered; in response to querying based on the first queue address that the first rendering command in the rendering queue has started execution, store a first timestamp of the first rendering command, the first timestamp being used to indicate the time when the first rendering command started execution; in response to querying that the first rendering command has finished execution, store a second timestamp of the first rendering command, the second timestamp being used to indicate the time when the first rendering command finished execution; and a determination module, configured to, based on the difference between the second timestamp and the first timestamp, determine the rendering time for executing the first rendering command.
[0014] In some embodiments of this disclosure, the apparatus further includes: a query module, configured to, in response to a query that a first rendering command in the rendering queue has started execution, query whether there is a rendering command that has started execution in the rendering queue based on the first queue address after a first query period, before saving the first timestamp of the first rendering command; or, after inserting a second rendering command into the rendering queue, query whether there is a rendering command that has started execution in the rendering queue based on the first queue address.
[0015] In some embodiments of this disclosure, the apparatus further includes: an insertion module, configured to insert the first rendering command into a CPU query queue in response to a query indicating that the first rendering command has been completed and before saving a second timestamp of the first rendering command; the saving module is further configured to save a second queue address of the CPU query queue, the CPU query queue being used to store rendering commands that have begun execution; specifically, the saving module is configured to save a second timestamp in response to a query indicating that the first rendering command in the CPU query queue has been completed based on the second queue address.
[0016] In some embodiments of this disclosure, the apparatus further includes: a query module, configured to, in response to a query based on the second queue address indicating that a first rendering command in the CPU query queue has been executed, query whether a completed rendering command exists in the CPU query queue based on the second queue address after a second query cycle, before saving the second timestamp; or, after inserting a second rendering command into the rendering queue, query whether a completed rendering command exists in the CPU query queue based on the second queue address.
[0017] In some embodiments of this disclosure, the determining module is further configured to, in response to inserting a first rendering command into a rendering queue and saving a first queue address of the rendering queue, determine a third timestamp of the third rendering command in response to inserting a third rendering command into the rendering queue, wherein the rendering queue includes at least one rendering command between the first rendering command and the third rendering command; the third timestamp is used to indicate the time when the third rendering command starts executing, or the third timestamp is used to indicate the time when the third rendering command finishes executing; and determine a target rendering time based on the difference between the third timestamp and a fourth timestamp, wherein the fourth timestamp is either the first timestamp or the second timestamp, and the target rendering time includes the rendering time for executing the at least one rendering command.
[0018] In some embodiments of this disclosure, the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command and the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the second timestamp, and the target rendering time is the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command, the rendering time of executing the at least one rendering command, and the rendering time of executing the third rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the second timestamp, and the target rendering time is the sum of the rendering time of executing the at least one rendering command and the rendering time of executing the third rendering command.
[0019] In some embodiments of this disclosure, the first rendering command is a rendering command for an empty task; and / or, the third rendering command is a rendering command for an empty task.
[0020] A third aspect of this disclosure provides an electronic device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the rendering time determination method as described in the first aspect.
[0021] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the rendering time determination method as described in the first aspect.
[0022] A fifth aspect of this disclosure provides a computer program product, wherein the computer program product includes a computer program that, when the computer program product is run on a processor, causes the processor to execute the computer program to implement the rendering time determination method as described in the first aspect.
[0023] A sixth aspect of this disclosure provides a chip including a processor and a communication interface coupled to the processor, the processor being used to execute program instructions to implement the rendering time determination method as described in the first aspect.
[0024] Compared with the prior art, the technical solution provided in this disclosure has the following advantages: In response to inserting a first rendering command into a rendering queue, the first queue address of the rendering queue is saved, and the rendering queue is used to store rendering commands corresponding to the video frames to be rendered; in response to querying that the first rendering command in the rendering queue has started execution based on the first queue address, a first timestamp of the first rendering command is saved, and the first timestamp is used to indicate the time when the first rendering command started execution; in response to querying that the first rendering command has been completed, a second timestamp of the first rendering command is saved, and the second timestamp is used to indicate the time when the first rendering command was completed; the rendering time of executing the first rendering command is determined based on the difference between the second timestamp and the first timestamp. In this embodiment of the disclosure, after inserting the first rendering command into the rendering queue, the first queue address of the rendering queue is saved. Subsequently, based on the first queue address, in response to the query that the first rendering command has started execution, a first timestamp is saved, and in response to the query that the first rendering command has been completed, a second timestamp is recorded. Then, based on the difference between the second timestamp and the first timestamp, the rendering time of the first rendering command is determined. In this way, by querying whether the first rendering command has started execution and whether it has been completed, the start execution timestamp and the completion timestamp of the first rendering command are obtained, and the rendering time of the first rendering command is determined. This does not block the execution of subsequent CPU code, and the statistical rendering time will not affect the playback frame rate and encoding time of the entire video. The rendering time of the first rendering command can be accurately queried without affecting the rendering performance. Attached Figure Description
[0025] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0026] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is one of the flowcharts illustrating the method for determining rendering time provided in this embodiment of the disclosure;
[0028] Figure 2 A second schematic flowchart of the rendering time determination method provided in this embodiment of the disclosure;
[0029] Figure 3 The third flowchart illustrates the method for determining rendering time provided in this embodiment of the present disclosure;
[0030] Figure 4A structural block diagram of a rendering time determination device provided in an embodiment of this disclosure;
[0031] Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0032] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0033] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0034] The terms "first," "second," etc., used in this disclosure and in the claims are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this disclosure can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0035] The electronic devices in this disclosure can be mobile electronic devices or non-mobile electronic devices. Mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc.; non-mobile electronic devices can be personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc.; this disclosure does not impose specific limitations.
[0036] The execution subject of the rendering time determination method provided in this embodiment can be the aforementioned electronic device (including mobile electronic devices and non-mobile electronic devices), or it can be a functional module and / or functional entity in the electronic device that can implement the rendering time determination method. The specific implementation subject can be determined according to actual usage requirements, and this embodiment does not limit it.
[0037] The rendering time determination method provided by the present disclosure will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0038] like Figure 1 As shown in the figure, this disclosure provides a method for determining rendering time, which may include the following steps 101 to 104.
[0039] 101. In response to inserting the first rendering command into the rendering queue, save the address of the first queue of the rendering queue.
[0040] The rendering queue stores the rendering commands corresponding to the video frames to be rendered. The first rendering command can be a rendering command for a rendering task targeting the video frame to be rendered. The first rendering command can also be a rendering command for a rendering task targeting a rendering module (decoding module, algorithm execution module, rendering execution module, or display module, etc.) in the rendering process.
[0041] The first queue address can be the starting address of the rendering queue (starting rendering queue address). The starting address refers to the initial location of the rendering queue in memory. The rendering queue typically consists of a series of rendering commands and data for the same video frame, used to guide the GPU in image rendering.
[0042] The first rendering command can be downsampling, adding effects, filters, transitions, upsampling, etc. The specific command can be determined according to the actual situation and is not limited here.
[0043] 102. In response to the query based on the first queue address indicating that the first rendering command in the rendering queue has started execution, save the first timestamp of the first rendering command.
[0044] The first timestamp is used to indicate the moment when the first rendering command begins execution.
[0045] It is understandable that the CPU can query the rendering queue based on the address of the first queue, then query the execution status of the rendering command in the rendering queue, and in response to determine that the first rendering command has started execution, determine the time when the first rendering command has started execution as the first timestamp, that is, determine the time when the first rendering command has started execution as the first timestamp of the first rendering command execution, and save the first timestamp.
[0046] To determine if the first rendering command has started execution, one can either check if the status of the first rendering command in the previous query was still in an unexecuted state, and if the status of the first rendering command in the current query is in an executing state, then the first rendering command has started execution; or one can compare the rendering commands in the previous query that are in an executing state with the rendering commands in the current query that are in an executing state to determine if the first rendering command is a newly added rendering command in an executing state, thus determining that the first rendering command has started execution; or one can determine if the first rendering command has started execution through other methods, which are not limited here.
[0047] In some embodiments of this disclosure, the CPU may periodically query whether there is a rendering command that has started to be executed in the rendering queue. Alternatively, the CPU may query whether there is a rendering command that has started to be executed in the rendering queue each time a new rendering command is inserted into the rendering queue. The specific details can be determined according to the actual situation and are not limited here.
[0048] 103. In response to the query that the first rendering command has been completed, save the second timestamp of the first rendering command.
[0049] The second timestamp is used to indicate the moment when the first rendering command was completed.
[0050] In some embodiments of this disclosure, the CPU can query the rendering queue based on the first queue address, then query the execution status of the rendering command in the rendering queue, and in response to determining that the first rendering command has been completed, determine the current time when the first rendering command has been completed as the second timestamp, that is, determine the time when the first rendering command has been completed as the second timestamp of the first rendering command completion, and save the second timestamp.
[0051] To determine if the first rendering command has been completed, one can either check if the status of the first rendering command queried in the previous query was still in the execution state, and if the status of the first rendering command queried in the current query is in the execution completed state, then the first rendering command has been completed; or one can compare the rendering commands that have been completed in the previous query with the rendering commands that have been completed in the current query to determine if the first rendering command is a newly added rendering command that has been completed, thus determining that the first rendering command has been completed; or one can determine if the first rendering command has been completed through other methods, which are not limited here.
[0052] In some embodiments of this disclosure, in response to finding a rendering command that has started execution in the rendering queue, the rendering command that has started execution can be stored in the CPU query queue and the second queue address of the CPU query queue can be saved. Then, in step 103 above, based on the second queue address, the CPU query queue is first queried, and then it is queried whether there is a rendering command that has been completed in the CPU query queue.
[0053] 104. Based on the difference between the second timestamp and the first timestamp, determine the rendering time for executing the first rendering command.
[0054] In some embodiments of this disclosure, since the GPU time standard and the CPU time standard are different, and both the first timestamp and the second timestamp are GPU time, the difference between the second timestamp and the first timestamp can be converted into CPU time, and the converted CPU time can be used to determine the rendering time for executing the first rendering command.
[0055] In this embodiment of the disclosure, after inserting the first rendering command into the rendering queue, the first queue address of the rendering queue is saved. Subsequently, in response to querying whether the first rendering command has started execution based on the first queue address, a first timestamp is saved, and in response to querying whether the first rendering command has been completed, a second timestamp is recorded. Then, based on the difference between the second timestamp and the first timestamp, the rendering time of the first rendering command is determined. In this way, by querying whether the first rendering command has started execution and whether it has been completed, the start execution timestamp and the completion timestamp of the first rendering command are obtained, and the rendering time of the first rendering command is determined. This does not block the execution of subsequent CPU code, and the statistical rendering time will not affect the playback frame rate and encoding time of the entire video. The rendering time of the first rendering command can be accurately queried without affecting the rendering performance.
[0056] In some embodiments of this disclosure, before step 102 above, the rendering time determination method provided by the embodiments of this disclosure may further include step 105 or step 106 below.
[0057] 105. After the first query cycle, based on the address of the first queue, query whether there is a rendering command that has started to be executed in the rendering queue.
[0058] The first query period can be determined based on the actual situation, and is not limited here.
[0059] In this embodiment of the present disclosure, according to the first query period, the rendering queue is periodically queried to see if there are any rendering commands that have started to be executed. In this way, it is possible to determine in a timely manner which rendering commands in the rendering queue have changed from an unexecuted state to an executed state. As a result, the determined first timestamp is closer to the time when the first rendering command started to be executed, and the rendering time of the first rendering command is determined to be more accurate.
[0060] 106. After inserting a second rendering command into the rendering queue, query the rendering queue based on the address of the first queue to see if there is a rendering command that has already started executing.
[0061] The second rendering command refers to any new rendering command inserted after the first rendering command.
[0062] In this embodiment of the disclosure, when a new rendering command is inserted into the rendering queue, a query is triggered to see if there is a rendering command that has already started executing in the rendering queue. In this way, since the interval between two adjacent rendering commands is relatively short, it is possible to determine in a timely manner which rendering commands in the rendering queue have changed from an unexecuted state to an executing state. As a result, the determined first timestamp is closer to the time when the first rendering command started executing, and the rendering time of the first rendering command is determined to be more accurate.
[0063] In some embodiments of this disclosure, combined with Figure 1 ,like Figure 2 As shown, before step 103 above, the rendering time determination method provided in this embodiment may further include step 107 below, and step 103 above can be implemented by step 103a below.
[0064] 107. Insert the first rendering command into the CPU query queue and save the address of the second queue of the CPU query queue.
[0065] The CPU query queue is used to store rendering commands that have already begun execution.
[0066] The address of the second queue can be the starting address of the CPU query queue.
[0067] 103a. In response to the fact that the first rendering command in the CPU query queue has been completed based on the second queue address, save the second timestamp.
[0068] It is understandable that the CPU can query the CPU query queue based on the second queue address, then query the execution status of the rendering command in the CPU query queue, and in response to determining that the first rendering command has been completed, determine the current time when the first rendering command has been completed as the second timestamp, that is, determine the timestamp when the first rendering command has been completed, and save the second timestamp.
[0069] In this embodiment of the disclosure, rendering commands that have started executing in the rendering queue are inserted into the CPU query queue, so as to facilitate timely querying of whether the rendering commands that have started executing have been completed.
[0070] In some embodiments of this disclosure, the CPU may periodically query the CPU query queue to see if there is a rendering command that has started execution. Alternatively, the CPU may query the CPU query queue to see if there is a rendering command that has started execution each time a new rendering command is inserted into the rendering queue. The specific details can be determined according to the actual situation and are not limited here.
[0071] In some embodiments of this disclosure, before step 103 above, the rendering time determination method provided by the embodiments of this disclosure may further include step 108 or step 109 below.
[0072] 108. After the second query cycle, based on the second queue address, query whether there is a rendering command that has been executed in the CPU query queue.
[0073] The second query period can be determined based on the actual situation and is not limited here. The second query period can be the same as or different from the first query period, depending on the actual situation and is not limited here.
[0074] In this embodiment of the disclosure, according to the second query cycle, the CPU query queue is periodically queried to see if there are any rendering commands that have been executed. In this way, it is possible to determine in a timely manner which rendering commands in the CPU query queue have changed from being executed to being completed. As a result, the determined second timestamp is closer to the time when the first rendering command is completed, and the rendering time of the first rendering command is determined more accurately.
[0075] 109. After inserting a second rendering command into the rendering queue, query the CPU query queue based on the address of the second queue to see if there is a rendering command that has been executed.
[0076] In this embodiment of the disclosure, when a new rendering command is inserted into the rendering queue, the CPU query queue is triggered to check whether there is a rendering command that has been executed. Since the interval between two adjacent rendering commands is relatively short, it is possible to determine in a timely manner which rendering commands in the CPU query queue have changed from the executing state to the executed state. As a result, the determined second timestamp is closer to the time when the first rendering command is completed, and the rendering time of the first rendering command is determined more accurately.
[0077] In some embodiments of this disclosure, after step 101 described above, the rendering time determination method provided by the embodiments of this disclosure may further include the following steps 110 and 111.
[0078] 110. In response to inserting a third rendering command into the rendering queue, determine the third timestamp of the third rendering command.
[0079] The rendering queue includes at least one rendering command between the first rendering command and the third rendering command; the third timestamp is used to indicate the time when the third rendering command starts executing, or the third timestamp is used to indicate the time when the third rendering command finishes executing.
[0080] Wherein, if the third timestamp is used to indicate the time when the third rendering command starts to be executed, then the third timestamp is the timestamp at which the third rendering command has started to be executed; if the third timestamp is used to indicate the time when the third rendering command finishes to be executed, then the third timestamp is the timestamp at which the third rendering command has finished to be executed.
[0081] Among them, at least one rendering command can be any rendering command, and there is no limitation here.
[0082] In some embodiments of this disclosure, at least one rendering command is a rendering command whose rendering time cannot be determined according to the method provided in steps 101 to 104 above. For example, at least one rendering command is a rendering command implemented by calling third-party code. Since the third-party code cannot be known or modified, the rendering time of executing at least one rendering command can be determined by the first timestamp of the first rendering command inserted before and after the third-party code and the timestamp of the third rendering command that has started execution.
[0083] In this embodiment of the disclosure, after the third rendering command is inserted into the rendering queue, the timestamp when the third rendering command has started to be executed, the timestamp when the third rendering command has been completed, and the rendering time of the third rendering command can be determined according to the methods provided in steps 101 to 104 above. For details, please refer to the relevant descriptions in steps 101 to 104 above, which will not be repeated here.
[0084] 111. Determine the target rendering time based on the difference between the third and fourth timestamps.
[0085] The fourth timestamp is either the first or the second timestamp, and the target rendering time includes the rendering time for executing the at least one rendering command.
[0086] Specifically, the difference between the third and fourth timestamps is converted into CPU time, and the converted CPU time is used to determine the execution time of the target rendering.
[0087] The target rendering time can be the rendering time for executing the at least one rendering command, or it can be the rendering time for multiple rendering commands, including the rendering time for executing the at least one rendering command.
[0088] In this embodiment of the disclosure, through the above steps 110 and 111, not only can the rendering time of executing a single rendering command be determined, but also the rendering time of executing multiple consecutive rendering commands can be determined.
[0089] In some embodiments of this disclosure, the third timestamp is the timestamp at which the third rendering command has started execution, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command and the rendering time of executing the at least one rendering command.
[0090] In some embodiments of this disclosure, the third timestamp is the timestamp at which the third rendering command has started execution, the fourth timestamp is the second timestamp, and the target rendering time is the rendering time for executing the at least one rendering command.
[0091] In some embodiments of this disclosure, the third timestamp is the timestamp at which the third rendering command has been completed, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command, the rendering time of executing the at least one rendering command, and the rendering time of executing the third rendering command.
[0092] In some embodiments of this disclosure, the third timestamp is the timestamp at which the third rendering command has been completed, the fourth timestamp is the second timestamp, and the target rendering time is the sum of the rendering time of executing the at least one rendering command and the rendering time of executing the third rendering command.
[0093] In this embodiment of the disclosure, the target rendering time for executing different rendering commands under various conditions can be determined based on the difference between the third and fourth timestamps.
[0094] In some embodiments of this disclosure, the first rendering command is a rendering command for an empty task; and / or, the third rendering command is a rendering command for an empty task.
[0095] In the rendering process, an empty task usually refers to a special case where there is no actual rendering work to be done.
[0096] In this embodiment of the disclosure, the first rendering command and / or the third rendering command can be set to the rendering command of an empty task according to actual needs, so as to better obtain the rendering time of executing at least one rendering command.
[0097] For example, such as Figure 3The diagram shows a rendering queue and its corresponding timeline, including rendering command 1, rendering commands 2 through 9, and rendering command 10. Rendering command 1 is the first rendering command, rendering command 10 is the third rendering command, and rendering commands 2 through 9 are eight second rendering commands. Timestamps 1, 2, 3, and 4 on the timeline correspond to the first, second, and third timestamps, respectively, the timestamp when the third rendering command started executing and the timestamp when the third rendering command completed. Therefore, the rendering time for executing rendering command 1 can be determined based on the difference between timestamp 2 and timestamp 1, the rendering time for executing rendering command 10 can be determined based on the difference between timestamp 4 and timestamp 3, the rendering time for executing rendering commands 2-9 can be determined based on the difference between timestamp 3 and timestamp 2, the rendering time for executing rendering commands 2-10 can be determined based on the difference between timestamp 4 and timestamp 2, the rendering time for executing rendering commands 1-9 can be determined based on the difference between timestamp 3 and timestamp 1, and the rendering time for executing rendering commands 1-10 can be determined based on the difference between timestamp 4 and timestamp 1.
[0098] Figure 4 This is a structural block diagram of a rendering time determination device shown in an embodiment of the present disclosure, such as... Figure 4 As shown, it includes: a storage module 401, used to store a first queue address of the rendering queue in response to inserting a first rendering command into the rendering queue, the rendering queue being used to store rendering commands corresponding to video frames to be rendered; in response to querying that the first rendering command in the rendering queue has started execution based on the first queue address, storing a first timestamp of the first rendering command, the first timestamp being used to indicate the time when the first rendering command started execution; in response to querying that the first rendering command has finished execution, storing a second timestamp of the first rendering command, the second timestamp being used to indicate the time when the first rendering command finished execution; and a determination module 402, used to determine the rendering time of executing the first rendering command based on the difference between the second timestamp and the first timestamp.
[0099] In some embodiments of this disclosure, the apparatus further includes: a query module, configured to, in response to a query based on the first queue address indicating that a first rendering command in the rendering queue has started execution, before saving a first timestamp of the first rendering command, query based on the first queue address after a first query period, whether there is a rendering command that has started execution in the rendering queue; or, after inserting a second rendering command into the rendering queue, query based on the first queue address whether there is a rendering command that has started execution in the rendering queue.
[0100] In some embodiments of this disclosure, the apparatus further includes: an insertion module, configured to insert the first rendering command into a CPU query queue in response to a query indicating that the first rendering command has been completed and before saving a second timestamp of the first rendering command; the saving module 401 is further configured to save a second queue address of the CPU query queue, the CPU query queue being used to store rendering commands that have begun execution; specifically, the saving module 401 is configured to save a second timestamp in response to a query indicating that the first rendering command in the CPU query queue has been completed based on the second queue address.
[0101] In some embodiments of this disclosure, the apparatus further includes: a query module, configured to, in response to a query based on the second queue address indicating that a first rendering command in the CPU query queue has been executed, query whether a completed rendering command exists in the CPU query queue based on the second queue address after a second query cycle, before saving the second timestamp; or, after inserting a second rendering command into the rendering queue, query whether a completed rendering command exists in the CPU query queue based on the second queue address.
[0102] In some embodiments of this disclosure, the determining module 402 is further configured to, in response to inserting a first rendering command into a rendering queue and saving a first queue address of the rendering queue, determine a third timestamp of the third rendering command in response to inserting a third rendering command into the rendering queue, wherein the rendering queue includes at least one rendering command between the first rendering command and the third rendering command; the third timestamp is used to indicate the time when the third rendering command starts executing, or the third timestamp is used to indicate the time when the third rendering command finishes executing; and determine a target rendering time based on the difference between the third timestamp and a fourth timestamp, wherein the fourth timestamp is either the first timestamp or the second timestamp, and the target rendering time includes the rendering time for executing the at least one rendering command.
[0103] In some embodiments of this disclosure, the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command and the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has begun, the fourth timestamp is the second timestamp, and the target rendering time is the rendering time of executing the at least one rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command, the rendering time of executing the at least one rendering command, and the rendering time of executing the third rendering command; the third timestamp is the timestamp at which the execution of the third rendering command has been completed, the fourth timestamp is the second timestamp, and the target rendering time is the sum of the rendering time of executing the at least one rendering command and the rendering time of executing the third rendering command.
[0104] In some embodiments of this disclosure, the first rendering command is a rendering command for an empty task; and / or, the third rendering command is a rendering command for an empty task.
[0105] In this embodiment of the disclosure, each module can implement the rendering time determination method provided in the above method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0106] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of the present disclosure. It is used to illustrate the electronic device that implements the arbitrary rendering time determination method in the embodiments of the present disclosure and should not be construed as a specific limitation on the embodiments of the present disclosure.
[0107] like Figure 5 As shown, the electronic device 500 may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the electronic device 500. The processor 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0108] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although an electronic device 500 with various devices is shown, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0109] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processor 501, it can perform the functions defined in any rendering time determination method provided in embodiments of this disclosure.
[0110] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0111] In some implementations, the client and server can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0112] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0113] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: in response to inserting a first rendering command into a rendering queue, save a first queue address of the rendering queue, the rendering queue being used to store rendering commands corresponding to video frames to be rendered; in response to querying based on the first queue address that the first rendering command in the rendering queue has started execution, save a first timestamp of the first rendering command, the first timestamp being used to indicate the time when the first rendering command started execution; in response to querying that the first rendering command has completed execution, save a second timestamp of the first rendering command, the second timestamp being used to indicate the time when the first rendering command completed execution; and determine the rendering time of executing the first rendering command based on the difference between the second timestamp and the first timestamp.
[0114] In embodiments of this disclosure, computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof. These programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on a computer, partially on a computer, as a standalone software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0115] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0116] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0117] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0118] In the context of this disclosure, a computer-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of computer-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0119] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0120] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0121] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A method for determining rendering time, characterized in that, The method includes: In response to inserting the first rendering command into the rendering queue, the first queue address of the rendering queue is saved, and the rendering queue is used to store the rendering commands corresponding to the video frames to be rendered. In response to the query based on the first queue address indicating that the first rendering command in the rendering queue has started execution, a first timestamp of the first rendering command is saved, the first timestamp being used to indicate the time when the first rendering command started execution; In response to the query that the first rendering command has been completed, a second timestamp of the first rendering command is saved, the second timestamp being used to indicate the moment when the first rendering command was completed; The rendering time for executing the first rendering command is determined based on the difference between the second timestamp and the first timestamp.
2. The method according to claim 1, characterized in that, Before saving the first timestamp of the first rendering command after querying the rendering queue based on the first queue address and finding that the first rendering command has started execution, the method further includes: After the first query cycle, based on the first queue address, query whether there is a rendering command that has started executing in the rendering queue; or, After inserting a second rendering command into the rendering queue, the system queries whether there is a rendering command that has already started executing in the rendering queue, based on the address of the first queue.
3. The method according to claim 1 or 2, characterized in that, Before saving the second timestamp of the first rendering command in response to the query that the first rendering command has been completed, the method further includes: The first rendering command is inserted into the CPU query queue, and the address of the second queue of the CPU query queue is saved. The CPU query queue is used to store rendering commands that have started to be executed. The step of saving the second timestamp of the first rendering command in response to the query that the first rendering command has been completed includes: In response to the query based on the second queue address indicating that the first rendering command in the CPU query queue has been completed, the second timestamp is saved.
4. The method according to claim 3, characterized in that, Before saving the second timestamp after querying the CPU query queue based on the second queue address and finding that the first rendering command has been completed, the method further includes: After the second query cycle, based on the second queue address, query whether there is a completed rendering command in the CPU query queue; or, After inserting a second rendering command into the rendering queue, the CPU query queue is queried based on the address of the second queue to see if there is a rendering command that has been executed.
5. The method according to claim 1, characterized in that, After responding to inserting the first rendering command into the rendering queue and saving the first queue address of the rendering queue, the method further includes: In response to inserting a third rendering command into the rendering queue, a third timestamp of the third rendering command is determined, wherein the rendering queue includes at least one rendering command between the first rendering command and the third rendering command; the third timestamp is used to indicate the time when the third rendering command begins execution, or the third timestamp is used to indicate the time when the third rendering command completes execution; The target rendering time is determined based on the difference between the third and fourth timestamps, wherein the fourth timestamp is either the first or the second timestamp, and the target rendering time includes the rendering time for executing the at least one rendering command.
6. The method according to claim 5, characterized in that, The third timestamp is the timestamp at which the third rendering command has started execution, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command and the rendering time of executing the at least one rendering command. The third timestamp is the timestamp at which the third rendering command has started execution, the fourth timestamp is the second timestamp, and the target rendering time is the rendering time for executing the at least one rendering command; The third timestamp is the timestamp at which the third rendering command has been completed, the fourth timestamp is the first timestamp, and the target rendering time is the sum of the rendering time of executing the first rendering command, the rendering time of executing at least one rendering command, and the rendering time of executing the third rendering command. The third timestamp is the timestamp at which the third rendering command has been completed, the fourth timestamp is the second timestamp, and the target rendering time is the sum of the rendering time of executing the at least one rendering command and the rendering time of executing the third rendering command.
7. The method according to claim 5, characterized in that, The first rendering command is a rendering command for an empty task; And / or, The third rendering command is a rendering command for an empty task.
8. A device for determining rendering time, characterized in that, include: A storage module is used to save the first queue address of the rendering queue in response to inserting the first rendering command into the rendering queue. The rendering queue is used to store the rendering commands corresponding to the video frames to be rendered. In response to the query based on the first queue address indicating that the first rendering command in the rendering queue has started execution, a first timestamp of the first rendering command is saved, the first timestamp being used to indicate the time when the first rendering command started execution; In response to the query that the first rendering command has been completed, a second timestamp of the first rendering command is saved, the second timestamp being used to indicate the moment when the first rendering command was completed; The determination module is used to determine the rendering time for executing the first rendering command based on the difference between the second timestamp and the first timestamp.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the rendering time determination method according to any one of claims 1 to 7 when the computer program is invoked.
10. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the rendering time determination method according to any one of claims 1 to 7.
11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the rendering time determination method according to any one of claims 1 to 7.