Data storage method and device

By selecting the appropriate cached data blocks for the indirect index map of the virtual map for storage, the problem of virtual map occupies a lot of memory and improves the game's running performance.

CN115034953BActive Publication Date: 2025-08-05ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210654181.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-10
Publication Date
2025-08-05
Estimated Expiration
2042-06-10

AI Technical Summary

Technical Problem

In the prior art, virtual map data occupies a large system memory space, resulting in a lot of memory fragments and affects the game's running performance.

Method used

By determining the size type of the indirect index map, selecting the cached data blocks associated with it for storage, the classification storage of virtual maps is realized and memory fragmentation is reduced.

Benefits of technology

Improve game performance, make full use of cache space, and reduce memory fragmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115034953B_ABST
    Figure CN115034953B_ABST
Patent Text Reader

Abstract

The present application provides a data storage method and apparatus. The data storage method includes: receiving a data storage request for target texture data; determining a target indirect index map corresponding to the target texture data based on the data storage request, wherein the target indirect index map carries an index map size type; in a cache area including at least one cache data block, selecting a target cache data block associated with the index map size type, wherein the cache area is composed of cache data blocks of at least one storage size type; storing the target indirect index map in the target cache data block. In a game scenario, a large number of game virtual textures with a large quantity and various types can be stored in a classified manner according to the above data storage method, which not only reduces a large number of memory fragments but also improves the actual running performance of the game.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly to a data storage method. This application also relates to a data storage device, a computing device, and a computer-readable storage medium. Background Art

[0002] With the development of Internet technology, online games have attracted more and more users. In order to provide users with better visual effects and gaming experiences, when rendering game scenes, an increasing number and variety of texture maps are used, and the performance accuracy of texture maps is also getting higher and higher. In the prior art, virtual texture mapping technology is used to optimize game scenes. However, when the number and variety of virtual texture maps are large, the virtual texture map data will occupy a large amount of system memory space, and moreover, the virtual texture map data is stored chaotically in the system memory space, bringing a large number of memory fragments to the system memory space, which will affect the actual running performance of the game. Summary of the Invention

[0003] In view of this, embodiments of this application provide a data storage method to solve the technical defects existing in the prior art. Embodiments of this application also provide a data storage device, a computing device, and a computer-readable storage medium.

[0004] According to the first aspect of the embodiments of this application, a data storage method is provided, including:

[0005] Receiving a data storage request for target texture map data;

[0006] Determining a target indirect index map corresponding to the target texture map data based on the data storage request, where the target indirect index map carries an index map size type;

[0007] Selecting a target cache data block associated with the index map size type in a cache area including at least one cache data block, where the cache area consists of cache data blocks of at least one storage size type;

[0008] Storing the target indirect index map into the target cache data block.

[0009] According to the second aspect of the embodiments of this application, a data storage device is provided, including:

[0010] A request receiving module configured to receive a data storage request for target texture map data;

[0011] An index map determining module configured to determine a target indirect index map corresponding to the target texture map data based on the data storage request, where the target indirect index map carries an index map size type;

[0012] A data block selection module, configured to select a target cache data block associated with the index map size type in a cache area including at least one cache data block, where the cache area consists of cache data blocks of at least one storage size type;

[0013] An index map storage module, configured to store the target indirect index map into the target cache data block.

[0014] According to a third aspect of an embodiment of the present application, a computing device is provided, including:

[0015] A memory and a processor;

[0016] The memory is used to store computer-executable instructions, and when the processor executes the computer-executable instructions, the steps of the data storage method are implemented.

[0017] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the data storage method are implemented.

[0018] According to a fifth aspect of an embodiment of the present application, a chip is provided, which stores a computer program, and when the computer program is executed by the chip, the steps of the data storage method are implemented.

[0019] The data storage method provided by the present application includes receiving a data storage request for target texture data; determining a target indirect index map corresponding to the target texture data based on the data storage request, where the target indirect index map carries an index map size type; selecting a target cache data block associated with the index map size type in a cache area including at least one cache data block, where the cache area consists of cache data blocks of at least one storage size type; and storing the target indirect index map into the target cache data block.

[0020] Specifically, during the process of storing data for the target indirect index map corresponding to the target texture map data, by determining the index map size type of the target indirect index map, a target cache data block is determined for the target indirect index map to store the target indirect index map. In the process of determining the target cache data block, it is necessary to select the target cache data block associated with the index map size type. This method determines the cache data block associated with the size type according to the index map size type, which can classify and store the indirect index maps corresponding to different index map size types, so as to manage the cache data blocks of different classifications by type. At the same time, in the game scenario, a large number of game virtual texture maps with various types can be stored in categories according to the above data storage method, which not only reduces a large amount of memory fragmentation but also improves the actual running performance of the game. Brief Description of the Drawings

[0021] Figure 1 is a schematic structural diagram of a data storage method provided by an embodiment of the present application;

[0022] Figure 2 is a flowchart of a data storage method provided by an embodiment of the present application;

[0023] Figure 3 is a schematic flowchart of a data storage method for virtual texture maps applied to a game scenario provided by an embodiment of the present application;

[0024] Figure 4 is a schematic structural diagram of a data storage device provided by an embodiment of the present application;

[0025] Figure 5 is a block diagram of the structure of a computing device provided by an embodiment of the present application. Detailed Embodiments

[0026] Many specific details are set forth in the following description in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of the present application. Therefore, the present application is not limited by the specific embodiments disclosed below.

