Image rendering time calculation method and device, storage medium and electronic equipment
By obtaining the rendering timestamp by matching timestamp query rules on the image rendering platform, the problems of low accuracy and low efficiency in rendering time calculation in the existing technology are solved, and unified and efficient rendering time statistics across multiple platforms are achieved.
Patent Information
- Application Number
- CN202310096157.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-31
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-01-31
AI Technical Summary
Existing methods for calculating image rendering time are inaccurate and inefficient, and cannot provide unified statistics across different platforms.
By determining the platform category of the image rendering platform, matching the corresponding timestamp query rules, generating timestamp query instructions, obtaining the start and end timestamps of rendering, and calculating the rendering time.
It improves the accuracy and efficiency of rendering time calculation, supports unified statistics across multiple platforms, reduces compilation and packaging time, and improves analysis efficiency.
Smart Images

Figure CN115994971B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method for calculating image rendering time, a device for calculating image rendering time, a computer-readable storage medium, and an electronic device. Background Technology
[0002] Existing time consumption statistics methods can determine the specific time consumption by segmenting data packets using relevant time consumption tools. However, the accuracy of the time consumption calculation results obtained by this method is relatively low.
[0003] It should be noted that the information in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0004] The purpose of this disclosure is to provide a method for calculating image rendering time, a device for calculating image rendering time, a computer-readable storage medium, and an electronic device, thereby overcoming, to at least some extent, the problem of low accuracy of time-consuming calculation results caused by limitations and defects in related technologies.
[0005] According to one aspect of this disclosure, a method for calculating image rendering time is provided, comprising:
[0006] Determine the platform category of the image rendering platform that renders the current image frame, and match timestamp query rules for the image rendering platform according to the platform category;
[0007] Generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules;
[0008] Obtain the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command.
[0009] Based on the rendering start timestamp and rendering end timestamp, the rendering time required for the image rendering platform to render the current image frame is calculated.
[0010] According to one aspect of this disclosure, an image rendering time calculation apparatus is provided, comprising:
[0011] The timestamp query rule matching module is used to determine the platform category of the image rendering platform that renders the current image frame, and to match timestamp query rules for the image rendering platform according to the platform category.
[0012] The timestamp query instruction module is used to generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules.
[0013] The timestamp acquisition module is used to acquire the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command.
[0014] The rendering time calculation module is used to calculate the rendering time required by the image rendering platform to render the current image frame based on the rendering start timestamp and the rendering end timestamp.
[0015] According to one aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the image rendering time calculation method described in any of the foregoing example embodiments.
[0016] According to one aspect of this disclosure, an electronic device is provided, comprising:
[0017] Processor; and
[0018] Memory for storing the executable instructions of the processor;
[0019] The processor is configured to execute the image rendering time calculation method described in any of the foregoing example embodiments by executing the executable instructions.
[0020] This disclosure provides a method for calculating image rendering time. On one hand, it can determine the corresponding timestamp query rule based on the platform category of the image rendering platform, and then obtain the rendering start timetamp and rendering end timetamp before and after rendering the current image frame based on the timestamp query rule in response to the timestamp query command from the image rendering platform. Based on the rendering start timetamp and rendering end timetamp, the rendering time required by the image rendering platform to render the current image frame is calculated. This avoids the problem in the prior art where the accuracy of the time calculation result is low due to the use of time-consuming tools to determine the specific time by truncating data packets, thus improving the accuracy of the obtained rendering time. On the other hand, since the corresponding timestamp can be directly obtained from the image rendering platform to calculate the rendering time, there is no need to calculate the corresponding rendering duration through compilation and packaging, thereby improving the calculation efficiency of rendering time.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0023] Figure 1 A flowchart illustrating a method for calculating image rendering time according to an example embodiment of the present disclosure is shown schematically.
[0024] Figure 2 The diagram schematically illustrates a structural example of a terminal device for implementing a method for calculating image rendering time according to an exemplary embodiment of the present disclosure.
[0025] Figure 3 The illustration schematically depicts a scenario example of sending a timestamp query command and a frame rendering pipeline to a first image rendering platform having a first platform category, according to an example embodiment of the present disclosure.
[0026] Figure 4 The illustration schematically depicts a scenario example of sending a timestamp query command and a frame rendering pipeline to a second image rendering platform having a second platform category, according to an example embodiment of the present disclosure.
[0027] Figure 5 The flowchart illustrates a method for calculating the total rendering time of all current image frames based on the rendering start timestamp and rendering end timestamp, and calculating the rendering time required for the second image rendering platform to render the current image frame based on the total rendering time, according to an example embodiment of the present disclosure.
[0028] Figure 6 The illustration schematically depicts a scenario example of vertex rendering and pixel rendering performed on a frame rendering pipeline using a second image rendering platform according to an exemplary embodiment of the present disclosure.
[0029] Figure 7 The flowchart illustrates a method for calculating the overlap time between the total time spent drawing vertices and the total time spent drawing pixels, according to an example embodiment of the present disclosure.
[0030] Figure 8 The illustration shows an example diagram of the actual rendering time obtained by performing vertex rendering and pixel rendering on a frame rendering pipeline using a second image rendering platform according to an example embodiment of the present disclosure.
[0031] Figure 9 A block diagram schematically illustrates an image rendering time calculation apparatus according to an exemplary embodiment of the present disclosure.
[0032] Figure 10 An electronic device for implementing the image rendering time calculation method described above, according to an example embodiment of the present disclosure, is illustrated. Detailed Implementation
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0034] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0035] Performance optimization is a crucial aspect of mobile game development (especially next-generation 3D mobile games), determining the maximum potential quality of a game within limited hardware capabilities. Among the key hardware components affecting mobile game performance are the CPU and GPU, which handle logical computation and graphics rendering, respectively. To optimize game performance, developers need to analyze CPU and GPU usage separately and then perform targeted optimizations based on the analysis results.
[0036] Among these metrics, CPUs have two key performance indicators: memory read / write speed and logical operation load. Similarly, GPUs also have two key performance indicators: GPU bandwidth and shader computation load. To perform targeted analysis of these metrics, analysis tools such as RenderDoc and Xcode are needed to acquire data. The numerical representation of shader computation load is GPU time consumption. Currently, the most widely known tools for obtaining GPU time consumption are: for Mac, Xcode is primarily used, as it can compile the game engine source code and generate a complete iOS game package for frame-by-frame analysis; while for PCs and Android, RenderDoc is mainly used for frame-by-frame analysis and time consumption calculation.
[0037] However, using Xcode and RenderDoc to analyze game frames and obtain GPU time consumption still has several drawbacks. Specifically, these include: First, low debugging efficiency; because Xcode requires compiling the game engine source code before taking frame screenshots, each time a time consumption analysis is performed, the entire process of compiling the engine and packaging must be completed; for example, in actual applications, compilation and packaging time can range from a few seconds to several hours, making performance analysis extremely inefficient. Second, difficulty in data collection; specifically, because Xcode and RenderDoc capture not only GPU time consumption but also many other performance data, each frame screenshot will pause the game for a few seconds, making it impossible to observe the changes in time consumption during normal gameplay. Third, inaccurate data; specifically, because Xcode and RenderDoc re-execute GPU instructions to collect time consumption statistics, each result is different and does not reflect the actual game runtime situation. Furthermore, multi-platform statistics are not possible; specifically, different tools can only collect time consumption statistics for their corresponding devices, which is not very convenient for targeted optimizations for different platforms.
[0038] Based on this, this exemplary embodiment first provides a method for calculating image rendering time. This method can run on a terminal device, which can be a mobile terminal, personal computer, desktop computer, or tablet computer, etc. Of course, those skilled in the art can also run the method disclosed herein on other platforms as needed, and this exemplary embodiment does not impose any special limitations on this. Specifically, refer to... Figure 1 As shown, the method for calculating the image rendering time may include the following steps:
[0039] Step S110. Determine the platform category of the image rendering platform that renders the current image frame, and match timestamp query rules for the image rendering platform according to the platform category;
[0040] Step S120. Generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules;
[0041] Step S130. Obtain the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command;
[0042] Step S140. Based on the rendering start timestamp and rendering end timestamp, calculate the rendering time required for the image rendering platform to render the current image frame.
[0043] In the above-mentioned method for calculating image rendering time, on the one hand, since the corresponding timestamp query rule can be determined according to the platform category of the image rendering platform, and then the rendering start timetamp and rendering end timetamp before and after rendering the current image frame are obtained based on the timestamp query rule in response to the timestamp query command of the image rendering platform; and then the rendering time required by the image rendering platform to render the current image frame is calculated based on the rendering start timetamp and rendering end timetamp, thus avoiding the problem in the prior art of determining the specific time by truncating data packets through time consumption tools, which results in low accuracy of the time consumption calculation result, the accuracy of the obtained rendering time is improved; on the other hand, since the corresponding timestamp can be directly obtained from the image rendering platform to calculate the rendering time, there is no need to calculate the corresponding rendering duration through compilation and packaging, thus improving the calculation efficiency of rendering time.
[0044] The following will explain and illustrate in detail the method for calculating image rendering time in the example embodiments of this disclosure, with reference to the accompanying drawings.
[0045] First, the terms used in the exemplary embodiments of this disclosure will be explained and described.
[0046] CPU (Central Processing Unit): As the core of a computer system for computation and control, it is the final execution unit for information processing and program execution.
[0047] GPU (Graphics Processing Unit): Also known as a display core, visual processor, or display chip, it is a microprocessor specifically designed for performing image and graphics-related calculations on personal computers, workstations, game consoles, and some mobile devices (such as tablets and smartphones).
[0048] RenderPass: A RenderPass is a single run of the rendering pipeline; for example, rendering opaque models, rendering shadows, rendering effects, etc., through the rendering pipeline are all separate RenderPasses.
[0049] Encode: The process by which the CPU submits GPU instructions to the GPU.
[0050] VS (Vertex Shader): The stage for drawing vertices.
[0051] PS (Pixel Shader): The stage for drawing pixels.
[0052] Secondly, the inventive purpose of the exemplary embodiments of this disclosure will be explained and described. Specifically, the image rendering time calculation method described in the exemplary embodiments of this disclosure calculates the time consumption for each RenderPass by calling the time consumption statistics API (Application Program Interface) of various platforms within the game engine. Specifically, for the dx11 / es3 / vulkan platform, query instructions are inserted before and after each RenderPass encoding to query the GPU timestamp, and the time consumption of each Pass is obtained by subtracting the first and last timestamps. For the metal platform, the start and end timestamps of the vs and ps of each RenderPass are automatically obtained by adding the MTLCounterSampleBuffer to the commandEncoder's Desc, and then the overlap calculation is performed to finally obtain the time consumption of each Pass. That is, in specific applications, the results calculated by different platforms are returned through the same interface, which means that users can get the results instantly through a single interface.
[0053] Secondly, the terminal device described in the exemplary embodiments of this disclosure will be explained and described. Specifically, the terminal device described in the exemplary embodiments of this disclosure may include an interface display layer 210, a central processing unit 220, and a vision processor 230; wherein, the interface display layer, the central processing unit, and the vision processor are sequentially connected in communication; and in specific application processes, the interface display layer is used to display an interactive interface and image rendering results, the central processing unit is used to implement the image rendering time calculation method described in the exemplary embodiments of this disclosure, and the vision processor is used to execute the image rendering process.
[0054] Furthermore, in the image rendering time calculation method provided in the exemplary embodiments of this disclosure:
[0055] In step S110, the platform category of the image rendering platform that renders the current image frame is determined, and a timestamp query rule is matched for the image rendering platform according to the platform category.
[0056] Specifically, in practical applications, when it is necessary to determine the image rendering time, a rendering time query request can be triggered through the page display layer of the terminal device. When the central processing unit receives the rendering time query request, it can write the rendering time request into the front buffer of the time buffer, that is, it can write the rendering time request into the front buffer of the time buffer. At the same time, after receiving the rendering time query request, it is also necessary to determine the platform category of the image rendering platform, and then match the corresponding timestamp query rule according to the platform category.
[0057] In one example embodiment, the platform category described above may include a first platform category and / or a second platform category; the timestamp query rule includes a first timestamp query rule corresponding to the first platform category and / or a second timestamp query rule corresponding to the second platform category; wherein, the first timestamp query rule includes: sending a start timestamp query instruction to the image rendering platform before submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform, and sending an end timestamp query instruction to the image rendering platform after submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform; the second timestamp query rule includes: writing the timestamp query instruction into the instruction descriptor of the frame rendering pipeline instruction corresponding to the current image frame, and submitting the timestamp query instruction at the same time as submitting the frame rendering pipeline instruction.
[0058] In one example embodiment, the first platform category mentioned above may include DX11, ES3, and Vulkan, etc., where DX11 stands for DirectX 11, which can be integrated into the Windows system; ES3 can also be integrated into the Windows system; and Vulkan is a cross-platform 2D and 3D graphics application programming interface based on the Windows system. Further, the second platform category mentioned above may include Metal; where Metal is a low-level rendering application programming interface based on the iOS system.
[0059] In step S120, a timestamp query instruction corresponding to the current image frame is generated, and the timestamp query instruction is submitted to the image rendering platform through the graphics library interface based on the timestamp query rule.
[0060] In this example embodiment, firstly, when the image rendering platform is of the first platform category, a timestamp query instruction corresponding to the current image frame is generated, and the timestamp query instruction is submitted to the image rendering platform through the graphics library interface based on the timestamp query rules. This can be achieved in two ways: Firstly, a frame rendering pipeline corresponding to the current image frame is generated, and a start timestamp query instruction and an end timestamp query instruction corresponding to the frame rendering pipeline are generated according to a preset query buffer; secondly, the start timestamp query instruction, the frame rendering pipeline submission instruction, and the end timestamp query instruction are submitted sequentially to the first image rendering platform of the first platform category through the graphics library interface. In other words, in specific applications, before the first frame rendering pipeline (also known as the first frame rendering thread) begins submitting rendering instructions (Encode) to the GPU, data structures such as queryBuffer and queryPool are prepared for the query. Then, for data query platforms with a first platform category, when Encode each Pass individually, timestamp query instructions are sent to the GPU at the BeginPass and EndPass of the Pass. That is, when submitting rendering instructions for each frame rendering pipeline to the GPU individually, a start timestamp query instruction can be submitted to the GPU before submitting the rendering instructions for that frame rendering pipeline, followed by the submission of the rendering instructions for that frame rendering pipeline, and finally the submission of the end timestamp query instruction. The specific sending process of each instruction and the frame rendering pipeline can be found in the following scenarios. Figure 3 As shown.
[0061] It should be noted here that the queryPool (query object pool) described above can be used to construct a TimeBuffer (time cache), which can include a frontBuffer (preceding cache) and a backBuffer (following cache). The frontBuffer can be used to support obtaining query data through the script interface (that is, receiving data sent by the front end that requires the rendering time), and the backBuffer is used to collect query time.
[0062] Secondly, when the image rendering platform is of the second platform category, a timestamp query instruction corresponding to the current image frame is generated, and the timestamp query instruction is submitted to the image rendering platform through the graphics library interface based on the timestamp query rules. This can be achieved as follows: First, a frame rendering pipeline corresponding to the current image frame is generated, and a timestamp query instruction corresponding to the frame rendering pipeline is generated according to a preset query buffer; second, the timestamp query instruction is written into the instruction descriptor of the frame rendering pipeline, and the frame rendering pipeline instruction including the timestamp query instruction is submitted to the second image rendering platform with the second platform category through the graphics library interface. In other words, in practical use, unlike the first image rendering platform (which uses a first platform category) to insert instructions to query timestamps before and after each pass's instructions to obtain the total pass's time, the second image rendering platform Metal (which uses a second platform category) can automatically query the start and end timestamps of the VS and PS for each RenderPass by adding the MTLCounterSampleBuffer to the commandEncoder's Desc (instruction descriptor). Here, VS represents vertex rendering, and PS represents pixel rendering. For details on the specific sending process of each instruction and the frame rendering pipeline, please refer to... Figure 4 As shown.
[0063] In step S130, the rendering start timestamp and rendering end timestamp before and after rendering the current image frame are obtained from the image rendering platform in response to the timestamp query command.
[0064] In this example embodiment, the aforementioned current image frame will first be explained and described. Specifically, the current image frame includes a first current image frame, a second current image frame, a third current image frame, a fourth current image frame, ..., the Nth current image frame; the frame rendering pipeline corresponding to the current image frame includes a first frame rendering pipeline, a second frame rendering pipeline, a third frame rendering pipeline, a fourth frame rendering pipeline, ..., the Nth frame rendering pipeline; where N is a positive integer, and the specific value of N can be determined according to the number of frames included in the current rendering task, which is not specifically limited in this example.
[0065] Secondly, obtaining the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query instruction, can be achieved as follows: Step S10, when it is detected that the currently submitted frame rendering pipeline instruction is the fourth frame rendering pipeline instruction, a timestamp acquisition instruction corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline is generated; Step S20, the timestamp acquisition instruction and the fourth frame rendering pipeline instruction are sequentially submitted to the image rendering platform through the graphics library interface; Step S30, the rendering start timestamp and rendering end timestamp corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline are obtained from the query buffer and sent by the image rendering platform in response to the timestamp acquisition instruction; wherein, each of the rendering start timestamp and rendering end timestamp is stored in the query buffer by the image rendering platform in response to the timestamp query instruction; Step S40, steps S10-S30 are sequentially looped to obtain the rendering start timestamp and rendering end timestamp corresponding to other frame rendering pipelines. In other words, in practical applications, due to the latency of GPU rendering instructions, it is impossible to obtain the corresponding timestamp query results simultaneously with submitting the rendering pipeline. Therefore, before the fourth frame rendering thread begins encoding, it is necessary to obtain the queryBuffers of the first, second, and third frame rendering pipelines and send the query results to the GPU to obtain the rendering start and end timestamps for each frame's rendering pipeline. It should be noted that the timing of sending the timestamp retrieval instructions to the GPU can be set according to actual needs; this example does not impose any special restrictions on this.
[0066] In step S140, based on the rendering start timestamp and the rendering end timestamp, the rendering time required for the image rendering platform to render the current image frame is calculated.
[0067] In this example embodiment, the rendering time required by the image rendering platform to render the current image frame, based on the rendering start timestamp and rendering end timestamp, can be calculated in two ways: First, when the image rendering platform is a first image rendering platform with a first platform category, a first time difference between the rendering end timestamp and the rendering start timestamp is calculated, and the rendering time required by the first image rendering platform to render the current image frame is obtained based on this first time difference. That is, if the image rendering platform is a first image rendering platform with a first platform category, the first time difference between the rendering end timestamp and the rendering start timestamp can be directly calculated, and the obtained first time difference is the rendering time required by the first image rendering platform to render the current image frame.
[0068] Another approach is to calculate the total rendering time for all current image frames based on the rendering start timestamp and rendering end timestamp, and then calculate the rendering time required for the second image rendering platform to render the current image frame based on the total rendering time. Specifically, refer to... Figure 5 As shown, calculating the total rendering time for all current image frames based on the rendering start timestamp and rendering end timestamp, and then calculating the rendering time required for the second image rendering platform to render the current image frame based on the total rendering time, may include the following steps:
[0069] Step S510: Obtain the vertex drawing start time stamp, pixel drawing start time stamp, vertex drawing end time stamp, and pixel drawing end time stamp included in the rendering start time stamp and rendering end time stamp.
[0070] Specifically, for a second image rendering platform with a second platform category, the rendering process of the current image frame may include vertex rendering and pixel rendering; among which, vertex rendering can refer to... Figure 6 The 601 pixel drawing shown can be referenced. Figure 6 As shown in Figure 602; therefore, in order to further improve the rendering time required by the second image rendering platform to render the current image frame, the vertex rendering time and pixel rendering time can be calculated separately to obtain the corresponding total time. Based on this, firstly, the vertex rendering start time, pixel rendering start time, vertex rendering end time, and pixel rendering end time included in the rendering start time and rendering end time, can be obtained. It should be noted here that in specific applications, pixel rendering of different frame rendering pipelines may be divided into two threads for parallel rendering; and it is not possible to know exactly which rendering pipeline is on which thread. Therefore, when calculating the specific rendering time, the vertex rendering time and pixel rendering time need to be calculated separately.
[0071] Step S520: Calculate the total time spent drawing the vertex based on the vertex drawing start timestamp and vertex drawing end timestamp, and calculate the total time spent drawing the pixels based on the pixel drawing start timestamp and pixel drawing end timestamp.
[0072] Specifically, since a single frame of the rendering pipeline may involve the rendering of multiple vertices and multiple pixels, in practical applications, the rendering time of each vertex and the rendering time of each pixel can be calculated separately. Then, based on the rendering time of each vertex and the rendering time of each pixel, the total rendering time of the vertex and the total rendering time of the pixel can be obtained.
[0073] Step S530: Calculate the overlap time between the total vertex rendering time and the total pixel rendering time, and calculate the second time difference between the total vertex rendering time, the total pixel rendering time and the overlap time.
[0074] In this example embodiment, firstly, the overlap time between the total vertex rendering time and the total pixel rendering time is calculated. Specifically, refer to... Figure 7 As shown, the following steps may be included:
[0075] Step S710: Construct a first set of original timestamps based on the vertex drawing start timestamp and vertex drawing end timestamp, and determine whether there are duplicate time nodes between the pixel drawing start timestamp and pixel drawing end timestamp;
[0076] Step S720: When it is determined that there are duplicate time nodes, a second original timestamp set is constructed based on the pixel drawing start timestamp and / or pixel drawing end timestamp of the pixel drawing with duplicate time nodes, and a third original timestamp set is constructed based on the pixel drawing start timestamp and / or pixel drawing end timestamp of the pixel drawing without duplicate time nodes.
[0077] Step S730: Calculate the overlap time between the total vertex rendering time and the total pixel rendering time based on the first original timestamp set, the second original timestamp set, and the third original timestamp set.
[0078] In one example embodiment, the overlap time between the total vertex rendering time and the total pixel rendering time is calculated based on the first original timestamp set, the second original timestamp set, and the third original timestamp set. This can be achieved as follows: First, the first original timestamp set, the second original timestamp set, and the third original timestamp set are sorted according to the order of the time nodes to obtain a first target timestamp set, a second target timestamp set, and a third target timestamp set. Second, a first overlap time interval is calculated between the first target timestamp set and the second target timestamp set, and a second overlap time interval is calculated between the second target timestamp set and the third target timestamp set, as well as a third overlap time interval between the first target timestamp set and the third target timestamp set. Then, the overlap time between the total vertex rendering time and the total pixel rendering time is calculated based on the first overlap time interval, the second overlap time interval, and the third overlap time interval.
[0079] In one example embodiment, the overlap time between the total vertex rendering time and the total pixel rendering time is calculated based on the first overlap time interval, the second overlap time interval, and the third overlap time interval. This can be achieved by: calculating a first target overlap interval between the first overlap time interval and the second overlap time interval, or a second target overlap interval between the second overlap time interval and the third overlap time interval, or a third target overlap interval between the first overlap time interval and the third overlap time interval; calculating the total time between the first overlap time interval, the second overlap time interval, and the third overlap time interval, and calculating the time difference between the total time and any target overlap interval to obtain the overlap time.
[0080] The following will explain and describe steps S710-S730. Specifically, since it's not possible to definitively know which rendering pipeline is on which thread, the calculation of overlap time involves the following steps: First, a first set of original timestamps is constructed based on the vertex rendering start and end timestamps. Then, it's determined whether there are overlapping timestamps between the pixel rendering start and end timestamps. If there is overlap, a second set of original timestamps is constructed based on the overlapping parts, indicating they are not on the same thread. A third set of original timestamps is constructed based on the non-overlapping parts, indicating they are on the same thread. This results in three sets of original timestamps (or a timestamp list). Further, these three sets are sorted to obtain three target timestamp sets. These target timestamp sets are then iterated through to calculate the overlap time between any two sets, i.e., pairwise comparisons are performed to obtain three lists of overlapping time intervals. Finally, the overlap interval between any two overlapping time intervals is calculated to obtain the target overlapping interval. The durations of the three overlapping time intervals are then summed and the target overlapping interval time is subtracted to obtain the total overlap time.
[0081] Secondly, after obtaining the overlap time, the second time difference between the total vertex rendering time and the total pixel rendering time and the overlap time can be calculated, which is the final overLapping.
[0082] Step S540: Calculate the rendering time required for the second image rendering platform to render the current image frame based on the second time difference.
[0083] Specifically, after obtaining the second time difference, the rendering time required for the second image rendering platform to render the current image frame can be obtained. This rendering time is the actual time consumed by the GPU's frame rendering pipeline, excluding resource loading / storage. Furthermore, in specific applications, the actual rendering time obtained from the corresponding interfaces can be referenced... Figure 8 As shown; at the same time, compared to the rendering time of 14.82ms obtained through Xcode, Figure 8 The Total(Overlap) value of 14.96ms shown is more accurate than Total16.07ms, achieving the intended purpose.
[0084] At this point, the rendering time required for the first image rendering platform (with a first platform category) and the second image rendering platform (with a second platform category) to render the frame rendering pipeline has been calculated. After obtaining this rendering time, the calculation method can further include: writing the rendering time into the subsequent buffer in the time buffer, and when it is detected that the currently submitted frame rendering pipeline instruction is the fifth frame rendering pipeline instruction, swapping the preceding buffer and the subsequent buffer in the time buffer; wherein, the preceding buffer is used to support obtaining time-consuming query data sent by the user through a script interface, and the subsequent buffer is used to store the rendering time. That is, before the fifth frame rendering thread starts encoding, the frontBuffer and backBuffer of the timebuffer can be swapped. The frontBuffer supports obtaining query data through a script interface, and the backBuffer continues to collect query time. Then, the rendering time cached in the backBuffer can be fed back to the interface display layer for display through the frontBuffer.
[0085] Thus, the image rendering time calculation method described in the exemplary embodiments of this disclosure has been fully implemented. Based on the foregoing description, it can be understood that the image rendering time calculation method described in the exemplary embodiments of this disclosure, on the one hand, allows the game engine to perform real-time statistics on GPU time consumption across different platforms such as PC, Android, and iOS, significantly improving the efficiency of game GPU performance analysis and promoting more efficient game performance optimization; on the other hand, the image rendering time calculation method described in the exemplary embodiments of this disclosure can be written into the engine source code, allowing analysis and calculation during normal packet output without additional time consumption; simultaneously, it can be obtained in real time, requiring only a single interface call to retrieve the GPU time consumption of the current frame; furthermore, by calling the graphics library API for statistics, the results are more accurate than those obtained using profile tools; additionally, it supports GPU time consumption statistics across multiple platforms, including DX11, Metal, ES3, Vulkan, etc.
[0086] This disclosure also provides an example embodiment of an image rendering time calculation device. Specifically, refer to... Figure 9 As shown, the image rendering time calculation device may include a timestamp query rule matching module 910, a timestamp query instruction generation module 920, a timestamp acquisition module 930, and a rendering time calculation module 940. Wherein:
[0087] The timestamp query rule matching module 910 can be used to determine the platform category of the image rendering platform that renders the current image frame, and match timestamp query rules for the image rendering platform according to the platform category.
[0088] The timestamp query instruction module 920 can be used to generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules.
[0089] The timestamp acquisition module 930 can be used to acquire the rendering start timestamp and rendering end timestamp of the current image frame before and after rendering, as fed back by the image rendering platform in response to the timestamp query command.
[0090] The rendering time calculation module 940 can be used to calculate the rendering time required by the image rendering platform to render the current image frame based on the rendering start timestamp and the rendering end timestamp.
[0091] In one example embodiment of this disclosure, the platform category includes a first platform category and / or a second platform category; the timestamp query rule includes a first timestamp query rule corresponding to the first platform category and / or a second timestamp query rule corresponding to the second platform category; wherein, the first timestamp query rule includes: sending a start timestamp query instruction to the image rendering platform before submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform, and sending an end timestamp query instruction to the image rendering platform after submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform; the second timestamp query rule includes: writing the timestamp query instruction into the instruction descriptor of the frame rendering pipeline instruction corresponding to the current image frame, and submitting the timestamp query instruction at the same time as submitting the frame rendering pipeline instruction.
[0092] In one example embodiment of this disclosure, generating a timestamp query instruction corresponding to the current image frame and submitting the timestamp query instruction to the image rendering platform through a graphics library interface based on the timestamp query rules includes: generating a frame rendering pipeline corresponding to the current image frame, and generating a start timestamp query instruction and an end timestamp query instruction corresponding to the frame rendering pipeline according to a preset query buffer; and sequentially submitting the start timestamp query instruction, the frame rendering pipeline submission instruction, and the end timestamp query instruction to a first image rendering platform with a first platform category through the graphics library interface.
[0093] In one example embodiment of this disclosure, generating a timestamp query instruction corresponding to the current image frame and submitting the timestamp query instruction to the image rendering platform through a graphics library interface based on the timestamp query rules includes: generating a frame rendering pipeline corresponding to the current image frame, and generating a timestamp query instruction corresponding to the frame rendering pipeline according to a preset query buffer; writing the timestamp query instruction into the instruction descriptor of the frame rendering pipeline, and submitting the frame rendering pipeline instruction including the timestamp query instruction to a second image rendering platform with a second platform category through a graphics library interface.
[0094] In one example embodiment of this disclosure, the current image frame includes a first current image frame, a second current image frame, a third current image frame, a fourth current image frame, ..., the Nth current image frame; the frame rendering pipeline corresponding to the current image frame includes a first frame rendering pipeline, a second frame rendering pipeline, a third frame rendering pipeline, a fourth frame rendering pipeline, ..., the Nth frame rendering pipeline;
[0095] The process of obtaining the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query instruction, includes: Step S10, when it is detected that the currently submitted frame rendering pipeline instruction is the fourth frame rendering pipeline instruction, generating a timestamp acquisition instruction corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline; Step S20, sequentially submitting the timestamp acquisition instruction and the fourth frame rendering pipeline instruction to the image rendering platform through the graphics library interface; Step S30, receiving the rendering start timestamp and rendering end timestamp corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline, obtained from the query buffer and sent by the image rendering platform in response to the timestamp acquisition instruction; wherein each of the rendering start timestamp and rendering end timestamp is stored in the query buffer by the image rendering platform in response to the timestamp query instruction; Step S40, sequentially looping steps S10-S30 to obtain the rendering start timestamp and rendering end timestamp corresponding to other frame rendering pipelines.
[0096] In one example embodiment of this disclosure, calculating the rendering time required by the image rendering platform to render the current image frame based on the rendering start timestamp and rendering end timestamp includes: when the image rendering platform is a first image rendering platform with a first platform category, calculating a first time difference between the rendering end timestamp and the rendering start timestamp, and obtaining the rendering time required by the first image rendering platform to render the current image frame based on the first time difference; when the image rendering platform is a second image rendering platform with a second platform category, calculating the total rendering time of all current image frames based on the rendering start timestamp and the rendering end timestamp, and calculating the rendering time required by the second image rendering platform to render the current image frame based on the total rendering time.
[0097] In one example embodiment of this disclosure, the total rendering time for all current image frames is calculated based on the rendering start timestamp and rendering end timestamp, and the rendering time required by the second image rendering platform to render the current image frame is calculated based on the total rendering time. This includes: obtaining the vertex drawing start timestamp, pixel drawing start timestamp, vertex drawing end timestamp, and pixel drawing end timestamp included in the rendering start timestamp and rendering end timestamp; calculating the total vertex drawing time based on the vertex drawing start timestamp and vertex drawing end timestamp, and calculating the total pixel drawing time based on the pixel drawing start timestamp and pixel drawing end timestamp; calculating the overlap time between the total vertex drawing time and the total pixel drawing time, and calculating a second time difference between the total vertex drawing time and the total pixel drawing time and the overlap time; and calculating the rendering time required by the second image rendering platform to render the current image frame based on the second time difference.
[0098] In one example embodiment of this disclosure, calculating the overlap time between the total vertex rendering time and the total pixel rendering time includes: constructing a first original timestamp set based on the vertex rendering start timestamp and vertex rendering end timestamp, and determining whether there are duplicate time nodes between the pixel rendering start timestamp and pixel rendering end timestamp; when it is determined that there are duplicate time nodes, constructing a second original timestamp set based on the pixel rendering start timestamp and / or pixel rendering end timestamp with duplicate time nodes, and constructing a third original timestamp set based on the pixel rendering start timestamp and / or pixel rendering end timestamp without duplicate time nodes; and calculating the overlap time between the total vertex rendering time and the total pixel rendering time based on the first original timestamp set, the second original timestamp set, and the third original timestamp set.
[0099] In one example embodiment of this disclosure, calculating the overlap time between the total vertex rendering time and the total pixel rendering time based on the first original timestamp set, the second original timestamp set, and the third original timestamp set includes: sorting the first original timestamp set, the second original timestamp set, and the third original timestamp set according to the chronological order of the time nodes to obtain a first target timestamp set, a second target timestamp set, and a third target timestamp set; calculating a first overlap time interval between the first target timestamp set and the second target timestamp set, and sequentially calculating a second overlap time interval between the second target timestamp set and the third target timestamp set, and a third overlap time interval between the first target timestamp set and the third target timestamp set; and calculating the overlap time between the total vertex rendering time and the total pixel rendering time based on the first overlap time interval, the second overlap time interval, and the third overlap time interval.
[0100] In one example embodiment of this disclosure, calculating the overlap time between the total vertex rendering time and the total pixel rendering time based on the first overlap time interval, the second overlap time interval, and the third overlap time interval includes: calculating a first target overlap interval between the first overlap time interval and the second overlap time interval, or a second target overlap interval between the second overlap time interval and the third overlap time interval, or a third target overlap interval between the first overlap time interval and the third overlap time interval; calculating the total time between the first overlap time interval, the second overlap time interval, and the third overlap time interval, and calculating the time difference between the total time and any target overlap interval to obtain the overlap time.
[0101] In one exemplary embodiment of this disclosure, the image rendering time calculation device further includes:
[0102] The rendering time writing module can be used to write the rendering time into the subsequent cache in the time cache, and when it is detected that the currently submitted frame rendering pipeline instruction is the fifth frame rendering pipeline instruction, the preceding cache and the subsequent cache in the time cache are swapped; wherein, the preceding cache is used to support obtaining the time consumption query data sent by the user through the script interface, and the subsequent cache is used to store the rendering time.
[0103] The specific details of each module in the above-mentioned image rendering time calculation device have been described in detail in the corresponding image rendering time calculation method, so they will not be repeated here.
[0104] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0105] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0106] In exemplary embodiments of this disclosure, an electronic device capable of implementing the above-described methods is also provided. Those skilled in the art will understand that various aspects of this disclosure can be implemented as systems, methods, or program products. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."
[0107] The following reference Figure 10 To describe an electronic device 1000 according to such an embodiment of the present disclosure. Figure 10 The electronic device 1000 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0108] like Figure 10 As shown, the electronic device 1000 is manifested in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, a bus 1030 connecting different system components (including storage unit 1020 and processing unit 1010), and a display unit 1040.
[0109] The storage unit stores program code that can be executed by the processing unit 1010, causing the processing unit 1010 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 1010 can perform actions such as... Figure 1 Step S110: Determine the platform category of the image rendering platform that renders the current image frame, and match a timestamp query rule for the image rendering platform according to the platform category; Step S120: Generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rule; Step S130: Obtain the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query instruction; Step S140: Calculate the rendering time required by the image rendering platform to render the current image frame based on the rendering start timestamp and rendering end timestamp.
[0110] Storage unit 1020 may include readable media in the form of volatile storage units, such as random access memory (RAM) 10201 and / or cache memory 10202, and may further include read-only memory (ROM) 10203.
[0111] Storage unit 1020 may also include a program / utility 10204 having a set (at least one) program module 10205, such program module 10205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0112] Bus 1030 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.
[0113] Electronic device 1000 can also communicate with one or more external devices 1100 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 1000, and / or any device that enables electronic device 1000 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1050. Furthermore, electronic device 1000 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1060. As shown, network adapter 1060 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0114] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0115] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible implementations, various aspects of this disclosure may also be implemented as a program product including program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of this disclosure described in the "Exemplary Methods" section above.
[0116] The program product for implementing the above-described method according to embodiments of the present disclosure may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0117] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may 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 readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable 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 devices, magnetic storage devices, or any suitable combination thereof.
[0118] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0119] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0120] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device 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 computing device (e.g., via the Internet using an Internet service provider).
[0121] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this disclosure and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0122] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention described herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not invented by this disclosure. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
Claims
1. A method for calculating image rendering time, characterized in that, include: Determine the platform category of the image rendering platform that renders the current image frame, and match timestamp query rules for the image rendering platform according to the platform category; The image rendering platform includes a first image rendering platform having a first platform category, and / or a second image rendering platform having a second platform category; Generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules; Obtain the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command. Based on the rendering start timestamp and rendering end timestamp, calculate the rendering time required for the image rendering platform to render the current image frame; Wherein, when the image rendering platform is a second image rendering platform with a second platform category, the rendering time is obtained in the following manner: obtaining the vertex drawing start time stamp, pixel drawing start time stamp, vertex drawing end time stamp, and pixel drawing end time stamp included in the rendering start time stamp and rendering end time stamp; calculating the total vertex drawing time based on the vertex drawing start time stamp and vertex drawing end time stamp, and calculating the total pixel drawing time based on the pixel drawing start time stamp and pixel drawing end time stamp; calculating the overlap time between the total vertex drawing time and the total pixel drawing time, and calculating the second time difference between the total vertex drawing time and the total pixel drawing time and the overlap time; calculating the rendering time required by the second image rendering platform to render the current image frame based on the second time difference.
2. The method for calculating image rendering time according to claim 1, characterized in that, The platform category includes a first platform category and / or a second platform category; The timestamp query rules include a first timestamp query rule corresponding to the first platform category and / or a second timestamp query rule corresponding to the second platform category; The first timestamp query rule includes: sending a start timestamp query instruction to the image rendering platform before submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform, and sending an end timestamp query instruction to the image rendering platform after submitting the frame rendering pipeline instruction corresponding to the current image frame to the image rendering platform. The second timestamp query rule includes: writing the timestamp query instruction into the instruction descriptor of the frame rendering pipeline instruction corresponding to the current image frame, and submitting the timestamp query instruction at the same time as submitting the frame rendering pipeline instruction.
3. The method for calculating image rendering time according to claim 2, characterized in that, Generating a timestamp query instruction corresponding to the current image frame, and submitting the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules, including: Generate a frame rendering pipeline corresponding to the current image frame, and generate a start timestamp query instruction and an end timestamp query instruction corresponding to the frame rendering pipeline according to a preset query buffer. The start timestamp query instruction, the frame rendering pipeline submission instruction, and the end timestamp query instruction are sequentially submitted to the first image rendering platform with the first platform category through the graphics library interface.
4. The method for calculating image rendering time according to claim 2, characterized in that, Generating a timestamp query instruction corresponding to the current image frame, and submitting the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules, including: Generate a frame rendering pipeline corresponding to the current image frame, and generate a timestamp query instruction corresponding to the frame rendering pipeline according to a preset query buffer; The timestamp query instruction is written into the instruction descriptor of the frame rendering pipeline, and the frame rendering pipeline instruction including the timestamp query instruction is submitted to the second image rendering platform with the second platform category through the graphics library interface.
5. The method for calculating image rendering time according to claim 1, characterized in that, The current image frame includes the first current image frame, the second current image frame, the third current image frame, the fourth current image frame, ..., the Nth current image frame; The frame rendering pipeline corresponding to the current image frame includes the first frame rendering pipeline, the second frame rendering pipeline, the third frame rendering pipeline, the fourth frame rendering pipeline, ..., the Nth frame rendering pipeline; The process of obtaining the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command, includes: Step S10: When it is detected that the frame rendering pipeline instruction to be submitted is the fourth frame rendering pipeline instruction, a timestamp acquisition instruction corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline is generated. Step S20: Submit the timestamp acquisition instruction and the fourth frame rendering pipeline instruction to the image rendering platform sequentially through the graphics library interface; Step S30: Receive the rendering start timestamp and rendering end timestamp corresponding to the first frame rendering pipeline, the second frame rendering pipeline, and the third frame rendering pipeline, obtained from the query buffer by the image rendering platform in response to the timestamp acquisition instruction; wherein, each of the rendering start timestamps and rendering end timestamps is stored in the query buffer by the image rendering platform in response to the timestamp query instruction. Step S40: Repeat steps S10-S30 sequentially to obtain the rendering start timestamp and rendering end timestamp corresponding to other frame rendering pipelines.
6. The method for calculating image rendering time according to claim 1, characterized in that, Based on the rendering start timestamp and rendering end timestamp, the rendering time required for the image rendering platform to render the current image frame is calculated, including: When the image rendering platform is a first image rendering platform with a first platform category, a first time difference between the rendering end timestamp and the rendering start timestamp is calculated, and the rendering time required for the first image rendering platform to render the current image frame is obtained based on the first time difference.
7. The method for calculating image rendering time according to claim 1, characterized in that, Calculating the overlap time between the total vertex rendering time and the total pixel rendering time includes: Construct a first set of original timestamps based on the vertex drawing start timestamp and vertex drawing end timestamp, and determine whether there are duplicate time nodes between the pixel drawing start timestamp and pixel drawing end timestamp; When it is determined that there are duplicate time nodes, a second original timestamp set is constructed based on the pixel drawing start timestamp and / or pixel drawing end timestamp of the pixel drawing with duplicate time nodes, and a third original timestamp set is constructed based on the pixel drawing start timestamp and / or pixel drawing end timestamp of the pixel drawing without duplicate time nodes. Based on the first set of original timestamps, the second set of original timestamps, and the third set of original timestamps, calculate the overlap time between the total time spent drawing the vertex and the total time spent drawing the pixels.
8. The method for calculating image rendering time according to claim 7, characterized in that, Based on the first original timestamp set, the second original timestamp set, and the third original timestamp set, calculate the overlap time between the total vertex rendering time and the total pixel rendering time, including: The first original timestamp set, the second original timestamp set, and the third original timestamp set are sorted according to the order of the time nodes to obtain the first target timestamp set, the second target timestamp set, and the third target timestamp set. Calculate the first overlapping time interval between the first target timestamp set and the second target timestamp set, and then calculate the second overlapping time interval between the second target timestamp set and the third target timestamp set, as well as the third overlapping time interval between the first target timestamp set and the third target timestamp set in sequence; Based on the first overlapping time interval, the second overlapping time interval, and the third overlapping time interval, calculate the overlap time between the total vertex rendering time and the total pixel rendering time.
9. The method for calculating image rendering time according to claim 8, characterized in that, Based on the first overlapping time interval, the second overlapping time interval, and the third overlapping time interval, calculate the overlap time between the total vertex rendering time and the total pixel rendering time, including: Calculate the first target overlap interval between the first overlap time interval and the second overlap time interval, or the second target overlap interval between the second overlap time interval and the third overlap time interval, or the third target overlap interval between the first overlap time interval and the third overlap time interval; The total time between the first overlapping time interval, the second overlapping time interval, and the third overlapping time interval is calculated, and the time difference between the total time interval and any target overlapping interval is calculated to obtain the overlapping time.
10. The method for calculating image rendering time according to claim 1, characterized in that, The method for calculating image rendering time also includes: The rendering time is written into the subsequent cache in the time cache, and when it is detected that the currently submitted frame rendering pipeline instruction is the fifth frame rendering pipeline instruction, the preceding cache and the subsequent cache in the time cache are swapped. The preceding cache is used to support obtaining time-consuming query data sent by the user through the script interface, and the following cache is used to store the rendering time.
11. A device for calculating image rendering time, characterized in that, include: The timestamp query rule matching module is used to determine the platform category of the image rendering platform that renders the current image frame, and match timestamp query rules for the image rendering platform according to the platform category; the image rendering platform includes a first image rendering platform with a first platform category, and / or a second image rendering platform with a second platform category; The timestamp query instruction module is used to generate a timestamp query instruction corresponding to the current image frame, and submit the timestamp query instruction to the image rendering platform through the graphics library interface based on the timestamp query rules. The timestamp acquisition module is used to acquire the rendering start timestamp and rendering end timestamp before and after rendering the current image frame, as fed back by the image rendering platform in response to the timestamp query command. The rendering time calculation module is used to calculate the rendering time required for the image rendering platform to render the current image frame based on the rendering start timestamp and the rendering end timestamp. Wherein, when the image rendering platform is a second image rendering platform with a second platform category, the rendering time is obtained in the following manner: obtaining the vertex drawing start time stamp, pixel drawing start time stamp, vertex drawing end time stamp, and pixel drawing end time stamp included in the rendering start time stamp and rendering end time stamp; calculating the total vertex drawing time based on the vertex drawing start time stamp and vertex drawing end time stamp, and calculating the total pixel drawing time based on the pixel drawing start time stamp and pixel drawing end time stamp; calculating the overlap time between the total vertex drawing time and the total pixel drawing time, and calculating the second time difference between the total vertex drawing time and the total pixel drawing time and the overlap time; calculating the rendering time required by the second image rendering platform to render the current image frame based on the second time difference.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for calculating the image rendering time according to any one of claims 1-10.
13. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the method for calculating the image rendering time according to any one of claims 1-10 by executing the executable instructions.
Citation Information
Patent Citations
Rendering time consumption acquisition method, rendering time display method, performance monitoring method and device, and equipment
CN112346935A
