Video memory management method, device and storage medium

By determining the target memory pool in the user mode driver UMD, the application can directly allocate and recycle video memory in the user mode, solving the problem of time-consuming video memory management in the prior art and improving operational efficiency.

CN118134750BActive Publication Date: 2025-05-02MOORE THREADS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410324084.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-20
Publication Date
2025-05-02
Estimated Expiration
2044-03-20

AI Technical Summary

Technical Problem

In the memory management, the switching process from user mode to kernel mode is time-consuming, resulting in frequent application resource creation that cannot meet the requirements of operational efficiency.

Method used

By determining the target memory pool in user mode driver UMD, the application can allocate and recycle video memory directly through the memory pool. The target memory pool includes one or more memory blocks, and the memory blocks are composed of GPU memory requested by UMD. According to the application's video memory requirements, determine the address of the target video memory block that meets the video memory size in the target video memory pool.

Benefits of technology

It effectively solves the problem of APP frequently allocating and releasing video memory, reduces the number of times UMD initiates allocation of video memory applications to Direct3DRuntime, and avoids the need for applications to switch to kernel mode to apply for video memory, thereby reducing delay and improving operational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118134750B_ABST
    Figure CN118134750B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a video memory management method, device and storage medium. The method comprises: in response to a request from an application to create a first target resource, determining a target video memory pool in a user mode driver UMD, the target video memory pool comprising one or more video memory blocks, the video memory blocks comprising a graphics processor GPU video memory requested by the UMD; according to the video memory size required by the first target resource, determining the address of a target video memory block that meets the video memory size in the target video memory pool, the address of the target video memory block being used to return to the application to satisfy the request to create the first target resource. According to the embodiment of the present disclosure, the problem of APP frequently allocating and releasing video memory can be effectively solved, the number of times the UMD initiates a video memory allocation request can be reduced, and at the same time, the APP can complete the video memory request in the user mode, reducing the number of switches to the kernel mode, reducing the delay, improving the operating efficiency, and more efficiently indexing the target video memory block of the most suitable size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a video memory management method, device and storage medium. Background Art

[0002] Video memory is a dedicated memory on the graphics card that is used to store image data, textures, vertex information, and other intermediate results required for rendering tasks. Usually, image rendering tasks require a large amount of image data to be processed and displayed. Before executing a rendering task, the application must first apply for video memory allocation. In the current method of video memory management, each time an application creates a resource, the user mode driver needs to initiate an application for video memory allocation and switch to kernel mode to apply for video memory resource allocation. Since the switching process from user mode to kernel mode is very time-consuming, especially when the application has frequent resource creation, the current solution cannot meet the demand for operating efficiency. Therefore, a new video memory management method is urgently needed to reduce the number of accesses, save resources, and improve operating efficiency. Summary of the invention

[0003] In view of this, the present disclosure proposes a video memory management method, device and storage medium.

[0004] According to one aspect of the present disclosure, a video memory management method is provided. The method comprises:

[0005] In response to a request from an application to create a first target resource, a target video memory pool is determined in a user mode driver UMD, where the target video memory pool includes one or more video memory blocks, and the video memory blocks include a graphics processor GPU video memory requested by the UMD;

[0006] According to the video memory size required by the first target resource, the address of the target video memory block that meets the video memory size is determined in the target video memory pool, and the address of the target video memory block is used to return to the application to meet the request to create the first target resource.

[0007] In a possible implementation, in response to a request from an application to create a first target resource, determining a target video memory pool in a user mode driver UMD includes:

[0008] In response to a request from an application to create a first target resource, determining whether there is a video memory pool in the UMD that matches an attribute of the first target resource, the attribute of the target resource indicating a purpose of the target resource;

[0009] In response to the presence of a video memory pool matching the attribute of the first target resource in the UMD, the video memory pool matching the attribute of the first target resource is used as a target video memory pool.

[0010] In a possible implementation, according to the video memory size required by the first target resource, determining the address of a target video memory block that meets the video memory size in the target video memory pool includes:

[0011] According to the meta information list, determining whether there is a first video memory block in the target video memory pool, the meta information list including meta information of available video memory blocks in the target video memory pool, the meta information including video memory size and address of the video memory block, the first video memory block being an available video memory block whose video memory size is not less than the video memory size required by the first target resource in the target video memory pool and whose video memory size is closest to the video memory size required by the first target resource;

[0012] In response to the existence of the first video memory block, an address of a target video memory block that satisfies the video memory size is determined.

[0013] In a possible implementation, in response to the existence of the first video memory block, determining the address of the target video memory block that satisfies the video memory size includes:

[0014] Splitting the first video memory block into a second video memory block and a third video memory block, wherein the video memory size of the second video memory block is the video memory size required by the first target resource;

[0015] Remove the meta information of the first video memory block from the meta information list;