[0027] The terms used in one or more embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of the present application. The singular forms "a", "the", and "said" used in one or more embodiments of the present application and the appended claims are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more of the associated listed items.

[0028] It should be understood that although the terms "first," "second," and the like may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are merely used to distinguish information of the same type from one another. For example, "first" may also be referred to as "second," and similarly, "second" may also be referred to as "first," without departing from the scope of one or more embodiments of the present application.

[0029] First, the terms involved in one or more embodiments of the present invention are explained.

[0030] Texturing: A step in the production process of 3D film, television animation and games, that is, the process of using graphic software such as Photoshop to create a material plane map and covering it on a three-dimensional model created using 3D production software such as Maya and 3DMax, is called texturing.

[0031] Virtual Texturing: This technology is used to address the problem of a large number of textures in a 3D scene and limited memory. All textures used by the program are processed into several large virtual textures. These virtual textures are usually very large and cannot be loaded into memory. Each virtual texture is divided into many n*n small blocks, each of which is called a page file and stored on disk. The virtual texture corresponds to an indirect index map (Indirect Texture), which is loaded into memory. The indirect index map (Indirect Texture) stores the position of each page block of each virtual texture corresponding to the real texture (or physical texture).

[0032] Virtual mapping technology is used to solve the problem of limited memory for a large number of textures in 3D scenes. Its idea can be referred to virtual memory technology. Physical memory is limited, but virtual memory can be much larger than physical memory. Virtual memory is abstracted into a page, or paging file, which can be actually loaded into physical memory or exist on a disk file. The memory address used during addressing is mapped to a specific memory location using a mapping table. The same is true for virtual mapping technology. All textures used by the program will be processed onto larger virtual textures. These virtual textures are usually large in size and cannot be fully loaded into memory. Therefore, by dividing the large virtual texture into multiple small blocks and generating a corresponding indirect index map (IndirectTexture), this map is loaded into memory. The indirect index map (Indirect Texture) stores the position of the real texture (or physical texture) corresponding to each page block position of each virtual texture.

[0033] However, with the popularity of games, more consideration needs to be given to memory issues on terminals during the operation of games. If the texture memory accounts for a large proportion in the game, as the game iterates and the project develops, the number of textures used in the UI (User Interface) interface will increase. Even considering compression and partial loading, it generally occupies a large amount of memory space during operation. Therefore, the management of virtual texture caching plays an important role in both program performance and running memory. The original memory allocation method is similar to the greedy algorithm. Each allocation directly finds a memory segment in the continuous memory (cache pool) that can store the indirectly indexed map of the specified size. In the frequent allocation and recycling process, if memory rearrangement is not performed, a large number of memory fragments are likely to be generated.

[0034] Based on this, the data storage method provided in the embodiments of the present application, in the virtual texture technology in the game scenario, determines the size of the indirectly indexed map, allocates a cache data block (i.e., block) corresponding to this size for the indirectly indexed map, and stores the indirectly indexed map in this cache data block. In each storage process of the indirectly indexed map of the virtual texture, the cache data block corresponding to the size of the stored indirectly indexed map is determined to complete the management of the cache memory; this method is not likely to generate a large number of memory fragments, making the memory space utilization rate of the cache data block relatively high, so as to improve the actual running performance of the game.

[0035] In the present application, a data storage method is provided. The present application is also related to a data storage device, a computing device, and a computer-readable storage medium, which will be described in detail one by one in the following embodiments.

[0036] It should be noted that the data storage method provided in the embodiments of the present application can be applied to various scenarios for storing a large amount of virtual texture data, including but not limited to 3D animation generation scenarios, game texture generation scenarios, etc.; however, in this embodiment, the data storage method is introduced in detail by taking the storage of virtual texture data in the game scenario as an example.

[0037] See Figure 1 , Figure 1 shows a schematic structural diagram of the data storage method provided in the embodiments of the present application, where Figure 1 includes virtual texture 102, memory allocator 104, and cache data block 106.

[0038] In practical applications, after the memory allocator 104 receives a data storage request for the virtual texture map 102, it can first determine the indirect index map corresponding to the virtual texture map 102, and then store the indirect index map in the cache data block 106 subsequently. Specifically, the memory allocator 104 first determines the index map size type of the virtual texture map 102, and selects a target cache data block associated with the index map size type from the cache data block 106. Among them, the cache data block 106 is as shown by the space divided by the dotted line in Figure 1 Figure 1, and has multiple cache data blocks. The cache data block can be understood as the cache space allocated from the system memory, which is convenient for the virtual texture map in subsequent applications; after the memory allocator 104 selects the target cache data block, it can store the indirect index map in the target cache data block.

[0039] In the data storage method provided by the embodiment of the present application, the memory allocator manages the allocation of the memory space corresponding to the cache data block, and stores the indirect index map corresponding to the virtual texture map in the cache data block associated with the index map size type of the indirect index map, so as to classify and store the indirect index map in the corresponding position, make more full use of the cache space, and avoid generating a large amount of memory fragmentation in the cache data block.

[0040] Figure 2 The flowchart of a data storage method provided by an embodiment of the present application is shown, which specifically includes the following steps.

[0041] Step 202: Receive a data storage request for the target texture map data.

[0042] Among them, the target texture map data can be understood as the texture map in the virtual texture map technology, that is, the material plan view made by various application software. For example, in the production process of 3D animations and games, a large amount of texture map data needs to be produced.

