Resource creation method and device, electronic equipment, storage medium and program product
By dividing resource creation requests into multiple video memory allocation requests and utilizing user mode drivers and kernel mode drivers to work together, the problem of video memory allocation failure is solved, and the success rate of video memory allocation and the stability of applications are improved.
Patent Information
- Application Number
- CN202510765139.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-06-09
AI Technical Summary
In the field of image rendering, in the prior art, when video memory resources are insufficient or fragmented, and when the demand for a single resource is large, video memory allocation failure is likely to occur.
The resource creation request is mapped into at least two video memory allocation requests, and the video memory resources are allocated and the target resources are created through the cooperation of the user mode driver and the kernel mode driver.
Improves the success rate of video memory allocation, enhances the running stability of applications, and increases the number of applications running simultaneously under the same video memory resources.
Smart Images

Figure CN120670159A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a resource creation method, a resource creation device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the field of image rendering, video memory allocation is a key step in ensuring the normal operation of applications (APPs). In related art, video memory allocation methods usually initiate a request to create video memory allocation when an application initiates a request to create resources.
[0003] However, in the related art, when video memory resources are insufficient or fragmented, and a single resource requires a large amount of video memory, it is easy to fail in allocating video memory. Summary of the Invention
[0004] The present disclosure provides a resource creation technical solution.
[0005] According to one aspect of the present disclosure, a resource creation method is provided, comprising:
[0006] In response to a resource creation request, determining a requested amount of video memory corresponding to the resource creation request;
[0007] In response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests; wherein the preset partitioning condition at least includes: a video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; and a 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;
[0008] Requesting video memory allocation according to 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;
[0009] Based on the at least two graphics memory allocation results, a target resource corresponding to the resource creation request is created.
[0010] In one possible implementation,
[0011] The method further includes: for any one of the at least two video memory allocation requests, determining description information of the video memory allocation request based on the characteristic information of the target resource and a video memory request amount corresponding to the video memory allocation request;
[0012] The requesting video memory allocation according to 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 according to description information of the video memory allocation request.
[0013] In a possible implementation, requesting video memory allocation according to the description information of the video memory allocation request includes:
[0014] Creating a handle corresponding to the video memory allocation request according to the description information of the video memory allocation request;
[0015] Requesting video memory allocation based on the handle corresponding to the video memory allocation request.
[0016] In one possible implementation,
[0017] The determining, in response to the resource creation request, a graphics memory request amount corresponding to the resource creation request, includes: determining, in response to the resource creation request via a user mode driver, a graphics memory request amount corresponding to the resource creation request;
[0018] In response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests includes: driving, by the user mode, in response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests;
[0019] Requesting video memory allocation according to 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 according to 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;
[0020] The 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.
[0021] In a possible implementation, requesting video memory allocation according to 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] sending, via the user mode driver, the at least two video memory allocation requests to the runtime;
[0023] forwarding the at least two video memory allocation requests to a kernel mode driver via the runtime;
[0024] In response to the at least two video memory allocation requests, the kernel mode driver returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime;
[0025] The at least two video memory allocation results are forwarded to the user-driven mode through the runtime.
[0026] In one possible implementation,
[0027] Before determining, by the user mode driver, the amount of video memory requested corresponding to the resource creation request in response to the resource creation request, the method further comprises: forwarding, by the runtime, the resource creation request to the user mode driver in response to the resource creation request from the application;
[0028] After creating, by the user mode driver, the target resource corresponding to the resource creation request based on the at least two video memory allocation results, the method further includes: returning the target resource to the application program by the runtime.
[0029] According to one aspect of the present disclosure, there is provided a resource creation device, comprising:
[0030] A first determining module, configured to determine, in response to a resource creation request, a requested amount of video memory corresponding to the resource creation request;
[0031] a mapping module, configured to map the resource creation request into at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition; wherein the preset partitioning condition at least includes: a video memory request amount corresponding to the resource creation request being greater than a preset allocation threshold; and a video memory request amount corresponding to any one of the at least two video memory allocation requests being less than or equal to the preset allocation threshold;
[0032] a request module, configured to request video memory allocation according to 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 a 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 apparatus further includes: a second determining module configured to determine, for any one of the at least two video memory allocation requests, description information of the video memory allocation request 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 configured to: for any one of the at least two video memory allocation requests, request video memory allocation according to description information of the video memory allocation request.
[0037] In a possible implementation, the request module is configured to:
[0038] Creating a handle corresponding to the video memory allocation request according to the description information of the video memory allocation request;
[0039] Requesting video memory allocation based on the handle corresponding to the video memory allocation request.
[0040] In one possible implementation,
[0041] The first determining module is configured to: respond to a resource creation request through a user mode driver to determine a video memory request amount corresponding to the resource creation request;
[0042] The mapping module is configured to: in response to the resource creation request satisfying a preset partitioning condition, map the resource creation request into at least two video memory allocation requests through the user mode driver;
[0043] The request module is configured 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;
[0044] The creation module is configured to: create a 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 a possible implementation, the request module is configured to:
[0046] sending, via the user mode driver, the at least two video memory allocation requests to the runtime;
[0047] forwarding the at least two video memory allocation requests to a kernel mode driver via the runtime;
[0048] In response to the at least two video memory allocation requests, the kernel mode driver returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime;
[0049] The at least two video memory allocation results are forwarded to the user-driven mode through the runtime.
[0050] In a possible implementation, the apparatus further includes:
[0051] a forwarding module, configured to respond to the resource creation request from the application program by the runtime and forward the resource creation request to the user mode driver;
[0052] A return module is used to return the target resource to the application program through the runtime.
[0053] According to one aspect of the present 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 call the executable instructions stored in the memory to execute the above method.
[0054] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the above method is implemented.
[0055] According to one aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.
[0056] In an embodiment of the present disclosure, a video memory request amount corresponding to a resource creation request is determined in response to the resource creation request. In response to the resource creation request satisfying a preset partitioning condition, the resource creation request is mapped into at least two video memory allocation requests, wherein the preset partitioning condition at least includes: the video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold, and 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; a video memory allocation is requested based on the at least two video memory allocation requests, at least two video memory allocation results corresponding to the at least two video memory allocation requests are obtained, and a target resource corresponding to the resource creation request is created based on the at least two video memory allocation results. Therefore, when creating a resource, by mapping a resource creation request with a larger video memory request amount into at least two video memory allocation requests with smaller video memory request amounts, a success rate of video memory allocation can be improved, and a success rate of resource creation can be improved, thereby improving not only the stability of application operation but also the number of applications running simultaneously under the same video memory resources.
[0057] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
[0058] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to explain the technical solutions of the present disclosure.
[0060] Figure 1 A flowchart of a resource creation method provided by an embodiment of the present disclosure is shown.
[0061] Figure 2 A schematic diagram illustrating mapping a resource creation request into multiple video memory allocation requests in the resource creation method provided by an embodiment of the present disclosure.
[0062] Figure 3 A schematic diagram of a resource creation method provided by an embodiment of the present disclosure is shown.
[0063] Figure 4 Another schematic diagram of the resource creation method provided by an embodiment of the present disclosure is shown.
[0064] Figure 5 A block diagram of a resource creation device provided by an embodiment of the present disclosure is shown.
[0065] Figure 6 A block diagram of an electronic device 1900 provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0066] Various exemplary embodiments, features, and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise indicated.
[0067] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0068] The term "and / or" herein simply describes an association relationship between associated objects, indicating that three relationships can exist. For example, "A and / or B" can represent the existence of three situations: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" herein refers to any combination of at least two of any one or more of a plurality of items. For example, "at least one of A, B, and C" can represent any one or more elements selected from the set consisting of A, B, and C.
[0069] In addition, numerous specific details are provided in the following detailed description to better illustrate the present disclosure. Those skilled in the art will appreciate that the present disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art are not described in detail in order to highlight the main points of the present disclosure.
[0070] An embodiment of the present disclosure provides a resource creation method, comprising: determining, in response to a resource creation request, a video memory request amount corresponding to the resource creation request; and mapping the resource creation request into at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition, wherein the preset partitioning condition at least includes: the video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; and 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; requesting video memory allocation based on the at least two video memory allocation requests, obtaining at least two video memory allocation results corresponding to the at least two video memory allocation requests, and creating a target resource corresponding to the resource creation request based on the at least two video memory allocation results. Thus, when creating a resource, by mapping a resource creation request with a larger video memory request amount into at least two video memory allocation requests with smaller video memory request amounts, a success rate of video memory allocation can be improved, thereby improving the success rate of resource creation, thereby improving the stability of application operation, and increasing the number of applications running simultaneously under the same video memory resources.
[0071] The resource creation method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0072] Figure 1 A flow chart of a resource creation method provided by an embodiment of the present disclosure is shown. In one possible implementation, the execution subject of the resource creation method may be a resource creation device. For example, the resource creation method may be executed by a terminal device or a server or other electronic device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device or a wearable device, etc. In some possible implementations, the resource creation method may be implemented by a processor calling computer-readable instructions stored in a memory. As Figure 1 As shown, the resource creation method includes steps S11 to S14.
[0073] In step S11 , in response to a resource creation request, a video memory request amount 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 into 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.
[0075] In step S13, video memory allocation is requested according to the at least two video memory allocation requests, and at least two video memory allocation results corresponding to the at least two video memory allocation requests are obtained.
[0076] In step S14, based on the at least two video memory allocation results, a target resource corresponding to the resource creation request is created.
[0077] In the embodiment of the present disclosure, when an application (APP) needs to create a new resource, it can initiate a resource creation request. Hereinafter, the resource requested to be created by the application is referred to as a target resource.
[0078] In a possible implementation, the application may initiate a resource creation request by calling a graphics API (Application Programming Interface), for example, the graphics API may be Direct3D.
[0079] In a possible implementation, the resource creation request may include type information of the target resource.
[0080] In a possible implementation, the target resource includes at least one type: a texture, a buffer, and a render target.
[0081] In this implementation, the type of resource may be a texture, a buffer, a render target, etc., which is not limited here.
[0082] In graphics rendering, a texture is a resource 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 a type of data storage resource. They can be used to store vertex data, index data, or other types of data that are used by the GPU during the rendering process. For example, the depth buffer can be used to store depth information to help determine which pixels should be rendered in front; constant buffers can be used to store data that does not change frequently, such as transformation matrices and lighting parameters; index buffers can be used to store vertex indices, which are used to determine which vertices make up a polygon; and so on.
[0084] A render target is a special buffer used to store the results of a rendering operation. For example, a frame buffer is a common render target that 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, where the characteristic information of the target resource may include the size of the target resource. For example, an app may need to create a 64MB texture resource to store image data.
[0086] In the embodiment of the present disclosure, the requested amount of video memory corresponding to the resource creation request may refer to the size of the video memory that needs to be allocated in order to satisfy the resource creation request.
[0087] In a possible implementation, the video memory request amount corresponding to the resource creation request may be determined according to the size of the target resource.
[0088] As an example of this implementation, the size of the target resource can be determined as the video memory request amount corresponding to the resource creation request. For example, if the resource creation request requests the creation of a 64MB texture resource, the video memory request amount corresponding to the resource creation request can be 64MB.
[0089] As another example of this implementation, the amount of graphics memory requested corresponding to the resource creation request may be slightly larger than the size of the target resource.
[0090] In a possible implementation, a user mode driver (UMD) may determine a requested amount of video memory corresponding to the resource creation request in response to the resource creation request.
[0091] In an embodiment of the present disclosure, in response to a resource creation request satisfying a preset partitioning condition, the resource creation request may be mapped into at least two video memory allocation requests. The preset partitioning condition may refer to a pre-set condition for determining whether to partition the resource creation request. Partitioning the resource creation request may refer to splitting a resource creation request with a larger video memory request into two or more video memory allocation requests with smaller video memory requests.
[0092] The preset division condition includes at least: the memory request amount corresponding to the resource creation request is greater than the preset allocation threshold. The preset allocation threshold can represent the upper limit of the memory request amount of the preset memory allocation request. For example, if the memory request amount corresponding to the resource creation request is A, the preset allocation threshold is t, and the resource creation request meets the preset division condition, then the resource creation request can be mapped to Video memory allocation requests, where Indicates rounding up.
[0093] In a possible implementation, the preset partitioning condition further includes at least one of the following: the target resource is a non-shared resource; and the target resource is not allowed to be modified by the CPU after being created.
[0094] As an example of this implementation, the preset division conditions also include: the target resource is a non-shared resource. A non-shared resource means that the resource is only used by one application or a specific context after creation, and will not be shared by multiple applications or multiple processes. In this case, the resource usage scenarios are relatively independent, so the resource creation request can be split into multiple small video memory allocation requests without worrying about shared access to resources between multiple users. For example, a texture resource in a game is only used by one scene and will not be shared by other scenes or modules. In this case, the resource creation request can be mapped to multiple video memory allocation requests.
[0095] As an example of this implementation, the preset division conditions also include: the target resource is not allowed to be modified by the CPU after creation. Among them, the resource is not allowed to be modified by the CPU after creation, which can mean that the resource is read-only to the CPU after creation, and its content will not be modified by the CPU during subsequent use. For non-modifiable resources, video memory allocation can be more flexible because there is no need to worry about subsequent modification operations affecting the integrity or consistency of the resources. 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 small allocation requests, thereby improving the success rate of video memory allocation.
[0096] In this implementation, by limiting the shareability and modifiability of resources when dividing resource creation requests, a large resource creation request can be more safely split into multiple small video memory allocation requests, thereby improving the success rate of video memory allocation and avoiding other potential risks caused by splitting.
[0097] In an embodiment of the present disclosure, the video memory request amount corresponding to 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 video memory request amounts corresponding to the at least two video memory allocation requests is equal to the video memory request amount corresponding to the resource creation request.
[0098] Figure 2 A schematic diagram showing a resource creation method provided by an embodiment of the present disclosure, in which a resource creation request is mapped into multiple video memory allocation requests. Figure 2 In the example shown, the size of the target resource requested by the resource creation request is 64Mb. The user-mode driver can map this resource creation request into four memory allocation requests, each with a memory request size of 16Mb. 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 the gray portion representing occupied memory and the white portion representing free memory. Four memory allocation requests are mapped to different locations in physical memory, with each request responsible for 16Mb of virtual address space. This mapping allows the system to more flexibly utilize free areas in physical memory, even if these areas are not contiguous.
[0099] In a possible implementation, the user mode driver may map the resource creation request into at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition.
[0100] In a possible implementation, if the resource creation request does not meet the preset partitioning condition, the user mode driver may 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 video memory allocation requests, determining description information of the video memory allocation request based on characteristic information of the target resource and a video memory request amount corresponding to the video memory allocation request; 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.
[0102] In this implementation, each video memory allocation request may include description information, which may be used to describe specific requirements for video memory allocation so that an operating system or a video memory manager can allocate video memory appropriately based on the description information.
[0103] In this implementation, the description information of the video memory allocation request may include feature information of the target resource and the video memory request amount corresponding to the video memory allocation request.
[0104] As an example of this implementation, for any of the at least two video memory allocation requests, the user-mode driver may determine description information of the video memory allocation request based on the characteristic information of the target resource and the requested amount of video memory corresponding to the video memory allocation request. Furthermore, for any of the at least two video memory allocation requests, the user-mode driver may request video memory allocation based on the description information of the video memory allocation request.
[0105] In this implementation, by requesting video memory allocation according to the description information of the video memory allocation request, the video memory manager can better understand the requirements of each video memory allocation request, thereby completing video 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 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 a texture, a buffer, a render target, and the like.
[0108] In another example, the characteristic information of the target resource may include usage information of the target resource, such as storing image data, storing vertex data, etc.
[0109] In this example, the target resource's characteristic information (including type and / or usage) provides important context for the memory allocation system, helping it better understand resource requirements and application scenarios. This characteristic information allows the memory allocation system to allocate memory more efficiently, improve allocation success rates, and optimize resource utilization.
[0110] As an example of this implementation, requesting video memory allocation according to the description information of the video memory allocation request includes: creating a handle corresponding to the video memory allocation request according to 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 that uniquely identifies a resource or request within the system. In video memory allocation, a handle can be used to uniquely identify a video memory allocation request and encapsulate request information. Specifically, a handle provides a unique identifier for each video memory allocation request, making it easier for the system to track and manage requests. Furthermore, a handle encapsulates the descriptive information of the video memory allocation request, allowing the system to directly access the required information during subsequent allocations.
[0112] In one example, the Direct3D Runtime's PFND3DDDI_ALLOCATECB interface can be called to create a handle corresponding to a video memory allocation request. When creating the handle, a description can be stored in the handle or associated with the handle. After the handle is created, the handle can be used to send a video memory allocation request to a video memory manager (e.g., an operating system (OS) or kernel-mode driver).
[0113] In this example, the handle encapsulates the description information, making the video memory allocation request more concise and efficient. In addition, the handle provides a unique identifier for each video memory allocation request, facilitating system management and tracking.
[0114] In a possible implementation, the video memory manager of the operating system may complete the video memory allocation through a kernel mode driver in response to the video memory allocation request.
[0115] In one possible implementation, determining, in response to a resource creation request, a video memory request amount corresponding to the resource creation request includes: determining, by a user mode driver, the video memory request amount corresponding to the resource creation request in response to the resource creation request; mapping, in response to the resource creation request satisfying a preset partitioning condition, the resource creation request to at least two video memory allocation requests includes: mapping, by the user mode driver, the resource creation request to at least two video memory allocation requests 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 by the user mode driver to obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests; creating, based on the at least two video memory allocation results, a target resource corresponding to the resource creation request includes: creating, by the user mode driver, the target resource corresponding to the resource creation request based on the at least two video memory allocation results.
[0116] In this implementation, a user-mode driver can complete processes such as responding to a resource creation request, determining whether a preset partitioning condition is satisfied, splitting the resource creation request into multiple video memory allocation requests, and creating a target resource based on the video memory allocation results. Specifically, the user-mode driver can, in response to a resource creation request, determine the video memory request amount corresponding to the resource creation request; in response to the resource creation request satisfying the preset partitioning condition, map the resource creation request into at least two video memory allocation requests; request video memory allocation based on the at least two video memory allocation requests; obtain at least two video memory allocation results corresponding to the at least two video memory allocation requests; and, based on the at least two video memory allocation results, create the target resource corresponding to the resource creation request.
[0117] As an example of this implementation, requesting video memory allocation according to the at least two video memory allocation requests by the user mode driver to obtain 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 by the user mode driver; forwarding the at least two video memory allocation requests to the kernel mode driver by the runtime; returning at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime by the kernel mode driver in response to the at least two video memory allocation requests; and forwarding the at least two video memory allocation results to the user mode driver by the runtime.
[0118] In this example, the runtime can be responsible for coordinating the communication between the user-mode driver and the kernel-mode driver. The runtime can receive the video memory allocation request sent by the user-mode driver and forward the video memory allocation request to the kernel-mode driver.
[0119] Kernel-mode drivers run at the core of the operating system and have direct access to hardware resources. They receive memory allocation requests forwarded by the runtime and allocate memory based on the system's memory status (e.g., total memory, allocated memory, and fragmentation). They attempt to find appropriate memory space to satisfy each memory allocation request and generate a memory allocation result.
[0120] In this example, the user-mode driver is responsible for resource management logic, the runtime is responsible for communication coordination, and the kernel-mode driver is responsible for hardware interaction. This division of labor makes the system more modular and easier to maintain and expand.
[0121] In one example, before the user mode driver determines the amount of video memory request corresponding to the resource creation request in response to the resource creation request, the method further includes: forwarding the resource creation request to the user mode driver in response to the resource creation request from the application through the runtime; after the user mode driver creates the target resource corresponding to the resource creation request based on the at least two video memory allocation results, the method further includes: returning the target resource to the application through the runtime.
[0122] Figure 3 A schematic diagram of a resource creation method provided by an embodiment of the present disclosure is shown. In step S1, an application (APP) may initiate a resource creation request. In step S2, a runtime (e.g., Direct3D Runtime) may forward the resource creation request to a user-mode driver (UMD) in response to the resource creation request from the application. In step S3, the user-mode driver may determine the video memory request amount corresponding to the resource creation request in response to the resource creation request; in response to the resource creation request meeting a preset partitioning condition, map the resource creation request into 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 a kernel-mode driver (DXGK (Display Graphics Kernel) and KMD (Kernel Mode Driver)). In step S5, the kernel-mode driver may return at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime in response to the at least two video memory allocation requests. 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 may create a 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 may return the target resource to the application.
[0123] The resource creation method provided in the embodiments of the present disclosure can be applied to technical fields such as GPU, image rendering, and video memory, and is not limited here.
[0124] The resource creation method provided by the embodiment of the present disclosure is described below through a specific application scenario. Figure 4Another schematic diagram of the resource creation method provided by the embodiment of the present disclosure is shown. In this application scenario, an application can initiate a resource creation request. The user mode driver can respond to the resource creation request and determine whether the resource creation request meets the preset division condition. The user mode driver can respond to the resource creation request and determine whether the resource creation request meets the preset division condition, and map the resource creation request to A video memory allocation request may be generated, where A represents the video memory request amount corresponding to the resource creation request and t represents a preset allocation threshold; or, in response to the resource creation request not meeting the preset partitioning condition, the user mode driver may create a video memory allocation request based on the resource creation request. A handle corresponding to the video memory allocation request may be created based on the description information of the video memory allocation request, and video memory allocation may be requested based on the handle corresponding to the video memory allocation request.
[0125] It is understood that the above-mentioned various method embodiments mentioned in this disclosure can be combined with each other to form combined embodiments without violating the principle logic. Due to space limitations, this disclosure will not go into details. It is understood by those skilled in the art that in the above-mentioned methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.
[0126] In addition, the present disclosure also provides a resource creation device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any resource creation method provided by the present disclosure. The corresponding technical solutions and technical effects can be found in the corresponding records in the method section and will not be repeated here.
[0127] Figure 5 FIG. 1 is a block diagram of a resource creation device provided by an embodiment of the present disclosure. Figure 5 As shown, the resource creation device includes:
[0128] A first determining module 51 is configured to determine, in response to a resource creation request, a requested amount of video memory corresponding to the resource creation request;
[0129] a mapping module 52 configured to map the resource creation request into at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition; wherein the preset partitioning condition at least includes: a video memory request amount corresponding to the resource creation request being greater than a preset allocation threshold; and a video memory request amount corresponding to any one of the at least two video memory allocation requests being less than or equal to the preset allocation threshold;
[0130] A request module 53 is configured to request video memory allocation according to 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 configured to create a 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 apparatus further includes: a second determining module configured to determine, for any one of the at least two video memory allocation requests, description information of the video memory allocation request 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 configured to: request video memory allocation for any one of the at least two video memory allocation requests according to description information of the video memory allocation request.
[0135] In a possible implementation, the request module 53 is configured to:
[0136] Creating a handle corresponding to the video memory allocation request according to the description information of the video memory allocation request;
[0137] Requesting video memory allocation based on the handle corresponding to the video memory allocation request.
[0138] In one possible implementation,
[0139] The first determining module 51 is configured to: respond to a resource creation request through a user mode driver and determine a video memory request amount corresponding to the resource creation request;
[0140] The mapping module 52 is configured to: in response to the resource creation request satisfying a preset partitioning condition, map the resource creation request into at least two video memory allocation requests via the user mode driver;
[0141] The request module 53 is configured 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 configured to create, through the user mode driver, a target resource corresponding to the resource creation request based on the at least two video memory allocation results.
[0143] In a possible implementation, the request module 53 is configured to:
[0144] sending, via the user mode driver, the at least two video memory allocation requests to the runtime;
[0145] forwarding the at least two video memory allocation requests to a kernel mode driver via the runtime;
[0146] In response to the at least two video memory allocation requests, the kernel mode driver returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime;
[0147] The at least two video memory allocation results are forwarded to the user-driven mode through the runtime.
[0148] In a possible implementation, the apparatus further includes:
[0149] a forwarding module, configured to respond to the resource creation request from the application program by the runtime and forward the resource creation request to the user mode driver;
[0150] A return module is used to return the target resource to the application program through the runtime.
[0151] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. Its specific implementation and technical effects can refer to the description of the above method embodiments. For the sake of brevity, they will not be repeated here.
[0152] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the above method. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
[0153] The embodiment of the present disclosure further provides a computer program, comprising a computer-readable code. When the computer-readable code is executed in an electronic device, a processor in the electronic device executes the above method.
[0154] An embodiment of the present disclosure further provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.
[0155] An embodiment of the present disclosure also provides an electronic device, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.
[0156] The electronic device may be provided as a terminal, a server, or other forms of devices.
[0157] Figure 61 shows a block diagram of an electronic device 1900 provided by an embodiment of the present disclosure. For example, the electronic device 1900 can be provided as a server or a server. Figure 6 The electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute the instructions to perform the above-described method.
[0158] The electronic device 1900 may further include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as a Microsoft Server operating system (Windows Server 2003). TM ), a graphical user interface operating system launched by Apple (MacOS X TM ), a multi-user, multi-process computer operating system (Unix TM ), a free and open source Unix-like operating system (Linux TM ), an 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 the processing component 1922 of the electronic device 1900 to perform the above method.
[0160] The present disclosure relates to the field of augmented reality. By acquiring image information of a target object in a real-world environment, the relevant features, states, and attributes of the target object are detected or identified using various vision-related algorithms, thereby achieving an AR effect that combines virtual and real life and matches the specific application. For example, the target object may be a face, limbs, gestures, movements, etc. related to the human body, or an identifier or marker related to an object, or a sandbox, display area, or display items related to a venue or location. Vision-related algorithms may involve visual positioning, SLAM, 3D reconstruction, image registration, background segmentation, key point extraction and tracking of objects, and object pose or depth detection. Specific applications can involve not only interactive scenarios such as guided tours, navigation, explanations, reconstruction, and virtual effect overlay displays related to real scenes or objects, but also special effects processing related to people, such as makeup beautification, body beautification, special effects display, and virtual model display. Detection or identification of the relevant features, states, and attributes of the target object can be achieved using a convolutional neural network. The above-mentioned convolutional neural network is a network model obtained by model training based on a deep learning framework.
[0161] The present disclosure may be a system, method and / or computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0162] A computer-readable storage medium can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.
[0163] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.
[0164] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state 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++, and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of 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., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0165] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts 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 device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in 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 so that a series of operational steps are 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 implement the functions / actions specified in one or more blocks in the flowchart and / or block diagram.
[0168] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and the part of the module, program segment or instruction contains one or more executable instructions for realizing the prescribed logical function. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the prescribed function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0169] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0170] The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced with each other and will not be repeated herein for the sake of brevity.
[0171] If the technical solutions of the embodiments of the present disclosure involve personal information, the products applying the technical solutions of the embodiments of the present disclosure have clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solutions of the embodiments of the present disclosure involve sensitive personal information, the products applying the technical solutions of the embodiments of the present disclosure have obtained the individual's separate consent before processing the sensitive personal information, and at the same time meet the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that they agree to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload their personal information. 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 type of personal information processed.
[0172] While various embodiments of the present disclosure have been described above, the above descriptions are illustrative, non-exhaustive, and not intended to be limiting of 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 selected to best explain the principles of the embodiments, their practical applications, or improvements to existing technologies, 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, determining a requested amount of video memory corresponding to the resource creation request; In response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests; wherein the preset partitioning condition at least includes: a video memory request amount corresponding to the resource creation request is greater than a preset allocation threshold; and a 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; Requesting video memory allocation according to 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; Based on the at least two graphics memory allocation results, a target resource corresponding to the resource creation request is created.
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 description information of the video memory allocation request based on the characteristic information of the target resource and a video memory request amount corresponding to the video memory allocation request; The requesting video memory allocation according to 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 according to description information of the video memory allocation request.
3. The method according to claim 2, characterized in that The requesting video memory allocation according to the description information of the video memory allocation request includes: Creating a handle corresponding to the video memory allocation request according to the description information of the video memory allocation request; Requesting video memory allocation based on the handle corresponding to the video memory allocation request.
4. The method according to claim 1, wherein The determining, in response to the resource creation request, a graphics memory request amount corresponding to the resource creation request, includes: determining, in response to the resource creation request via a user mode driver, a graphics memory request amount corresponding to the resource creation request; In response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests includes: driving, by the user mode, in response to the resource creation request satisfying a preset partitioning condition, mapping the resource creation request into at least two video memory allocation requests; Requesting video memory allocation according to 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 according to 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; The 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.
5. The method according to claim 4, characterized in that The step of requesting video memory allocation according to 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, via the user mode driver, the at least two video memory allocation requests to the runtime; forwarding the at least two video memory allocation requests to a kernel mode driver via the runtime; In response to the at least two video memory allocation requests, the kernel mode driver returns at least two video memory allocation results corresponding to the at least two video memory allocation requests to the runtime; The at least two video memory allocation results are forwarded to the user-driven mode through the runtime.
6. The method according to claim 5, characterized in that Before determining, by the user mode driver, the amount of video memory requested corresponding to the resource creation request in response to the resource creation request, the method further comprises: forwarding, by the runtime, the resource creation request to the user mode driver in response to the resource creation request from the application; After creating, by the user mode driver, the target resource corresponding to the resource creation request based on the at least two video memory allocation results, the method further includes: returning the target resource to the application program by the runtime.
7. A resource creation device, characterized in that: include: A first determining module is configured to determine, in response to a resource creation request, a requested amount of video memory corresponding to the resource creation request; a mapping module, configured to map the resource creation request into at least two video memory allocation requests in response to the resource creation request satisfying a preset partitioning condition; wherein the preset partitioning condition at least includes: a video memory request amount corresponding to the resource creation request being greater than a preset allocation threshold; and a video memory request amount corresponding to any one of the at least two video memory allocation requests being less than or equal to the preset allocation threshold; a request module, configured to request video memory allocation according to 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 a 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; a memory for storing executable instructions; The one or more processors are configured to call the executable instructions stored in the memory to execute 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 a processor, the method according to any one of claims 1 to 6 is implemented.
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 executed in an electronic device, a processor in the electronic device executes the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Dynamic memory control method and dynamic memory control system
CN105159615A
Video memory management method and related products
CN112860423A
Method, system and equipment for sharing same GPU (Graphics Processing Unit) by multiple services and medium
CN113127192A
Video memory management method and device and storage medium
CN118134750A
Video memory space allocation method, equipment and medium
CN119225961A