Model resource management method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202610147950.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-03
- Publication Date
- 2026-03-06
AI Technical Summary
[0003]然而,现有技术针对每个模型都会创建独立的几何体和材质资源,不同模型之间无法共享相同的模型资源,会造成严重的GPU性能浪费
[0009]本申请实施例提供的一种模型资源管理方法、装置、存储介质及电子装置,通过在目标场景发起资源删除请求时查找相应的目标模型资源,在确定目标模型资源存在的情况下基于目标模型资源的共享状态数据确定其共享状态,在确定目标模型资源处于未被共享状态的情况下对其进行删除,解决了删除资源时导致对其共享的模型渲染异常,进一步限制多模型之间共享资源导致的渲染性能浪费的问题,实现了提高模型资源的利用效率,节约计算机的渲染性能和内存。
Smart Images

Figure CN121616448A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a model resource management method, apparatus, storage medium, and electronic device. Background Technology
[0002] The visual scenes provided by computers are rendered from a series of models. Typically, the model data used for rendering is submitted to the CPU (Central Processing Unit) memory. The CPU then submits drawing instructions to the GPU (Graphics Processing Unit). The GPU retrieves the model data stored on the graphics card according to the drawing instructions, performs a series of transformations and shading, and finally outputs the rendered model resources, which are then loaded into the scene by the CPU. When a model is removed from the scene, the corresponding model data needs to be released promptly to reduce the occupation of storage resources.
[0003] However, current technology creates independent geometry and material resources for each model, preventing different models from sharing the same model resources and resulting in significant GPU performance waste. Furthermore, when a model is removed, related resources are immediately destroyed to free up memory. Therefore, if multiple models directly share the same resources, rendering errors in other models will occur when one model is removed. Summary of the Invention
[0004] This application provides a model resource management method, apparatus, storage medium, and electronic device, with the aim of improving the utilization efficiency of model resources and saving computer rendering performance and memory.
[0005] According to one aspect of the embodiments of this application, a model resource management method is provided, including: Locate the target model resource based on the resource deletion request initiated by the target scenario; If the existence of the target model resource is confirmed, the sharing status of the target model resource is determined based on the sharing status data of the target model resource; If the target model resource is in a non-shared state, delete the target model resource.
[0006] According to another aspect of the embodiments of this application, a model resource management apparatus is provided, comprising: The deletion search module is used to search for target model resources based on resource deletion requests initiated by the target scenario. A state determination module is used to determine the sharing state of the target model resource based on the sharing state data of the target model resource when it is determined that the target model resource exists. The resource deletion module is used to delete the target model resource when it is in an unshared state.
[0007] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein the program executes the model resource management method provided in any embodiment of the present invention when it is run.
[0008] According to another aspect of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the model resource management method provided in any embodiment of the present invention through the computer program.
[0009] This application provides a model resource management method, apparatus, storage medium, and electronic device. By searching for the corresponding target model resource when a resource deletion request is initiated in the target scene, determining its sharing status based on the sharing status data of the target model resource if it is determined to exist, and deleting the target model resource if it is determined to be in an unshared state, this solves the problem of abnormal rendering of shared models caused by resource deletion, and further limits the rendering performance waste caused by sharing resources among multiple models. This improves the utilization efficiency of model resources and saves computer rendering performance and memory. Attached Figure Description
[0010] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the hardware environment for a model resource management method according to an embodiment of this application; Figure 2 This is a flowchart of a model resource management method provided in an embodiment of the present invention; Figure 3 This is a flowchart of a model resource management method provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a model resource management device provided in an embodiment of the present invention; Figure 5This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0013] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0014] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0015] According to one aspect of the embodiments of this application, a model resource management method is provided. This model resource management method is widely used in whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned model resource management method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0016] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0017] This embodiment provides a model resource management method applied to a terminal device, preferably executed by the CPU of the terminal device. Figure 2 A flowchart of a model resource management method provided in an embodiment of the present invention includes the following steps: Step 210: Locate the target model resource based on the resource deletion request initiated by the target scenario.
[0018] The target scene can be a scene rendered from a model on a terminal device, and the scene content can be changed by loading or deleting model resources in the scene. A resource deletion request is a request initiated when model resources need to be deleted from the scene. The target model resource can be the model resource that needs to be deleted from the scene.
[0019] The target scene can be composed of models, each of which can contain at least one model resource, such as geometry or texture patterns. When a model needs to be removed from the target scene, a resource deletion request can be initiated for that model or its contained target model resources. Therefore, based on the resource deletion request, the target model resources or their associated target model resources can be searched. When loading a model into the target scene, the model resources contained within the model can be drawn on the GPU based on the model data and then fed back to the CPU for loading and storage. Typically, the model resources contained in the loaded models in the target scene can be found.
[0020] In an optional implementation, the resource deletion request may include resource identification information of the target model resource. The resource identification information may be the name, storage address, and / or any information that can uniquely identify the target model resource; no limitation is made here. The target model resource can be uniquely located based on this resource identification information. This resource identification information may be generated when the target model resource is initially created and may be provided to the target scenario so that the target scenario can initiate a resource deletion request for the target model resource based on this identification information.
[0021] In an optional implementation, before searching for the target model resource based on the resource deletion request initiated by the target scenario, the method may further include: generating a resource feature identifier for the target model resource based on the resource feature data of the target model resource; and providing the resource feature identifier to the target scenario so that the target scenario can initiate a resource deletion request based on the resource feature identifier.
[0022] Resource feature data can be data describing the characteristics of the target model resource. Resource feature identifiers can be data generated based on the characteristics of the target model resource and can be used to uniquely identify the target model resource.
[0023] Resource feature data can include data describing the content characteristics of model resources, or data describing the format or storage characteristics of model resources; there are no restrictions here, but it is necessary to ensure that the resource feature data is different for each model resource. A resource feature identifier can be generated based on the resource feature data. This can be done by processing the entire content of the resource feature data in a specific way to obtain a resource feature identifier. The generated resource feature identifier is provided to the target scenario. When the target scenario determines that a model to be deleted contains the target model resource, it can inform the CPU of the target model resource's resource feature identifier through a resource deletion request, allowing the CPU to locate the corresponding target model resource based on the resource feature identifier.
[0024] In an optional implementation, the target model resource can be a static model resource created by importing model data using an external address. In this case, the resource feature data can be the URL (Uniform Resource Locator) of the model data. Generating a resource feature identifier for the target model resource based on its resource feature data can include: calculating an MD5 (Message-Digest Algorithm 5) hash value based on the URL of the target model resource, and determining the MD5 hash value as the resource feature identifier for the target model resource.
[0025] In one optional implementation, the target model resource can be a dynamic model resource, dynamically generated based on model data, and the resource feature data can be the content of the model data. Specifically, depending on the content of the input model data, the resource feature data can include geometric data such as vertices, colors, normals, and UV coordinates (texture coordinates) from the model data. Generating a resource feature identifier for the target model resource based on its resource feature data can include: calculating an MD5 hash value from the geometric data of the target model resource, and determining the MD5 hash value as the resource feature identifier of the target model resource. Alternatively, the resource feature data can be image data from the model data. Generating a resource feature identifier for the target model resource based on its resource feature data can include: calculating an MD5 hash value from all pixel data of the image data of the target model resource, and determining the MD5 hash value as the resource feature identifier of the target model resource.
[0026] In an optional implementation, finding the target model resource based on the resource deletion request initiated by the target scenario may include: comparing the resource feature identifier in the resource deletion request with the resource feature identifiers of each stored model resource; the model resource whose comparison result is consistent can be identified as the target model resource.
[0027] The above implementation method initiates resource deletion requests and searches for created model resources by using resource feature identifiers of model resources. This can reduce the amount of computation in model resource management, improve the execution efficiency of the method, and save CPU performance.
[0028] In an optional implementation, the resource deletion request may further include identification information of the target model to be deleted in the target scene. Based on the identification information of the target model to be deleted in the resource deletion request, the success of the target model resource search can be verified by checking whether the found target model resource is included in the target model. Alternatively, after the target model is deleted, the usage of the target model resource by each model in the target scene can be determined.
[0029] Step 220: If the existence of the target model resource is confirmed, determine the sharing status of the target model resource based on the sharing status data of the target model resource.
[0030] Shared state data can be data describing whether the target model resource is used simultaneously by multiple models in the target scenario.
[0031] When multiple models loaded in the target scene all contain the same model resource, the GPU does not need to repeatedly render that model resource. Instead, it is initially rendered, fed back to the CPU, and loaded, then stored. This allows the CPU to directly use the stored model resource when loading multiple models subsequently. Therefore, the shared state of model resources can be recorded through shared state data. Shared state data can be data recording the association between the target model resource and the models that use the target model resource, data recording information about the models that use the target model resource, or data recording the number of models that use the target model resource, etc., without limitation.
[0032] In an optional implementation, after searching for the target model resource based on the resource deletion request initiated by the target scenario, the method may further include: if it is determined that the target model resource does not exist, returning an exception prompt data to the target scenario.
[0033] Among them, the error message data can be used to indicate that there is an error in the response to this resource deletion request.
[0034] In the event of an exception during the rendering process, the target model resource is searched based on the resource deletion request. If it cannot be found, and the target model resource does not exist, an exception message can be returned to the target scene so that the target scene can proceed to the next step, or the exception can be handled to avoid the entire rendering process being halted.
[0035] In an optional implementation, the exception message data may be a logical deletion flag of the target model resource. After locating the target model resource based on the resource deletion request initiated by the target scenario, the implementation may further include: if it is determined that the target model resource does not exist, setting the logical deletion flag of the target model resource to False; returning exception message data to the target scenario may include: returning the logical deletion flag to the target scenario.
[0036] The logical deletion flag can be a preset boolean value, used to indicate whether the target model resource can be successfully deleted. If the target model resource does not exist, it means that a normal response cannot be given to the resource deletion request. Therefore, the logical deletion flag can be set to False and returned to the target scenario as an error message.
[0037] Step 230: If the target model resource is in an unshared state, delete the target model resource.
[0038] The "not shared" state can be a state where the target model resource is only contained in one model that has been loaded in the target scene and is not shared by multiple models.
[0039] The fact that the target model resource is in a non-shared state indicates that only the model that needs to be deleted uses the target model resource in the target scene. Therefore, the target model resource can be deleted directly to release the memory space it occupies without affecting the rendering of other models in the target scene.
[0040] In an optional implementation, after deleting the target model resource, the process may further include: returning deletion request response data to the target scene.
[0041] The deletion request response data can be data used to indicate that the resource deletion request has been successfully completed.
[0042] After deleting the target model resource, the response to the resource deletion request initiated by the target scenario has been completed. Therefore, the deletion request response data can be returned to the target scenario so that the target scenario can determine that the relevant operation in response to the resource deletion request of the target model resource has been completed, and continue the subsequent related processes.
[0043] In an optional implementation, after deleting the target model resources, the process may further include sending a resource deletion command to the GPU. After the CPU confirms the deletion of the target model resources, a resource deletion command can be sent to the GPU to control the GPU to delete the relevant data of the target model resources during the creation process, thereby freeing up GPU memory resources and performance.
[0044] In an optional implementation, after determining the sharing status of the target model resource based on the sharing status data of the target model resource, the method may further include: if the target model resource is in a shared state, retaining the target model resource and returning deletion request response data to the target scene; and updating the sharing status data based on the resource deletion request.
[0045] The shared state can be a state in which the target model resource is contained in multiple models that have been loaded in the target scene and is shared by multiple models.
[0046] The fact that the target model resource is shared indicates that other models in the target scene are also using it, besides the model that needs to be deleted. Deleting the target model resource at this point would cause rendering errors in other models using it. Therefore, the target model resource should be retained.
[0047] At this point, although the target model resource is retained, the response to the resource deletion request has been completed. Therefore, deletion request response data can be returned to the target scenario. Furthermore, the shared state data needs to be updated based on the resource deletion request to record in the shared state data that the deleted model is no longer using the target model resource.
[0048] In an optional implementation, the deletion request response data may be a logical deletion flag of the target model resource. After locating the target model resource based on the resource deletion request initiated by the target scenario, the process may further include: if it is determined that the target model resource exists, setting the logical deletion flag of the target model resource to True; returning the deletion request response data to the target scenario may include: returning the logical deletion flag to the target scenario.
[0049] The existence of the target model resource indicates that a normal response can be given to the resource deletion request. Therefore, the logical deletion flag can be set to True and returned to the target scenario as the deletion request response data.
[0050] The above implementation method, by setting a Boolean-type logical deletion flag, achieves efficient and timely feedback of the response status of resource deletion requests to the target scenario with concise logic and data content, thereby improving the efficiency and performance of model resource management.
[0051] In one optional implementation, the shared status data may include the number of associations. Accordingly, determining the shared status of the target model resource based on its shared status data may include: decrementing the number of associations of the target model resource by 1; and determining that the target model resource is in a shared state if the number of associations is greater than 0.
[0052] The number of relationships can be the number of models that have been loaded in the target scene and use the target model resources.
[0053] The number of models using the target model resource in the target scenario is recorded by the number of relationships. Based on the resource deletion request initiated by the target scenario, it can be determined that one fewer model is using the target model resource in the target scenario. Therefore, the number of relationships can be decremented by 1. If the number of relationships is still greater than 0 after decrementing by 1, it indicates that besides the model deleted in this resource deletion request, other models in the target scenario also use the target model resource. This confirms that the target model resource is in a shared state.
[0054] In an optional implementation, after decrementing the number of associations of the target model resource by 1, the method may further include: when the number of associations reaches 0, detecting resource loading requests from the target scene for the target model resource within a preset delay time; and when no resource loading request is detected, determining that the target model resource is in an unshared state.
[0055] The preset delay time can be a pre-set waiting time based on the needs of rendering performance. A resource loading request can be a request initiated when model resources need to be loaded in the scene.
[0056] When the number of associations reaches 0 after decrementing by 1, it indicates that only the model deleted in this resource deletion request used the target model resource in the target scenario, and no other models used the target model resource. In this case, we can wait for a resource loading request initiated by the target scenario within a preset delay time. If no resource loading request for the target model resource is detected within the preset delay time, it means that there are currently no new models that need to use the target model resource, so it can be determined that it is in an unshared state and can be deleted directly.
[0057] In one optional implementation, the preset delay time can be the preset frame loading time of the target scene. The preset frame loading time can be the time required to load the preset number of frames in the target scene. Each time the target scene loads one frame, it may include making different changes to different models, thereby initiating corresponding resource loading requests or resource deletion requests. Therefore, the preset delay time, determined based on the preset frame loading time, can be used to detect whether the target scene initiates a new resource loading request for the target model resources within the preset frame loading time.
[0058] The above implementation method, when it is determined that there are no models in the current target scene that need to use the target model resources, can continue to wait for the resource loading request initiated by the target scene within a preset delay time. If it is determined that there are no new models that need to use the target model resources to be loaded within the preset delay time, then it is determined that the target model resources are in an unshared state. This avoids the problem of needing to recreate the target model resources within the preset delay time after they are deleted, as well as the risk of rendering anomalies in newly loaded models that need to use the target model resources during the deletion process, thus ensuring that the timing of resource deletion is appropriate.
[0059] In an optional implementation, after detecting a resource loading request from the target scene for the target model resource within a preset delay time, the method may further include: upon detecting a resource loading request, incrementing the number of associations of the target model resource by 1 to determine that the target model resource is in a shared state.
[0060] If the target scene initiates a resource loading request for the target model resource within the preset delay time, it indicates that the target scene needs to load a new model, and this model needs to use the target model resource. The number of associations of the target model resource can be incremented by 1 accordingly, and it can be determined that the target model resource has changed to a shared state. At this time, the target model resource cannot be deleted, otherwise the target scene will need to load the target model resource again during the process of loading the new model, resulting in performance waste and the risk of abnormal rendering of the newly loaded model.
[0061] The above embodiments provide a model resource management method, including a method for deleting model resources. This method enables the timely deletion of model resources when they are not in use, thereby releasing the memory they occupy. It also avoids the problem of simultaneous deletion of model resources when multiple models share the same model resource, which could cause rendering errors in other models. Correspondingly, optionally, embodiments of the present invention may further include a method for loading model resources within the model resource management method.
[0062] In an optional implementation, before searching for the target model resource based on the resource deletion request initiated by the target scenario, the method may further include: searching for the target model resource based on the resource loading request initiated by the target scenario; if the target model resource exists, loading the target model resource into the target scenario; and updating the shared state data of the target model resource based on the resource loading request, so that the shared state data can be used to determine that the target model resource is in a shared state.
[0063] If a new model needs to be loaded in the target scene, a resource loading request can be initiated based on the target model resources required by the model. The resource loading request is used to search for the target model resources. If the existence of the target model resources is confirmed, it means that the target model resources have already been loaded into the models already loaded in the target scene. Therefore, the already created target model resources can be directly loaded into the newly loaded model in the target scene.
[0064] Furthermore, the newly loaded model in the target scene becomes the model using the target model resource. Therefore, the shared state data of the target model resource can be updated so that the shared state data can record the shared state of the target model resource. The method of updating the shared state data can be determined based on the content of the shared state data. For example, it could be adding the association between the target model resource and the newly loaded model, or recording relevant information about the newly loaded model, or incrementing the number of models that use the target model resource by 1. There is no limitation here.
[0065] In an optional implementation, updating the shared state data of the target model resource according to the resource loading request, so that the shared state data can be used to determine that the target model resource is in a shared state, may include: incrementing the number of associations of the target model resource by 1.
[0066] The number of associations can be the number of models that have been loaded in the target scene and use the target model resources. If a newly loaded model in the target scene uses the target model resources, the number of associations can be incremented by 1.
[0067] In an optional implementation, after incrementing the number of associations for the target model resource by 1, it may further include: establishing an association between the target model resource and the target model object.
[0068] The target model object can be the loading location or object of a target model resource in a newly loaded model within the target scene. When the target model resource is a geometric resource, the target model object can be a virtual node created based on the model data, recording the model resource's ID (Identifier) and the matrix information of the geometric transformations required to load it into the model. When the target model resource is a texture resource, the target model object can be the object on which the texture is loaded, including the surface portion of the model that needs to display the texture. By establishing the association between the target model resource and the target model object, the target model resource can be quickly associated when a model is deleted.
[0069] In an optional implementation, before searching for the target model resource based on the resource deletion request initiated by the target scenario, the method may further include: searching for the target model resource based on the resource loading request initiated by the target scenario; creating the target model resource if it is determined that the target model resource does not exist; loading the created target model resource into the target scenario; and configuring shared state data for the target model resource based on the resource loading request, so that the shared state data is used to determine that the target model resource is in an unshared state.
[0070] The absence of the target model resource indicates that no model using the target model resource has been loaded in the target scene, the target model resource has not been created, and it cannot be obtained directly. Therefore, the target model resource needs to be created, and then loaded into the corresponding model in the target scene to complete the rendering of the model in the target scene.
[0071] Furthermore, shared state data can be configured for the newly created target model resource to record whether the target model resource is used simultaneously by multiple models in the target scene. In this case, only the newly loaded model in the target scene uses the newly created target model resource; therefore, the shared state data of the target model resource can be configured to describe the target model resource as being in a non-shared state.
[0072] In an optional implementation, configuring shared state data for the target model resource based on the resource loading request, so that the shared state data is used to determine that the target model resource is in a non-shared state, may include: configuring the number of associations for the target model resource to 1. In this case, only the newly loaded model in the target scene uses the target model resource, so the number of associations can be set to 1.
[0073] In an optional implementation, after setting the number of associations for the target model resource to 1, it may further include: establishing an association between the target model resource and the target model object.
[0074] It should be noted that creating a target model resource can specifically involve the CPU sending rendering instructions to the GPU. The GPU then renders the target model resource based on the corresponding model data and sends it back to the CPU. The CPU can then load the target model resource provided by the GPU into the corresponding model in the target scene and store it, thus completing the creation of the target model resource in the CPU. When the target scene subsequently requests to load the target model resource again, it can find the already created target model resource without needing to send instructions to the GPU again to re-render it.
[0075] In an optional implementation, the resource loading request may include resource characteristic data of the target model resource, model data required to create the target model resource, and resource type of the target model resource for use when the target model resource needs to be created.
[0076] In a typical example Figure 3 This is a flowchart illustrating a model resource management method provided in an embodiment of the present invention. Figure 3 As shown, this method can be implemented through the interaction process between the scene end, feature calculation end, resource management end and resource release end in the CPU, which can be specifically divided into resource loading process and resource release process.
[0077] In the resource loading process, the scene can first pass the model data and resource types to be loaded, including geometric resources or texture resources, to the feature calculation terminal to calculate the data feature fingerprint and return a unique MD5 hash value. The feature fingerprint calculation process can include: if the input is a URL, the MD5 hash value is calculated directly based on the URL; if the input is geometric data such as vertices, colors, normals, and UV coordinates, all data are combined to calculate the MD5 hash value; if the input is image data, all pixel data are combined to calculate the MD5 hash value.
[0078] The scenario can use the returned feature code to send the feature code, original model data, and resource type to the resource management terminal to request the target model resource. The resource management terminal searches for the resource based on the feature code. If the corresponding resource exists, it determines the type based on the resource type. If it is a texture resource, the resource's reference count is incremented by 1, and the target resource is associated with the texture object. If it is a geometric resource, a virtual node is created, recording the resource's ID and matrix information, and the geometric resource's reference count is incremented by 1, while the target resource is associated with the virtual node. If the corresponding resource does not exist, a new shared resource is created based on the feature code, original data, and resource type. If it is a texture resource, the resource count is set to 1, and the target resource is associated with the texture object. If it is a geometric resource, a virtual node is created, recording the resource's ID and matrix information, and the geometric resource's reference count is set to 1, while the target resource is associated with the virtual node. Finally, the resource management terminal returns the target resource.
[0079] In the resource release process, the scene sends the signature code and shared object to be deleted to the resource management component, requesting resource deletion. The resource management component searches for the corresponding resource based on the signature code. If the resource is found, the logical deletion flag is set to True, and the reference count of the corresponding resource is decremented by 1. The resource management component then checks the current reference count of the resource. If the count is 0, the signature code and resource are added to the release list, and the current frame number is recorded. After a delay of N frames, if the scene does not request the resource again, the corresponding memory and video memory resources are released directly, and the logical deletion flag is returned. If the corresponding resource is not found, the logical deletion flag is returned directly.
[0080] This application provides a model resource management method, apparatus, storage medium, and electronic device. By searching for the corresponding target model resource when a resource deletion request is initiated in the target scene, determining its sharing status based on the sharing status data of the target model resource if it is determined to exist, and deleting the target model resource if it is determined to be in an unshared state, this solves the problem of abnormal rendering of shared models caused by resource deletion, and further limits the rendering performance waste caused by sharing resources among multiple models. This improves the utilization efficiency of model resources and saves computer rendering performance and memory.
[0081] According to another aspect of the embodiments of the present invention, Figure 4 This is a schematic diagram of the structure of a model resource management device provided in an embodiment of the present invention, as shown below. Figure 4 As shown, the device includes a deletion search module 410, a status determination module 420, and a resource deletion module 430, wherein: The deletion search module 410 is used to search for target model resources based on resource deletion requests initiated by the target scenario; The state determination module 420 is used to determine the sharing state of the target model resource based on the sharing state data of the target model resource when it is determined that the target model resource exists. The resource deletion module 430 is used to delete the target model resource when the target model resource is in an unshared state.
[0082] In an optional implementation, the model resource management device may further include: a resource retention module, configured to retain the target model resource and return deletion request response data to the target scene when the target model resource is in a shared state; and update the shared state data according to the resource deletion request.
[0083] In an optional implementation, the shared state data may include: the number of associations; the state determination module 420 may include: a quantity reduction unit, used to reduce the number of associations of the target model resource by 1; and a sharing determination unit, used to determine that the target model resource is in a sharing state when the number of associations is greater than 0.
[0084] In an optional implementation, the state determination module 420 may further include: a delay detection unit, used to detect resource loading requests from the target scene to the target model resource within a preset delay time when the number of associations reaches 0; and an unshared determination unit, used to determine that the target model resource is in an unshared state when no resource loading request is detected.
[0085] In an optional implementation, the model resource management device may further include: a loading search module, used to search for target model resources according to a resource loading request initiated by the target scene; a resource loading module, used to load the target model resources into the target scene if it is determined that the target model resources exist; and a status update module, used to update the shared status data of the target model resources according to the resource loading request, so that the shared status data can be used to determine that the target model resources are in a shared state.
[0086] In an optional implementation, the model resource management device may further include: a loading search module for searching for target model resources based on a resource loading request initiated by the target scene; a resource creation module for creating target model resources when it is determined that the target model resources do not exist; a creation loading module for loading the created target model resources into the target scene; and a status configuration module for configuring shared status data for the target model resources based on the resource loading request, so that the shared status data is used to determine that the target model resources are in an unshared state.
[0087] In an optional implementation, the model resource management device may further include: a feature identification module, used to generate a resource feature identifier for the target model resource based on the resource feature data of the target model resource; and to provide the resource feature identifier to the target scene so that the target scene can initiate a resource deletion request based on the resource feature identifier.
[0088] According to another aspect of the embodiments of the present invention, Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, such as... Figure 5 As shown, the electronic device includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of processors 510 in the electronic device can be one or more. Figure 5 Taking a processor 510 as an example; the processor 510, memory 520, input device 530, and output device 540 in the electronic device can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.
[0089] The memory 520, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the model resource management method in this embodiment of the invention (e.g., the deletion search module 410, the status determination module 420, and the resource deletion module 430 in the model resource management system). The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 520, thereby implementing the aforementioned model resource management method.
[0090] The memory 520 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 520 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include memory remotely located relative to the processor 510, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0091] Input device 530 can be used to receive input digital or character information, and generate key signal inputs related to user settings and function control of the electronic device. It can also be a camera for acquiring images and a sound pickup device for acquiring audio data. Output device 540 may include display devices such as a screen, and audio devices such as a speaker. It should be noted that the specific composition of input device 530 and output device 540 can be set according to actual conditions. Processor 510 executes various functional applications and data processing of the electronic device by running software programs, instructions, and modules stored in memory 520.
[0092] According to another aspect of the present invention, the present invention also provides a computer-readable storage medium comprising a stored program, wherein the program, when executed, performs the following model resource management method: Locate the target model resource based on the resource deletion request initiated by the target scenario; If the existence of the target model resource is confirmed, the sharing status of the target model resource is determined based on the sharing status data of the target model resource; If the target model resource is in a non-shared state, delete the target model resource.
[0093] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the method operations described above, but can also perform related operations in the model resource management method provided in any embodiment of the present invention.
[0094] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0095] It is worth noting that in the embodiments of the above-mentioned model resource management device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.
[0096] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A model resource management method characterized by comprising: The method comprises the following steps: According to the target scene initiated resource deletion request to find the target model resource; In the case of determining that the target model resource exists, according to the sharing state data of the target model resource to determine the sharing state of the target model resource; In the case of the target model resource being in the unshared state, deleting the target model resource.
2. The method of claim 1, wherein, After determining the sharing state of the target model resource according to the sharing state data of the target model resource, the method further comprises the following steps: In the case of the target model resource being in the shared state, retaining the target model resource and returning a deletion request response data to the target scene; According to the resource deletion request to update the sharing state data.
3. The method of claim 1, wherein, The sharing state data comprises an association relationship quantity. According to the sharing state data of the target model resource to determine the sharing state of the target model resource, comprising: Subtracting 1 from the association relationship quantity of the target model resource; In the case of the association relationship quantity being greater than 0, determining that the target model resource is in the shared state.
4. The method of claim 3, wherein, After subtracting 1 from the association relationship quantity of the target model resource, the method further comprises the following steps: In the case of the association relationship quantity reaching 0, detecting a resource loading request of the target scene to the target model resource within a preset delay time; In the case of not detecting the resource loading request, determining that the target model resource is in the unshared state.
5. The method of claim 1, wherein, Before the target model resource is found according to the resource deletion request initiated by the target scene, the method further comprises the following steps: According to the resource loading request initiated by the target scene to find the target model resource; In the case of determining that the target model resource exists, loading the target model resource to the target scene; According to the resource loading request to update the sharing state data of the target model resource, so that the sharing state data is used to determine that the target model resource is in the shared state.
6. The method of claim 1, wherein, Before the target model resource is found according to the resource deletion request initiated by the target scene, the method further comprises the following steps: According to the resource loading request initiated by the target scene to find the target model resource; In the case of determining that the target model resource does not exist, creating the target model resource; Loading the created target model resource to the target scene; According to the resource loading request to configure the sharing state data for the target model resource, so that the sharing state data is used to determine that the target model resource is in the unshared state.
7. The method of claim 1, wherein, Before the target model resource is found according to the resource deletion request initiated by the target scene, the method further comprises the following steps: According to the resource characteristic data of the target model resource, generating a resource characteristic identifier of the target model resource; Providing the resource characteristic identifier to the target scene, so that the target scene initiates the resource deletion request according to the resource characteristic identifier.
8. A model resource management apparatus characterized by comprising: The method comprises the following steps: A deletion finding module is configured to find a target model resource according to a resource deletion request initiated by a target scene; A state determining module is configured to determine a sharing state of the target model resource according to sharing state data of the target model resource when it is determined that the target model resource exists. A resource deleting module is configured to delete the target model resource when the target model resource is in an unshared state.
9. A computer readable storage medium, characterized in that, The computer readable storage medium comprises a stored program, and the program is configured to execute the model resource management method in any one of claims 1 to 7 when running. 10.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to execute the model resource management method in any one of claims 1 to 7 through the computer program. The memory stores a computer program, and the processor is configured to execute the model resource management method in any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Resource scheduling method and device, electronic equipment and computer readable storage medium
CN111026552A
Data processing method and device, equipment and medium
CN115292020A