[0043] In practical applications, the memory allocator can receive a data storage request for the target texture map data. This data storage request can be understood as a request for the memory allocator to allocate a piece of memory for caching the target texture map data. For example, in the process of game production, the memory allocator needs to cache a large amount of texture map data so as to call the texture map data from the cache space subsequently for game production; the process of the memory allocator storing the target texture map data can be understood as a memory allocation process in response to the data storage request.

[0044] Step 204: Determine the target indirect index map corresponding to the target texture map data based on the data storage request, where the target indirect index map carries an index map size type.

[0045] Among them, the target indirect index map can be understood as a map used to store the correspondence between the positions of each page block in the texture data and the positions of their corresponding physical textures, which plays a role in mapping the texture data and the correspondence between the physical textures corresponding to the texture data.

[0046] The index map size type can be understood as the size of the memory space occupied by the indirect index map when stored in a physical location, such as 8K, 12K, 18K, etc.

[0047] In practical applications, the memory allocator can determine the actual memory required to store the target texture data according to this data storage request. Then, the target texture data can be first divided into small squares of n*n, and a target indirect index map can be generated based on the divided multiple small squares. And there is a correspondence between the position of each small square in the target indirect index map and the position of its corresponding physical texture; at the same time, the target indirect index map also carries the index map size type to clarify the size of the memory space occupied by the cache of the target indirect index map; it should be noted that the process of determining the corresponding target indirect index map for the target texture data can refer to the process of generating an index texture in virtual texture technology, including but not limited to a certain generation method, and this embodiment does not limit this.

[0048] For example, during the production of game textures, for a texture with a character, first determine the indirect index map corresponding to the character texture data, and the index map size type of this indirect index map is 8K.

[0049] Step 206: In a cache area containing at least one cache data block, select a target cache data block associated with the index map size type, where the cache area is composed of cache data blocks of at least one storage size type.

[0050] Among them, the cache data block can be understood as a fixed-size memory segment in continuous memory, and can also be called a block; the cache area can be understood as an area or cache pool for caching data. For example, a continuous memory space is applied to the system memory for the caching function of running data.

[0051] The storage size type can be understood as the size type set for the cache data block that can store the index map. For example, if the index map size type is 8K, then the storage size type of a certain cache data block can be set to 8K, which means that this cache data block can only store an indirect index map with an index map size type of 8K.

[0052] In practical applications, after the memory allocator determines the target indirect index map based on the target texture data, it needs to determine the cache data block corresponding to storing the target indirect index map. Then, a cache data block that can store the target indirect index map can be selected from the continuous memory space. Specifically, when implementing, the memory manager needs to select a target cache data block from a cache area containing at least one cache data block. Since there are at least one storage size type for the multiple cache data blocks in this cache area, the memory allocator needs to select the storage size type associated with the index map size type of the target indirect index map. Then, the cache data block corresponding to the associated storage size type is the target cache data block. Continuing with the above example, when the memory allocator determines that the index map size type of the indirect index map is 8K, among the cache data blocks corresponding to the multiple storage size types in the cache area, it can select the target cache data block associated with the index map size type 8K, such as the cache data block with the storage size type of 8K, as the target cache data block.

[0053] Further, the memory allocator can pre-apply a segment of continuous memory in the system memory to generate a cache area for multiple cache data blocks to cache the indirect index map corresponding to the texture data. Specifically, before selecting the target cache data block associated with the index map size type in the cache area containing at least one cache data block, it further includes:

[0054] Create a target index map size type in response to a task processing request, and determine the target memory size based on the target index map size type;

[0055] Apply for a memory space in the system memory to be allocated that is the same as the target memory size, and use this memory space as the cache area for the target texture data.

[0056] Among them, the task processing request can be understood as a processing request for pre-configuring a segment of continuous memory, and this task processing request can vary according to the memory size requested by different application scenarios.

[0057] The target index map size type can be understood as the size type of the largest indirect index map among all the indirect index maps in the application scenario, that is, the memory size occupied by the largest indirect index map. For example, in a game scenario, the largest size of an indirect index map is 18K, then the target index map size type is set to 18K.

[0058] The target memory size can be understood as determining the memory size to be applied for in the system memory, and it is a multiple of the target index map size type and larger than the memory size of the target index map size type. For example, if the target index map size type is set to 18K, then the target memory size can be a multiple of 18K and larger than 18K, such as 18K * 100 = 1800K, 18K * 200 = 3600K, and so on.

[0059] In practical applications, the memory allocator can respond to the task processing request to create the target index map size type, that is, it can determine the maximum index map size type according to the current application scenario, and determine the memory size of the cache area according to the determined maximum index map size type, that is, the target memory size; at the same time, the target memory size can meet certain limiting conditions, can be a multiple of the maximum index map size type and larger than the memory space occupied by the maximum index map size type. This embodiment does not make specific limitations here.

[0060] Furthermore, the memory allocator can apply for a memory space in the to-be-allocated system memory that is the same as the target memory size, and use the applied memory space as the cache area for the target texture data, for subsequent dynamic reallocation of the indirect index map. The to-be-allocated system memory can be understood as the running memory space in the system corresponding to the application program. Continuing with the above example, when the memory allocator determines that the maximum index map size type is 18K, it can first apply for a continuous memory from the to-be-allocated system memory, such as a cache space with a memory space size of 3600K. Then, the 3600K-sized memory space will be used as the cache area for the texture data, for subsequent dynamic storage of the indirect index map corresponding to the texture data.

