Resource creation method and apparatus, electronic device, storage medium, and program product

CN120670159BActive Publication Date: 2026-08-07MOORE THREADS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
MOORE THREADS TECH CO LTD
Filing Date
2025-06-09
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0003]然而,在相关技术中,当显存资源不足或显存资源碎片化,而单个资源需求显存较大时,很容易出现分配显存失败的情况

Benefits of technology

[0056]在本公开实施例中,通过响应于资源创建请求,确定所述资源创建请求对应的显存请求量,响应于所述资源创建请求满足预设的划分条件,将所述资源创建请求映射为至少两个显存分配请求,其中,所述预设的划分条件至少包括:所述资源创建请求对应的显存请求量大于预设分配阈值,所述至少两个显存分配请求中的任一显存分配请求对应的显存请求量小于或等于所述预设分配阈值,根据所述至少两个显存分配请求,请求显存分配,得到所述至少两个显存分配请求对应的至少两项显存分配结果,并基于所述至少两项显存分配结果,创建所述资源创建请求对应的目标资源,由此在创建资源时,通过将一个显存请求量较大的资源创建请求映射为至少两个显存请求量较小的显存分配请求,能够提高显存分配的成功率,提高资源创建的成功率,从而不仅能够提高应用程序运行的稳定性,还能够提高在相同显存资源下同时运行的应用程序的数量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670159B_ABST
    Figure CN120670159B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a resource creation method, device, electronic equipment, storage medium and program product. The method comprises: in response to a resource creation request, determining a video memory request amount corresponding to the resource creation request; in response to the resource creation request satisfying a preset division condition, mapping the resource creation request into at least two video memory allocation requests; wherein the preset division condition at least includes: the video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; the video memory request amount corresponding to any video memory allocation request in the at least two video memory allocation requests is less than or equal to the preset allocation threshold; according to the at least two video memory allocation requests, requesting video memory allocation to obtain at least two items of video memory allocation results corresponding to the at least two video memory allocation requests; and based on the at least two items of video memory allocation results, creating a target resource corresponding to the resource creation request. The present disclosure can improve the success rate of resource creation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a resource creation method, resource creation apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology

[0002] In the field of image rendering, video memory allocation is a critical step in ensuring the normal operation of an application (APP). In related technologies, video memory allocation typically involves initiating a video memory allocation request when the application requests the creation of resources.

[0003] However, in related technologies, when video memory resources are insufficient or fragmented, and individual resources require a large amount of video memory, it is easy for video memory allocation to fail. Summary of the Invention

[0004] This disclosure provides a technical solution for resource creation.

[0005] According to one aspect of this disclosure, a method for creating a resource is provided, comprising:

[0006] In response to a resource creation request, determine the amount of video memory requested corresponding to the resource creation request;

[0007] In response to the resource creation request satisfying a preset partitioning condition, the resource creation request is mapped to at least two video memory allocation requests; wherein, the preset partitioning condition includes at least: the amount of video memory requests corresponding to the resource creation request is greater than a preset allocation threshold; and the amount of video memory requests corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold.

[0008] Based on the at least two memory allocation requests, request memory allocation and obtain at least two memory allocation results corresponding to the at least two memory allocation requests;

[0009] Based on the at least two memory allocation results, create the target resource corresponding to the resource creation request.

[0010] In one possible implementation,

[0011] The method further includes: for any one of the at least two video memory allocation requests, determining the description information of the video memory allocation request based on the feature information of the target resource and the video memory request amount corresponding to the video memory allocation request;

[0012] The step of requesting video memory allocation based on the at least two video memory allocation requests includes: for any one of the at least two video memory allocation requests, requesting video memory allocation based on the description information of the video memory allocation request.

[0013] In one possible implementation, requesting video memory allocation based on the description information of the video memory allocation request includes:

[0014] Based on the description information of the video memory allocation request, create a handle corresponding to the video memory allocation request;

[0015] Request memory allocation based on the handle corresponding to the memory allocation request.

[0016] In one possible implementation,

[0017] The step of responding to a resource creation request and determining the amount of video memory required for the resource creation request includes: determining the amount of video memory required for the resource creation request in response to a resource creation request via a user-mode driver.

[0018] The step of mapping the resource creation request to at least two video memory allocation requests in response to the resource creation request meeting the preset partitioning conditions includes: mapping the resource creation request to at least two video memory allocation requests through the user mode driver in response to the resource creation request meeting the preset partitioning conditions.