[0016] Insert the meta information of the third video memory block into the meta information list;

[0017] The address of the target video memory block is determined to be the address of the second video memory block.

[0018] In a possible implementation, according to the video memory size required by the first target resource, determining the address of a target video memory block that meets the video memory size in the target video memory pool includes:

[0019] In response to the first video memory block not existing, applying to create a video memory block of a preset size in the UMD by switching to kernel mode, and inserting meta information of the video memory block into the meta information list;

[0020] The created video memory block is used as the first video memory block.

[0021] In a possible implementation, the address of the target video memory block includes an offset of a start address of the target video memory block relative to a start address of a target video memory pool.

[0022] In a possible implementation, in response to a request from an application to create a first target resource, determining a target video memory pool in a user mode driver UMD includes:

[0023] In response to the absence of a video memory pool matching the attributes of the first target resource in the UMD, an application is made to create a video memory pool matching the attributes of the first target resource in the UMD by switching to kernel mode, and the created video memory pool is used as the target video memory pool.

[0024] In a possible implementation, the method further includes:

[0025] In response to a request from the application to release the second target resource, determining a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource;

[0026] Insert the meta information of the fifth video memory block into the meta information list.

[0027] In a possible implementation, in response to a request from an application to release a second target resource, determining a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource includes:

[0028] In response to a request from the application to release the second target resource, determining whether a previous video memory block and a subsequent video memory block of a fourth video memory block in the video memory are available;

[0029] In response to the previous video memory block being available, merging the previous video memory block with the fourth video memory block so that the fifth video memory block includes the previous video memory block and the fourth video memory block;

[0030] In response to the next video memory block being available, merging the next video memory block with the fourth video memory block so that the fifth video memory block includes the next video memory block and the fourth video memory block;

[0031] In response to the previous video memory block being unavailable and the next video memory block being unavailable, the fifth video memory block is made the fourth video memory block.

[0032] According to another aspect of the present disclosure, a video memory management device is provided. The device includes:

[0033] A first determination module, configured to determine a target video memory pool in a user mode driver UMD in response to a request from an application to create a first target resource, wherein the target video memory pool includes one or more video memory blocks, and the video memory blocks include a graphics processor GPU video memory applied for by the UMD;

[0034] The second determination module is used to determine the address of a target video memory block that meets the video memory size in the target video memory pool according to the video memory size required by the first target resource, and the address of the target video memory block is used to return to the application to meet the request to create the first target resource.

[0035] In a possible implementation manner, the first determining module is configured to:

[0036] In response to a request from an application to create a first target resource, determining whether there is a video memory pool in the UMD that matches an attribute of the first target resource, the attribute of the target resource indicating a purpose of the target resource;

[0037] In response to the presence of a video memory pool matching the attribute of the first target resource in the UMD, the video memory pool matching the attribute of the first target resource is used as a target video memory pool.

[0038] In a possible implementation manner, the second determining module is configured to:

[0039] According to the meta information list, determining whether there is a first video memory block in the target video memory pool, the meta information list including meta information of available video memory blocks in the target video memory pool, the meta information including video memory size and address of the video memory block, the first video memory block being an available video memory block whose video memory size is not less than the video memory size required by the first target resource in the target video memory pool and whose video memory size is closest to the video memory size required by the first target resource;

[0040] In response to the existence of the first video memory block, an address of a target video memory block that satisfies the video memory size is determined.

[0041] In a possible implementation, in response to the existence of the first video memory block, determining the address of the target video memory block that satisfies the video memory size includes:

[0042] Splitting the first video memory block into a second video memory block and a third video memory block, wherein the video memory size of the second video memory block is the video memory size required by the first target resource;

[0043] Remove the meta information of the first video memory block from the meta information list;

[0044] Insert the meta information of the third video memory block into the meta information list;

[0045] The address of the target video memory block is determined to be the address of the second video memory block.

[0046] In a possible implementation manner, the second determining module is configured to:

[0047] In response to the first video memory block not existing, applying to create a video memory block of a preset size in the UMD by switching to kernel mode, and inserting meta information of the video memory block into the meta information list;

[0048] The created video memory block is used as the first video memory block.

[0049] In a possible implementation, the address of the target video memory block includes an offset of a start address of the target video memory block relative to a start address of a target video memory pool.

[0050] In a possible implementation manner, the first determining module is configured to:

[0051] In response to the absence of a video memory pool matching the attributes of the first target resource in the UMD, an application is made to create a video memory pool matching the attributes of the first target resource in the UMD by switching to kernel mode, and the created video memory pool is used as the target video memory pool.

[0052] In a possible implementation, the device further includes:

[0053] A third determining module, configured to determine a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource in response to a request from the application to release the second target resource;

[0054] The inserting module is used to insert the meta information of the fifth video memory block into the meta information list.