[0061] The data storage method provided by the embodiment of this application, by pre-applying for a continuous memory space from the system memory as the cache area, facilitates the subsequent memory allocator to cache the indirect index map into this cache area, and realizes the application of the texture data.

[0062] Furthermore, in order to facilitate determining the specific position to store the indirect index map in the cache area, it is also necessary to pre-create the concept of data blocks in the cache area, that is, this cache area is composed of at least one cache data block; specifically, the step of using the memory space as the cache area for the target texture data includes:

[0063] Dividing the memory space based on the target index map size type to obtain at least one sub-memory space;

[0064] Using the at least one sub-memory space as at least one cache data block, and generating the cache area for the target texture data based on the at least one cache data block.

[0065] In practical applications, after the memory allocator applies for the corresponding memory space from the system memory to be allocated, it divides the memory space based on the maximum indirect index map size type, and obtains at least one sub-memory space. Here, the sub-memory space can be understood as the memory space obtained by dividing the applied memory space according to certain rules. Then, each sub-memory space can be used as a cache data block, that is, the memory occupied by the maximum indirect index map size is used as a cache data block (block); and then a cache area corresponding to the texture data is generated according to multiple cache data blocks.

[0066] Continuing with the above example, if the memory allocator determines that the maximum index map size type is 18K, then the memory size of each divided cache data block is 18K, and the memory space composed of multiple 18K memory sizes is the cache area.

[0067] It should be noted that when dividing the memory space in this embodiment, the maximum index map size type is used because it is considered that in the application scenario, the index maps of the maximum index map size type can all be stored in the cache data blocks, so the index maps smaller than the maximum index map size type can also be cached in the cache data blocks.

[0068] The data storage method provided by the embodiment of the present application divides the system memory applied by the memory allocator, and each divided sub-memory space can be used as a cache data block, thereby constituting the entire cache area, which is convenient for subsequent classification caching of indirect index maps based on each cache data block as the basis for index map storage classification.

[0069] The above two embodiments can be understood as the process of the memory allocator pre-creating the cache area and cache data blocks in the application scenario. The data storage method provided by the following embodiment can specifically describe how to select a target cache data block in at least one cache data block of the cache area to store the target indirect index map; specifically, selecting a target cache data block associated with the index map size type in the cache area including at least one cache data block includes:

[0070] Determine at least one storage size type associated with the cache area, where the cache area includes at least one cache data block;

[0071] In the at least one storage size type, search for a target storage size type associated with the index map size type;

[0072] When it is determined that there is remaining cache space in the cache data block corresponding to the target storage size type, select the cache data block corresponding to the target storage size type as the target cache data block.

[0073] Among them, the target storage size type can be understood as a size type having an association relationship with the index map size type. This association relationship can be understood as the same size as the index map size type, or other association relationships such as a multiple relationship with the index map size type. It should be noted that the meaning of "association" mentioned in the embodiments of this application can be understood as the same size relationship, multiple relationship, etc.

[0074] In practical applications, the memory allocator can determine the storage size type of all cache data blocks in the cache area, and search for the target storage size type associated with the index map size type of the target indirect index map among all the storage size types. Furthermore, the cache data block corresponding to this target storage size type can be determined. In order to store the target indirect index map into this cache data block, it is also necessary to determine whether there is remaining cache space in this cache data block and whether this remaining cache space can store this target indirect index map. After the memory allocator determines that the target indirect index map can be stored into this cache data block, this cache data block can be used as the target cache data block.

[0075] Continuing with the above example, the memory size occupied by each cache data block in the cache area is 18K, and each cache data block has its own storage size type. If the size type of the target indirect index map is 2K, then it can be searched in all the storage size types in the cache area to see if there is a cache data block with a storage size type of 2K. If it exists, then it can be further determined whether the cache data block with a storage size type of 2K still has remaining storage space to store the target indirect index map with a size of 2K. If it can be stored, that is, the cache data block with a storage size type of 2K is the target cache data block for this target indirect index map.

[0076] It should be noted that during the initialization process of the cache area, if the memory allocator pre-allocates which cache data block stores the indirect index map of which storage size type, then it is equivalent to marking this cache data block, determining that this cache data block can subsequently continue to store the indirect index map of the corresponding storage size type, and achieving classified storage of the indirect index map according to different storage size types.

[0077] The data storage method provided by the embodiments of this application selects the corresponding target cache data block for the target indirect index map according to the storage size type of each cache data block in the cache area, and realizes storing the target indirect index map by type.

[0078] In addition, in another embodiment of the present application, when the target indirect index map cannot be stored in the cache data block corresponding to the target storage size type determined by the memory allocator, a new cache data block can be reallocated for the target indirect index map; specifically, after finding the target storage size type associated with the index map size type in the cache area including at least one cache data block, the following steps are further included:

[0079] When it is determined that the remaining cache space in the cache data block corresponding to the target storage size type does not meet the storage conditions, apply for a sub-memory space to be allocated from the at least one sub-memory space;

[0080] Use the sub-memory space to be allocated as the target cache data block, and mark the storage size type of the target cache data block as the target storage size type.