[0019] The step of requesting video memory allocation based on the at least two video memory allocation requests and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests includes: requesting video memory allocation based on the at least two video memory allocation requests through the user mode driver and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests;

[0020] The step of creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results includes: creating the target resource corresponding to the resource creation request through the user mode driver based on the at least two video memory allocation results.

[0021] In one possible implementation, the step of requesting video memory allocation based on the at least two video memory allocation requests by the user-mode driver, and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests, includes:

[0022] The user-mode driver sends the at least two video memory allocation requests to the runtime.

[0023] The runtime forwards the at least two video memory allocation requests to the kernel-mode driver.

[0024] The kernel-mode driver responds to the at least two video memory allocation requests and returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime.

[0025] The runtime forwards the at least two video memory allocation results to the user-driven mode.

[0026] In one possible implementation,

[0027] Before determining the amount of video memory required for a resource creation request in response to a resource creation request via a user-mode driver, the method further includes: forwarding the resource creation request to the user-mode driver in response to the resource creation request from the application via the runtime.

[0028] After creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results via the user-mode driver, the method further includes: returning the target resource to the application via the runtime.

[0029] According to one aspect of this disclosure, a resource creation apparatus is provided, comprising:

[0030] The first determining module is used to determine the amount of video memory requested corresponding to the resource creation request in response to the resource creation request;

[0031] A mapping module is used to map the resource creation request into at least two memory allocation requests in response to the resource creation request meeting a preset partitioning condition; wherein the preset partitioning condition includes at least: the amount of memory requests corresponding to the resource creation request is greater than a preset allocation threshold; and the amount of memory requests corresponding to any one of the at least two memory allocation requests is less than or equal to the preset allocation threshold.

[0032] The request module is configured to request video memory allocation based on the at least two video memory allocation requests, and obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests;

[0033] A creation module is used to create the target resource corresponding to the resource creation request based on the at least two video memory allocation results.

[0034] In one possible implementation,

[0035] The device further includes: a second determining module, configured to determine the description information of the video memory allocation request for any one of the at least two video memory allocation requests, based on the characteristic information of the target resource and the video memory request amount corresponding to the video memory allocation request;

[0036] The request module is used to: for any one of the at least two video memory allocation requests, request video memory allocation based on the description information of the video memory allocation request.

[0037] In one possible implementation, the request module is used to:

[0038] Based on the description information of the video memory allocation request, create a handle corresponding to the video memory allocation request;

[0039] Request memory allocation based on the handle corresponding to the memory allocation request.

[0040] In one possible implementation,

[0041] The first determining module is used to: determine the amount of video memory requested corresponding to the resource creation request in response to the resource creation request through a user-mode driver;

[0042] The mapping module is used to: map the resource creation request into at least two video memory allocation requests in response to the user mode driver meeting the preset partitioning conditions;

[0043] The request module is used to: request video memory allocation based on the at least two video memory allocation requests through the user mode driver, and obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests;

[0044] The creation module is used to: create the target resource corresponding to the resource creation request based on the at least two video memory allocation results through the user mode driver.

[0045] In one possible implementation, the request module is used to:

[0046] The user-mode driver sends the at least two video memory allocation requests to the runtime.

[0047] The runtime forwards the at least two video memory allocation requests to the kernel-mode driver.

[0048] The kernel-mode driver responds to the at least two video memory allocation requests and returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime.

[0049] The runtime forwards the at least two video memory allocation results to the user-driven mode.

[0050] In one possible implementation, the device further includes:

[0051] The forwarding module is used to forward the resource creation request to the user-mode driver in response to the resource creation request from the application at runtime.

[0052] The return module is used to return the target resource to the application via the runtime.

[0053] According to one aspect of this disclosure, an electronic device is provided, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to invoke the executable instructions stored in the memory to perform the method described above.

[0054] According to one aspect of this disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the above-described method.

[0055] According to one aspect of this disclosure, a computer program product is provided, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in an electronic device, a processor in the electronic device performs the above-described method.

[0056] In this embodiment, in response to a resource creation request, the amount of video memory requested corresponding to the resource creation request is determined. In response to the resource creation request satisfying a preset partitioning condition, the resource creation request is mapped to at least two video memory allocation requests. The preset partitioning condition includes at least: the amount of video memory requested corresponding to the resource creation request is greater than a preset allocation threshold; the amount of video memory requested corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold; video memory allocation is requested based on the at least two video memory allocation requests; at least two video memory allocation results are obtained corresponding to the at least two video memory allocation requests; and the target resource corresponding to the resource creation request is created based on the at least two video memory allocation results. Therefore, by mapping a resource creation request with a large amount of video memory requested to at least two video memory allocation requests with smaller amounts of video memory requested during resource creation, the success rate of video memory allocation and the success rate of resource creation can be improved. This not only improves the stability of application operation but also increases the number of applications running simultaneously with the same amount of video memory resources.