[0055] In a possible implementation manner, the third determining module is configured to:

[0056] In response to a request from the application to release the second target resource, determining whether a previous video memory block and a subsequent video memory block of a fourth video memory block in the video memory are available;

[0057] In response to the previous video memory block being available, merging the previous video memory block with the fourth video memory block so that the fifth video memory block includes the previous video memory block and the fourth video memory block;

[0058] In response to the next video memory block being available, merging the next video memory block with the fourth video memory block so that the fifth video memory block includes the next video memory block and the fourth video memory block;

[0059] In response to the previous video memory block being unavailable and the next video memory block being unavailable, the fifth video memory block is made the fourth video memory block.

[0060] According to another aspect of the present disclosure, a video memory management device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0061] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.

[0062] According to another 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 a processor of an electronic device, the processor in the electronic device executes the above method.

[0063] According to the disclosed embodiment, by responding to the application's request to create the first target resource, the target video memory pool is determined in the UMD, so that the application can directly allocate and reclaim video memory through the video memory pool. Since the target video memory pool is the GPU video memory applied for by the UMD, by determining the address of the target video memory block that meets the video memory size in the target video memory pool according to the video memory size required by the first target resource, the address of the target video memory block is used to return to the application to meet the request to create the first target resource, which can effectively solve the problem of APP frequently allocating and releasing video memory, and reduce the number of times UMD initiates video memory allocation requests to Direct3DRuntime. At the same time, the APP does not need to switch to kernel mode to apply for video memory, and can be completed in user mode, reducing the number of switches to kernel mode, thereby reducing latency, improving operating efficiency, and more efficiently indexing the most suitable size target video memory block.

[0064] 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

[0065] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0066] Figure 1 A schematic diagram showing video memory allocation in the prior art is shown.

[0067] Figure 2 A schematic diagram showing an application scenario of an embodiment of the present disclosure.

[0068] Figure 3 A flowchart of a video memory management method according to an embodiment of the present disclosure is shown.

[0069] Figure 4 A flowchart of a video memory management method according to an embodiment of the present disclosure is shown.

[0070] Figure 5 A flowchart of a video memory management method according to an embodiment of the present disclosure is shown.

[0071] Figure 6 A structural diagram of a video memory management device according to an embodiment of the present disclosure is shown.

[0072] Figure 7 It is a block diagram showing a device 1900 for video memory management according to an exemplary embodiment. DETAILED DESCRIPTION

[0073] 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 specified.

[0074] 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.

[0075] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0076] Video memory is a dedicated memory on the graphics card that is used to store image data, textures, vertex information, and other intermediate results required for rendering tasks. Usually, image rendering tasks require a large amount of image data to be processed and displayed. Before executing a rendering task, an application (APP) must first apply for video memory allocation. In the current method of video memory management, each time an application creates a resource, the user mode driver needs to initiate an application for video memory allocation and switch to kernel mode to apply for video memory resource allocation.

[0077] See also Figure 1 , which shows a schematic diagram of video memory allocation in the prior art. Figure 1 As shown, taking Windows 10 as an example, in the prior art, each time an application (APP) needs to create resources, the APP sends a request to create resources to the Direct3D Runtime of the operating system. After the Direct3D Runtime sends a request to create resources to the user mode driver (UMD), the UMD applies to the Direct3D Runtime for allocation of video memory. At this time, the Direct3D Runtime switches from user mode to kernel mode, and applies to the DirectX graphics kernel subsystem (DXGK) and kernel mode driver (KMD) in kernel mode for allocation of video memory. DXGK and KMD jointly complete the video memory allocation and return the allocation result to the Direct3D Runtime, which then returns the allocation result to the UMD. Based on the allocation result, the UMD returns the resources to the APP through the Direct3D Runtime.

[0078] Since the switching process from user mode to kernel mode is very time-consuming, especially when the application has frequent resource creation, the current solution cannot meet the demand for operating efficiency. Therefore, a new video memory management method is urgently needed to reduce the number of accesses, save resources, and improve operating efficiency.

[0079] In view of this, the present disclosure proposes a video memory management method, device and storage medium. The method of the embodiment of the present disclosure determines the target video memory pool in the user mode driver UMD in response to the application's request to create a first target resource, so that the application can directly allocate and recycle video memory through the video memory pool. Since the target video memory pool is the GPU video memory applied for by the UMD, the address of the target video memory block that meets the video memory size is determined in the target video memory pool according to the video memory size required by the first target resource. The address of the target video memory block is used to return to the application to meet the request to create the first target resource, which can effectively solve the problem of APP frequently allocating and releasing video memory, reduce the number of times UMD initiates video memory allocation requests to Direct3D Runtime, and at the same time, the APP does not need to switch to kernel mode to apply for video memory, which can be completed in user mode, reducing the number of switches to kernel mode, thereby reducing latency, improving operating efficiency, and more efficiently indexing the target video memory block of the most appropriate size.