[0081] In practical applications, when the memory allocator determines the remaining storage space of the cache data block corresponding to the target storage size type, if the remaining storage space does not meet the storage conditions, it can continue to apply for a sub-memory space to be allocated from at least one sub-memory space. Here, the storage conditions can be understood as insufficient remaining storage space, or other storage functions of the remaining storage space that prevent the storage of the current target indirect index map, etc., which are not specifically limited in this embodiment. Further, after the memory allocator applies for a sub-memory space to be allocated from a continuous memory, it can use the sub-memory space to be allocated as the target cache data block. Since the target cache data block is a newly allocated cache data block, the corresponding storage size type of the cache data block can be marked. Since the target indirect index map needs to be stored subsequently, the storage size type can be marked as the target storage size type associated with the index map size type of the target indirect index map.

[0082] In the data storage method provided by the embodiment of the present application, when the memory allocator allocates, it checks whether there is a free cache data block with a matching size. If not, a new cache data block will be allocated and the size type of the new cache data block will be marked for subsequent continued use of this new cache data block.

[0083] Step 208: Store the target indirect index map in the target cache data block.

[0084] In practical applications, after the memory allocator determines the target cache data block corresponding to the target indirect index map, the target indirect index map can be stored in the target cache data block, so as to be called from the cache data block subsequently to complete the application of the virtual texture technology and will not affect the running performance in various application scenarios.

[0085] In order to store a large number of indirect index maps orderly in cache data blocks to reduce the generation of memory fragmentation, during the specific storage process, the storage offset can be calculated, and the indirect index map can be stored according to the storage address corresponding to the offset; specifically, storing the target indirect index map into the target cache data block includes:

[0086] Determine the data block identifier and data block address information of the target cache data block;

[0087] Based on the index map size type, the data block identifier, and the data block address information, determine the memory offset address corresponding to the target indirect index map;

[0088] Store the target indirect index map into the target cache data block based on the memory offset address.

[0089] Among them, the data block identifier can be understood as the identifier (ID) for sorting each data block in the cache area; the data block address information can be understood as the offset information (BlockOffset) of the data block in the memory of the cache area.

[0090] In practical applications, the memory allocator needs to first determine the offset information (BlockOffset) of the cache data block described in the cache data block in the memory, and the sorting identifier (ID); furthermore, determine the index size type of the target indirect index map to be stored; further, calculate the available memory offset address allocated in the specified memory segment of the cache data block. Specifically, it can be seen that DstMemlOffset (memory offset address) = BlockOffset + ID * DstByteSize, and store the target indirect index map into the target cache data block according to this memory offset address.

[0091] It should be noted that the cache data block refers to a fixed-size memory segment in continuous memory. All cache data blocks in the allocator are memory segments of the same size. The size (BlockByteSize) of the cache data block is M (the maximum index map size type) or a multiple of M. Among them, the cache data block describes the offset (BlockOffset) of the cache data block in the memory, the size (DstByteSize) specified for allocating the indirect index map, and the identifier (ID) of the cache data block.

[0092] When allocating an indirect index map of a specific size, a cache data block needs to be found, and this cache data block needs to meet the following conditions: 1. The size specified by the cache data block is the same as the target index Figure 12. The number of available cache data blocks has not reached the upper limit; if it exists, the cache data block is returned; if it does not exist, a new cache data block is allocated on the continuous memory, and the available memory offset address allocated in the specified memory segment of the cache data block is calculated and returned, and the indirect index map of the specific size is stored according to the memory offset address.

[0093] The data storage method provided in an embodiment of the present application calculates the memory offset address of the storage target indirect index map to achieve continuous storage of content in the target cache data block, with the aim of reducing the large amount of memory fragmentation that appears in a cache data block and improving the utilization of memory space.

[0094] Another embodiment of the present application provides a data storage method that can also provide data cleaning for cached data blocks and reclaim the memory space occupied by the data blocks; specifically, after storing the target indirect index map in the target cached data block, the method further includes:

[0095] When it is determined that the target indirect index map has not been called within a preset time period, the target indirect index map in the target cache data block is deleted.

[0096] In actual game production applications, after the memory allocator stores the target indirect index map in the target cache data block, in order to facilitate the production program's call to the target texture, when calling the target texture data, it is necessary to first call the target indirect index map stored in the target cache data block, and generate the target texture data based on the target indirect index map for application in the game scene. However, there is another situation where the target texture data may not be called within a certain period of time. This can also be understood as the target texture data is temporarily not needed during the game production process, and there is no need to render the target texture data. Then, if it is determined that the target indirect index map has not been called within the preset period of time, the cache can be cleared, and the target indirect index map in the target cache data block can be deleted. The preset period of time can be considered based on multiple factors such as the frequency and importance of the texture data required for different application scenarios. The specific value of the preset period of time is not limited here.

[0097] The data storage method provided in the embodiment of the present application can clean up indirect index maps that have not been called for a long time, delete the indirect index maps stored in the cache data blocks, release memory, reduce the storage pressure of the memory, and improve the running performance of the program.

[0098] In another embodiment of the present application, the data storage method provides a memory allocator that can further determine whether a cached data block meets a recycling condition. If the recycling condition is met, the cached data block can be recycled to increase the system memory space. Specifically, after deleting the target indirect index map in the target cached data block, the method further includes:

[0099] When it is determined that the remaining storage space in the target cache data block meets the preset data block reclaiming condition, the target cache data block is marked as a free data block, and the memory space occupied by the target cache data block is returned to the target system memory.