[0057] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure.

[0058] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description

[0059] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.

[0060] Figure 1 A flowchart illustrating a resource creation method provided in an embodiment of this disclosure is shown.

[0061] Figure 2 This diagram illustrates how a resource creation request is mapped to multiple video memory allocation requests in a resource creation method provided in an embodiment of this disclosure.

[0062] Figure 3 A schematic diagram of a resource creation method provided in an embodiment of this disclosure is shown.

[0063] Figure 4 Another schematic diagram of the resource creation method provided in the embodiments of this disclosure is shown.

[0064] Figure 5 A block diagram of a resource creation apparatus provided in an embodiment of this disclosure is shown.

[0065] Figure 6 A block diagram of an electronic device 1900 provided in an embodiment of this disclosure is shown. Detailed Implementation

[0066] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.

[0067] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.

[0068] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0069] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.

[0070] This disclosure provides a resource creation method. In response to a resource creation request, the method determines the amount of video memory requested corresponding to the request. In response to the resource creation request satisfying a preset partitioning condition, the method maps the resource creation request to at least two video memory allocation requests. The preset partitioning condition includes at least: the amount of video memory requested corresponding to the resource creation request is greater than a preset allocation threshold; the amount of video memory requested corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold; video memory allocation is requested based on the at least two video memory allocation requests; at least two video memory allocation results are obtained corresponding to the at least two video memory allocation requests; and a target resource corresponding to the resource creation request is created based on the at least two video memory allocation results. Therefore, by mapping a resource creation request with a large amount of video memory requested to at least two video memory allocation requests with smaller amounts of video memory requested during resource creation, the success rate of video memory allocation and resource creation can be improved. This not only improves the stability of application operation but also increases the number of applications running simultaneously with the same amount of video memory resources.

[0071] The resource creation method provided in the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.

[0072] Figure 1 A flowchart illustrating a resource creation method provided in an embodiment of this disclosure is shown. In one possible implementation, the entity executing the resource creation method may be a resource creation device, such as a terminal device, server, or other electronic device. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, or wearable device, etc. In some possible implementations, the resource creation method may be implemented by a processor calling computer-readable instructions stored in memory. Figure 1 As shown, the resource creation method includes steps S11 to S14.

[0073] In step S11, in response to the resource creation request, the amount of video memory requested corresponding to the resource creation request is determined.

[0074] In step S12, in response to the resource creation request satisfying a preset partitioning condition, the resource creation request is mapped to at least two video memory allocation requests; wherein, the preset partitioning condition includes at least: the amount of video memory requests corresponding to the resource creation request is greater than a preset allocation threshold; and the amount of video memory requests corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold.

[0075] In step S13, according to the at least two memory allocation requests, memory allocation is requested, and at least two memory allocation results corresponding to the at least two memory allocation requests are obtained.

[0076] In step S14, based on the at least two memory allocation results, the target resource corresponding to the resource creation request is created.

[0077] In this embodiment of the disclosure, when an application (APP) needs to create a new resource, it can initiate a resource creation request. Hereinafter, the resource requested by the application to be created will be referred to as the target resource.

[0078] In one possible implementation, the application can initiate a resource creation request by calling a graphics API (Application Programming Interface). For example, the graphics API could be Direct3D.

[0079] In one possible implementation, the resource creation request may include type information of the target resource.

[0080] In one possible implementation, the target resource includes at least one type: texture, buffer, or rendering target.

[0081] In this implementation, the resource type can be a texture, a buffer, a render target, etc., and there are no restrictions here.

[0082] In graphics rendering, textures are resources used to store image data that can be mapped onto the surface of a 3D model to provide detail and color information.

[0083] Buffers are data storage resources that can be used to store vertex data, index data, or other types of data that are used by the GPU during rendering. For example, depth buffers can store depth information to help determine which pixels should be rendered in front; constant buffers can store data that does not change frequently, such as transformation matrices and lighting parameters; index buffers can store vertex indices, which are used to determine which vertices make up a polygon; and so on.

[0084] A rendering target is a special buffer used to store the results of rendering operations. For example, a framebuffer is a common rendering target; it stores the final rendered image, which can be displayed on the screen or used for further processing.