[0080] Figure 2 The schematic diagram of an application scenario of an embodiment of the present disclosure is shown. The video memory management method of the embodiment of the present disclosure can be used in a scenario where an application APP performs an image rendering task, such as Figure 2 As shown, in the scenario of the embodiment of the present disclosure, a video memory pool is created in the UMD, so that when the APP applies to create resources, a request to create a target resource is sent to the UMD through the Direct3D Runtime. According to the method of the embodiment of the present disclosure, the target video memory pool can be determined in the UMD, and the address of the target video memory block of the video memory size that meets the target resource requirements can be determined in the target video memory pool, so that the UMD can return resources (i.e., the address of the target video memory block) through the Direct3D Runtime to meet the request of the APP to create the target resource. This process is performed in the user mode of the operating system.

[0081] The method of the disclosed embodiment can be used for a server or a terminal device. The terminal device can be any one or more of a mobile phone, a foldable electronic device, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), and a vehicle-mounted device. The disclosed embodiment does not impose any special restrictions on the specific type of the terminal device, and the terminal device can have a wired or wireless communication function.

[0082] The server can be located locally or in the cloud, and can be a physical device or a virtual device, such as a virtual machine, a container, etc., and has a wireless communication function, wherein the wireless communication function can be set in the chip (system) or other parts or components of the server. The wireless communication function can be realized, for example, through mobile communication technologies such as 2G / 3G / 4G / 5G, as well as Wi-Fi, Bluetooth, frequency modulation (FM), digital radio, satellite communication, etc. Communication can also be carried out through wired connection to achieve interaction with other devices.

[0083] The following Figure 3-Figure 5 , the video memory management method of the embodiment of the present disclosure is introduced.

[0084] Figure 3 A flowchart of a video memory management method according to an embodiment of the present disclosure is shown. The method can be used in the above-mentioned terminal device or server, such as Figure 3 As shown, the method includes:

[0085] Step S301 , in response to a request from an application to create a first target resource, a target video memory pool is determined in a user mode driver UMD.

[0086] During the process of executing the image rendering task by the application, a request for creating the first target resource may be generated. The first target resource may be a video memory resource for storing the intermediate result of the image rendering task. Figure 2 , the APP sends a request to create the first target resource to the UMD through the Direct3D Runtime to determine the corresponding target video memory pool in the UMD.

[0087] The target video memory pool is a video memory pool that matches the attributes of the first target resource. Figure 4 Determine the target video memory pool. Figure 4 , shows a flow chart of a video memory management method according to an embodiment of the present disclosure. Figure 4 As shown, the S301 includes:

[0088] Step S401: In response to a request from an application to create a first target resource, it is determined whether there is a video memory pool in the UMD that matches the attributes of the first target resource.

[0089] The properties of the target resource indicate the purpose of the target resource. Since the request to create a resource can come from different apps, the resource can be used to perform different image rendering tasks. The purpose of the target resource can refer to the intermediate results stored thereon for CPU or GPU processing, the frequency of reading and writing the intermediate results, etc. Resources with the same properties can be stored in the same video memory pool to facilitate reading and writing.

[0090] Step S402: In response to the presence of a video memory pool matching the attributes of the first target resource in the UMD, the video memory pool matching the attributes of the first target resource is used as a target video memory pool.

[0091] At this time, the starting address of the video memory pool can be determined as the starting address of the target video memory pool.

[0092] The target video memory pool may include one or more video memory blocks, and the video memory blocks include the GPU video memory requested by the UMD.

[0093] Different video memory blocks may be pre-divided when creating a video memory pool, or may be formed by division in a subsequent video memory allocation process, or may be formed in a subsequent resource release process.

[0094] Optionally, S301 may further include:

[0095] Step S403, in response to the absence of a video memory pool matching the attributes of the first target resource in the UMD, applying to create a video memory pool matching the attributes of the first target resource in the UMD by switching to kernel mode, and using the created video memory pool as the target video memory pool.

[0096] In response to the application's request to create the first target resource, the UMD may apply to the Direct3D Runtime for allocation of a preset size of video memory (i.e., for creation of a preset size of video memory pool). At this time, the Direct3D Runtime switches from the user mode to the kernel mode, and applies to the DXGK and KMD in the kernel mode for allocation of video memory. The DXGK and KMD jointly complete the video memory allocation and return the allocation result to the Direct3D Runtime, which then returns the allocation result to the UMD, thereby creating a preset size of video memory pool.

[0097] The newly created video memory pool may be matched with the attribute of the first target resource, and the video memory pool may be used as the target video memory pool.