[0100] Among them, the preset data block recycling conditions can be understood as the conditions for the data block to trigger the recycling operation and return the occupied memory space, such as the indirect index map data in the cache data block has not been called for a long time, or there is no data stored in the cache data block after the data is released, that is, the cache data block is in an idle state.

[0101] In actual applications, the memory allocator determines whether the remaining storage space in the target cache data block meets the preset data block recycling conditions. If the target cache data block meets the preset data block recycling conditions, the target cache data block can be marked as a free data block, and the target cache data block can be recycled to return the memory space of the target cache data block to the target system memory. It should be noted that the target system memory and the system memory to be allocated in the above embodiment can have the same meaning and represent the same system memory space. This embodiment does not impose too many restrictions on this.

[0102] Furthermore, when the memory allocator determines to recycle the specified indirect index map, it can calculate the offset information of the data block and the identification of the data block based on the memory offset address calculated in the above embodiment, and find the corresponding target data block. The reference calculation method is: BlockOffset = DstMemlOffset / BlockByteSize; ID = (DstMemlOffset-BlockOffset) / DstByteSize; after the recycling operation is completed, the recycled cache data block can be used for the next allocation.

[0103] Based on this, the data storage method provided in the embodiment of the present application, in which the memory allocator manages memory allocation, aims to reduce memory fragmentation caused by indirect index map memory allocation during frequent allocation and recovery, and to accelerate the allocation and recovery process. Another function of the virtual mapping technology is that the virtual mapping in use can dynamically adjust the resolution according to the current usage, wherein the resolution adjustment is mainly achieved by dynamically resizing the indirect index map, and the dynamic resizing of the indirect index map actually requires the reallocation of the indirect index map, so the dynamic allocation performance of the indirect index map will affect the actual runtime performance. The data storage methods provided in the above embodiments can all achieve dynamic adjustment of the indirect index map to adapt to the program running performance in different scenarios.

[0104] The following combinedFigure 3 Taking the application of the data storage method provided by this application to the virtual map data storage in the game scene as an example, the data storage method is further explained. Figure 3 A flow chart of a method for storing virtual texture data in a gaming scenario, provided by one embodiment of the present application, is shown.

[0105] Figure 3 It includes a memory allocator and a cache data block, wherein the memory allocator further includes a virtual texture schematic diagram and an indirect index map schematic diagram; the virtual texture schematic diagram is a virtual texture with a target character, and in a game production scenario, the virtual texture with the target character will be reused in large quantities; the indirect index map is an indirect index map corresponding to the virtual texture with the target character; if there are multiple dotted squares in the cache data block, it can be said that there are multiple data blocks to store the indirect index map; it should be noted that each cache data block has its own storage size type, and the meaning of the storage size type can be referred to the description in the above embodiment, and will not be elaborated on here.

[0106] In specific implementation, the data storage method provided by the embodiment of the present application is Figure 3 It can be divided into two major steps:

[0107] Step 302: The memory allocator generates a corresponding indirect index map based on the virtual map.

[0108] In practical applications, after receiving the virtual map, the memory allocator can determine the indirect index map based on the virtual map, such as Figure 3 The dotted arrow in the virtual map points to the grid area represented by the oblique lines in the indirect index map corresponding to the head of the character in the virtual map; subsequently, the data memory of the grid area represented by the oblique lines in the indirect index map is stored in Figure 3 The cache data block at the bottom of the middle makes it easy to repeatedly call the indirect index map during game production and render a virtual map with the target character.

[0109] Step 304: The memory allocator stores the indirect index map into a cache data block.

[0110] In practical applications, the memory allocator can predetermine the size M of the largest indirect index map in the game scene, and determine a section of continuous memory based on the size M of the largest indirect index map for subsequent dynamic reallocation of the indirect index map. At the same time, the memory size of the continuous memory is recommended to be a multiple of M and larger than M. During runtime, the memory can be expanded according to the operating conditions; and the memory allocator can configure the memory occupied by the size of the largest indirect index map as a block, and each block only allocates an indirect index map of one size.

[0111] When the memory allocator allocates memory, it checks if there is a free block with a matching size. If there is, it uses that block for allocation. Here, a Block refers to a fixed-size memory segment within contiguous memory. All Block blocks in the allocator have the same size, and the size of a Block block (BlockByteSize) is the size M of the largest indirect index map in the game scene or a multiple of M. For example, the memory allocator first determines the index map size type corresponding to the virtual texture map, such as 8K, and then selects a storage size type that is the same as this index map size type from the Figure 3 bottom cache data blocks, such as a cache data block with a storage size type of 8K. Then, when it is determined that the remaining storage space of the cache data block with a storage size type of 8K can store 8K of data, the indirect index map can be stored in the cache data block with a storage size type of 8K; Figure 3 In , only the parts of two indirect index maps in the head area of the target character are used as examples and are indicated by two implementation arrows pointing to Figure 3 the bottom cache data blocks in , facilitating subsequent game production programs to call the indirect index maps from these cache data blocks to generate corresponding game virtual texture maps with the target character.