[0085] In one possible implementation, the resource creation request may include characteristic information of the target resource, which may include the size of the target resource. For example, an app might need to create a 64MB texture resource to store image data.

[0086] In this embodiment of the disclosure, the amount of video memory requested corresponding to the resource creation request can refer to the amount of video memory that needs to be allocated to satisfy the resource creation request.

[0087] In one possible implementation, the amount of video memory requested corresponding to the resource creation request can be determined based on the size of the target resource.

[0088] As an example of this implementation, the size of the target resource can be determined as the amount of video memory requested by the resource creation request. For example, if the resource creation request requests the creation of a 64MB texture resource, the amount of video memory requested by the resource creation request can be 64MB.

[0089] As another example of this implementation, the amount of video memory requested for a resource creation request can be slightly larger than the size of the target resource.

[0090] In one possible implementation, the User Mode Driver (UMD) can respond to a resource creation request and determine the amount of video memory requested corresponding to that resource creation request.

[0091] In this embodiment of the disclosure, in response to a resource creation request satisfying a preset partitioning condition, the resource creation request can be mapped to at least two memory allocation requests. The preset partitioning condition can refer to a pre-set condition used to determine whether to partition the resource creation request. Partitioning the resource creation request can mean decomposing a resource creation request with a large memory request into two or more memory allocation requests with smaller memory requests.

[0092] The preset partitioning conditions include at least the following: the memory request amount corresponding to the resource creation request is greater than a preset allocation threshold. The preset allocation threshold can represent a pre-defined upper limit for the memory request amount of a memory allocation request. For example, if the memory request amount corresponding to a resource creation request is A, the preset allocation threshold is t, and the resource creation request meets the preset partitioning conditions, then the resource creation request can be mapped to... One video memory allocation request, of which This indicates rounding up to the nearest integer.

[0093] In one possible implementation, the preset partitioning condition further includes at least one of the following: the target resource is a non-shared resource; the target resource is not allowed to be modified by the CPU after its creation.

[0094] As an example of this implementation, the predefined partitioning condition also includes: the target resource is a non-shared resource. A non-shared resource is one that, after creation, is used only by one application or a specific context and is not shared by multiple applications or processes. In this case, the resource's usage scenario is relatively independent, so the resource creation request can be split into multiple small memory allocation requests without worrying about shared access issues between multiple users. For example, a texture resource in a game might only be used by one scene and not shared by other scenes or modules. In this case, the resource creation request can be mapped to multiple memory allocation requests.

[0095] As an example of this implementation, the preset partitioning condition also includes: the target resource cannot be modified by the CPU after creation. This means that the resource is read-only from the CPU's perspective after creation, and its content will not be modified by the CPU during subsequent use. For unmodifiable resources, more flexible memory allocation is possible because there is no need to worry about subsequent modifications affecting the integrity or consistency of the resource. For example, some static texture resources (such as background textures in games) will not be modified by the CPU after loading. In this case, the resource creation request can be split into multiple smaller allocation requests, thereby improving the success rate of memory allocation.

[0096] In this implementation, by restricting the sharing and modifiability of resources when dividing resource creation requests, a large resource creation request can be more safely split into multiple smaller memory allocation requests, thereby improving the success rate of memory allocation and avoiding other potential risks caused by splitting.

[0097] In this embodiment of the disclosure, the amount of video memory requested by any one of the at least two video memory allocation requests is less than or equal to a preset allocation threshold, and the sum of the amounts of video memory requested by the at least two video memory allocation requests is equal to the amount of video memory requested by the resource creation request.

[0098] Figure 2 This diagram illustrates how a resource creation request is mapped to multiple video memory allocation requests in a resource creation method provided in an embodiment of this disclosure. Figure 2 In the example shown, the target resource requested by the resource creation request is 64Mb in size. The user-mode driver can map this resource creation request into four memory allocation requests, each requesting 16Mb of memory, and each memory allocation request is responsible for mapping 16Mb of virtual address space to physical address space. Figure 2 The bottom of the diagram shows the physical memory layout, with gray areas representing occupied memory and white areas representing free memory. Four memory allocation requests are mapped to different locations in the physical memory, with each request responsible for 16MB of virtual address space. This mapping method allows the system to utilize free areas in the physical memory more flexibly, even if these areas are not contiguous.

[0099] In one possible implementation, the user-mode driver can map a resource creation request to at least two memory allocation requests in response to a resource creation request meeting a preset partitioning condition.

