GPU resource dynamic allocation and loading method based on CPU delay read-back

By using a CPU-delayed readback method for dynamic allocation and loading of GPU resources, the problem of coordination between rendering and resource loading in real-time 3D rendering is solved, rendering performance is improved, and real-time rendering effects for complex scenes are achieved.

CN121391584APending Publication Date: 2026-01-23CISDI ENGINEERING CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511548617.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

In real-time 3D rendering, the I/O speed of resource loading is much lower than the GPU rendering speed, which limits the speed of the rendering process and makes it impossible to achieve efficient rendering and resource loading coordination, especially in ultra-large and complex scenes.

Method used

A method for dynamic allocation and loading of GPU resources based on CPU latency readback is adopted. The CPU reads GPU resource loading requirement information with latency, and while the GPU is processing rendering tasks, the CPU summarizes and loads the requirement information. By using thread-safe hash tables and view frustum culling technology, resource status management and efficient resource allocation and loading are achieved.

Benefits of technology

It achieves efficient collaboration between the CPU and GPU, improves the rendering efficiency of 3D scenes, and ensures real-time rendering effects for complex scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121391584A_ABST
    Figure CN121391584A_ABST
Patent Text Reader

Abstract

The invention relates to a GPU resource dynamic allocation and loading method based on CPU delayed read-back, and belongs to the technical field of GPU resource allocation, and the method comprises the following steps: S1, constructing a resource management object for a three-dimensional rendering program to realize resource state management; s2, removing the scene through a GPU pre-rendering process, collecting an ID of a resource required by an object after removal, obtaining the ID content through CPU delay, and adding the ID content into a corresponding loading queue; s3, updating the state in the resource management object based on the information in the loading queue; and S4, initiating a resource allocation and loading task to complete resource loading.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of GPU resource allocation, and relates to a GPU resource dynamic allocation and loading method based on CPU delayed readback. BACKGROUND

[0002] In the field of three-dimensional real-time rendering, resource dynamic loading of super-large complex scenes is an important technology, which supports the application and popularization of three-dimensional real-time rendering technology in strategic fields such as industry. A fact is that in a computer, the IO speed of resource loading is much lower than the speed of GPU rendering of resource data, so if resource loading is directly inserted into the rendering process, waiting for the GPU preprocessing result, based on the result, resource loading is performed, and after resource loading is successful, the GPU is further processed, the speed of the entire rendering process will be limited to the speed of IO, thereby greatly reducing the system running efficiency, so that three-dimensional real-time rendering cannot be actually performed. The GPU resource dynamic allocation and loading method based on CPU delayed readback realizes efficient cooperation of CPU-GPU by delaying reading of resource loading demand information generated by the GPU by the CPU, and realizing demand information summarization and loading task initiation by the CPU while the GPU processes the rendering task, thereby effectively supporting real-time rendering of super-large complex scenes.

[0003] In the rendering of complex three-dimensional scenes (such as open-world games and large-scale simulations), the rendering resources required by the scene cannot be loaded into the memory or the video memory at one time, so dynamic loading needs to be performed according to the information of the current observer. In such a complex scene, how to better guarantee efficient cooperation of rendering and resource loading, and thereby improve rendering performance, is a problem of great research value. SUMMARY

[0004] Therefore, the purpose of the application is to provide a GPU resource dynamic allocation and loading method based on CPU delayed readback, which is used to solve the problem of efficient cooperation of rendering and resource loading in the rendering of complex three-dimensional scenes, and improve the rendering performance.

[0005] To achieve the above purpose, the application provides the following technical scheme. A GPU resource dynamic allocation and loading method based on CPU delayed readback, comprising the following steps: S1: constructing a resource management object for a three-dimensional rendering program to realize resource state management; S2: realizing culling of the scene through a GPU pre-rendering process, collecting IDs of resources required by objects after culling, and adding the IDs to a corresponding loading queue by CPU delayed reading of the IDs; S3: updating the state in the resource management object based on the information in the loading queue; S4: Initiating resource allocation and loading task, completing resource loading.

[0006] Further, step S1 specifically comprises: using thread-safe hash table combined with smart pointer for resource management object construction, taking each resource ID as key and resource state object as value, and maintaining an event object representing whether the resource is loaded successfully in the resource state object; when the external program logic queries whether the resource is loaded successfully, the state of the event object is returned; when the external program logic needs to use the resource, the waiting function of the event object is called to ensure that the resource is loaded, and the data view in the resource is returned.

[0007] Further, step S1 specifically comprises the following steps: S11: According to the use form of the resource by the pipeline to be rendered, the specific class form of the resource state object is determined, and the general form is: resource type object + resource loading event object; S12: Determine the resource management class form, and the general form is: hash table (key: resource ID, value: resource state object) + thread safety auxiliary object; S13: According to the determined resource state and resource management class form, the empty resource management object is instantiated, and the singleton is used as the instantiation form.