[0098] like Figure 4As shown, when executing step S402, if there is a video memory pool in the UMD that matches the attributes of the first target resource, the video memory pool may be applied for by the UMD by switching to the kernel mode when the application once issued a request to create the first target resource before step S301, performing an operation similar to step S403. Since the video memory pool already exists and matches the attributes of the first target resource during this request, there is no need to switch to the kernel mode for application, thereby reducing the number of switches to the kernel mode.

[0099] Step S302: According to the video memory size required by the first target resource, an address of a target video memory block that meets the video memory size is determined in the target video memory pool.

[0100] Since the target video memory pool may include multiple video memory blocks of different sizes, the target video memory block of the most suitable size can be indexed among the multiple video memory blocks according to the video memory size required by the first target resource. The address of the target video memory block can be used to return to the application to meet the request to create the first target resource. The size of the target video memory block can also be returned to the APP in response to the APP's request to create the first target resource. Thus, the allocation of video memory can be completed.

[0101] The address of the target video memory block may include an offset of the start address of the target video memory block relative to the start address of the target video memory pool. Optionally, the address of the target video memory block may also include the start address of the target video memory pool. The above address may represent the physical address of the corresponding video memory.

[0102] According to the disclosed embodiment, by responding to the application's request to create the first target resource, the target video memory pool is determined in the UMD, so that the application can directly allocate and reclaim video memory through the video memory pool. Since the target video memory pool is the GPU video memory applied for by the UMD, by determining the address of the target video memory block that meets the video memory size in the target video memory pool according to the video memory size required by the first target resource, the address of the target video memory block is used to return to the application to meet the request to create the first target resource, which can effectively solve the problem of APP frequently allocating and releasing video memory, and reduce the number of times UMD initiates video memory allocation requests to Direct3DRuntime. At the same time, the APP does not need to switch to kernel mode to apply for video memory, and can be completed in user mode, reducing the number of switches to kernel mode, thereby reducing latency, improving operating efficiency, and more efficiently indexing the most suitable size target video memory block.

[0103] The following Figure 5 The method for determining the target video memory block in the embodiment of the present disclosure is introduced, see Figure 5 , shows a flow chart of a video memory management method according to an embodiment of the present disclosure. Figure 5 As shown, step S302 may include:

[0104] Step S501: judging whether there is a first video memory block in the target video memory pool according to the meta information list.

[0105] A meta information list may be set for each video memory pool. The meta information list of the target video memory pool may include meta information of available video memory blocks in the target video memory pool. The availability of a video memory block means that the video memory resources on the video memory block can be returned as the first target resource and allocated to the APP to meet the request of the APP to create the first target resource. An identifier of whether the video memory block is available may also be stored in the video memory corresponding to the video memory block.

[0106] The meta information includes the video memory size and address of the video memory block. The address may include the offset of the start address of the video memory block relative to the start address of the video memory pool in which it is located, and may also include the start address of the video memory pool in which it is located. In the meta information list, the meta information of the available video memory blocks in the target video memory pool may be arranged according to the video memory size of the available video memory blocks.

[0107] The available video memory blocks in the meta information list may be traversed to determine whether there is a first video memory block, wherein the first video memory block is an available video memory block whose video memory size is closest to the video memory size required by the first target resource among the video memory blocks whose video memory size is not less than the video memory size required by the first target resource in the target video memory pool.

[0108] For example, if the video memory size required by the first target resource is X, the metadata list of the target video memory pool can be traversed to determine the available video memory block (whose video memory size is, for example, Y) whose video memory size is not less than X and closest to X, and the available video memory block with the video memory size of Y is used as the first video memory block.

[0109] Step S502: in response to the existence of the first video memory block, determining an address of a target video memory block that satisfies the video memory size.

[0110] Since the video memory size of the first video memory block is not necessarily completely consistent with the video memory size required by the first target resource, for example, when the video memory size of the first video memory block is Y, its video memory size is greater than the video memory size X required by the first target resource. At this time, in order to allocate an available video memory block of the most appropriate size to the first target resource, and since the first video memory block is continuous in the video memory address, the first video memory block can be split to determine the target video memory block.

[0111] In response to the video memory size of the first video memory block being larger than the video memory size required by the first target resource, step S502 may include:

[0112] Splitting the first video memory block into a second video memory block and a third video memory block;

[0113] Remove the meta information of the first video memory block from the meta information list;

[0114] Insert the meta information of the third video memory block into the meta information list;

[0115] The address of the target video memory block is determined to be the address of the second video memory block.

[0116] The video memory size of the second video memory block is the video memory size required by the first target resource. For example, when the video memory size of the first video memory block is Y and the video memory size required by the first target resource is X, after the first video memory block is split, the video memory size of the second video memory block is X, and the video memory size of the third video memory block is YX.