[0112] It should be noted that when allocating an indirect index map of a specific size, a Block block needs to be found. This Block block needs to meet the following conditions: 1. The specified size of the Block block is the same as the target index Figure 1 ; 2. The available quantity of the Block block has not reached the upper limit. If there is one, return that Block block. If not, allocate a Block block on the contiguous memory. Calculate and return the available memory offset in the specified memory segment of the Block block: DstMemlOffset = BlockOffset + ID * DstByteSize; When recycling a specified indirect index map, calculate BlockOffset and ID based on DstMemlOffset to find the specified Block block: BlockOffset = DstMemlOffset / BlockByteSize; ID = (DstMemlOffset - BlockOffset) / DstByteSize; After verifying the legality, the Block block records the cache data block ID and completes the recycling for the next allocation.

[0113] Continuing with the above example, if the indirect index map corresponding to the virtual texture map with the target character cannot be stored in the cache data block with a storage size type of 8K, the memory allocator can also allocate a new cache data block for storing this indirect index map and mark this new cache data block as having a storage size type of 8K.

[0114] In addition, the memory allocator also has the functions of releasing data and recycling data blocks. For details, reference can be made to the descriptions in the above embodiments, and no specific limitations are provided here.

[0115] In summary, the data storage method provided by the embodiments of the present application manages memory allocation by the memory allocator, aiming to reduce memory fragmentation caused by indirect index map memory allocation during frequent allocation and recycling processes and accelerate the allocation and recycling processes. Another function in the virtual texture mapping technology is that the virtual texture in use can dynamically increase or decrease the resolution according to the current usage situation. Among them, the increase or decrease of the resolution is mainly achieved by dynamically adjusting the size of the indirect index map, and the dynamic adjustment of the size of the indirect index map actually requires reallocating the indirect index map. Therefore, the dynamic allocation performance of the indirect index map will affect the actual runtime performance. The data storage methods provided by the above embodiments can all achieve the dynamic adjustment of the indirect index map to adapt to the program running performance in different scenarios, so as to solve the problem of a large amount of memory fragmentation generated without memory sorting in the frequent allocation and recycling process.

[0116] Corresponding to the above method embodiments, the present application also provides an embodiment of a data storage device. Figure 4 The structure diagram of a data storage device provided by an embodiment of the present application is shown. As Figure 4 shown, the device includes:

[0117] A request receiving module 402, configured to receive a data storage request for target texture data;

[0118] An index map determining module 404, configured to determine a target indirect index map corresponding to the target texture data based on the data storage request, where the target indirect index map carries an index map size type;

[0119] A data block selecting module 406, configured to select a target cache data block associated with the index map size type in a cache area including at least one cache data block, where the cache area consists of cache data blocks of at least one storage size type;

[0120] An index map storing module 408, configured to store the target indirect index map into the target cache data block.

[0121] Optionally, the device further includes:

[0122] A cache area determining module, configured to create a target index map size type in response to a task processing request and determine a target memory size based on the target index map size type;

[0123] Apply for a memory space of the same size as the target memory size from the system memory to be allocated, and use the memory space as the cache area for the target texture data.

[0124] Optionally, the cache area determination module is further configured to:

[0125] Divide the memory space based on the target index map size type to obtain at least one sub-memory space;

[0126] Use the at least one sub-memory space as at least one cache data block, and generate a cache area for the target texture data based on the at least one cache data block.

[0127] Optionally, the data block selection module 406 is further configured to:

[0128] Determine at least one storage size type associated with the cache area, where the cache area includes at least one cache data block;

[0129] In the at least one storage size type, search for a target storage size type associated with the index map size type;

[0130] In the case where there is remaining cache space in the cache data block corresponding to the target storage size type, select the cache data block corresponding to the target storage size type as the target cache data block.

[0131] Optionally, the data block selection module 406 is further configured to:

[0132] In the case where the remaining cache space in the cache data block corresponding to the target storage size type does not meet the storage condition, apply for a sub-memory space to be allocated from the at least one sub-memory space;

[0133] Use the sub-memory space to be allocated as the target cache data block, and mark the storage size type of the target cache data block as the target storage size type.

[0134] Optionally, the index map storage module 408 is further configured to:

[0135] Determine the data block identifier and data block address information of the target cache data block;

[0136] Based on the index map size type, the data block identifier, and the data block address information, determine the memory offset address corresponding to the target indirect index map;

[0137] Store the target indirect index map into the target cache data block based on the memory offset address.

[0138] Optionally, the device further includes:

[0139] A data release module, configured to delete the target indirect index map in the target cache data block when it is determined that the target indirect index map has not been called within a preset time period.

[0140] Optionally, the device further includes:

[0141] A data recovery module, configured to mark the target cache data block as an idle data block and return the memory space occupied by the target cache data block to the target system memory when it is determined that the remaining storage space in the target cache data block meets the preset data block recovery condition.

[0142] The data storage device provided by the embodiments of the present application, in the process of storing the target indirect index map corresponding to the target texture data, determines the target cache data block for storing the target indirect index map by determining the index map size type of the target indirect index map. Among them, in the process of determining the target cache data block, it is necessary to select the target cache data block associated with the index map size type. In this way, the cache data block associated with the size type is determined according to the index map size type, which can classify and store the indirect index maps corresponding to different index map size types, so as to manage the cache data blocks of different classifications by type; at the same time, in the game scenario, a large number and various types of game virtual texture maps are stored according to the above data storage method, which can not only classify and store the game virtual texture maps, reduce a large number of memory fragments, but also improve the actual running performance of the game.