[0008] Further, in step S2, the scene culling in the GPU pre-rendering process is realized by using the view frustum culling and depth culling techniques, and the resources required by the objects after culling are collected and de-duplicated on the GPU. After de-duplication, the information is copied back from the GPU to the CPU; because the current frame GPU task is being performed, the CPU does not read the resource information of the current rendering frame, but reads the resource information of N frames ago, and based on the above information, necessary storage resources are allocated, and the loading of resource data from the hard disk to the storage resources is initiated through multi-threading.

[0009] Further, step S2 comprises the following steps: S21: Allocate N GPU memory resources and CPU memory resources for storing culling results, each corresponding to one frame; S22: The CPU waits for the completion of the related commands of S23-S25 in the current frame-N frames, that is, delays N frames to read back, and reads back the memory resource content of S25 and S21, obtains the information of the resources required for rendering, and allocates necessary storage resources based on the above information; S23: Initiating GPU pre-rendering command for the current frame, and writing the resource ID information required by the objects through culling into the GPU memory resource of S21; S24: Initiating GPU deduplication algorithm command for the current frame, removing duplicate resource IDs through prefix sum, sorting or bit operation techniques, and updating the GPU memory resource content of S21; S25: initiating a GPU-CPU copy command for the current frame, copying the GPU memory resource content described in S21 into the CPU memory resource described in S21.

[0010] Further, in step S3, before the CPU initiates the multi-thread loading, based on the information obtained in S22, the key of the resource management object described in S1 is determined; if the key already exists in the resource management object, the processing for the resource is terminated; if the key does not exist in the resource management object, an initialized but marked as unloaded resource state object is inserted into the resource management object described in S1 under the guarantee of thread safety.

[0011] Further, the step S4 comprises the following steps: S41: putting the resource loading information into a task queue; S42: constructing a new thread or waking up the waiting thread in the thread pool as a working thread, and making the working thread obtain the loading information from the queue; S43: the working thread executes the resource loading logic, and after completing the resource loading, marks the state of the resource in the resource management object as completed, and notifies the external program logic waiting for the completion of the resource loading.

[0012] The beneficial effects of the present application are that the present application solves the efficient cooperation problem of rendering and resource loading when processing a complex three-dimensional scene rendering through the hash table resource management, CPU delayed read and other ways, improves the rendering efficiency of the three-dimensional scene, and achieves the effect of real-time rendering. Other advantages, objects, and features of the present application will be apparent to those skilled in the art from the following specification and drawings, and will be learned from the practice of the present application. The objects and other advantages of the present application can be realized and obtained by the following specification. BRIEF DESCRIPTION OF DRAWINGS

[0013] In order to make the objects, technical solutions and advantages of the present application clearer, the preferred detailed description of the present application will be made below in combination with the drawings, in which: Figure 1 The flow framework diagram of the GPU resource dynamic allocation and loading method based on CPU delayed read of the present application. DETAILED DESCRIPTION

[0014] Following make use of specific, specific examples illustrate the embodiments of the present application, those skilled in the art can easily understand the advantages and effects of the present application from the disclosure. The present application can also be implemented or applied by means of other different embodiments, and the details in the specification can be modified or changed based on different views and applications without departing from the spirit of the present application. It should be noted that the drawings provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and the drawings in the following examples and the features in the examples can be combined with each other without conflict.

[0015] It should be noted that the drawings provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and the drawings in the following examples and the features in the examples can be combined with each other without conflict.

[0016] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the application, however, it is obvious to those skilled in the art that the embodiments of the application can be implemented without these specific details, and in other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail, to avoid making the embodiments of the application difficult to understand.

[0017] Embodiment 1: The application provides a GPU resource dynamic allocation and loading method based on CPU delay read, which solves the efficient cooperation problem of rendering and resource loading when rendering a complex three-dimensional scene, improves the rendering efficiency of the three-dimensional scene, and achieves real-time rendering effect.

[0018] As Figure 1 The method flow framework diagram of the present application is shown in the following figure, including S1-S4.