[0100] In one possible implementation, if the resource creation request does not meet the preset partitioning conditions, the user-mode driver can create a video memory allocation request based on the resource creation request.

[0101] In one possible implementation, the method further includes: for any one of the at least two memory allocation requests, determining the description information of the memory allocation request based on the characteristic information of the target resource and the memory request amount corresponding to the memory allocation request; the step of requesting memory allocation based on the at least two memory allocation requests includes: for any one of the at least two memory allocation requests, requesting memory allocation based on the description information of the memory allocation request.

[0102] In this implementation, each video memory allocation request can include descriptive information. The descriptive information of the video memory allocation request can be used to detail the specific needs of video memory allocation, so that the operating system or video memory manager can allocate video memory reasonably according to the descriptive information of the video memory allocation request.

[0103] In this implementation, the description information of the video memory allocation request may include the characteristic information of the target resource and the amount of video memory requested corresponding to the video memory allocation request.

[0104] As an example of this implementation, for any one of the at least two memory allocation requests, the user-mode driver can determine the description information of the memory allocation request based on the characteristic information of the target resource and the memory request amount corresponding to the memory allocation request. Furthermore, for any one of the at least two memory allocation requests, the user-mode driver can request memory allocation based on the description information of the memory allocation request.

[0105] In this implementation, memory allocation is requested based on the description information of the memory allocation request, which helps the memory manager better understand the needs of each memory allocation request, thereby completing the memory allocation more efficiently.

[0106] As an example of this implementation, the characteristic information of the target resource includes: the type of the target resource and / or the usage information of the target resource.

[0107] In one example, the characteristic information of the target resource may include the type of the target resource, such as texture, buffer, rendering target, etc.

[0108] In another example, the characteristic information of the target resource may include the purpose information of the target resource. For example, the purpose information of the target resource may be storing image data, storing vertex data, etc.

[0109] In this example, the target resource's characteristics (including type and / or usage information) provide crucial context for the video memory allocation system, helping it better understand resource requirements and application scenarios. Through this information, the video memory allocation system can allocate video memory more efficiently, improve allocation success rates, and optimize resource utilization.

[0110] As an example of this implementation, requesting video memory allocation based on the description information of the video memory allocation request includes: creating a handle corresponding to the video memory allocation request based on the description information of the video memory allocation request; and requesting video memory allocation based on the handle corresponding to the video memory allocation request.

[0111] A handle is an identifier used to uniquely identify a resource or request within the system. In video memory allocation, the handle's role includes uniquely identifying the memory allocation request and encapsulating request information. Specifically, the handle provides a unique identifier for each memory allocation request, facilitating system tracking and management of requests. Furthermore, the handle can encapsulate descriptive information about the memory allocation request, allowing the system to directly obtain the necessary information during subsequent allocation processes.

[0112] In one example, the PFND3DDDI_ALLOCATECB interface of the Direct3D Runtime can be called to create a handle corresponding to a memory allocation request. When creating the handle, description information can be stored in the handle, or the handle can be associated with description information. After creating the handle, a memory allocation request can be sent to the memory manager (such as the operating system or kernel-mode driver) through the handle.

[0113] In this example, encapsulating descriptive information through handles makes memory allocation requests more concise and efficient. Furthermore, the handle provides a unique identifier for each memory allocation request, facilitating system management and tracking.

[0114] In one possible implementation, the operating system's video memory manager can respond to video memory allocation requests and complete video memory allocation through a kernel-mode driver.

[0115] In one possible implementation, determining the amount of video memory requested corresponding to the resource creation request in response to the resource creation request includes: determining the amount of video memory requested corresponding to the resource creation request through a user-mode driver in response to the resource creation request; mapping the resource creation request to at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition includes: mapping the resource creation request to at least two video memory allocation requests through the user-mode driver in response to the resource creation request satisfying a preset partitioning condition; requesting video memory allocation based on the at least two video memory allocation requests to obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests includes: requesting video memory allocation based on the at least two video memory allocation requests through the user-mode driver to obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests; creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results includes: creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results through the user-mode driver.

[0116] In this implementation, the user-mode driver can handle processes such as responding to resource creation requests, determining whether preset partitioning conditions are met, splitting the resource creation request into multiple memory allocation requests, and creating the target resource based on the memory allocation results. Specifically, the user-mode driver can respond to a resource creation request, determine the amount of memory requested corresponding to the resource creation request, and if the resource creation request meets preset partitioning conditions, map the resource creation request to at least two memory allocation requests. Based on the at least two memory allocation requests, it requests memory allocation, obtains at least two memory allocation results corresponding to the at least two memory allocation requests, and creates the target resource corresponding to the resource creation request based on the at least two memory allocation results.

