A web-side dynamic rendering and processing method based on a three-dimensional scene model
By using interceptors and calculation threads to perform parallel rendering calculations in the rendering operation of the three-dimensional scene model, the performance degradation and frame reduction problems caused by excessive time in the main thread are solved, and more efficient rendering processing is achieved.
Patent Information
- Application Number
- CN202310148548.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2043-05-29
AI Technical Summary
In the Browser/Server structure, the rendering operation of the three-dimensional scene model takes up a lot of main thread time, resulting in a degradation in model performance and frame count.
Respond to rendering operations and switch states by adding it to the interceptor after the application is loaded. Then, create a calculation thread corresponding to the rendering operation, use the replica data to perform the rendering calculation in parallel, and the result is returned to the main thread and the calculation thread is destroyed.
By processing rendering calculations in parallel, the burden on the main thread is reduced, performance degradation and frame reduction are avoided, and the working efficiency of the model is improved.
Smart Images

Figure CN116342367B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer graphics technology, and particularly to a method for dynamic rendering processing of a 3D scene model on the web side. Background Art
[0002] In a Browser / Server (browser and server) architecture, if threejs or babylon has loaded the model and operations need to be performed on the scene involved in the model, it is necessary to calculate the required state that the model should reach in each frame of the application, and then perform operations on each frame. However, when there are many objects or complex transformations in the scene model, a large amount of time is spent calculating the final result in the frame, and then it can be written into the Graphics Processing Unit (GPU) of the graphics processor, resulting in a decline in the performance of the model and a reduction in the number of frames. Summary of the Invention
[0003] Aiming at the technical problem that operating on the scene model in the main thread in the prior art leads to a decline in the performance of the model and a reduction in the number of frames, the present invention provides a method for dynamic rendering processing of a 3D scene model on the web side.
[0004] To achieve the above objectives, the present invention is realized through the following technical solutions:
[0005] In a first aspect of an embodiment of the present invention, a method for dynamic rendering processing of a 3D scene model on the web side is provided, which is applied to the web front end. The method includes:
[0006] After the application program finishes loading the 3D scene model, add the 3D scene model to an interceptor, and in response to the rendering operation of the 3D scene model, switch the current state of the 3D scene model to the rendering state through the interceptor;
[0007] For the rendering state, create a calculation thread corresponding to the main thread of the rendering operation, and create copy data according to the data source and calculation rules corresponding to the main thread;
[0008] Keep running the main thread, and send the copy data to the calculation thread, so that the calculation thread and the main thread run in parallel to perform rendering calculations on the data source according to the calculation rules, and obtain the rendering calculation result corresponding to the 3D scene model;
[0009] Return the rendering calculation result to the main thread, and after sending the rendering calculation result is completed, destroy the calculation thread, and add the rendering calculation result to the renderer of the main thread, so that the renderer renders the frame loop in the 3D scene model according to the rendering calculation result.
[0010] In a preferred embodiment, before creating a computing thread corresponding to the main thread of the rendering operation and creating copy data according to the data source and computing rules corresponding to the main thread for the rendering state, it includes:
[0011] Obtain the minimum number of threads occupied by the frame loop in the main thread when running the three-dimensional scene model and the maximum number of threads occupied by the main thread during the rendering calculation;
[0012] Predict the stack space complexity when each sub-main thread in the main thread runs the frame loop through the main thread corresponding to the minimum number of threads;
[0013] Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads;
[0014] Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread;
[0015] Determine that the rendering complexity is greater than a preset complexity threshold;
[0016] The method further includes:
[0017] In the case where the rendering complexity is less than or equal to the preset complexity threshold, the renderer in the main thread performs rendering calculation on the data source according to the calculation rules to obtain the rendering calculation result corresponding to the three-dimensional scene model by the renderer in the main thread.
[0018] In a preferred embodiment, the step of predicting the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads includes:
[0019] In the case where the main thread performs rendering calculation with the maximum number of threads, predict the amount of call data of the data source called by each sub-main thread in the main thread;
[0020] Predict the coding calculation duration of each coding tree unit in each sub-main thread in the case of the corresponding amount of call data of each sub-main thread in the main thread; and,
[0021] Predict the waiting duration of each sub-main thread in the main thread for the rendering calculation of the previous sub-main thread to complete when the calculation of this sub-main thread starts;
[0022] Calculate the duration and the waiting duration according to the corresponding encoding, and determine the calculation depth of each encoding tree unit in each sub-main thread in the main thread during rendering calculation.
[0023] In a preferred embodiment, the step of predicting the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the current sub-main thread starts to calculate includes:
[0024] For each sub-main thread in the main thread, predict the number of sub-main threads that have performed rendering calculation before the current sub-main thread performs rendering calculation;
[0025] Obtain the average thread communication time consumption among the main threads in the main thread;
[0026] Determine the thread communication waiting duration of the current sub-main thread according to the corresponding number of sub-main threads and the average thread communication time consumption;
[0027] Predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the current sub-main thread starts to calculate according to the thread communication waiting duration corresponding to the current sub-main thread and the encoding calculation durations corresponding to the encoding tree units of the sub-main threads before the current sub-main thread.
[0028] In a preferred embodiment, the step of predicting the stack space complexity when each sub-main thread in the main thread runs when the frame loop is run through the main thread corresponding to the minimum number of threads includes:
[0029] Predict the remaining stack capacity of each sub-main thread in the main thread when the frame loop is run through the main thread corresponding to the minimum number of threads;
[0030] For any sub-main thread, take the one with the larger remaining stack capacity among the previous adjacent sub-main thread and the next adjacent sub-main thread of the current sub-main thread as the target adjacent sub-main thread;
[0031] Predict the overflow value generated by adding the remaining stack capacity of the current sub-main thread and the remaining stack capacity of the target adjacent sub-main thread;
[0032] Predict the stack space complexity when each sub-main thread in the main thread runs according to the size relationship between the overflow value and the preset stack capacity threshold.
[0033] In a preferred embodiment, the step of determining the rendering complexity of the main thread for the rendering operation according to the calculation depths and the stack space complexities corresponding to the sub-main threads in the main thread includes:
[0034] Based on the calculation depth, stack space complexity, and corresponding weights of each sub-main thread in the main thread, the rendering complexity of the main thread for the rendering operation is determined by weighting.
[0035] In a preferred embodiment, the step of returning the rendering calculation result to the main thread and destroying the calculation thread after sending the rendering calculation result includes:
[0036] When returning the rendering calculation result to the main thread, an inquiry request is sent to the interceptor, and the inquiry request is used to request the interceptor to send feedback information indicating that a new rendering operation has been intercepted;
[0037] During the process of returning the rendering calculation result to the main thread, continuously monitor whether the interceptor sends the feedback information;
[0038] After sending the rendering calculation result, if the feedback information has not been received yet, destroy the calculation thread.
[0039] In the second aspect of the embodiments of the present invention, a dynamic rendering processing device for a three-dimensional scene model web end is provided, which is applied to the Web front end. The device includes:
[0040] An adding module, configured to add the three-dimensional scene model to the interceptor after the application program finishes loading the three-dimensional scene model, and in response to the rendering operation of the three-dimensional scene model, switch the current state of the three-dimensional scene model to the rendering state through the interceptor;
[0041] A creating module, configured to create a calculation thread corresponding to the main thread of the rendering operation for the rendering state, and create copy data according to the data source and calculation rules corresponding to the main thread;
[0042] A parallel computing module, configured to keep the main thread running, and send the copy data to the calculation thread, so that the calculation thread and the main thread run in parallel to perform rendering calculations on the data source according to the calculation rules to obtain the rendering calculation result corresponding to the three-dimensional scene model;
[0043] A rendering module, configured to return the rendering calculation result to the main thread, and after sending the rendering calculation result, destroy the calculation thread, and add the rendering calculation result to the renderer of the main thread, so that the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result.
[0044] In a preferred embodiment, the device includes: a determination module configured to, before creating a calculation thread corresponding to the main thread of the rendering operation and creating copy data according to the data source and calculation rules corresponding to the main thread for the rendering state, obtain the minimum number of threads occupied by the frame loop in running the three-dimensional scene model by the main thread and the maximum number of threads occupied by the main thread in performing the rendering calculation;
[0045] Predict the stack space complexity when each sub-main thread in the main thread runs the frame loop through the main thread corresponding to the minimum number of threads;
[0046] Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads;
[0047] Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread;
[0048] Determine that the rendering complexity is greater than a preset complexity threshold;
[0049] The rendering module is further configured to, when the rendering complexity is less than or equal to the preset complexity threshold, perform rendering calculation on the data source by the renderer in the main thread according to the calculation rules to obtain the rendering calculation result corresponding to the three-dimensional scene model by the renderer in the main thread.
[0050] In a preferred embodiment, the determination module is configured to:
[0051] When the main thread performs rendering calculation with the maximum number of threads, predict the amount of call data of the data source called by each sub-main thread in the main thread;
[0052] Predict the encoding calculation duration of each coding tree unit in each sub-main thread in the case of the corresponding call data volume of each sub-main thread in the main thread; and,
[0053] Predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the calculation of this sub-main thread starts;
[0054] Determine the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation according to the corresponding encoding calculation duration and the waiting duration.
[0055] In a preferred embodiment, the determination module is configured to:
[0056] For each of the sub-main threads in the main thread, predict the number of sub-main threads that will perform rendering calculations before this sub-main thread performs rendering calculations;
[0057] Obtain the average thread communication time consumption among the main threads in the main thread;
[0058] Determine the thread communication waiting duration of this sub-main thread according to the corresponding number of sub-main threads and the average thread communication time consumption;
[0059] According to the thread communication waiting duration corresponding to this sub-main thread and the encoding calculation durations corresponding to each coding tree unit of the sub-main threads before this sub-main thread, predict the waiting duration for the rendering calculations of the sub-main threads waiting in front to be completed when this sub-main thread starts to calculate in the main thread.
[0060] In a preferred embodiment, the determining module is configured to:
[0061] Predict the remaining stack capacity of each sub-main thread in the main thread when running the frame loop through the main thread corresponding to the minimum number of threads;
[0062] For any one of the sub-main threads, use the one with the larger remaining stack capacity among the previous adjacent sub-main thread and the next adjacent sub-main thread of this sub-main thread as the target adjacent sub-main thread;
[0063] Predict the overflow value generated by adding the remaining stack capacity of this sub-main thread and the remaining stack capacity of the target adjacent sub-main thread;
[0064] Predict the stack space complexity of each sub-main thread in the main thread according to the magnitude relationship between the overflow value and the preset stack capacity threshold.
[0065] In a preferred embodiment, the determining module is configured to:
[0066] Weightedly determine the rendering complexity of the main thread for the rendering operation according to the calculation depths, stack space complexities, and corresponding weights of the sub-main threads in the main thread.
[0067] In a preferred embodiment, the rendering module is configured to:
[0068] When returning the rendering calculation result to the main thread, send an inquiry request to the interceptor, where the inquiry request is used to request the interceptor to send feedback information indicating that a new rendering operation has been intercepted;
[0069] During the process of returning the rendering calculation result to the main thread, continuously monitor whether the interceptor sends the feedback information;
[0070] After sending the rendering calculation result, if the feedback information has not been received yet, destroy the calculation thread.
[0071] A third aspect of the embodiments of the present invention provides an electronic device, including:
[0072] A processor;
[0073] A memory for storing executable instructions of the processor;
[0074] Wherein, the processor is configured to implement the steps of the method for dynamic rendering processing of the web end based on the three-dimensional scene model according to any one of the first aspects of the present disclosure when executing the executable instructions.
[0075] Beneficial effects
[0076] The present invention provides a method for dynamic rendering processing of the web end based on a three-dimensional scene model. Compared with the prior art, it has the following beneficial effects:
[0077] Through the above solution, after the application program finishes loading the three-dimensional scene model, add the three-dimensional scene model to the interceptor. In response to the rendering operation of the three-dimensional scene model, switch the current state of the three-dimensional scene model to the rendering state through the interceptor; create a calculation thread corresponding to the main thread of the rendering operation for the rendering state, create copy data according to the data source and calculation rules corresponding to the main thread; keep the main thread running, send the copy data to the calculation thread, and the calculation thread runs in parallel with the main thread to perform rendering calculations on the data source according to the calculation rules to obtain the rendering calculation result; return the rendering calculation result to the main thread, and after sending the rendering calculation result, destroy the calculation thread, add the rendering calculation result to the renderer of the main thread, and the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result. For the rendering operation, keep the main thread running and perform rendering calculations in parallel through the calculation thread without occupying the main thread. The main thread no longer needs to calculate complex data, reducing the pressure on the main thread, avoiding a decrease in model performance and frame rate, and improving the working efficiency of the model. Description of the drawings
[0078] The drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0079] Figure 1 It is a flowchart of a method for dynamic rendering processing of the web end based on a three-dimensional scene model shown according to an exemplary embodiment.
[0080] Figure 2 It is a flowchart of another method for dynamically rendering and processing a 3D scene model on the web side according to an exemplary embodiment.
[0081] Figure 3 It is a method for implementing Figure 2 step S23 in accordance with an exemplary embodiment.
[0082] Figure 4 It is a schematic diagram of asynchronous rendering of a 3D scene model according to an exemplary embodiment.
[0083] Figure 5 It is a structural block diagram of a device for dynamically rendering and processing a 3D scene model on the web side according to an exemplary embodiment. Detailed implementation manners
[0084] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0085] Please refer to Figure 1 , Figure 1 It is a flowchart of a method for dynamically rendering and processing a 3D scene model on the web side according to an exemplary embodiment. The method for dynamically rendering and processing a 3D scene model provided by the present invention can be applied to the Web front end. The method includes the following steps.
[0086] Step S11: After the application program finishes loading the 3D scene model, add the 3D scene model to the interceptor, and in response to the rendering operation of the 3D scene model, switch the current state of the 3D scene model to the rendering state through the interceptor;
[0087] Step S12: For the rendering state, create a calculation thread corresponding to the main thread of the rendering operation, and create copy data according to the data source and calculation rules corresponding to the main thread;
[0088] Step S13: Keep running the main thread, and send the copy data to the calculation thread, so that the calculation thread and the main thread run in parallel to perform rendering calculations on the data source according to the calculation rules to obtain the rendering calculation result corresponding to the 3D scene model;
[0089] Step S14: Return the rendering calculation result to the main thread. After sending the rendering calculation result is completed, destroy the calculation thread, and add the rendering calculation result to the renderer of the main thread, so that the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result.
[0090] In the embodiments of the present disclosure, after creating a scene object in the application program according to the three-dimensional scene model, add the scene object in the three-dimensional scene model to the interceptor, and change the state of the scene object through the interceptor to intercept the state information of the scene object, so as to implement proxy rendering.
[0091] Further, create a calculation thread. Data is transferred between the calculation thread and the main thread in the form of a copy. The main thread sends the data source and calculation rules to the calculation thread, and the main thread continues to execute downward. The calculation thread calculates the data source according to the instructions sent by the main thread, and sends the result back to the main thread after the calculation is completed, realizing asynchronous update of the scene.
[0092] Through the above solution, after the application program completes the loading of the three-dimensional scene model, add the three-dimensional scene model to the interceptor. In response to the rendering operation of the three-dimensional scene model, switch the current state of the three-dimensional scene model to the rendering state through the interceptor; create a calculation thread corresponding to the main thread of the rendering operation for the rendering state, and create copy data according to the data source and calculation rules corresponding to the main thread; keep the main thread running, send the copy data to the calculation thread, and the calculation thread runs in parallel with the main thread to perform rendering calculations on the data source according to the calculation rules to obtain the rendering calculation result; return the rendering calculation result to the main thread, and after sending the rendering calculation result is completed, destroy the calculation thread, and add the rendering calculation result to the renderer of the main thread, and the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result. For the rendering operation, keep the main thread running, and perform rendering calculations in parallel through the calculation thread, without occupying the main thread. The main thread no longer needs to calculate complex data, reducing the pressure on the main thread, avoiding a decrease in model performance and frame rate, and improving the working efficiency of the model.
[0093] In a preferred embodiment, as shown in Figure 2 Before creating a calculation thread corresponding to the main thread of the rendering operation and creating copy data according to the data source and calculation rules corresponding to the main thread for the rendering state, it includes:
[0094] Step S21: Obtain the minimum number of threads occupied by the main thread when running the frame loop in the three-dimensional scene model and the maximum number of threads occupied by the main thread when performing the rendering calculation.
[0095] Step S22: Predict the stack space complexity when each sub-main thread in the main thread runs while the frame loop runs through the main thread corresponding to the minimum number of threads.
[0096] Step S23: Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads.
[0097] Step S24: Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth corresponding to each sub-main thread in the main thread and the stack space complexity.
[0098] Step S25: Determine that the rendering complexity is greater than a preset complexity threshold.
[0099] The method further includes:
[0100] Step S26: In the case where the rendering complexity is less than or equal to the preset complexity threshold, the renderer in the main thread performs rendering calculation on the data source according to the calculation rule to obtain the rendering calculation result of the renderer in the main thread for the three-dimensional scene model.
[0101] In a preferred embodiment, as shown in Figure 3 Step S23, the step of predicting the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads includes:
[0102] Step S231: When the main thread performs rendering calculation with the maximum number of threads, predict the amount of call data of the data source called by each sub-main thread in the main thread.
[0103] Step S232: Predict the coding calculation duration of each coding tree unit in each sub-main thread in the case of the corresponding amount of call data of each sub-main thread in the main thread.
[0104] Step S233: Predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the calculation of this sub-main thread starts.
[0105] Step S234: According to the corresponding coding calculation duration and the waiting duration, determine the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation.
[0106] In a preferred embodiment, step S233, the step of predicting the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the sub-main thread waiting ahead when the current sub-main thread starts to calculate includes:
[0107] For each sub-main thread in the main thread, predict the number of sub-main threads that perform rendering calculations before the current sub-main thread performs rendering calculations;
[0108] Obtain the average thread communication time consumption among the main threads in the main thread;
[0109] According to the corresponding number of sub-main threads and the average thread communication time consumption, determine the thread communication waiting duration of the current sub-main thread;
[0110] According to the thread communication waiting duration corresponding to the current sub-main thread and the encoding calculation duration corresponding to each coding tree unit of the sub-main thread before the current sub-main thread, predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the sub-main thread waiting ahead when the current sub-main thread starts to calculate.
[0111] In a preferred embodiment, step S23, the step of predicting the stack space complexity when each sub-main thread in the main thread runs while the main thread runs the frame loop through the main thread corresponding to the minimum number of threads includes:
[0112] Predict the remaining stack capacity of each sub-main thread in the main thread when the main thread runs the frame loop through the main thread corresponding to the minimum number of threads;
[0113] For any one of the sub-main threads, use the one with the larger remaining stack capacity among the previous adjacent sub-main thread and the next adjacent sub-main thread of the current sub-main thread as the target adjacent sub-main thread;
[0114] Predict the overflow value generated by adding the remaining stack capacity of the current sub-main thread and the remaining stack capacity of the target adjacent sub-main thread;
[0115] According to the magnitude relationship between the overflow value and the preset stack capacity threshold, predict the stack space complexity when each sub-main thread in the main thread runs.
[0116] In a preferred embodiment, the step of determining the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread includes:
[0117] According to the calculation depth, the stack space complexity, and the corresponding weights corresponding to each sub-main thread in the main thread, determine the rendering complexity of the main thread for the rendering operation by weighted calculation.
[0118] In a preferred embodiment, the step of returning the rendering calculation result to the main thread and destroying the calculation thread after sending the rendering calculation result includes:
[0119] When returning the rendering calculation result to the main thread, send an inquiry request to the interceptor, where the inquiry request is used to request the interceptor to send feedback information indicating that a new rendering operation has been intercepted;
[0120] During the process of returning the rendering calculation result to the main thread, continuously monitor whether the interceptor sends the feedback information;
[0121] After sending the rendering calculation result, if the feedback information has not been received yet, destroy the calculation thread.
[0122] In the embodiments of the present disclosure, while ensuring the normal operation of the application program, the rendering operations that affect performance are removed from the frame loop in an asynchronous and proxy manner to reduce the calculation time of each frame of the main thread in the application program, thereby improving performance.
[0123] Among them, rendering operations can be performed through a Proxy proxy and a calculation thread. The calculation thread can be, for example, a WebWorker thread. The Proxy proxy can perform interception operations on scene objects. Only when the interception state changes will corresponding calculations be performed, instead of continuously asking whether the state has changed in the frame loop. A calculation thread is created to perform rendering operation calculations, especially for complex rendering operation calculations. This calculation thread can work in parallel with the main thread of the application program. The complex data source and calculation requirements are sent to the calculation thread, and the calculation thread performs data calculations according to the requirements of the main thread. After the calculation is completed, the calculation result is sent back to the main thread, and at the same time, the calculation thread is destroyed.
[0124] The proxy effectively changes the way of asking whether data needs to be updated to an interception method, eliminating the need to repeatedly judge whether the state has changed, reducing irrelevant calculations in the frame loop, and improving program performance; while the calculation thread changes the original serial calculation to an asynchronous parallel calculation, and the greatest effect is to reduce the pressure on the main thread. The main thread no longer needs to perform complex data calculations.
[0125] The technical solution of the present invention will be exemplarily described below through an embodiment. See Figure 4 As shown, after the main thread in the application program loads the three-dimensional scene model, state interception is performed on the scene object through an interceptor. For example, the scene object can be a camera object, an environmental scene object, or a renderer object. Then, in the case of intercepting a rendering operation for the scene object, the rendering complexity of the rendering operation is calculated through the Proxy proxy method.
[0126] Further, when the rendering complexity is greater than a preset complexity threshold, an asynchronous computing thread is established, and copy data is created according to the data source and computing rules corresponding to the main thread. Then, the main thread is kept running, and the copy data is sent to the computing thread. The computing thread runs in parallel with the main thread to perform rendering calculations on the data source according to the computing rules, and obtains the rendering calculation result corresponding to the three-dimensional scene model. After the computing thread calculates the rendering calculation result, the rendering calculation result is sent back to the main thread, and then the scene object is rendered in the renderer and added to the frame loop.
[0127] Further, when the rendering complexity is less than or equal to the preset complexity threshold, the property update calculation of the scene object is directly performed through the main thread, so that the scene object is rendered in the renderer and added to the frame loop.
[0128] An embodiment of the present invention provides a web-side dynamic rendering processing device based on a three-dimensional scene model, which is applied to the Web front end. Refer to Figure 5 As shown, the device 500 includes:
[0129] An adding module 510, configured to add the three-dimensional scene model to an interceptor after the application program finishes loading the three-dimensional scene model, and in response to a rendering operation of the three-dimensional scene model, switch the current state of the three-dimensional scene model to a rendering state through the interceptor;
[0130] A creating module 520, configured to create a computing thread corresponding to the main thread of the rendering operation for the rendering state, and create copy data according to the data source and computing rules corresponding to the main thread;
[0131] A parallel computing module 530, configured to keep the main thread running and send the copy data to the computing thread, so that the computing thread runs in parallel with the main thread to perform rendering calculations on the data source according to the computing rules, and obtains the rendering calculation result corresponding to the three-dimensional scene model;
[0132] A rendering module 540, configured to return the rendering calculation result to the main thread, and after sending the rendering calculation result is completed, destroy the computing thread, and add the rendering calculation result to the renderer of the main thread, so that the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result.
[0133] In a preferred embodiment, the apparatus 500 includes: a determination module configured to, before creating a calculation thread corresponding to the main thread of the rendering operation and creating copy data according to the data source and calculation rules corresponding to the main thread for the rendering state, obtain the minimum number of threads occupied by the frame loop in the main thread during running of the three-dimensional scene model and the maximum number of threads occupied by the main thread during the rendering calculation;
[0134] Predict the stack space complexity when each sub-main thread in the main thread runs the frame loop through the main thread corresponding to the minimum number of threads;
[0135] Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation when the main thread is in the case of the maximum number of threads;
[0136] Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread;
[0137] Determine that the rendering complexity is greater than a preset complexity threshold;
[0138] The rendering module 540 is further configured to, when the rendering complexity is less than or equal to the preset complexity threshold, perform rendering calculation on the data source by the renderer in the main thread according to the calculation rules, and obtain the rendering calculation result corresponding to the three-dimensional scene model by the renderer in the main thread.
[0139] In a preferred embodiment, the determination module is configured to:
[0140] Predict the amount of call data of the data source called by each sub-main thread in the main thread when the main thread performs rendering calculation with the maximum number of threads;
[0141] Predict the encoding calculation duration of each coding tree unit in each sub-main thread in the case of the corresponding amount of call data; and
[0142] Predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the calculation of this sub-main thread starts;
[0143] Determine the calculation depth of each coding tree unit in each sub-main thread in the main thread during rendering calculation according to the corresponding encoding calculation duration and the waiting duration.
[0144] In a preferred embodiment, the determination module is configured to:
[0145] For each of the sub-main threads in the main thread, predict the number of sub-main threads that will perform rendering calculations before this sub-main thread performs rendering calculations;
[0146] Obtain the average thread communication latency among the main threads in the main thread;
[0147] Determine the thread communication waiting duration of this sub-main thread based on the corresponding number of sub-main threads and the average thread communication latency;
[0148] Predict the waiting duration for the rendering calculations of the sub-main threads waiting in front to complete when this sub-main thread starts calculating, based on the thread communication waiting duration corresponding to this sub-main thread and the encoding calculation durations corresponding to the respective coding tree units of the sub-main threads before this sub-main thread.
[0149] In a preferred embodiment, the determining module is configured to:
[0150] Predict the remaining stack capacity of each sub-main thread in the main thread when running the frame loop through the main thread corresponding to the minimum number of threads;
[0151] For any one of the sub-main threads, use the one with the larger remaining stack capacity among the previous adjacent sub-main thread and the next adjacent sub-main thread of this sub-main thread as the target adjacent sub-main thread;
[0152] Predict the overflow value generated by adding the remaining stack capacity of this sub-main thread and the remaining stack capacity of the target adjacent sub-main thread;
[0153] Predict the stack space complexity of each sub-main thread in the main thread when running, based on the magnitude relationship between the overflow value and a preset stack capacity threshold.
[0154] In a preferred embodiment, the determining module is configured to:
[0155] Weightedly determine the rendering complexity of the main thread for the rendering operation based on the calculation depths, stack space complexities, and corresponding weights of the respective sub-main threads in the main thread.
[0156] In a preferred embodiment, the rendering module 540 is configured to:
[0157] When returning the rendering calculation result to the main thread, send an inquiry request to the interceptor, where the inquiry request is used to request the interceptor to send feedback information indicating that a new rendering operation has been intercepted;
[0158] During the process of returning the rendering calculation result to the main thread, continuously monitor whether the interceptor sends the feedback information;
[0159] After sending the rendering calculation result, if the feedback information has not been received yet, destroy the calculation thread.
[0160] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0161] Those skilled in the art should understand that the device embodiments described above are merely illustrative. For example, the division of modules is only a logical function division, and in actual module division, it is not limited by the above division method. Multiple modules can be combined or one module can be divided into multiple sub-modules.
[0162] In addition, the modules described as separate components may or may not be physically separated. And each module can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. When implemented using hardware, it can be implemented in whole or in part in the form of an integrated circuit or chip.
[0163] An embodiment of the present invention further provides an electronic device, including:
[0164] A processor;
[0165] A memory for storing executable instructions of the processor;
[0166] Wherein, the processor is configured to implement the steps of the method for dynamic rendering processing of a 3D scene model web end described in any one of the foregoing embodiments of the present disclosure when executing the executable instructions.
[0167] Taking the ideal embodiments based on this application as inspiration, through the above description, relevant staff can completely make various changes and modifications without departing from the technical idea of this application. The technical scope of this application is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.
[0168] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirits of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for dynamic rendering processing of a 3D scene model on the web side, characterized in that, Applied to the Web front end, the method includes: After the application program finishes loading the 3D scene model, add the 3D scene model to the interceptor, and in response to the rendering operation of the 3D scene model, switch the current state of the 3D scene model to the rendering state through the interceptor; For the rendering state, create a calculation thread corresponding to the main thread of the rendering operation, and create copy data according to the data source and calculation rules corresponding to the main thread; Keep running the main thread, and send the copy data to the calculation thread, so that the calculation thread and the main thread run in parallel to perform rendering calculations on the data source according to the calculation rules, and obtain the rendering calculation result corresponding to the 3D scene model; Return the rendering calculation result to the main thread, and after sending the rendering calculation result is completed, destroy the calculation thread, and add the rendering calculation result to the renderer of the main thread, so that the renderer renders the frame loop in the 3D scene model according to the rendering calculation result; Wherein, before creating a calculation thread corresponding to the main thread of the rendering operation and creating copy data according to the data source and calculation rules corresponding to the main thread for the rendering state, it includes: Obtain the minimum number of threads occupied by the main thread when running the frame loop in the 3D scene model and the maximum number of threads occupied by the main thread when performing the rendering calculation; Predict the stack space complexity when each sub-main thread in the main thread runs when the main thread runs the frame loop corresponding to the minimum number of threads; Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread when the main thread performs rendering calculations in the case of the maximum number of threads; Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread; Determine that the rendering complexity is greater than the preset complexity threshold; The method further includes: In the case where the rendering complexity is less than or equal to the preset complexity threshold, perform a rendering calculation on the data source by the renderer in the main thread according to the calculation rules, and obtain the rendering calculation result corresponding to the 3D scene model by the renderer in the main thread.
2. The method according to claim 1, characterized in that, The step of predicting the calculation depth of each coding tree unit in each sub-main thread in the main thread when the main thread performs rendering calculations in the case of the maximum number of threads includes: In the case where the main thread performs rendering calculations with the maximum number of threads, predict the amount of call data of the data source called by each sub-main thread in the main thread; Predict the coding calculation duration of each coding tree unit in each sub-main thread when each sub-main thread in the main thread performs rendering calculations in the case of the corresponding amount of call data; and Predict the waiting duration of each sub-main thread in the main thread for the rendering calculation of the previous sub-main thread to complete when the calculation of this sub-main thread starts. Calculate the duration and the waiting duration according to the corresponding encoding, and determine the calculation depth of each encoding tree unit in the sub-main thread in the main thread during rendering calculation.
3. The method according to claim 2, characterized in that, The step of predicting the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the current sub-main thread starts to calculate includes: For each sub-main thread in the main thread, predict the number of sub-main threads that have performed rendering calculation before the current sub-main thread performs rendering calculation; Obtain the average thread communication time consumption among the main threads in the main thread; Determine the thread communication waiting duration of the current sub-main thread according to the corresponding number of sub-main threads and the average thread communication time consumption; Predict the waiting duration for each sub-main thread in the main thread to wait for the rendering calculation of the previous sub-main thread to complete when the current sub-main thread starts to calculate according to the thread communication waiting duration corresponding to the current sub-main thread and the encoding calculation duration corresponding to each encoding tree unit of the sub-main thread before the current sub-main thread.
4. The method according to claim 1, characterized in that, The step of predicting the stack space complexity when each sub-main thread in the main thread runs when running the frame loop through the main thread corresponding to the minimum number of threads includes: Predict the remaining stack capacity of each sub-main thread in the main thread when running the frame loop through the main thread corresponding to the minimum number of threads; For any sub-main thread, use the one with the larger remaining stack capacity among the previous adjacent sub-main thread and the next adjacent sub-main thread of the current sub-main thread as the target adjacent sub-main thread; Predict the overflow value generated by adding the remaining stack capacity of the current sub-main thread and the remaining stack capacity of the target adjacent sub-main thread; Predict the stack space complexity when each sub-main thread in the main thread runs according to the magnitude relationship between the overflow value and the preset stack capacity threshold.
5. The method according to any one of claims 2 - 4, characterized in that, The step of determining the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread includes: Weightedly determine the rendering complexity of the main thread for the rendering operation according to the calculation depth, the stack space complexity, and the corresponding weights corresponding to each sub-main thread in the main thread.
6. The method according to claim 1, characterized in that, The step of returning the rendering calculation result to the main thread and destroying the calculation thread after sending the rendering calculation result includes: When returning the rendering calculation result to the main thread, send an inquiry request to the interceptor, and the inquiry request is used to request the interceptor to send feedback information indicating that a new rendering operation has been intercepted; During the process of returning the rendering calculation result to the main thread, continuously monitor whether the interceptor sends the feedback information; After sending the rendering calculation result, if the feedback information has not been received yet, destroy the calculation thread.
7. A web - end dynamic rendering and processing device based on a three - dimensional scene model, characterized in that, Applied to the Web front end, the device includes: An adding module, configured to add the three-dimensional scene model to an interceptor after the application finishes loading the three-dimensional scene model, and in response to a rendering operation of the three-dimensional scene model, switch the current state of the three-dimensional scene model to a rendering state through the interceptor; A creating module, configured to create a computing thread corresponding to the main thread of the rendering operation for the rendering state, and create copy data according to the data source and computing rules corresponding to the main thread; A parallel computing module, configured to keep the main thread running, and send the copy data to the computing thread, so that the computing thread and the main thread run in parallel to perform rendering calculations on the data source according to the computing rules to obtain a rendering calculation result corresponding to the three-dimensional scene model; A rendering module, configured to return the rendering calculation result to the main thread, and after sending the rendering calculation result is completed, destroy the computing thread, and add the rendering calculation result to a renderer in the main thread, so that the renderer renders the frame loop in the three-dimensional scene model according to the rendering calculation result; A determining module, configured to: before creating a computing thread corresponding to the main thread of the rendering operation for the rendering state and creating copy data according to the data source and computing rules corresponding to the main thread, obtain the minimum number of threads occupied by the main thread when running the frame loop in the three-dimensional scene model and the maximum number of threads occupied by the main thread when performing the rendering calculation in the main thread; Predict the stack space complexity when each sub-main thread in the main thread runs when the frame loop is run through the main thread corresponding to the minimum number of threads; Predict the calculation depth of each coding tree unit in each sub-main thread in the main thread when the main thread performs rendering calculations in the case of the maximum number of threads; Determine the rendering complexity of the main thread for the rendering operation according to the calculation depth and the stack space complexity corresponding to each sub-main thread in the main thread; Determine that the rendering complexity is greater than a preset complexity threshold; The rendering module is further configured to, when the rendering complexity is less than or equal to the preset complexity threshold, perform rendering calculations on the data source by the renderer in the main thread according to the computing rules to obtain a rendering calculation result corresponding to the three-dimensional scene model by the renderer in the main thread.
8. An electronic device, characterized in that, Comprising: A processor; A memory for storing processor-executable instructions; Wherein, the processor is configured to implement the steps of the method according to any one of claims 1-6 when executing the executable instructions.
Citation Information
Patent Citations
Page rendering method, device and equipment and computer readable storage medium
CN115982489A