[0117] After the first video memory block is split into the second video memory block and the third video memory block, in order to avoid repeated allocation of video memory resources when there is a subsequent resource creation request, the meta information of the first video memory block can be removed from the meta information list of the target video memory pool, and the identifier corresponding to the first video memory block can be marked as unavailable. Since the second video memory block can be used for allocation as the target video memory block, there is no need to add the meta information of the second video memory block to the meta information list, and the identifier corresponding to the second video memory block can be marked as unavailable. The identifier corresponding to the third video memory block can be marked as available, and the meta information of the third video memory block can be inserted into the meta information list.

[0118] The new meta information list can be re-sorted according to video memory size.

[0119] If, based on the judgment in S501, the first video memory block does not exist in the target video memory pool, the step S302 may further include:

[0120] Step S503 , in response to the absence of the first video memory block, applying to create a video memory block of a preset size in the UMD by switching to the kernel mode, and inserting the meta information of the video memory block into the meta information list.

[0121] For example, UMD can apply to Direct3D Runtime for allocation of a preset size of video memory, and Direct3D Runtime switches from user mode to kernel mode. DXGK and KMD in kernel mode jointly complete the video memory allocation and return the allocation result to create a preset size of video memory block in UMD and add the video memory block to the target video memory pool.

[0122] Step S504: Use the created video memory block as the first video memory block.

[0123] Therefore, step S502 can be continued.

[0124] In the process of reclaiming video memory resources, the method may further include:

[0125] In response to a request from the application to release the second target resource, determining a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource;

[0126] Insert the meta information of the fifth video memory block into the meta information list.

[0127] The APP may send a request for releasing the second target resource to the UMD through the Direct3D Runtime, so as to reclaim the video memory corresponding to the second target resource.

[0128] In order to alleviate the phenomenon that there are too many video memory block fragments in the video memory pool during the frequent allocation and release of video memory, when determining the fifth video memory block, the available video memory blocks before and after it can be merged and recycled.

[0129] In response to a request from the application to release the second target resource, it is determined whether a previous video memory block and a subsequent video memory block of the fourth video memory block in the video memory are available.

[0130] The fourth video memory block may represent a target video memory block allocated to the APP in response to the request to create the second target resource. The previous video memory block and the next video memory block of the fourth video memory block may be the previous video memory block and the next video memory block that are continuous with the fourth video memory block in the physical address of the video memory. Whether the previous video memory block and the next video memory block are available can be determined by the corresponding identifiers on the previous video memory block and the next video memory block.

[0131] In response to the previous video memory block being available, the previous video memory block is merged with the fourth video memory block so that the fifth video memory block includes the previous video memory block and the fourth video memory block. After the merging, the video memory size of the fifth video memory block is the video memory size of the previous video memory block plus the video memory size of the fourth video memory block.

[0132] In response to the next video memory block being available, the next video memory block is merged with the fourth video memory block so that the fifth video memory block includes the next video memory block and the fourth video memory block.

[0133] At this time, if the previous video memory block is unavailable and the next video memory block is available, after merging, the video memory size of the fifth video memory block is the video memory size of the next video memory block plus the video memory size of the fourth video memory block; if the previous video memory block is available and the next video memory block is unavailable, after merging, the video memory size of the fifth video memory block is the video memory size of the previous video memory block plus the video memory size of the fourth video memory block; if the previous video memory block is available and the next video memory block is available, after merging, the video memory size of the fifth video memory block is the sum of the video memory size of the next video memory block, the memory size of the fourth video memory block, and the video memory size of the previous video memory block.

[0134] In response to the previous video memory block being unavailable and the next video memory block being unavailable, the fifth video memory block is made the fourth video memory block.

[0135] The meta information of the fifth video memory block may be inserted into the meta information list, and the new meta information list may be reordered according to the video memory size.

[0136] Thus, the video memory resources can be recycled.

[0137] Figure 6 FIG. 1 shows a structural diagram of a video memory management device according to an embodiment of the present disclosure. The device can be used in the above-mentioned terminal device or server, such as Figure 6 As shown, the device comprises:

[0138] A first determination module 601 is used to determine a target video memory pool in a user mode driver UMD in response to a request for creating a first target resource by an application program, wherein the target video memory pool includes one or more video memory blocks, and the video memory blocks include a graphics processor GPU video memory applied for by the UMD;

[0139] The second determination module 602 is used to determine the address of a target video memory block that meets the video memory size in the target video memory pool according to the video memory size required by the first target resource, and the address of the target video memory block is used to return to the application to meet the request to create the first target resource.

[0140] In a possible implementation, the first determining module 601 is configured to:

[0141] In response to a request from an application to create a first target resource, determining whether there is a video memory pool in the UMD that matches an attribute of the first target resource, the attribute of the target resource indicating a purpose of the target resource;

[0142] In response to the presence of a video memory pool matching the attribute of the first target resource in the UMD, the video memory pool matching the attribute of the first target resource is used as a target video memory pool.