[0117] As an example of this implementation, the step of requesting video memory allocation based on the at least two video memory allocation requests by the user-mode driver and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests includes: sending the at least two video memory allocation requests to the runtime through the user-mode driver; forwarding the at least two video memory allocation requests to the kernel-mode driver through the runtime; responding to the at least two video memory allocation requests by the kernel-mode driver and returning at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime; and forwarding the at least two video memory allocation results to the user-mode driver through the runtime.

[0118] In this example, the runtime can be responsible for coordinating communication between the user-mode driver and the kernel-mode driver. The runtime can receive memory allocation requests sent by the user-mode driver and forward them to the kernel-mode driver.

[0119] Kernel-mode drivers run in the core layer of the operating system and have direct access to hardware resources. They can receive runtime-forwarded memory allocation requests and allocate memory based on the system's memory status (such as total memory size, allocated memory, and fragmentation). Kernel-mode drivers can attempt to find suitable memory space to satisfy each allocation request and generate the allocation result.

[0120] In this example, the user-mode driver handles resource management logic, the runtime handles communication coordination, and the kernel-mode driver handles hardware interaction. This division of labor makes the system more modular, easier to maintain, and easier to extend.

[0121] In one example, before determining the amount of video memory required for the resource creation request in response to the resource creation request by the user-mode driver, the method further includes: forwarding the resource creation request to the user-mode driver in response to the resource creation request from the application by the runtime; after creating the target resource corresponding to the resource creation request by the user-mode driver based on the at least two video memory allocation results, the method further includes: returning the target resource to the application by the runtime.

[0122] Figure 3 This diagram illustrates a resource creation method provided by an embodiment of the present disclosure. In step S1, an application (APP) may initiate a resource creation request. In step S2, a runtime (e.g., Direct3D Runtime) may, in response to the resource creation request from the application, forward the resource creation request to a user-mode driver (UMD). In step S3, the user-mode driver may, in response to the resource creation request, determine the amount of video memory requested corresponding to the resource creation request; in response to the resource creation request satisfying a preset partitioning condition, map the resource creation request to at least two video memory allocation requests; and send the at least two video memory allocation requests to the runtime. In step S4, the runtime may forward the at least two video memory allocation requests to the kernel-mode driver (DXGK (Display Graphics Kernel) and KMD (Kernel Mode Driver)). In step S5, the kernel-mode driver may, in response to the at least two video memory allocation requests, return at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime. In step S6, the runtime may forward the at least two video memory allocation results to the user-mode driver. In step S7, the user-mode driver can create the target resource corresponding to the resource creation request based on the at least two video memory allocation results, and return the target resource to the runtime. In step S8, the runtime can return the target resource to the application.

[0123] The resource creation method provided in this disclosure can be applied to the technical fields of GPU, image rendering, video memory, etc., and is not limited thereto.

[0124] The resource creation method provided in this disclosure embodiment is illustrated below through a specific application scenario. Figure 4This diagram illustrates another resource creation method provided in an embodiment of the present disclosure. In this application scenario, an application can initiate a resource creation request. The user-mode driver can respond to the resource creation request by determining whether the resource creation request meets preset partitioning conditions. If the user-mode driver finds that the resource creation request meets the preset partitioning conditions, it can map the resource creation request to... A memory allocation request is made, where A represents the memory request amount corresponding to the resource creation request, and t represents a preset allocation threshold; or, the user-mode driver can create a memory allocation request based on the resource creation request if the resource creation request does not meet the preset partitioning conditions. A handle corresponding to the memory allocation request can be created based on the description information of the memory allocation request, and memory allocation can be requested based on the handle corresponding to the memory allocation request.

[0125] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0126] In addition, this disclosure also provides a resource creation apparatus, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any of the resource creation methods provided in this disclosure. The corresponding technical solutions and effects can be found in the relevant descriptions in the method section, and will not be repeated here.

[0127] Figure 5 A block diagram of a resource creation apparatus provided in an embodiment of this disclosure is shown. Figure 5 As shown, the resource creation device includes:

[0128] The first determining module 51 is used to determine the amount of video memory requested corresponding to the resource creation request in response to the resource creation request;

[0129] The mapping module 52 is used to map the resource creation request into at least two video memory allocation requests in response to the resource creation request meeting a preset partitioning condition; wherein the preset partitioning condition includes at least: the amount of video memory requests corresponding to the resource creation request is greater than a preset allocation threshold; and the amount of video memory requests corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold.