[0143] The above is a schematic solution of a data storage device in this embodiment. It should be noted that the technical solution of this data storage device belongs to the same concept as the technical solution of the above data storage method. For the details not described in the technical solution of the data storage device, reference can be made to the description of the technical solution of the above data storage method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method. Each functional module is not an actual functional division or separation limitation. The device claim defined by such a set of functional modules should be understood as mainly implementing the functional module framework of the solution through the computer program recorded in the specification, rather than mainly implementing the physical device of the solution through hardware means.

[0144] Figure 5FIG. 0 shows a structural block diagram of a computing device 500 provided according to an embodiment of the present application. The components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and a database 550 is used to store data.

[0145] The computing device 500 further includes an access device 540, which enables the computing device 500 to communicate via one or more networks 560. Examples of such networks include the Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of wired or wireless network interfaces (e.g., Network Interface Card (NIC)), such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.

[0146] In an embodiment of the present application, the above components of the computing device 500 and Figure 5 other components not shown may also be connected to each other, for example, via a bus. It should be understood that Figure 5 the shown structural block diagram of the computing device is for illustrative purposes only and is not a limitation on the scope of the present application. Those skilled in the art can add or replace other components as needed.

[0147] The computing device 500 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 500 can also be a mobile or stationary server.

[0148] Among them, the processor 520 is used to execute computer-executable instructions of the data storage method.

[0149] The above is a schematic solution of a computing device in this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the above data storage method belong to the same concept. For the details not described in the technical solution of the computing device, reference can be made to the description of the technical solution of the above data storage method.

[0150] One embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are executed by a processor for a data storage method.

[0151] The above is a schematic solution of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the above data storage method belong to the same concept. For the details not described in detail in the technical solution of the storage medium, reference can be made to the description of the technical solution of the above data storage method.

[0152] The computer instructions include computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0153] One embodiment of the present application further provides a chip storing a computer program, which implements the steps of the data storage method when executed by the chip.

[0154] It should be noted that for the foregoing method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0155] In the above embodiments, the descriptions of each embodiment have their own focuses. For the parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0156] The preferred embodiments of the present application disclosed above are only used to help illustrate the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can well understand and utilize the present application. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. A data storage method, characterized in that: include: Receive a data storage request for target texture data; Determining a target indirect index map corresponding to the target map data based on the data storage request, wherein the target indirect index map carries an index map size type; Selecting a target cache data block associated with the index map size type in a cache area containing at least one cache data block, comprising: determining at least one storage size type associated with the cache area; searching for a target storage size type associated with the index map size type in the at least one storage size type; and selecting the cache data block corresponding to the target storage size type as the target cache data block when it is determined that there is remaining cache space in the cache data block corresponding to the target storage size type, wherein the cache area is composed of cache data blocks of at least one storage size type, and the cache area contains at least one cache data block; The target indirect index map is stored in the target cache data block.

2. The method according to claim 1, characterized in that Before selecting a target cache data block associated with the index map size type in a cache area including at least one cache data block, the method further includes: creating a target index map size type in response to a task processing request, and determining a target memory size based on the target index map size type; Apply for a memory space with the same size as the target memory from the system memory to be allocated, and use the memory space as a cache area for the target texture data.

3. The method according to claim 2, characterized in that The step of using the memory space as a cache area for the target texture data includes: Dividing the memory space based on the target index map size type to obtain at least one sub-memory space; The at least one sub-memory space is used as at least one cache data block, and a cache area for the target texture data is generated based on the at least one cache data block.

4. The method according to claim 1, wherein After searching the cache area containing at least one cache data block for the target storage size type associated with the index map size type, the method further includes: Applying for a sub-memory space to be allocated from the at least one sub-memory space when it is determined that the remaining cache space of the cache data block corresponding to the target storage size type does not meet the storage condition; The sub-memory space to be allocated is used as a target cache data block, and the storage size type of the target cache data block is marked as a target storage size type.

5. The method according to claim 1, wherein Storing the target indirect index map to the target cache data block includes: Determine the data block identifier and data block address information of the target cache data block; Determining a memory offset address corresponding to the target indirect index map based on the index map size type, the data block identifier, and the data block address information; The target indirect index map is stored in the target cache data block based on the memory offset address.

6. The method according to claim 1, characterized in that After storing the target indirect index map in the target cache data block, the method further includes: When it is determined that the target indirect index map has not been called within a preset time period, the target indirect index map in the target cache data block is deleted.

7. The method according to claim 6, characterized in that After deleting the target indirect index map in the target cache data block, the method further includes: When it is determined that the remaining storage space in the target cache data block meets the preset data block reclaiming condition, the target cache data block is marked as a free data block, and the memory space occupied by the target cache data block is returned to the target system memory.

8. A data storage device, characterized in that include: A request receiving module configured to receive a data storage request for target map data; an index map determining module configured to determine a target indirect index map corresponding to the target map data based on the data storage request, wherein the target indirect index map carries an index map size type; a data block selection module configured to select a target cache data block associated with the index map size type in a cache area comprising at least one cache data block, wherein the cache area is composed of cache data blocks of at least one storage size type; The data block selection module is further configured to determine at least one storage size type associated with a cache area, wherein the cache area includes at least one cache data block; search for a target storage size type associated with the index map size type in the at least one storage size type; and if it is determined that the cache data block corresponding to the target storage size type has remaining cache space, select the cache data block corresponding to the target storage size type as the target cache data block; The index map storage module is configured to store the target indirect index map in the target cache data block.

9. A computing device, characterized in that include: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the data storage method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the data storage method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Resource management method and device

    CN114155330A