[0143] In a possible implementation, the second determining module 602 is configured to:

[0144] According to the meta information list, determining whether there is a first video memory block in the target video memory pool, the meta information list including meta information of available video memory blocks in the target video memory pool, the meta information including video memory size and address of the video memory block, the first video memory block being an available video memory block whose video memory size is not less than the video memory size required by the first target resource in the target video memory pool and whose video memory size is closest to the video memory size required by the first target resource;

[0145] In response to the existence of the first video memory block, an address of a target video memory block that satisfies the video memory size is determined.

[0146] In a possible implementation, in response to the existence of the first video memory block, determining the address of the target video memory block that satisfies the video memory size includes:

[0147] Splitting the first video memory block into a second video memory block and a third video memory block, wherein the video memory size of the second video memory block is the video memory size required by the first target resource;

[0148] Remove the meta information of the first video memory block from the meta information list;

[0149] Insert the meta information of the third video memory block into the meta information list;

[0150] The address of the target video memory block is determined to be the address of the second video memory block.

[0151] In a possible implementation, the second determining module 602 is configured to:

[0152] In response to the first video memory block not existing, applying to create a video memory block of a preset size in the UMD by switching to kernel mode, and inserting meta information of the video memory block into the meta information list;

[0153] The created video memory block is used as the first video memory block.

[0154] In a possible implementation, the address of the target video memory block includes an offset of a start address of the target video memory block relative to a start address of a target video memory pool.

[0155] In a possible implementation, the first determining module 601 is configured to:

[0156] In response to the absence of a video memory pool matching the attributes of the first target resource in the UMD, an application is made to create a video memory pool matching the attributes of the first target resource in the UMD by switching to kernel mode, and the created video memory pool is used as the target video memory pool.

[0157] In a possible implementation, the device further includes:

[0158] A third determining module, configured to determine a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource in response to a request from the application to release the second target resource;

[0159] The inserting module is used to insert the meta information of the fifth video memory block into the meta information list.

[0160] In a possible implementation manner, the third determining module is configured to:

[0161] In response to a request from the application to release the second target resource, determining whether a previous video memory block and a subsequent video memory block of a fourth video memory block in the video memory are available;

[0162] In response to the previous video memory block being available, merging the previous video memory block with the fourth video memory block so that the fifth video memory block includes the previous video memory block and the fourth video memory block;

[0163] In response to the next video memory block being available, merging the next video memory block with the fourth video memory block so that the fifth video memory block includes the next video memory block and the fourth video memory block;

[0164] In response to the previous video memory block being unavailable and the next video memory block being unavailable, the fifth video memory block is made the fourth video memory block.

[0165] According to the disclosed embodiment, by responding to the application's request to create the first target resource, the target video memory pool is determined in the UMD, so that the application can directly allocate and reclaim video memory through the video memory pool. Since the target video memory pool is the GPU video memory applied for by the UMD, by determining the address of the target video memory block that meets the video memory size in the target video memory pool according to the video memory size required by the first target resource, the address of the target video memory block is used to return to the application to meet the request to create the first target resource, which can effectively solve the problem of APP frequently allocating and releasing video memory, and reduce the number of times UMD initiates video memory allocation requests to Direct3DRuntime. At the same time, the APP does not need to switch to kernel mode to apply for video memory, and can be completed in user mode, reducing the number of switches to kernel mode, thereby reducing latency, improving operating efficiency, and more efficiently indexing the most suitable size target video memory block.

[0166] 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. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0167] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.

[0168] The embodiment of the present disclosure also proposes a video memory management device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0169] The embodiments of the present disclosure also provide a computer program product, 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 a processor of an electronic device, the processor in the electronic device executes the above method.

[0170] Figure 7 1 is a block diagram of a device 1900 for video memory management according to an exemplary embodiment. For example, the device 1900 may be provided as a server or a terminal device. Figure 7, the apparatus 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, such as an application, that can be executed by the processing component 1922. 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 instructions to perform the above method.

[0171] The device 1900 may also include a power supply component 1926 configured to perform power management of the device 1900, a wired or wireless network interface 1950 configured to connect the device 1900 to a network, and an input / output interface 1958 (I / O interface). The device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2000. TM , MacOS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.

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

[0173] The present disclosure may be a system, a method and / or a 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.

[0174] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may 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 of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) 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 disk 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 of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted 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 a wire.

[0175] 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, optical fiber transmissions, wireless transmissions, 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 for storage in the computer-readable storage medium in each computing / processing device.

[0176] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related 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++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely 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 completely 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., using 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 customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0177] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0178] 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 that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0179] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating 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 boxes in the flowchart and / or block diagram.