[0130] Request module 53 is used to request video memory allocation based on the at least two video memory allocation requests, and obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests;

[0131] The creation module 54 is used to create the target resource corresponding to the resource creation request based on the at least two video memory allocation results.

[0132] In one possible implementation,

[0133] The device further includes: a second determining module, configured to determine the description information of the video memory allocation request for any one of the at least two video memory allocation requests, based on the characteristic information of the target resource and the video memory request amount corresponding to the video memory allocation request;

[0134] The request module 53 is used to: request memory allocation for any one of the at least two memory allocation requests, based on the description information of the memory allocation request.

[0135] In one possible implementation, the request module 53 is used to:

[0136] Based on the description information of the video memory allocation request, create a handle corresponding to the video memory allocation request;

[0137] Request memory allocation based on the handle corresponding to the memory allocation request.

[0138] In one possible implementation,

[0139] The first determining module 51 is used to: determine the amount of video memory requested corresponding to the resource creation request in response to the resource creation request through a user-mode driver;

[0140] The mapping module 52 is used to: map the resource creation request into at least two video memory allocation requests in response to the user mode driver meeting the preset partitioning conditions;

[0141] The request module 53 is used to: request video memory allocation according to the at least two video memory allocation requests through the user mode driver, and obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests;

[0142] The creation module 54 is used to: create the target resource corresponding to the resource creation request based on the at least two video memory allocation results through the user mode driver.

[0143] In one possible implementation, the request module 53 is used to:

[0144] The user-mode driver sends the at least two video memory allocation requests to the runtime.

[0145] The runtime forwards the at least two video memory allocation requests to the kernel-mode driver.

[0146] The kernel-mode driver responds to the at least two video memory allocation requests and returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime.

[0147] The runtime forwards the at least two video memory allocation results to the user-driven mode.

[0148] In one possible implementation, the device further includes:

[0149] The forwarding module is used to forward the resource creation request to the user-mode driver in response to the resource creation request from the application at runtime.

[0150] The return module is used to return the target resource to the application via the runtime.

[0151] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation and technical effects can be referred to the description of the above method embodiments. For the sake of brevity, they will not be repeated here.

[0152] This disclosure also provides a computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the above-described method. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.

[0153] This disclosure also proposes a computer program including computer-readable code, wherein when the computer-readable code is run in an electronic device, a processor in the electronic device executes the above-described method.

[0154] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in an electronic device, the processor in the electronic device executes the above-described method.

[0155] This disclosure also provides an electronic device, including: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to invoke the executable instructions stored in the memory to perform the above-described method.

[0156] Electronic devices can be provided as terminals, servers, or other forms of devices.

[0157] Figure 6A block diagram of an electronic device 1900 provided according to an embodiment of this disclosure is shown. For example, the electronic device 1900 may be provided as a server or a server-like device. (Refer to...) Figure 6 The electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.

[0158] Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). Electronic device 1900 can operate on an operating system stored in memory 1932, such as Microsoft Server operating system (Windows Server). TM Apple's graphical user interface-based operating system (MacOS X) TM ), a multi-user, multi-process computer operating system (Unix) TM Linux is a free and open-source Unix-like operating system. TM ), the open-source Unix-like operating system (FreeBSD) TM (or similar.)

[0159] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions that can be executed by a processing component 1922 of an electronic device 1900 to perform the above-described method.

[0160] This disclosure relates to the field of augmented reality (AR). It involves acquiring image information of target objects in a real-world environment and then using various visual algorithms to detect or identify the relevant features, states, and attributes of these objects, thereby achieving an AR effect that combines virtual and real elements to suit specific applications. For example, target objects may include human features such as faces, limbs, gestures, and movements; objects such as signs and markers; or venues such as sand tables, display areas, or displayed items. Visual algorithms may include visual localization, SLAM, 3D reconstruction, image registration, background segmentation, keypoint extraction and tracking of objects, and pose or depth detection. Specific applications can include interactive scenarios related to real-world scenes or objects, such as guided tours, navigation, explanations, reconstruction, and virtual effect overlay displays, as well as human-related special effects processing, such as makeup enhancement, limb enhancement, special effects displays, and virtual model displays. Convolutional neural networks (CNNs) can be used to detect or identify the relevant features, states, and attributes of target objects. The aforementioned CNNs are network models trained using deep learning frameworks.

[0161] This disclosure can be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of this disclosure.