[0019] S1: Construct a resource management object for a three-dimensional rendering program to realize resource state management; use a thread-safe hash table to construct the resource management object, use each resource ID as the key, use the resource state object as the value, and maintain an event object (such as a C++ conditional variable) representing whether the resource is loaded successfully in the resource state object; S2: Use techniques such as frustum culling, depth culling, etc. to realize scene culling in GPU pre-rendering process, and collect and de-duplicate the resources (such as models, texture maps, etc.) required by the objects after culling on the GPU, and copy the information back to the CPU after de-duplication. Because the current frame GPU task is being processed, the CPU does not read the resource information of the current rendering frame, but reads the resource information of N frames ago (delayed readback), and allocates necessary storage resources (such as page-locked memory, video memory) based on the above information; S3: Before the CPU initiates multi-threaded loading, insert the resource ID and newly allocated resource state object as a key-value pair into the resource management object, so that the subsequent external program logic and loading threads can access and update the state object; S4: The CPU initiates multi-threaded resource loading. In the resource loading thread, after completing the loading of each resource, the state of the resource in the resource management object is marked as completed, and the external program logic waiting for resource loading completion is notified, so that the program logic recovers from waiting and continues to use the resource content.

[0020] Specifically, the S1 includes the following steps: S11: According to the use form of the resource by the rendering pipeline, determine the specific class form of the resource state object, and the general form is: resource type object + resource loading event object; S12: Determine the resource management class form, and the general form is: hash table (key: resource ID, value: resource state object) + thread safety auxiliary object (such as mutex); S13: According to the determined resource state and resource management class form, instantiate an empty resource management object, and generally use singleton as the instantiation form.

[0021] Specifically, the S2 includes the following steps: S21: Allocate N portions of GPU video memory and CPU memory resources for storing culling results, each portion corresponding to one frame; S22: The CPU waits for the completion of the related commands of S23-S25 in the current frame-N frames (wait for the completion of the commands initiated in the last round of the current frame), that is, delayed N-frame readback, and reads back the memory resource content of S25 and S21, obtains the information of the resources required for rendering, and allocates necessary storage resources (such as page-locked memory, video memory) based on the above information; S23: Initiate GPU pre-rendering commands for the current frame, and write the required resource (model, texture, etc.) ID information of the objects removed by culling into the video memory resource of S21; S24: Initiate GPU deduplication algorithm commands for the current frame, remove duplicate resource IDs through prefix sum, sorting or bit manipulation techniques, and update the video memory resource content of S21; S25: Initiating a GPU-CPU copy command for the current frame, copying the content of the video memory resource in S21 to the memory resource in S21.

[0022] Specifically, the S3 comprises the following steps: S31: determining the key of the resource management object based on the information obtained in S22; S32: if the key already exists in the resource management object, the processing of the resource is terminated; S32: if the key does not exist in the resource management object, an initialized but marked as unloaded resource state object is inserted into the resource management object in S1 under the guarantee of thread safety Specifically, the S4 comprises the following steps: S41: putting the resource loading information into a task queue; S42: constructing a new thread or waking up a waiting thread in the thread pool as a working thread, and letting the working thread obtain the loading information from the queue; S43: the working thread in S42 executes the resource loading logic, and after completing the resource loading, marks the state of the resource in the resource management object as completed, and notifies the external program logic waiting for the completion of the resource loading.

[0023] In addition, it should be noted that based on the above S1-S4, the CPU main thread, the GPU and the working thread for loading resources can work simultaneously, wherein the CPU main thread delays to obtain the GPU result, so that the CPU is consuming the result of the frame completed by the GPU, and the GPU is still calculating the result of the frame not completed, thereby realizing the efficient cooperation of the GPU and the GPU. And in the CPU, the resource loading working thread does not wait for other tasks except for the CPU main thread, so as to realize the effective utilization of multiple CPU cores. Therefore, the above S1-S4 effectively realizes the efficient cooperation of the CPU and the GPU, improves the rendering efficiency of the three-dimensional scene, and ensures that the complex scene requiring dynamic loading can achieve real-time rendering effect.

[0024] Embodiment 2: An electronic device, comprising a memory and a processor; The memory is configured to store a computer program; The processor is configured to implement the method of embodiment 1 when executing the computer program.

[0025] Embodiment 3: A computer readable storage medium, the storage medium stores a computer program, when the computer program is executed by a processor, the method of embodiment 1 is realized.

[0026] Embodiment 4: A computer program product comprising a computer program which, when executed by a processor, implements the method of embodiment 1.

[0027] In the above embodiments, references in the specification to "this embodiment" indicate that a particular feature, structure, or characteristic described is included in at least some embodiments, but not necessarily all embodiments, of the application. The various appearances of "this embodiment" are not necessarily all referring to the same embodiment.

[0028] In the above embodiments, although the application has been described in conjunction with specific embodiments thereof, numerous alternatives, modifications, and variations will be readily apparent to those of ordinary skill in the art in light of the foregoing descriptions. For example, other storage structures (e.g., dynamic RAM (DRAM)) can use the embodiments discussed. The embodiments of this application are intended to cover all such alternatives, modifications, and variations as come within the scope of the appended claims.