[0180] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0181] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A video memory management method, characterized in that: The method comprises: In response to a request from an application to create a first target resource, determining a target video memory pool in a user mode driver UMD, wherein the target video memory pool includes one or more video memory blocks, and the video memory blocks include a graphics processor GPU video memory requested by the UMD; According to the video memory size required by the first target resource, the address of a target video memory block that meets the video memory size is determined in the target video memory pool, and the address of the target video memory block is used to return to the application to meet the request to create the first target resource. The target video memory pool matches the attributes of the first target resource, and the attributes of the target resource are used to indicate the purpose of the target resource.

2. The method according to claim 1, characterized in that The step of determining a target video memory pool in a user mode driver UMD in response to a request from an application to create a first target resource comprises: In response to a request from an application to create a first target resource, determining whether there is a video memory pool in the UMD that matches an attribute of the first target resource, wherein the attribute of the target resource indicates a purpose of the target resource; In response to the presence of a video memory pool matching the attribute of the first target resource in the UMD, the video memory pool matching the attribute of the first target resource is used as the target video memory pool.

3. The method according to claim 1, characterized in that: The step of determining, in the target video memory pool, an address of a target video memory block that satisfies the video memory size according to the video memory size required by the first target resource, comprises: Judging whether there is a first video memory block in the target video memory pool according to the meta information list, the meta information list including meta information of available video memory blocks in the target video memory pool, the meta information including video memory size and address of the video memory block, the first video memory block being an available video memory block whose video memory size is not less than the video memory size required by the first target resource and whose video memory size is closest to the video memory size required by the first target resource among the video memory blocks in the target video memory pool whose video memory size is not less than the video memory size required by the first target resource; In response to the existence of the first video memory block, an address of a target video memory block that satisfies the video memory size is determined.

4. The method according to claim 3, characterized in that In response to the existence of the first video memory block, determining the address of the target video memory block that satisfies the video memory size includes: Splitting the first video memory block into a second video memory block and a third video memory block, wherein the video memory size of the second video memory block is the video memory size required by the first target resource; Remove the meta information of the first video memory block from the meta information list; Inserting the meta information of the third video memory block into the meta information list; The address of the target video memory block is determined to be the address of the second video memory block.

5. The method according to claim 3, characterized in that: The step of determining, in the target video memory pool, an address of a target video memory block that satisfies the video memory size according to the video memory size required by the first target resource, comprises: In response to the absence of the first video memory block, applying to create a video memory block of a preset size in the UMD by switching to kernel mode, and inserting meta information of the video memory block into the meta information list; The created video memory block is used as the first video memory block.

6. The method according to claim 1, characterized in that The address of the target video memory block includes an offset of a start address of the target video memory block relative to a start address of the target video memory pool.

7. The method according to claim 2, characterized in that The step of determining a target video memory pool in a user mode driver UMD in response to a request from an application to create a first target resource comprises: In response to the absence of a video memory pool matching the attributes of the first target resource in the UMD, applying to create a video memory pool matching the attributes of the first target resource in the UMD by switching to kernel mode, and using the created video memory pool as the target video memory pool.

8. The method according to claim 1, characterized in that The method further comprises: In response to a request from the application to release the second target resource, determining a fifth video memory block according to an address of a fourth video memory block corresponding to the second target resource; Inserting the meta information of the fifth video memory block into the meta information list.

9. The method according to claim 8, characterized in that The step of responding to a request from the application to release the second target resource and determining the fifth video memory block according to an address of the fourth video memory block corresponding to the second target resource comprises: In response to a request from the application to release the second target resource, determining whether a previous video memory block and a subsequent video memory block of the fourth video memory block in the video memory are available; In response to the previous video memory block being available, merging the previous video memory block with the fourth video memory block so that the fifth video memory block includes the previous video memory block and the fourth video memory block; In response to the latter video memory block being available, merging the latter video memory block with the fourth video memory block so that the fifth video memory block includes the latter video memory block and the fourth video memory block; In response to the previous video memory block being unavailable and the next video memory block being unavailable, the fifth video memory block is made the fourth video memory block.

10. A video memory management device, characterized in that: The device comprises: A first determination module, configured to determine a target video memory pool in a user mode driver UMD in response to a request from an application to create a first target resource, wherein the target video memory pool includes one or more video memory blocks, and the video memory blocks include a graphics processor GPU video memory requested by the UMD; The second determination module is used to determine the address of a target video memory block that meets the video memory size required by the first target resource in the target video memory pool, the address of the target video memory block is used to return to the application to meet the request to create the first target resource, the target video memory pool matches the attributes of the first target resource, and the attributes of the target resource are used to indicate the purpose of the target resource.

11. A video memory management device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 9 when executing the instructions stored in the memory.

12. A non-volatile 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 9 is implemented.

Citation Information

Patent Citations

  • Video memory access method and device and storage medium

    CN110231988A

  • Video memory management method and device, equipment, storage medium and program product

    CN114418828A