[0162] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0163] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0164] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0165] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0166] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0167] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0169] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0170] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0171] If the technical solution of this disclosure involves personal information, the product applying the technical solution of this disclosure has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this disclosure involves sensitive personal information, the product applying the technical solution of this disclosure has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to indicate that the user has entered the scope of personal information collection and that personal information will be collected. If the user voluntarily enters the collection scope, it is deemed to have consented to the collection of their personal information; or on the personal information processing device, with clear signs / information informing the user of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.

[0172] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A resource creation method, characterized in that, include: In response to a resource creation request, determine the amount of video memory requested corresponding to the resource creation request; In response to the resource creation request satisfying a preset partitioning condition, the resource creation request is mapped to at least two video memory allocation requests; wherein, the preset partitioning condition includes at least: the video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; the video memory request amount corresponding to any one of the at least two video memory allocation requests is less than or equal to the preset allocation threshold; the preset allocation threshold represents a pre-set upper limit value for the video memory request amount of the video memory allocation request; Based on the at least two memory allocation requests, request memory allocation and obtain at least two memory allocation results corresponding to the at least two memory allocation requests; Based on the at least two memory allocation results, create the target resource corresponding to the resource creation request.

2. The method according to claim 1, characterized in that, The method further includes: for any one of the at least two video memory allocation requests, determining the description information of the video memory allocation request based on the feature information of the target resource and the video memory request amount corresponding to the video memory allocation request; The step of requesting video memory allocation based on the at least two video memory allocation requests includes: for any one of the at least two video memory allocation requests, requesting video memory allocation based on the description information of the video memory allocation request.

3. The method according to claim 2, characterized in that, The step of requesting video memory allocation based on the description information of the video memory allocation request includes: Based on the description information of the video memory allocation request, create a handle corresponding to the video memory allocation request; Request memory allocation based on the handle corresponding to the memory allocation request.

4. The method according to claim 1, characterized in that, The step of responding to a resource creation request and determining the amount of video memory required for the resource creation request includes: determining the amount of video memory required for the resource creation request in response to a resource creation request via a user-mode driver. The step of mapping the resource creation request to at least two video memory allocation requests in response to the resource creation request meeting the preset partitioning conditions includes: mapping the resource creation request to at least two video memory allocation requests through the user mode driver in response to the resource creation request meeting the preset partitioning conditions. The step of requesting video memory allocation based on the at least two video memory allocation requests and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests includes: requesting video memory allocation based on the at least two video memory allocation requests through the user mode driver and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests; The step of creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results includes: creating the target resource corresponding to the resource creation request through the user mode driver based on the at least two video memory allocation results.

5. The method according to claim 4, characterized in that, The process of requesting video memory allocation based on the at least two video memory allocation requests through the user-mode driver, and obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests, includes: The user-mode driver sends the at least two video memory allocation requests to the runtime. The runtime forwards the at least two video memory allocation requests to the kernel-mode driver. The kernel-mode driver responds to the at least two video memory allocation requests and returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime. The runtime forwards the at least two video memory allocation results to the user-mode driver.

6. The method according to claim 5, characterized in that, Before determining the amount of video memory required for a resource creation request in response to a resource creation request via a user-mode driver, the method further includes: forwarding the resource creation request to the user-mode driver in response to the resource creation request from the application via the runtime. After creating the target resource corresponding to the resource creation request based on the at least two video memory allocation results via the user-mode driver, the method further includes: returning the target resource to the application via the runtime.

7. A resource creation device, characterized in that, include: The first determining module is used to determine the amount of video memory requested corresponding to the resource creation request in response to the resource creation request; A mapping module is configured to map the resource creation request into at least two memory allocation requests in response to the resource creation request meeting a preset partitioning condition; wherein the preset partitioning condition includes at least: the memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; the memory request amount corresponding to any one of the at least two memory allocation requests is less than or equal to the preset allocation threshold; the preset allocation threshold represents a pre-set upper limit value for the memory request amount of a memory allocation request; The request module is configured to request video memory allocation based on the at least two video memory allocation requests, and obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests; A creation module is used to create the target resource corresponding to the resource creation request based on the at least two video memory allocation results.

8. An electronic device, characterized in that, include: One or more processors; Memory used to store executable instructions; The one or more processors are configured to invoke executable instructions stored in the memory to perform the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 6.

10. A computer program product comprising computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, characterized in that, When the computer-readable code is run in an electronic device, the processor in the electronic device performs the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Video memory management method and device and storage medium

    CN118134750A