A rendering method, device and computer equipment capable of automatically adjusting rendering strategy
By performing performance testing and scoring when the rendering engine is started, and dynamically adjusting the rendering strategy, the user experience problem of web-side digital twin rendering under low-performance hardware and unstable networks is solved, achieving high-quality 3D rendering and smooth user interaction. .
Patent Information
- Application Number
- CN202410953621.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-16
AI Technical Summary
In the field of web-side digital twin rendering, traditional methods are difficult to provide high-quality 3D rendering under low-performance hardware and unstable network conditions, resulting in a limited user experience, especially when large 3D models and data sets are slow to load or during the rendering process. Stuttering occurs.
By performing a performance test before the first screen is loaded when the rendering engine is started, the number of CPU cores, available memory and network bandwidth of the device are scored, the rendering strategy is determined based on the scores, and the rendering parameters are adjusted to adapt to different devices and network conditions. After the first screen is loaded, continue to perform performance testing and dynamically adjust the rendering strategy to optimize the user experience.
It provides the best user experience under different devices and network conditions, ensures rendering quality and performance, reduces lags and loading times in the user experience, and reduces hardware and network requirements.
Smart Images

Figure CN118505875B
Abstract
Description
Technical Field
[0001] The present invention relates to a digital twin rendering method, and more specifically to a rendering method, device and computer equipment that can automatically adjust rendering strategies. Background Art
[0002] In the field of digital twin rendering on the Web, it is often necessary to process and display complex 3D models and large amounts of data to achieve goals such as virtual simulation, data visualization, and interactive experience. The completion of these tasks faces a series of challenges.
[0003] First, high-quality 3D rendering usually requires powerful hardware support or high-computing cloud services. In the traditional Web environment, users may not have high-performance hardware that can support such rendering requirements. Even for cloud services, the cost may become a limiting factor, and for some tasks, the performance and availability of cloud services cannot meet the needs of real-time rendering. Secondly, network latency and bandwidth limitations are also important factors affecting rendering quality and user experience. Especially for large 3D models and data sets, they need to be transmitted to the user end through the network, and this process may be affected by network bandwidth limitations and delays, resulting in slow data loading or freezes during rendering, affecting user experience.
[0004] Therefore, it is necessary to design a new method to automatically adjust the rendering strategy according to the rendering capability and interaction mode to provide the best user experience under different device and network conditions. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the prior art and provide a rendering method, device and computer equipment that can automatically adjust the rendering strategy.
[0006] To achieve the above object, the present invention adopts the following technical solution: a rendering method capable of automatically adjusting a rendering strategy, comprising:
[0007] When the rendering engine is started, the system is tested for performance before the first screen loads to obtain a performance score before rendering;
[0008] Set the performance score global variable;
[0009] Determine whether there is a subscription callback function currently;
[0010] If there are currently subscription callback functions, all callback functions will be executed;
[0011] Render the scene based on the pre-rendering performance score and various rendering parameters;
[0012] When the time set by the timer is reached, a performance test is performed in the worker thread after the first screen is loaded to obtain a performance score after rendering, and the setting of the performance score global variable is executed.
[0013] A further technical solution is: when the rendering engine is started, the system is tested for performance before the first screen is loaded to obtain a performance score before rendering, including:
[0014] When starting the rendering engine, obtain the number of CPU cores, available memory, and network bandwidth of the device to obtain performance-related information;
[0015] The CPU performance score, the memory performance score, and the network score are calculated based on the performance-related information and summed to obtain a performance score before rendering.
[0016] Its further technical solution is: the determination of whether there is a subscription callback function currently includes:
[0017] Determine whether the callback function is currently subscribed through the subscribe method;
[0018] If the callback function is subscribed to through the subscribe method, it is determined that the subscription callback function currently exists;
[0019] If the callback function is not subscribed to through the subscribe method, it is determined that there is no subscription callback function currently.
[0020] Its further technical solution is: the execution of all callback functions includes:
[0021] The callback function is executed to modify the rendering parameters of the material and texture.
[0022] A further technical solution is: performing scene rendering according to the performance score before rendering and various rendering parameters includes:
[0023] Determine rendering strategy based on pre-rendering performance scores and various rendering parameters;
[0024] The scene is rendered according to the rendering strategy.
[0025] Its further technical solution is: when the time set by the timer is reached, the performance test after the first screen loading is performed in the worker thread to obtain the performance score after rendering, and the setting of the performance score global variable is executed, including:
[0026] When the timer set time is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
[0027] Its further technical solution is: when the time set by the timer is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain a performance score after rendering, and the setting of the performance score global variable is executed, including:
[0028] When the timer reaches the time set, run the test code at each test point in the worker thread to collect the corresponding data;
[0029] Calculate the scores of CPU, GPU, available memory, network, user interaction frequency, and browser frame rate according to the data and the set scoring criteria;
[0030] The scores are aggregated to obtain a performance score after rendering, and the setting of the performance score global variable is performed.
[0031] The present invention also provides a rendering device capable of automatically adjusting a rendering strategy, comprising:
[0032] A first performance detection unit is used to perform a performance detection on the system before the first screen is loaded when the rendering engine is started, so as to obtain a performance score before rendering;
[0033] Setting unit, used to set performance score global variables;
[0034] A judgment unit, used to judge whether a subscription callback function currently exists;
[0035] The execution unit is used to execute all the subscription callback functions if there are currently subscription callback functions;
[0036] A rendering unit, used to render the scene based on the pre-rendering performance score and various rendering parameters;
[0037] The second performance detection unit is used to perform a performance detection after the first screen is loaded in the worker thread when the time set by the timer is reached, so as to obtain a performance score after rendering, and execute the setting of the performance score global variable.
[0038] Its further technical solution is: the first performance detection unit includes:
[0039] The related information acquisition subunit is used to obtain the number of CPU cores, available memory and network bandwidth of the device when starting the rendering engine to obtain performance related information;
[0040] The score calculation subunit is used to calculate the CPU performance score, the memory performance score and the network score according to the performance related information, and sum them up to obtain the performance score before rendering.
[0041] The present invention further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program.
[0042] The beneficial effect of the present invention compared with the prior art is as follows: when starting rendering, the present invention first performs a performance test before the first screen is loaded, sets a performance score global variable, determines various rendering parameters in combination with whether a subscription callback function exists, determines the rendering strategy and renders the scene in combination with the various rendering parameters and the performance score before rendering, and after rendering, performs a performance test after the first screen is loaded in the worker thread, resets the performance score global variable, and automatically adjusts the rendering strategy according to the rendering capability and interaction method to provide the best user experience under different device and network conditions.
[0043] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0045] Figure 1 A schematic flow chart of a rendering method capable of automatically adjusting a rendering strategy provided by an embodiment of the present invention;
[0046] Figure 2 A schematic block diagram of a rendering device capable of automatically adjusting a rendering strategy provided by an embodiment of the present invention;
[0047] Figure 3 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0050] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0051] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0052] See also Figure 1 , Figure 1 A schematic flow chart of a rendering method capable of automatically adjusting a rendering strategy provided by an embodiment of the present invention. The rendering method capable of automatically adjusting a rendering strategy is applied in a browser. The browser is carried on a terminal, exchanges data with a server, and can automatically adjust a rendering strategy according to the rendering capability of a user's device and the mode of interaction with an application. This rendering engine dynamically adjusts rendering parameters (such as image quality, resolution, etc.) by monitoring the user's device performance and network status in real time, thereby providing the best user experience under different device and network conditions.
[0053] Figure 1 FIG. 1 is a flow chart of a rendering method capable of automatically adjusting a rendering strategy provided by an embodiment of the present invention. Figure 1 As shown, the method includes the following steps S110 to S160.
[0054] S110: When the rendering engine is started, a performance test is performed on the system before the first screen is loaded to obtain a performance score before rendering.
[0055] In this embodiment, the pre-rendering performance score refers to a performance test of the system before the rendering engine is started, and a performance score is given based on the test results. This score reflects the performance of the system before the first screen is loaded, and can help determine the performance level of the system before starting to load the page.
[0056] The purpose of the score is to evaluate the overall performance of the system before starting to render the page, so that necessary optimization measures can be taken in time to ensure good performance and user experience when loading the page.
[0057] In one embodiment, the above-mentioned step S110 may include steps S111 - S112 .
[0058] S111. When starting the rendering engine, obtain the number of CPU cores, available memory, and network bandwidth of the device to obtain performance-related information.
[0059] In this example, the number of CPU cores of the device is obtained by using the navigator.hardwareConcurrency property. This property returns an integer value representing the number of CPU cores of the device.
[0060] Memory related information is obtained by using the performance.memory object in the Performance API. The performance.memory.jsHeapSizeLimit property indicates the maximum size of the available heap in the context, while the performance.memory.totalJSHeapSize property indicates the allocated heap size in bytes. By calculating these two values, information about available memory can be obtained.
[0061] Use the navigator.connection object to get information about the current network connection. The navigator.connection.downlink property indicates the current downlink bandwidth of the device in Mbps (megabits per second).
[0062] S112: Calculate a CPU performance score, a memory performance score, and a network score according to the performance-related information, and sum them up to obtain a performance score before rendering.
[0063] In this embodiment, the CPU performance score is calculated using a given formula based on the number of CPU cores obtained. If the number of cores is greater than or equal to 8, a full score of 4 is obtained; otherwise, the score is calculated based on the core ratio, and the score range is between 0 and 4.
[0064] Based on the available memory information obtained, the memory performance score is calculated using the given formula. If the available memory is greater than or equal to 3 GB, a full score of 3 is obtained; otherwise, the score is calculated based on the available memory ratio, and the score range is between 0 and 3.
[0065] Based on the obtained network bandwidth information, the network performance score is calculated using the given formula. If the bandwidth is greater than or equal to 25Mbps, the full score is 3 points; otherwise, the score is calculated based on the bandwidth ratio, and the score range is between 0 and 3.
[0066] Add the CPU performance score, memory performance score, and network performance score together to get the pre-rendering performance score.
[0067] Specifically, the CPU performance score (out of 4 points):
[0068] Get the number of cores: Get the number of CPU cores through navigator.hardwareConcurrency.
[0069] CPU score calculation: If the number of cores is greater than or equal to 8, the full score is 4; otherwise, the score is calculated based on the core ratio, and the score range is between 0 and 4.
[0070] Memory performance score (out of 3 points):
[0071] Obtain available memory: Obtain the available heap memory of the context through performance.memory.jsHeapSizeLimit and performance.memory.totalJSHeapSize and convert it to GB.
[0072] Memory score calculation: If the available memory is greater than or equal to 3 GB, the full score is 3 points; otherwise, the score is calculated based on the available memory ratio, ranging from 0 to 3.
[0073] Network rating (out of 3 points):
[0074] Get the current network bandwidth: Get the network bandwidth through navigator.connection.downlink, in Mbps.
[0075] Network score calculation: If the bandwidth is greater than or equal to 25Mbps, the full score is 3 points; otherwise, the score is calculated based on the bandwidth ratio, ranging from 0 to 3.
[0076] The total score is the performance score calculation before rendering:
[0077] Total score = CPU performance score + memory performance score + network performance score.
[0078] These scores and calculation formulas can help evaluate the performance of the device before the first screen loads, so as to better understand the performance level of the system and take corresponding optimization measures when necessary to ensure good performance and user experience when the page loads.
[0079] Through this process, we can obtain information related to the performance of the device and calculate a comprehensive performance score based on this information, so that we can have a clear understanding of the performance status of the device before starting the rendering engine.
[0080] S120. Set performance score global variables.
[0081] In this embodiment, after the performance evaluation is completed, the rendering adjuster assigns the calculated performance score to a global variable score, and also sets a global variable isFirstRender to indicate whether it is the first rendering. The setting of these two global variables is to allow users to obtain this information in their own code and customize the rendering logic that meets their own needs according to their personal needs.
[0082] Users can use the global variable score to make corresponding logical judgments and optimizations based on the performance of the device, such as loading resources of different sizes and selecting different rendering methods based on different scores. The global variable isFirstRender can help users distinguish between the first rendering and non-first rendering, so as to execute the corresponding logic.
[0083] By using these global variables, users can flexibly customize their rendering logic in code according to the device's performance score and first rendering status to provide better user experience and performance optimization.
[0084] S130, determining whether there is a subscription callback function currently.
[0085] In one embodiment, the above-mentioned step S130 may include steps S131 - S133 .
[0086] S131, determine whether the callback function is currently subscribed through the subscribe method;
[0087] S132, if the callback function is subscribed to through the subscribe method, determining that the subscription callback function currently exists;
[0088] S133. If the callback function is not subscribed to through the subscribe method, it is determined that there is no subscription callback function currently.
[0089] In this embodiment, the subscriber function is a common design pattern used to implement the event subscription and publishing mechanism. In this pattern, an array storing user subscription functions is maintained globally. When a specific event occurs, the subscribed functions will be called in sequence. The following is a detailed description of the subscriber function:
[0090] Array for storing subscription functions: A global array is maintained, usually named subscribers or a similar name, to store functions subscribed by users.
[0091] subscribe method: When the user calls the subscribe method, the subscription function passed in by the user will be added to the global array. In this way, when a specific event occurs, the subscription function stored in the global array will be executed.
[0092] off method: Users can call the off method and pass in a function, which will be found and removed from the global array. This means that users can unsubscribe from a specific function and prevent it from being executed when an event occurs.
[0093] Execute subscription functions: At a specific time (such as after the performance evaluation is completed and before the user code is executed), all subscription functions in the global array will be called one by one to execute the pre-subscribed operations or logic.
[0094] User code operations: When the subscription functions are called, users can perform various operations in these functions, such as adjusting the required parameters of materials, textures, etc., or executing other necessary logic.
[0095] Through the subscriber function, users can predefine a series of operations to be performed at a specific time, making the execution logic of the code more flexible and scalable. This mode is often used in event-driven programming scenarios to help achieve decoupling and enhance the maintainability of the code.
[0096] S140: If there are currently subscription callback functions, all callback functions are executed.
[0097] In this embodiment, the callback function is executed to modify the rendering parameters of the material and texture.
[0098] Specifically, users can define subscription callback functions to modify the rendering parameters of materials and textures; users can subscribe to the above callback functions by calling the subscribe method; if they need to unsubscribe, they can call the off method. Through this implementation, when a specific time is triggered (such as after the performance evaluation is completed), the subscription function in the global array will be executed, thereby achieving the purpose of modifying the rendering parameters of materials and textures. This mode allows users to flexibly adjust the rendering parameters at predefined times while maintaining the maintainability and extensibility of the code.
[0099] S150, performing scene rendering according to the pre-rendering performance score and various rendering parameters.
[0100] In one embodiment, the above-mentioned step S150 may include steps S151 - S152 .
[0101] S151, determining a rendering strategy according to the performance score before rendering and various rendering parameters;
[0102] S152: Perform scene rendering according to the rendering strategy.
[0103] The above content can be implemented by the rendering strategy adjuster, which is used after the performance test is completed. It mainly provides two functions:
[0104] Provides performance test result scores and variables for whether it is the first rendering, so that developers can make adjustments based on these parameters during development.
[0105] Provides a subscription API, users can subscribe to functions through the subscribe method (and unsubscribe with the off method). These functions will be called after each performance score is measured, and users can adjust rendering strategies and customize some behaviors based on the score.
[0106] The rendering strategy includes three device performance ratings: high, medium, and low.
[0107] The high-performance rendering strategy is:
[0108] High-resolution rendering: Use high-resolution settings and complex lighting and shadow effects to provide the highest quality visual experience;
[0109] Detailed Textures and Materials: Load high-quality textures and complex materials to increase the realism and detail of your scenes;
[0110] Advanced Effects: Enable advanced rendering effects such as ambient occlusion, dynamic shadows, and reflections to enhance the visual quality and immersion of your scenes.
[0111] The medium performance rendering strategy is:
[0112] Medium resolution: Moderately lowers the rendering resolution to balance performance and visual quality;
[0113] Optimize textures and materials: Use medium-quality textures and simplified materials to reduce rendering burden while maintaining visual effects;
[0114] Balanced Effects: Enables some rendering effects, but avoids overly complex processing, such as simplifying lighting and shadow effects, to maintain smooth rendering performance.
[0115] The low performance rendering strategy is:
[0116] Low-resolution rendering: significantly reduce the rendering resolution to reduce rendering burden and improve performance;
[0117] Basic textures and materials: Use low-quality textures and more basic materials to reduce GPU and memory usage;
[0118] Minimal effects: Turn off most advanced effects and keep only basic lighting and color processing to ensure a good user experience even on low-performance devices.
[0119] Through such rendering strategy adjustments, the best visual effects and user experience can be provided according to different device performance. At the same time, the subscription-based API also allows developers to dynamically adjust the rendering strategy based on real-time performance evaluation results to optimize performance and user experience.
[0120] S160. When the time set by the timer is reached, a performance test is performed in the worker thread after the first screen is loaded to obtain a performance score after rendering, and the setting of the performance score global variable is executed.
[0121] In this embodiment, when the time set by the timer is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested after the first screen is loaded in the worker thread to obtain a performance score after rendering, and the setting of the performance score global variable is executed.
[0122] In one embodiment, the above-mentioned step S160 may include steps S161 - S163 .
[0123] S161. When the time set by the timer is reached, the test code is run at each test point in the worker thread to collect corresponding data;
[0124] S161, calculating scores corresponding to CPU, GPU, available memory, network, user interaction frequency, and browser frame rate according to the data and the set scoring criteria;
[0125] S162: Summarize the scores to obtain a performance score after rendering, and execute the step of setting a performance score global variable.
[0126] In this embodiment, after the first screen is loaded, more comprehensive test points need to be considered. In order not to affect the main thread, the test code is run in the worker thread. The test includes evaluation of CPU, GPU, available memory, network, user interaction frequency and browser frame rate.
[0127] CPU performance score (out of 2 points):
[0128] The Fibonacci sequence is calculated using a recursive method. The shorter the task time, the higher the score. A full score of 2 points is awarded if the task is completed within 300ms. If it exceeds 300ms, the score is based on the completion time.
[0129] GPU performance score (out of 2 points):
[0130] Use OffscreenCanvas to render the scene and record the total rendering time to evaluate GPU performance. 2 points are given for rendering time within 150ms, 1.5 points for 150ms to 300ms, and 1 point for more than 300ms.
[0131] Memory and Network Rating:
[0132] The scoring method is consistent with the first screen loading, with full scores of 1 and 2 respectively.
[0133] User interaction frequency score (maximum 1 point):
[0134] The interaction frequency is evaluated based on the number of operations per minute such as clicks, rotation of the view, and selection of models by the user. A high-frequency operation is scored as 1 point if it is less than 15 times, and 0.5 points if it is more than 15 times.
[0135] Rendering frame rate score (full score 2 points):
[0136] The frame rate is evaluated by the number of requestAnimationFrame API calls, with 2 points for more than 50 frames, 1 point for 30 to 50 frames, and 0.5 points for less than 30 frames.
[0137] The total score is the performance score calculation after rendering:
[0138] Total score = CPU performance score + GPU performance score + network score + memory score + interaction frequency score + rendering frame rate score.
[0139] It should be noted that the CPU and GPU tests consume the most performance and are generally performed every 5 minutes; while the interaction frequency and frame rate tests consume less performance and can be recorded in real time, and the rating interval is consistent with the CPU and GPU tests.
[0140] If a subscription callback function currently exists, step S150 is executed.
[0141] In this embodiment, the performance detection module calculates the rendering strategy level of the device by analyzing factors such as processor capability, graphics card performance, memory size, network bandwidth, latency, user interaction frequency, and rendering frame rate, which are usually divided into three levels: high, medium, and low. According to this level, the rendering strategy adjuster dynamically adjusts rendering parameters such as image resolution, texture quality, and rendering quality.
[0142] Equipment performance levels are divided into 10 points:
[0143] High performance: Total score ≥ 8 (e.g., 8 points or more).
[0144] Moderate performance: 4 ≤ total score ≤ 7 (e.g., 4-7 points).
[0145] Low performance: Total score < 4 (e.g., below 4).
[0146] The total score is calculated by the performance detection module, which is comprehensively evaluated based on the test results of CPU performance, GPU performance, memory, network, user interaction frequency and rendering frame rate. According to the different ranges of the total score, the device is divided into three performance levels: high, medium and low, so that the subsequent rendering strategy adjuster can dynamically adjust the rendering parameters accordingly to provide the best user experience.
[0147] In addition, the method rendering method of this embodiment can implement performance testing before and after rendering, thereby ensuring that the user obtains the most suitable rendering experience for the current device during the entire use process. The reasons are as follows:
[0148] Comprehensive performance evaluation: This method obtains information such as the number of CPU cores, available memory, network bandwidth, etc. of the device before rendering, and calculates a comprehensive performance score based on this information to comprehensively evaluate the performance of the device.
[0149] Automatically adjust rendering strategy: Render the scene based on the pre-rendering performance score and various rendering parameters. By automatically adjusting the rendering strategy, a good rendering experience can be provided on devices with different performance levels.
[0150] Intelligent performance testing: Within the time set by the timer, the performance test after the first screen is loaded is performed in the worker thread, including testing the CPU, GPU, available memory, network, user interaction frequency, browser frame rate, etc., to obtain the performance score after rendering, thereby realizing intelligent performance evaluation.
[0151] Reduce user burden: Since rendering capability detection and adjustment are handled by automatically executed scripts, users do not need to manually adjust rendering parameters, thereby reducing the user's mental burden and allowing users to focus more on using the system.
[0152] Accurate performance evaluation: In addition to hardware performance, this method also takes into account factors such as network, frame rate, and user interaction frequency. The data obtained through measurement is more accurate than the user's subjective perception, thereby achieving accurate performance evaluation.
[0153] For example, suppose we have a web page or application that needs to automatically adjust the rendering strategy based on the performance of the device to achieve a better user experience. First, when starting the rendering engine, we perform a performance test on the system before the first screen loads, obtain information such as the number of CPU cores, available memory, and network bandwidth of the device, and then calculate the performance score. For example, suppose we get the following data:
[0154] Number of CPU cores: 4
[0155] Available memory: 4GB
[0156] Network bandwidth: 10 Mbps;
[0157] Based on this information, we can calculate the CPU performance score, memory performance score, and network score, and sum them up to get the performance score before rendering.
[0158] Next, we check if there is a subscription callback function. If there is a subscription callback function, we execute all callback functions, such as modifying the rendering parameters of materials and textures.
[0159] Then, the rendering strategy is determined based on the pre-rendering performance score and various rendering parameters, and the scene is rendered. For example, the rendering mode and image quality to be used are determined based on the performance score.
[0160] Finally, we perform performance testing after the first screen loads in the worker thread, obtain the performance score after rendering, and perform operations to set the performance score global variable. For example, we test the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate in the worker thread, and calculate the corresponding score according to the designed scoring criteria, and finally obtain the performance score after rendering.
[0161] The above-mentioned rendering method that can automatically adjust the rendering strategy, when starting rendering, first performs a performance test before the first screen is loaded, and sets a performance score global variable, combines whether a subscription callback function exists to determine various rendering parameters, combines various rendering parameters and the performance score before rendering to determine the rendering strategy and render the scene, and after rendering, performs a performance test after the first screen is loaded in the worker thread, resets the performance score global variable, and realizes automatic adjustment of the rendering strategy according to the rendering capability and interaction method, so as to provide the best user experience under different device and network conditions.
[0162] Figure 2 FIG. 3 is a schematic block diagram of a rendering device 300 capable of automatically adjusting a rendering strategy provided by an embodiment of the present invention. Figure 2 As shown, corresponding to the above rendering method capable of automatically adjusting the rendering strategy, the present invention also provides a rendering device 300 capable of automatically adjusting the rendering strategy. The rendering device 300 capable of automatically adjusting the rendering strategy includes a unit for executing the above rendering method capable of automatically adjusting the rendering strategy, and the device can be configured in a browser of a terminal. Figure 2 The rendering device 300 capable of automatically adjusting the rendering strategy includes a first performance detection unit 301 , a setting unit 302 , a judgment unit 303 , an execution unit 304 , a rendering unit 305 and a second performance detection unit 306 .
[0163] The first performance detection unit 301 is used to perform a performance detection on the system before the first screen is loaded when the rendering engine is started, so as to obtain a performance score before rendering; the setting unit 302 is used to set a performance score global variable; the judgment unit 303 is used to judge whether there is a subscription callback function currently; the execution unit 304 is used to execute all subscription callback functions if there is a subscription callback function currently; the rendering unit 305 is used to render the scene according to the performance score before rendering and various rendering parameters; the second performance detection unit 306 is used to perform a performance detection after the first screen is loaded in the worker thread when the time set by the timer is reached, so as to obtain a performance score after rendering, and execute the setting of the performance score global variable.
[0164] In one embodiment, the first performance detection unit 301 includes:
[0165] The relevant information acquisition subunit is used to obtain the number of CPU cores, available memory and network bandwidth of the device when starting the rendering engine to obtain performance related information; the score calculation subunit is used to calculate the CPU performance score, memory performance score and network score based on the performance related information, and sum them up to obtain the performance score before rendering.
[0166] In one embodiment, the determining unit 303 includes:
[0167] The function judgment subunit is used to judge whether the callback function is currently subscribed through the subscribe method; the first determination subunit is used to determine whether the subscription callback function currently exists if the callback function is subscribed through the subscribe method; the second determination subunit is used to determine whether the subscription callback function currently does not exist if the callback function is not subscribed through the subscribe method.
[0168] In one embodiment, the execution unit 304 is used to execute the callback function to modify the rendering parameters of the material and texture.
[0169] In one embodiment, the rendering unit 305 includes:
[0170] The strategy determination subunit is used to determine the rendering strategy according to the performance score before rendering and various rendering parameters; the scene rendering subunit is used to perform scene rendering according to the rendering strategy.
[0171] In one embodiment, the second performance detection unit 306 is used to test the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate after the first screen is loaded in the worker thread when the time set by the timer is reached to obtain a performance score after rendering, and execute the setting of the performance score global variable.
[0172] In one embodiment, the second performance detection unit 306 includes:
[0173] The collecting subunit is used to run the test code at each test point in the worker thread to collect corresponding data when the time set by the timer is reached; the scoring calculation subunit is used to calculate the scores corresponding to the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate according to the set scoring criteria based on the data; the summarizing subunit is used to summarize the scores to obtain the performance score after rendering, and execute the setting of the performance score global variable.
[0174] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the rendering device 300 and each unit that can automatically adjust the rendering strategy can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0175] The rendering device 300 capable of automatically adjusting the rendering strategy can be implemented in the form of a computer program. Figure 3 Runs on the computer device shown.
[0176] See also Figure 3 , Figure 3 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal.
[0177] See also Figure 3 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0178] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a rendering method that can automatically adjust a rendering strategy.
[0179] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0180] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a rendering method that can automatically adjust the rendering strategy.
[0181] The network interface 505 is used to communicate with other devices over the network. Figure 3The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0182] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:
[0183] When the rendering engine is started, a performance test is performed on the system before the first screen is loaded to obtain a performance score before rendering; a performance score global variable is set; it is determined whether a subscription callback function currently exists; if a subscription callback function currently exists, all callback functions are executed; the scene is rendered according to the performance score before rendering and various rendering parameters; when the time set by the timer is reached, a performance test is performed after the first screen is loaded in the worker thread to obtain a performance score after rendering, and the setting of the performance score global variable is executed.
[0184] In one embodiment, when the processor 502 implements the step of performing a performance test on the system before first screen loading to obtain a performance score before rendering when starting the rendering engine, the processor 502 specifically implements the following steps:
[0185] When the rendering engine is started, the number of CPU cores, available memory, and network bandwidth of the device are obtained to obtain performance-related information; the CPU performance score, memory performance score, and network score are calculated based on the performance-related information, and the scores are summed to obtain the performance score before rendering.
[0186] In one embodiment, when implementing the step of determining whether a subscription callback function currently exists, the processor 502 specifically implements the following steps:
[0187] Determine whether the callback function is currently subscribed through the subscribe method; if the callback function is subscribed through the subscribe method, it is determined that the subscription callback function currently exists; if the callback function is not subscribed through the subscribe method, it is determined that the subscription callback function currently does not exist.
[0188] In one embodiment, when the processor 502 implements the step of executing all callback functions, it specifically implements the following steps:
[0189] The callback function is executed to modify the rendering parameters of the material and texture.
[0190] In one embodiment, when the processor 502 implements the step of rendering the scene according to the pre-rendering performance score and various rendering parameters, the processor 502 specifically implements the following steps:
[0191] A rendering strategy is determined according to a performance score before rendering and various rendering parameters; and scene rendering is performed according to the rendering strategy.
[0192] In one embodiment, when the processor 502 performs the performance test after the first screen is loaded in the worker thread when the time set by the timer is reached to obtain the performance score after rendering, and executes the step of setting the performance score global variable, the processor 502 specifically implements the following steps:
[0193] When the timer set time is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
[0194] In one embodiment, when the processor 502 implements the step of performing the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate tests after the first screen is loaded in the worker thread when the time set by the timer is reached to obtain a performance score after rendering, and executes the step of setting the performance score global variable, the following steps are specifically implemented:
[0195] When the time set by the timer is reached, the test code is run at each test point in the worker thread to collect corresponding data; the scores corresponding to the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are calculated according to the data and the set scoring criteria; the scores are summarized to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
[0196] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0197] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0198] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:
[0199] When the rendering engine is started, a performance test is performed on the system before the first screen is loaded to obtain a performance score before rendering; a performance score global variable is set; it is determined whether a subscription callback function currently exists; if a subscription callback function currently exists, all callback functions are executed; the scene is rendered according to the performance score before rendering and various rendering parameters; when the time set by the timer is reached, a performance test is performed after the first screen is loaded in the worker thread to obtain a performance score after rendering, and the setting of the performance score global variable is executed.
[0200] In one embodiment, when the processor executes the computer program to implement the step of performing a performance test on the system before first screen loading to obtain a performance score before rendering when starting the rendering engine, the processor specifically implements the following steps:
[0201] When the rendering engine is started, the number of CPU cores, available memory, and network bandwidth of the device are obtained to obtain performance-related information; the CPU performance score, memory performance score, and network score are calculated based on the performance-related information, and the scores are summed to obtain the performance score before rendering.
[0202] In one embodiment, when the processor executes the computer program to implement the step of determining whether a subscription callback function currently exists, the processor specifically implements the following steps:
[0203] Determine whether the callback function is currently subscribed through the subscribe method; if the callback function is subscribed through the subscribe method, it is determined that the subscription callback function currently exists; if the callback function is not subscribed through the subscribe method, it is determined that the subscription callback function currently does not exist.
[0204] In one embodiment, when the processor executes the computer program to implement the step of executing all callback functions, the processor specifically implements the following steps:
[0205] The callback function is executed to modify the rendering parameters of the material and texture.
[0206] In one embodiment, when the processor executes the computer program to implement the step of rendering the scene according to the pre-rendering performance score and various rendering parameters, the processor specifically implements the following steps:
[0207] A rendering strategy is determined according to a performance score before rendering and various rendering parameters; and scene rendering is performed according to the rendering strategy.
[0208] In one embodiment, when the processor executes the computer program to implement the step of performing a performance test after the first screen is loaded in the worker thread when the time set by the timer is reached to obtain a performance score after rendering, and executing the step of setting a performance score global variable, the following steps are specifically implemented:
[0209] When the timer set time is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
[0210] In one embodiment, when the processor executes the computer program to implement the step of performing, in the worker thread, a test of the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate after the first screen is loaded when the time set by the timer is reached to obtain a performance score after rendering, and executing the step of setting a performance score global variable, the following steps are specifically implemented:
[0211] When the time set by the timer is reached, the test code is run at each test point in the worker thread to collect corresponding data; the scores corresponding to the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are calculated according to the data and the set scoring criteria; the scores are summarized to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
[0212] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0213] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0214] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0215] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0216] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0217] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A rendering method capable of automatically adjusting a rendering strategy, characterized in that: include: When the rendering engine is started, the system is tested for performance before the first screen loads to obtain a performance score before rendering; Set the performance score global variable; Determine whether there is a subscription callback function currently; If there are currently subscription callback functions, all callback functions will be executed; Render the scene based on the pre-rendering performance score and various rendering parameters; When the time set by the timer is reached, the performance test after the first screen loading is performed in the worker thread to obtain the performance score after rendering, and the setting of the performance score global variable is executed; When the rendering engine is started, the system is tested for performance before the first screen is loaded to obtain a performance score before rendering, including: When starting the rendering engine, obtain the number of CPU cores, available memory, and network bandwidth of the device to obtain performance-related information; Calculate a CPU performance score, a memory performance score, and a network score according to the performance-related information, and sum them up to obtain a performance score before rendering; The scene rendering is performed based on the pre-rendering performance score and various rendering parameters, including: Determine rendering strategy based on pre-rendering performance scores and various rendering parameters; The scene is rendered according to the rendering strategy.
2. A rendering method capable of automatically adjusting rendering strategy according to claim 1, characterized in that: The determining whether a subscription callback function currently exists includes: Determine whether the callback function is currently subscribed through the subscribe method; If the callback function is subscribed to through the subscribe method, it is determined that the subscription callback function currently exists; If the callback function is not subscribed to through the subscribe method, it is determined that there is no subscription callback function currently.
3. The rendering method capable of automatically adjusting rendering strategy according to claim 1, characterized in that: The execution of all callback functions includes: The callback function is executed to modify the rendering parameters of the material and texture.
4. The rendering method capable of automatically adjusting rendering strategy according to claim 1, characterized in that: When the time set by the timer is reached, the performance test after the first screen loading is performed in the worker thread to obtain the performance score after rendering, and the setting of the performance score global variable is executed, including: When the timer set time is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain the performance score after rendering, and the setting of the performance score global variable is executed.
5. A rendering method capable of automatically adjusting rendering strategy according to claim 4, characterized in that: When the timer setting time is reached, the CPU, GPU, available memory, network, user interaction frequency, and browser frame rate are tested in the worker thread after the first screen is loaded to obtain the performance score after rendering, and the setting of the performance score global variable is executed, including: When the timer reaches the time set, run the test code at each test point in the worker thread to collect the corresponding data; Calculate the scores of CPU, GPU, available memory, network, user interaction frequency, and browser frame rate according to the data and the set scoring criteria; The scores are aggregated to obtain a performance score after rendering, and the setting of the performance score global variable is performed.
6. A rendering device capable of automatically adjusting a rendering strategy, characterized in that: include: A first performance detection unit is used to perform a performance detection on the system before the first screen is loaded when the rendering engine is started, so as to obtain a performance score before rendering; Setting unit, used to set performance score global variables; A judgment unit, used to judge whether a subscription callback function currently exists; The execution unit is used to execute all the subscription callback functions if there are currently subscription callback functions; A rendering unit, used to render the scene based on the pre-rendering performance score and various rendering parameters; A second performance detection unit is used to perform a performance detection after the first screen is loaded in the worker thread when the time set by the timer is reached, so as to obtain a performance score after rendering, and execute the setting of the performance score global variable; Wherein, the first performance detection unit includes: The related information acquisition subunit is used to obtain the number of CPU cores, available memory and network bandwidth of the device when starting the rendering engine to obtain performance related information; A score calculation subunit, used to calculate a CPU performance score, a memory performance score and a network score according to the performance-related information, and sum them up to obtain a performance score before rendering; The scene rendering is performed based on the pre-rendering performance score and various rendering parameters, including: Determine rendering strategy based on pre-rendering performance scores and various rendering parameters; The scene is rendered according to the rendering strategy.
7. A computer device, characterized in that: The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 5 when executing the computer program.