[0029] The computer readable storage medium in this embodiment can be understood by those skilled in the art that all or part of the steps of the above-mentioned method embodiments can be completed by a computer program related hardware. The foregoing computer program can be stored in a computer readable storage medium. The program, when executed, performs steps including the above-mentioned method embodiments; and the foregoing storage medium includes ROM, RAM, magnetic disk or optical disk and various media that can store program codes.

[0030] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected with the processor and the transceiver and complete communication between each other. The memory is used for storing a computer program, and the communication interface is used for communication. The processor and the transceiver are used for running the computer program, so that the electronic terminal executes each step of the above method.

[0031] In this embodiment, the memory can include random access memory (RAM) and can also include non-volatile memory, such as at least one disk memory.

[0032] The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0033] The present application can be applied to numerous general or special computing system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, etc.

[0034] The present application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform particular tasks or implement particular abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media including memory storage devices.

[0035] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit it. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the present application, and all of them should be covered in the scope of the claims of the present application.

Claims

1. A method for dynamic allocation and loading of GPU resources based on CPU latency readback, characterized in that: Includes the following steps: S1: Construct resource management objects for 3D rendering programs to achieve resource status management; S2: The scene is culled through the GPU pre-rendering process. The IDs of the resources required by the culled objects are collected. The CPU obtains the content of the ID with a delay and adds it to the corresponding loading queue. S3: Update the state of the resource management object based on the information in the loading queue; S4: Initiate resource allocation and loading tasks to complete resource loading.

2. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 1, characterized in that: Step S1 specifically includes: constructing a resource management object using a thread-safe hash table combined with smart pointers, using each resource ID as the key and the resource status object as the value, and maintaining an event object in the resource status object to represent whether the resource has been successfully loaded; when external program logic queries whether the resource has been successfully loaded, the status of the event object is returned; when external program logic needs to use the resource, the wait function of the event object is called to ensure that the resource has been loaded, and the data view within the resource is returned.

3. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 2, characterized in that: Step S1 specifically includes the following steps: S11: Determine the specific class form of the resource state object based on how the pipeline to be rendered uses the resources. The general form is: resource type object + resource loading event object. S12: Determine the form of the resource management class. The general form is: hash table (key: resource ID, value: resource status object) + thread-safe auxiliary object; S13: Based on the determined resource status and resource management class form, instantiate an empty resource management object, using a singleton as the instantiation form.

4. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 1, characterized in that: In step S2, scene culling in the GPU pre-rendering process is achieved using frustum culling and depth culling techniques. The resources required for the culled objects are collected and deduplicated on the GPU. After deduplication, the information is copied from the GPU back to the CPU. Since the GPU task is in progress in the current frame, the CPU does not read the resource information of the current rendering frame, but reads the resource information from N frames ago. Based on the above information, the CPU allocates the necessary storage resources and initiates the loading of resource data from the hard disk to the storage resources through multi-threading.

5. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 4, characterized in that: Step S2 includes the following steps: S21: Allocate N portions of GPU memory resources and CPU memory resources to store the culling results, with each portion corresponding to one frame; S22: The CPU waits for the relevant commands of S23-S25 in the current frame to N frames to be completed, that is, delays the readback of N frames, and reads back the memory resource content mentioned in S25 and S21 to obtain the information of the resources required for rendering, and allocates the necessary storage resources based on the above information. S23: Initiate a GPU pre-rendering command for the current frame, and write the required resource ID information corresponding to the culled objects into the GPU video memory resources mentioned in S21; S24: Initiate a GPU deduplication algorithm command for the current frame, remove duplicate resource IDs through prefix sum, sorting or bit manipulation techniques, and update the GPU memory resource content mentioned in S21. S25: Initiate a GPU-CPU copy command for the current frame to copy the GPU video memory resource content described in S21 to the CPU memory resource described in S21.

6. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 5, characterized in that: In step S3, before the CPU initiates multi-threaded loading, the key of the resource management object described in S1 is determined based on the information obtained in S22. If the key already exists in the resource management object, the processing of this resource is terminated. If the key does not exist in the resource management object, an initialized but marked as unloaded resource state object is inserted into the resource management object described in S1 under the protection of thread safety.

7. The method for dynamic allocation and loading of GPU resources based on CPU latency readback according to claim 1, characterized in that: Step S4 includes the following steps: S41: Add resource loading information to a task queue; S42: Construct a new thread or wake up a waiting thread in the thread pool as a worker thread, and instruct the worker thread to retrieve loading information from the queue; S43: The worker thread executes the resource loading logic, and after the resource loading is completed, it marks the status of the resource in the resource management object as completed, and notifies the external program logic waiting for the resource loading to be completed.