Method and device for updating and rendering data between CPU and GPU and medium

By setting global buffers and changing local buffers between the CPU and GPU, dynamically updating the rendering data, the problems of inefficient rendering efficiency and poor system performance caused by frequent data changes in traditional rendering processes are solved, and efficient rendering data management and update are achieved.

CN119806861APending Publication Date: 2025-04-11珠海剑心互动娱乐有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411827044.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In traditional rendering processes, the number of binding buffers caused by frequent data changes, the number of draw commands called, the amount of data submitted per frame is too large, the total memory overhead is too large, and the data read and write competition between the CPU and the GPU, resulting in low rendering efficiency and poor system performance.

Method used

By setting a global buffer and a variable local buffer between the CPU and the GPU, receiving dynamic instance rendering data sent by the CPU and rendering, dynamically updating the variable rendering data to reduce the number of direct communications and data binding operations.

Benefits of technology

It effectively reduces the number of direct communication between the CPU and the GPU, avoids the problem of inefficient rendering, reduces the bandwidth requirements and memory overhead of data transmission, and avoids the data read and write competition between the CPU and the GPU, improving rendering efficiency and overall system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806861A_ABST
    Figure CN119806861A_ABST
Patent Text Reader

Abstract

The invention discloses a data updating and rendering method and device between a CPU and a GPU and a medium, and the method comprises the steps: firstly, receiving a plurality of dynamic instance rendering data sent by the CPU, and storing the data in a global buffer area; then, according to the initial key identification of the dynamic instance, the data in the global buffer area is rendered to generate an image frame sequence. Then, changing rendering data in the current image frame sent by the CPU is stored in the changing local buffer area; the variation instance index refers to the dynamic instance which varies. And then, according to the initial key identifier, the target key identifier of the change instance and the change rendering data, dynamically updating the rendering data of the dynamic instance. And rendering the updated rendering data again to generate a new image frame sequence. According to the embodiment of the invention, the technical problem of a traditional rendering process is solved, the rendering efficiency and the overall performance of the system are remarkably improved, and flexible processing and efficient updating of the dynamic instance rendering data are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to, but are not limited to, the field of computer technology, and in particular to a method, device, and medium for updating and rendering data between a CPU and a GPU. Background Art

[0002] In the traditional rendering process, the central processing unit (CPU) is mainly responsible for processing complex logical operations, physical simulation, and scene management tasks, while the graphics processing unit (GPU) is mainly responsible for efficient graphics rendering. The CPU will regularly send the data required for rendering (such as vertex information, texture coordinates, color values, etc.) to the GPU for rendering. In order to optimize this rendering process, a common strategy is to set up a buffer between the CPU and the GPU to temporarily store the data to be rendered. However, in dynamic scenes, as objects move, deform, or are added or deleted, the rendering data will change frequently, which brings the following major problems to the rendering process: Too many buffer binding times: Whenever the rendering data changes, the traditional approach often requires the CPU to rebind the new data buffer to the GPU, which will result in a large number of binding operations when the data changes frequently, increasing the burden on the CPU and reducing the rendering efficiency. Too many drawing command calls: Due to frequent data changes, the CPU may need to frequently call drawing commands to update the rendering data in the GPU, which not only increases the workload of the CPU, but also may lead to inefficiency of the rendering pipeline. The amount of data submitted to the GPU for each frame is too large: In dynamic scenes, a large amount of changing data may need to be submitted to the GPU for each frame, which increases the bandwidth requirements for data transmission and may cause rendering delays. The total memory overhead is too large: In order to store frequently changing rendering data, a large number of buffers may need to be set up between the CPU and the GPU, which not only increases memory usage, but may also cause complexity in memory management.

[0003] How to efficiently manage the data in these buffers, especially when the data changes frequently, remains a key technical problem that needs to be solved urgently. Summary of the invention

[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0005] The embodiment of the present application provides a data update rendering method between the CPU and the GPU, which effectively solves the technical problems of the traditional rendering process, significantly improves the rendering efficiency and the overall performance of the system, and realizes flexible processing and efficient updating of dynamic instance rendering data.

[0006] In a first aspect, an embodiment of the present application provides a data update rendering method between a CPU and a GPU, which is applied to a GPU, and the method includes: receiving rendering data of multiple dynamic instances sent by the CPU, and storing the multiple rendering data in a global buffer, each of the dynamic instances corresponding to an initial key identifier; rendering the multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence; receiving change rendering data in the current image frame sent by the CPU, and storing the change rendering data in a change local buffer, the change rendering data is the rendering data of the change instance, and the change instance is the dynamic instance corresponding to the rendering data with data change in the current image frame, and each of the change instance corresponds to a target key identifier; dynamically updating the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the change rendering data to obtain the updated rendering data; rendering the updated rendering data to obtain the updated image frame sequence.

[0007] In combination with the first aspect, in an embodiment of the present application, the rendering data of the dynamic instance is dynamically updated according to the initial key identifier, the target key identifier and the change rendering data to obtain the updated rendering data, including: reading the change rendering data of the change instance corresponding to the target key identifier from the change local buffer; confirming the dynamic instance corresponding to the change instance according to the initial key identifier and the target key identifier; and dynamically updating the rendering data of the dynamic instance according to the change rendering data to obtain the updated rendering data.

[0008] In combination with the first aspect, in an embodiment of the present application, rendering the multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence includes: obtaining the data amount of the rendering data of the dynamic instance and the initial key identifier of the dynamic instance; according to the initial key identifier and the data amount, reading the corresponding rendering data from the global buffer for rendering to obtain an image frame sequence.

[0009] In combination with the first aspect, in an embodiment of the present application, the global buffer includes multiple data areas, each of the data areas stores rendering data of the dynamic instance, and the data volume is the size of the data area corresponding to the dynamic instance; according to the initial key identifier and the data volume, the corresponding rendering data is read from the global buffer for rendering to obtain an image frame sequence, including: according to the initial key identifier and the data volume, calculating the offset of the data area of ​​the dynamic instance corresponding to the initial key identifier in the global buffer; according to the offset, obtaining the rendering data of the dynamic instance in the data area; rendering the dynamic instance according to the rendering data to obtain an image frame sequence.

[0010] In combination with the first aspect, in an embodiment of the present application, storing the rendering data in a global buffer includes: storing the rendering data in a temporary buffer; and retrieving the corresponding rendering data from the temporary buffer according to a transmission command and storing it in the global buffer.

[0011] In a second aspect, an embodiment of the present application provides a data update rendering method between a CPU and a GPU, which is applied to a CPU, and the method comprises: acquiring scene instance data, and obtaining a global rendering data buffer according to the scene instance data, wherein the global rendering data buffer comprises rendering data of multiple dynamic instances; sending the rendering data of the multiple dynamic instances to the GPU, wherein each of the dynamic instances corresponds to an initial key identifier, so that the GPU stores the multiple rendering data in the global buffer, and renders the multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence; collecting the changed rendering data in the current image frame, and rendering the global rendering data buffer according to the changed rendering data; The rendering data obtains a change instance buffer, the change rendering data is the rendering data of the change instance, the change instance is the dynamic instance corresponding to the rendering data with data change in the current image frame, and each of the change instances corresponds to a target key identifier; the change rendering data in the current image frame is sent to the GPU, so that the GPU stores the change rendering data in the change local buffer, and dynamically updates the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the change rendering data to obtain the updated rendering data, and renders the updated rendering data to obtain the updated image frame sequence.

[0012] In combination with the second aspect, in an embodiment of the present application, obtaining a global rendering data buffer based on the scene instance data includes: generating a data area based on the number of dynamic instances of the scene instance data and the amount of rendering data of the dynamic instances; and copying the rendering data of the dynamic instances to the corresponding data area to obtain a global rendering data buffer.

[0013] In combination with the second aspect, in an embodiment of the present application, obtaining a changing instance buffer according to the changing rendering data includes: obtaining the type and quantity of the changing rendering data, generating a changing data area according to the type and quantity of the changing rendering data; and copying the changing rendering data to the corresponding changing data area to obtain a changing instance buffer.

[0014] On the other hand, an embodiment of the present application provides an electronic device, comprising: at least one processor; at least one memory for storing at least one program; at least one of the programs is executed by at least one of the processors to execute the data update rendering method between the CPU and the GPU as described above.

[0015] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a processor. When the processor-executable computer program is executed by the processor, it is used to implement the data update rendering method between the CPU and the GPU as described above.

[0016] The embodiment of the present application provides a data update rendering method between a CPU and a GPU, first receiving rendering data of multiple dynamic instances sent by the CPU, storing the multiple rendering data in a global buffer, each dynamic instance corresponding to an initial key identifier; then, rendering the multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence. After receiving the change rendering data in the current image frame sent by the CPU, the change rendering data is stored in the change local buffer, the change rendering data is the rendering data of the change instance, the change instance is the dynamic instance corresponding to the rendering data with data changes in the current image frame, and each change instance corresponds to a target key identifier. Subsequently, according to the initial key identifier, the target key identifier and the change rendering data, the rendering data of the dynamic instance is dynamically updated to obtain the updated rendering data. The updated rendering data is rendered to obtain an updated image frame sequence. By setting a global buffer and a change local buffer, the number of direct communications between the CPU and the GPU can be effectively reduced. The CPU only needs to send the rendering data to the global buffer or the change local buffer without frequently performing data binding operations. When the rendering data changes, the CPU only needs to send the changed rendering data to the changing local buffer, and dynamically update the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data, which effectively avoids the problem of low rendering efficiency caused by frequent data changes in the traditional rendering process, and improves the rendering efficiency. In addition, since the rendering data in the global buffer is stable over a period of time, it is only necessary to send the changed rendering data to the changing local buffer when the data changes, without submitting a large amount of changed data to the GPU for each image frame, so it can effectively reduce the bandwidth requirements for data transmission and effectively reduce memory overhead. In addition, in view of the read and write competition problem that may be caused when the CPU and GPU access the same data block at the same time, this problem often causes the CPU to pause and wait for the GPU operation to complete. By deploying a global buffer and dynamically adjusting the local buffer, the GPU can directly read the data required for rendering from these two buffers, thereby effectively avoiding data read and write access conflicts with the CPU. To summarize, the embodiments of the present application effectively solve the problems of low rendering efficiency, high data transmission bandwidth requirements, large memory overhead, and data reading and writing competition between the CPU and GPU caused by frequent data changes in the traditional rendering process through the setting of a global buffer and a variable local buffer, thereby improving the rendering efficiency and the overall performance of the system, and realizing flexible processing and efficient updating of dynamic instance rendering data. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a flowchart of a data update rendering method between a CPU and a GPU provided in an embodiment of the present application;

[0018] Figure 2 is a schematic diagram of the organization format of the global buffer provided in an embodiment of the present application;

[0019] Figure 3 is a schematic diagram of a specific process of obtaining an image frame sequence provided in an embodiment of the present application;

[0020] Figure 4 The embodiment of this application provides Figure 1 A specific flow chart of step 140;

[0021] Figure 5 It is a schematic diagram of the organizational format of a variable local buffer provided in an embodiment of the present application;

[0022] Figure 6 It is a schematic diagram of the process of updating rendering data provided by a specific example of this application;

[0023] Figure 7 is a flowchart of a data update rendering method between a CPU and a GPU provided by another embodiment of the present application;

[0024] Figure 8 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0026] It should be noted that, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a different order from that in the flowchart. The terms "first", "second", etc. in the specification, claims and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions that can be implemented in this application, so they have no technical substantive significance. Any modification of the structure, change of the proportional relationship or adjustment of the size, without affecting the effects that can be produced by this application and the purposes that can be achieved, should still fall within the scope of the technical content disclosed in this application. At the same time, the terms such as "upper", "lower", "left", "right", "middle" and "one" quoted in this specification are only for the convenience of narration, and are not used to limit the scope of implementation of this application. The change or adjustment of the relative relationship should also be regarded as the scope of implementation of this application without substantial change of the technical content.

[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0028] In the relevant technical field, the current mainstream personal computer platforms, including desktops, notebooks, mobile phones, etc., all include core components such as central processing unit (CPU), graphics processing unit (GPU), memory, hard disk, etc. The CPU is mainly used to execute computer program codes and communicate with other components, such as GPU, sound card, keyboard, mouse, etc. The GPU is responsible for processing the graphics commands sent by the CPU and outputting the final image to the display. The memory and hard disk are components for storing program data and user data.

[0029] It is worth noting that in the current field of computer technology, various personal computer platforms, such as desktops, laptops, and smartphones, are equipped with core components, including central processing units (CPUs), graphics processing units (GPUs), memory, and hard disks. As the core computing unit, the CPU not only executes computer program codes, but is also responsible for communicating with other components such as GPUs, sound cards, keyboards, and mice. The GPU focuses on graphics processing, generating the final image based on the graphics commands sent by the CPU and outputting it to the display. The memory and hard disk are responsible for storing program data and user data, respectively.

[0030] In the traditional rendering process, the CPU and GPU have clear division of labor: the CPU handles complex logical operations, physical simulation and scene management, while the GPU is responsible for efficient graphics rendering. The CPU can regularly send rendering data, such as vertex information, texture coordinates and color values, to the GPU for rendering. Taking real-time 3D games as an example, the CPU can respond to user input, execute game logic, load resource data from the hard disk to the system memory, and send rendering commands and resource data to the GPU. Memory can be divided into CPU memory (system memory) and GPU memory (video memory) according to access rights. CPU memory can be directly accessed by the CPU, usually as a memory stick plugged into the motherboard; while GPU memory can be directly accessed by the GPU. In desktop computers, it is mostly an independent memory chip on the graphics card. In smartphones, it may share memory with the CPU, but it will be divided into different access areas.

[0031] For the GPU to use rendering data, it can first be loaded from the hard disk to the CPU memory through the CPU, and then transferred to the GPU memory through buses such as PCI-E. This data path is long, and the bus transmission speed is slower than the GPU processing speed. For static data, such as fixed scene elements such as buildings and trees, the rendering data only needs to be loaded from the hard disk to the GPU memory once. Because it does not change, a slightly slower transmission speed will not affect the user experience. However, for dynamic data, such as special effects, swimming schools of fish, etc., the rendering data changes all the time. If data is frequently transmitted to the GPU, the execution efficiency of the CPU and GPU will be greatly reduced, causing the game to freeze and not be smooth, affecting the user experience.

[0032] For multiple dynamic objects in the scene, traditional data processing methods include:

[0033] Method 1: For each dynamic object, the GPU maintains an independent rendering data buffer (Buffer refers to an area reserved in memory for temporarily storing input and output data). When the rendering data of an object needs to be modified, the CPU can construct a temporary CPU-side Buffer with the modified new data, and then send it to the corresponding GPU-side Buffer. If there are multiple objects with rendering data changes, it needs to be updated and submitted multiple times.

[0034] Method 2: All dynamic objects use a global large buffer for rendering data, and the CPU maintains a backup of the large buffer of the same size. When the rendering data of an object needs to be modified, the CPU updates the corresponding area of ​​the backup buffer. If multiple objects have data changes in a frame, the backup buffer is updated multiple times. Finally, before executing the rendering task in the current frame, the entire backup large buffer is submitted and transferred to the GPU buffer at one time.

[0035] Method 3: If the hardware supports GPU-side mapping of CPU memory, then the global large buffer of method 2 is directly stored in the CPU memory, and then mapped to the GPU, so that the GPU can directly access the CPU memory. In this way, when the rendering data of an object needs to be modified, the CPU updates the corresponding area of ​​the buffer, and then sends a message to inform the GPU that the data in the buffer area has changed, so that the GPU can refresh its internal storage, etc.

[0036] It should be noted that the traditional data processing method has the following problems:

[0037] In method 1, for each dynamic object, the GPU needs to maintain an independent rendering data Buffer. When drawing an object, you need to bind the Buffer first, and then draw. If there are multiple dynamic objects in the whole scene, you need to bind the Buffer multiple times and call the drawing command (Draw Call) multiple times. Binding the Buffer and calling the drawing command are both time-consuming and expensive operations for the graphics API. When there are many dynamic objects in the scene, the accumulated overhead of binding the Buffer and calling the drawing command each time may be very large, causing the game to freeze.

[0038] In method 2, the rendering data of all dynamic objects are combined into a large buffer. The CPU and GPU each maintain a copy of the large buffer, which the CPU uses for modification and the GPU uses for rendering. This reduces the number of times the buffer is bound and the number of times the drawing command is called. When the rendering data of all objects is in a large buffer, the Instancing Draw technology can be used to draw multiple objects by calling a drawing command only once. However, because the data of all objects are combined into a large buffer, as long as the rendering data of one object needs to be modified and updated, the large buffer containing the drawing data of all objects needs to be submitted and updated to the GPU, and the amount of data submitted is huge. When the object data is very large, it will inevitably cause lag. In addition, the CPU side needs to maintain a large buffer of the same size, resulting in twice the memory usage of method 1.

[0039] In method 3, the problem of maintaining two memories, CPU Buffer and GPU Buffer, is solved by hardware support for GPU mapping CPU memory. However, since the GPU and CPU are two independent processors, each has its own Cache hierarchy. When a certain section of the large Buffer is modified on the CPU side, the GPU needs to be informed of the change in the data of the area through the 3D graphics API refresh command, and the GPU refreshes its cache hierarchy. That is, for each dynamic object whose rendering data is modified, the 3D graphics API refresh command needs to be called once to refresh the GPU Cache. The graphics API data refresh GPU Cache command has a certain overhead. When the number of calls is large, the performance loss caused by it cannot be ignored. For method 3, there is another factor that affects performance more. Because the CPU and GPU share this large Buffer, when the GPU is using the data in the Buffer for drawing (such as the drawing command of the previous frame), if the CPU side modifies the data in the Buffer, and it happens to be the section of data that the GPU is using, it will cause data read and write access conflicts, resulting in errors in the drawn screen. Therefore, when the CPU needs to modify the data in the buffer, it can only detect whether the data is being used by the GPU through the 3D graphics API. If it is, it needs to wait for the GPU to finish using it, which causes the CPU to stagnate. Finally, the function of GPU mapping CPU memory requires hardware support, and not all hardware currently supports this function.

[0040] In summary, the traditional methods have the following problems: too many buffer binding times, too many drawing command calls, too much data submitted to the GPU per frame, too much total memory overhead, and CPU and GPU competition for the same data causing CPU stalls. Therefore, how to efficiently manage the data in these buffers, especially when the data changes frequently, is still a key technical problem that needs to be solved.

[0041] In view of this, the embodiment of the present application provides a data update rendering method between a CPU and a GPU, an electronic device, and a computer-readable storage medium. The method can be applied to a GPU. First, the rendering data of multiple dynamic instances sent by the CPU are received, and the multiple rendering data are stored in a global buffer. Each dynamic instance corresponds to an initial key identifier; then, the multiple rendering data in the global buffer are rendered according to the initial key identifier to obtain an image frame sequence. After receiving the change rendering data in the current image frame sent by the CPU, the change rendering data is stored in a change local buffer. The change rendering data is the rendering data of the change instance. The change instance is a dynamic instance corresponding to the rendering data with data changes in the current image frame. Each change instance corresponds to a target key identifier. Subsequently, according to the initial key identifier, the target key identifier and the change rendering data, the rendering data of the dynamic instance is dynamically updated to obtain the updated rendering data. The updated rendering data is rendered to obtain an updated image frame sequence. By setting a global buffer and a change local buffer, the number of direct communications between the CPU and the GPU can be effectively reduced. The CPU only needs to send the rendering data to the global buffer or the change local buffer without frequently performing data binding operations. When the rendering data changes, the CPU only needs to send the changed rendering data to the changing local buffer, and dynamically update the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data, which effectively avoids the problem of low rendering efficiency caused by frequent data changes in the traditional rendering process, and improves the rendering efficiency. In addition, since the rendering data in the global buffer is stable over a period of time, it is only necessary to send the changed rendering data to the changing local buffer when the data changes, without submitting a large amount of changed data to the GPU for each image frame, so it can effectively reduce the bandwidth requirements for data transmission and effectively reduce memory overhead. In addition, in view of the read and write competition problem that may be caused when the CPU and GPU access the same data block at the same time, this problem often causes the CPU to pause and wait for the GPU operation to complete. By deploying a global buffer and dynamically adjusting the local buffer, the GPU can directly read the data required for rendering from these two buffers, thereby effectively avoiding data read and write access conflicts with the CPU. To summarize, the embodiments of the present application effectively solve the problems of low rendering efficiency, high data transmission bandwidth requirements, large memory overhead, and data reading and writing competition between the CPU and GPU caused by frequent data changes in the traditional rendering process through the setting of a global buffer and a variable local buffer, thereby improving the rendering efficiency and the overall performance of the system, and realizing flexible processing and efficient updating of dynamic instance rendering data.

[0042] The embodiments of the present application are further described below in conjunction with the accompanying drawings.

[0043] Reference Figure 1 , Figure 1 1 is a flow chart of a data updating and rendering method between a CPU and a GPU provided in an embodiment of the present application. The method can be applied to a GPU side, and the specific process may include but is not limited to steps 110 to 150.

[0044] Step 110: receiving rendering data of multiple dynamic instances sent by the CPU, storing the multiple rendering data in a global buffer, each dynamic instance corresponding to an initial key identifier;

[0045] Step 120: Rendering multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence;

[0046] Step 130: receiving the changed rendering data in the current image frame sent by the CPU, and storing the changed rendering data in the changed local buffer, where the changed rendering data is the rendering data of the changed instance, and the changed instance is a dynamic instance corresponding to the rendering data with data changes in the current image frame, and each changed instance corresponds to a target key identifier;

[0047] Step 140: dynamically updating the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data to obtain updated rendering data;

[0048] Step 150: Render the updated rendering data to obtain an updated image frame sequence.

[0049] Steps 110 to 150 are described in detail below.

[0050] In a feasible embodiment, the rendering data of a dynamic instance refers to a series of data generated or processed by a central processing unit (CPU) during the graphics rendering process, which is used to describe and define the appearance and behavior of multiple dynamic instances (i.e., dynamic graphics objects). These dynamic instances can be characters in a game, objects in a scene, elements in a user interface, etc. Specifically, the rendering data may include the following types of information: Geometry data: describes the shape, size, and position of the dynamic instance, such as vertex coordinates, normals, texture coordinates, etc. These data are usually used to determine the position and appearance of the instance in three-dimensional space. Material properties: define the surface characteristics of the dynamic instance, such as color, glossiness, transparency, texture mapping, etc. These properties determine the performance of the instance under lighting. Transformation information: includes transformation matrices such as translation, rotation, and scaling, which are used to perform spatial transformations on the instance before rendering. Animation data: If the instance is animated, it also needs to include animation data such as keyframes and animation curves to describe the behavior of the instance over time. Lighting and shadow information: Although lighting calculations are usually performed on the GPU, the CPU may send some lighting parameters or pre-calculated lighting data to the GPU to assist the rendering process. Other rendering states: such as depth testing, blending mode, clipping information, etc., which are used to control how instances are handled during the rendering process. After the CPU prepares this rendering data, it can send it to the GPU (usually through some form of memory or video memory). The GPU then uses this data to render these dynamic instances to the screen.

[0051] In a feasible embodiment, the global buffer is an area for storing and temporarily managing rendering data. In this buffer, each dynamic instance is assigned a unique initial key identifier (such as an ID or index). Through this ID, the corresponding rendering data can be indexed in the global buffer to perform rendering operations. Taking Instancing Draw as an example, its working principle is as follows: First, the rendering data of all objects that need to be drawn (i.e., instances) are integrated and stored in the global buffer. Subsequently, all objects can be drawn at once by calling an instantiation drawing command. When calling instantiation drawing, the number of objects to be drawn can be explicitly specified through parameters. It is worth noting that in the internal mechanism of instantiation drawing, the corresponding rendering data can be accurately indexed from the global buffer according to the ID of each dynamic instance, and rendering can be performed.

[0052] In a feasible embodiment, when the rendering data is stored in the global buffer, the rendering data may be first stored in the temporary buffer; then, the corresponding rendering data may be retrieved from the temporary buffer according to the transmission command and stored in the global buffer. It is worth noting that the rendering data may be in an unstable state when it is generated or received, and directly storing it in the global buffer may cause data damage or loss. The temporary buffer provides a safe intermediate storage location to ensure that the data is in a stable state before transmission. In addition, the rendering data may come from different sources or undergo different processing steps, and its format and size may be inconsistent. The temporary buffer allows the data to be sorted, formatted or verified as necessary to ensure that it meets the storage requirements of the global buffer. In addition, the global buffer may be accessed by multiple processes or threads at the same time, and direct writing may cause data conflicts. By controlling the writing timing and order of data through the transmission command, the synchronization and consistency of the data can be ensured. Therefore, the process of storing the rendering data in the temporary buffer first and then storing it in the global buffer according to the transmission command not only ensures the stability and reliability of the data, but also realizes the flexible scheduling and efficient use of the data. This process design meets the requirements of modern computer systems for data processing and helps to improve the execution efficiency and quality of rendering tasks.

[0053] In a feasible embodiment, the organization format of the global buffer is as follows: Figure 2 As shown. Assume that the global buffer is divided into N continuous data areas, which store N data items in sequence. These data items represent the rendering data of dynamic instances. Figure 2 In the , these data items are labeled as "object 1 data", "object 2 data", "object 3 data", "object 4 data", and "object N data". Each data item has a corresponding offset, which represents the distance from the starting position of the global buffer (usually the first byte) to the starting position of the data item. Specifically, the offset of object 1 data can be labeled as offset1, the offset of object 2 data can be labeled as offset2, the offset of object 3 data can be labeled as offset3, the offset of object 4 data can be labeled as offset4, and so on. The offset of object N data can be labeled as offsetN. At the same time, the size of each data item (that is, the total number of bytes occupied by the data item in the global buffer) is Figure 2 They are also clearly listed in the , corresponding to size1, size2, size3, size4, and sizeN, etc. When you need to access or modify a specific data item, you can use its offset to quickly find the starting position of the data item in the global buffer, and combine its size information to determine the complete range of the data item.

[0054] In a feasible embodiment, the image frame sequence refers to a series of continuous image frames, which can be arranged in time order and together constitute a dynamic visual content. In the process of rendering multiple rendering data in the global buffer according to the initial key identifier to obtain the image frame sequence, the data volume of the rendering data of the dynamic instance and the initial key identifier of the dynamic instance can be first obtained; then, according to the initial key identifier and the data volume, the corresponding rendering data is read from the global buffer for rendering to obtain the image frame sequence. Specifically, the data volume of the rendering data of each dynamic instance (that is, the size of the data area corresponding to the dynamic instance) and their initial key identifiers (such as ID or index) are first obtained. This information is the basis for accurately reading the rendering data from the global buffer in the future. Subsequently, this information can be used to locate the corresponding rendering data in the global buffer. Once the position of the rendering data in the global buffer is determined, the rendering data of the corresponding size can be read from this position. This process may involve underlying operations such as memory access and data transmission. After reading the rendering data, it can be further passed to the rendering engine or GPU for rendering operations. In this process, the rendering engine can generate corresponding image frames according to the content of the rendering data. By repeating the above steps, a corresponding image frame can be generated for each dynamic instance. By arranging these image frames in chronological order or logical order, a complete image frame sequence can be obtained.

[0055] In a possible embodiment, if Figure 3 As shown, according to the initial key identifier and the data amount, the corresponding rendering data is read from the global buffer for rendering, and the specific process of obtaining the image frame sequence may include but is not limited to steps 310 to 330.

[0056] Step 310: Calculate the offset of the data area of ​​the dynamic instance corresponding to the initial key identifier in the global buffer according to the initial key identifier and the data volume;

[0057] Step 320: Obtain rendering data of the dynamic instance in the data area according to the offset;

[0058] Step 330: Render the dynamic instance according to the rendering data to obtain an image frame sequence.

[0059] In a feasible embodiment, the data volume represents the size of the data area of ​​each dynamic instance, that is, in the global buffer, each dynamic instance occupies a continuous memory space. The offset refers to the number of bytes between the starting position of the global buffer and the starting position of the target dynamic instance data area. Based on the initial key identifier (such as ID or index) and the data volume, the offset of the data area of ​​the dynamic instance in the global buffer can be calculated.

[0060] In a feasible embodiment, the global buffer includes multiple data areas, each of which stores rendering data of a dynamic instance. It should be noted that the size of the data area of ​​each dynamic instance can be the same or different. In addition, the dynamic instances can be stored in the global buffer in a certain order (such as ascending or descending order of the initial key identifier).

[0061] In a feasible embodiment, it is assumed that the dynamic instance is stored in the ascending order of the initial key identifier, and the size of the data area is fixed, the initial key identifier is an integer, and it increases continuously from 0. Specifically, it is assumed that 4 dynamic instances are stored in the global buffer, the data area size of each instance is 128 bytes, and they are stored in the ascending order of the initial key identifier (ID). The data area with the dynamic instance ID of 0 is stored at the starting position of the global buffer (offset is 0). The data area with the dynamic instance ID of 1 is immediately after the data area with the ID of 0, so its offset is 128 bytes (0+1*128). By analogy, the offset of the dynamic instance ID of 2 is 256 bytes (0+2*128), and the offset of the ID of 3 is 384 bytes (0+3*128). Assume that the offset of the dynamic instance with ID of 2 in the global buffer needs to be calculated: it is known that the data area size of each dynamic instance is 128 bytes. It is known that the dynamic instance is stored in the ascending order of ID. Therefore, the offset of the dynamic instance with ID 2 can be calculated by the following formula: Offset = (Target ID - Start ID) * Data area size of each instance. In this example, the start ID is 0, the target ID is 2, and the data area size of each instance is 128 bytes. Therefore, offset = (2-0) * 128 = 256 bytes.

[0062] In a feasible embodiment, the calculated offset may be used to further locate the corresponding data area in the global buffer, and read the rendering data in the area.

[0063] In a feasible embodiment, the acquired rendering data can be passed to a rendering engine or GPU, and corresponding rendering commands can be called to perform rendering operations. The rendering engine can generate corresponding image frames according to the content of the rendering data, and these image frames are arranged in a chronological order or a logical order to form an image frame sequence.

[0064] In a possible embodiment, if Figure 4 As shown, the specific process of step 140 may include but is not limited to steps 410 to 430.

[0065] Step 410: Read the change rendering data of the change instance corresponding to the target key identifier from the change local buffer;

[0066] Step 420: confirming the dynamic instance corresponding to the changed instance according to the initial key identifier and the target key identifier;

[0067] Step 430: dynamically update the rendering data of the dynamic instance according to the changed rendering data to obtain updated rendering data.

[0068] In a feasible embodiment, the change local buffer is used to store all the changed rendering data in the current image frame. These changed rendering data are directly associated with the dynamic instances that have undergone data changes in the current frame, which can be called change instances. Each change instance also has a target key identifier. By systematically traversing the change local buffer, the target key identifier of each change instance and their corresponding change rendering data can be accurately read.

[0069] In a feasible embodiment, in order to accurately apply the changed rendering data to the corresponding dynamic instance, the target key identifier read from the changed local buffer can be compared one by one with the initial key identifiers of all dynamic instances stored in the global buffer. When a target key identifier matches an initial key identifier in the global buffer, it means that the dynamic instance whose rendering data has changed in the current image frame has been found.

[0070] In a feasible embodiment, after successfully matching a dynamic instance, the changed rendering data can be further integrated into the current rendering data of the dynamic instance. This may involve adjusting various rendering attributes such as color, position, size, texture, etc. Through this series of update operations, it is possible to ensure that the rendering data of the dynamic instance is always consistent with the latest changes, thereby presenting a smooth and accurate visual effect to the user.

[0071] In a feasible embodiment, the organizational format of the local buffer is changed as follows: Figure 5 As shown. In the current image frame, assume that the rendering data of dynamic instance 2 and dynamic instance 4 stored in the global buffer have changed. Once the changed rendering data corresponding to these dynamic instances are received, these data can be stored in the local buffer. Figure 5 In the example, the dynamic instances with rendering data changes are instance 2 and instance 4, and their corresponding change data (i.e., the data of change instance 2 and change instance 4) can be stored in the corresponding data area in the local buffer. Figure 6As shown, it is assumed that the rendering data of N dynamic instances have been continuously stored in the global buffer in advance, and these data are respectively marked as "object 1 data", "object 2 data", "object 3 data", "object 4 data", and so on, until "object N data". If in the current image frame, the object 2 data and the object 4 data are changed, and the changed rendering data corresponding to these two objects (also called instances) (i.e., the data of changed instance 2 and changed instance 4) have been stored in the local buffer, then for each changed instance, the corresponding instance rendering data can be read from the changed local buffer according to its ID and other information. Subsequently, these data are located in the data area corresponding to the instance on the GPU-side global buffer, and the data in the changed local buffer is used to overwrite the corresponding data area in the global buffer.

[0072] Reference Figure 7 , Figure 7 This is a flow chart of a data update rendering method between a CPU and a GPU provided by another embodiment of the present application. The method can be applied to the CPU side, and the specific process may include but is not limited to steps 710 to 740.

[0073] Step 710: Acquire scene instance data, and obtain a global rendering data buffer according to the scene instance data, wherein the global rendering data buffer includes rendering data of multiple dynamic instances;

[0074] Step 720: Send rendering data of multiple dynamic instances to the GPU, each dynamic instance corresponds to an initial key identifier, so that the GPU stores the multiple rendering data in a global buffer, and renders the multiple rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence;

[0075] Step 730: collecting the changed rendering data in the current image frame, and obtaining a changed instance buffer according to the changed rendering data, wherein the changed rendering data is the rendering data of the changed instance, and the changed instance is a dynamic instance corresponding to the rendering data with data changes in the current image frame, and each changed instance corresponds to a target key identifier;

[0076] Step 740: Send the changed rendering data in the current image frame to the GPU, so that the GPU stores the changed rendering data in the changed local buffer, and dynamically updates the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data to obtain the updated rendering data, and renders the updated rendering data to obtain the updated image frame sequence.

[0077] In a feasible embodiment, scene instance data refers to the collection of all objects or entities in the rendering scene, which can be static (such as fixed background buildings) or dynamic (such as moving characters, objects, etc.). These instance data usually contain the geometric information of the object (such as vertices, faces, etc.), material information (such as color, texture, etc.), position information (such as coordinates, rotation angle, etc.) and other properties that may affect rendering. Scene instance data can be obtained in a variety of ways, such as loading predefined scene data from a file, or through real-time generation (such as programmatic generation of terrain, objects, etc.). In addition, the data of dynamic instances can also be updated in real time based on user input, game logic or physical simulation.

[0078] In a feasible embodiment, the global rendering data buffer can be used to store the rendering data of the dynamic instances in all scene instances for subsequent rendering processing. This buffer is usually located in the memory for fast access and processing.

[0079] In a feasible embodiment, when obtaining a global rendering data buffer according to scene instance data, a data area can be generated first according to the number of dynamic instances of the scene instance data and the amount of rendering data of the dynamic instances; then the rendering data of the dynamic instances can be copied to the corresponding data area to obtain a global rendering data buffer. Specifically, the specific number of dynamic instances contained in the scene is first determined, and then, for each dynamic instance, the amount of rendering data required is analyzed and determined in detail. Generally, these data can cover a series of key data such as vertex data, texture coordinates, color values, material properties, and lighting information. After the number of dynamic instances and the amount of rendering data of each instance are determined, the corresponding data areas can be planned and allocated for these instances in the global rendering data buffer. It is worth noting that in order to improve the efficiency of data access and the speed of rendering, the allocation of data areas usually follows certain optimization strategies. For example, instance data of the same type can be put together, or the storage location of the data can be arranged according to the priority of rendering. Next, the rendering data of each dynamic instance can be copied from the original storage location to a specific data area allocated to it in the global rendering data buffer. After the above steps, a global rendering data buffer containing all dynamic instance rendering data can be obtained.

[0080] In a feasible embodiment, when obtaining a variable instance buffer according to variable rendering data, the type and quantity of the variable rendering data can be first obtained, and a variable data area can be generated according to the type and quantity of the variable rendering data; then the variable rendering data can be copied to the corresponding variable data area to obtain the variable instance buffer. Specifically, the specific type of the variable rendering data is first identified. These types may include vertex data, texture coordinates, color values, lighting parameters, etc. Count the number: Then count the number of each type of variable rendering data. This helps to allocate sufficient storage space for these data in the variable instance buffer. After understanding the type and quantity of the variable rendering data, the variable data area can be planned. This includes determining the size and location of each data area and the relationship between them. It is worth noting that in order to improve the efficiency of data access and reduce memory fragmentation, some optimization strategies can be used to layout the variable data area. For example, data of the same type can be put together, or their storage locations can be arranged according to the access frequency of the data. Next, the variable rendering data can be copied from the original storage location to the variable data area. This step needs to ensure the integrity and consistency of the data to avoid data loss or damage during the copying process. After the above steps, a variable instance buffer containing all variable rendering data can be finally obtained.

[0081] In a feasible embodiment, the CPU can use a compute shader to perform data conversion and update operations, thereby minimizing the amount of data sent to the GPU synchronously and effectively avoiding data access conflicts between the CPU and the GPU. Among them, a compute shader is a type of shader, and a shader is a program code segment executed on the GPU, which is usually written in a specific shader language (such as GLSL, HLSL, etc.). The shader code can be loaded by the CPU and sent to the GPU for execution after being compiled by the graphics driver. During the rendering process of each frame of the image, the CPU can collect all instances where the rendering data has changed and store them in a change instance buffer. Subsequently, the CPU can submit these changed data to the local change buffer on the GPU side. Then, the CPU will issue a command to start the compute shader responsible for data conversion. The compute shader that performs data conversion is also a GPU command, which is received and executed by the GPU like a drawing command. It should be noted that the compute shader for data conversion and the command for rendering dynamic objects in the drawing scene can be submitted to the GPU in sequence. The GPU can first execute the compute shader that updates the data conversion to update the data, and then use the updated data for rendering. This sequential execution method ensures that there will be no conflict between rendering data updates and rendering data accesses, thereby avoiding waiting for either the CPU or the GPU. In addition, since only the changed data needs to be submitted for each frame, the data submitted to the GPU is minimized, which not only reduces memory usage, but also avoids performance issues caused by submitting large amounts of data.

[0082] It should be noted that the variable instance buffer can be regarded as a copy of the GPU's variable local buffer, and the data structure format of the two can be designed to be consistent. It should be noted that the variable instance buffer can be temporary, used to store data changes for a short time, or it can be resident and dynamically growing to adapt to the needs of continuous data changes.

[0083] Reference Figure 8 The embodiment of the present application also discloses an electronic device, which includes: at least one processor 810; at least one memory 820, used to store at least one program; when the at least one program is executed by the at least one processor 810, the data update rendering method between the CPU and the GPU as described above can be implemented.

[0084] The embodiment of the present application further discloses a computer-readable storage medium, which stores a computer program executable by a processor. When the computer program executable by the processor is executed by the processor, the data update rendering method between the CPU and the GPU as described above can be implemented.

[0085] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data update rendering method between a CPU and a GPU, characterized in that: Applied to a GPU, the method comprises: Receiving rendering data of multiple dynamic instances sent by the CPU, storing the multiple rendering data in a global buffer, each of the dynamic instances corresponding to an initial key identifier; Rendering the plurality of rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence; Receive the changed rendering data in the current image frame sent by the CPU, and store the changed rendering data in a changed local buffer, wherein the changed rendering data is rendering data of a changed instance, and the changed instance is the dynamic instance corresponding to the rendering data with data changes in the current image frame, and each of the changed instances corresponds to a target key identifier; Dynamically updating the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data to obtain the updated rendering data; The updated rendering data is rendered to obtain the updated image frame sequence.

2. The data updating rendering method between the CPU and the GPU according to claim 1, characterized in that: The dynamically updating the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data to obtain the updated rendering data includes: Reading the change rendering data of the change instance corresponding to the target key identifier from the change local buffer; According to the initial key identifier and the target key identifier, confirming the dynamic instance corresponding to the change instance; The rendering data of the dynamic instance is dynamically updated according to the changed rendering data to obtain the updated rendering data.

3. The data updating and rendering method between a CPU and a GPU according to claim 1, characterized in that: The step of rendering the plurality of rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence includes: Acquire the data volume of the rendering data of the dynamic instance and the initial key identifier of the dynamic instance; According to the initial key identifier and the data amount, the corresponding rendering data is read from the global buffer for rendering to obtain an image frame sequence.

4. The data updating and rendering method between the CPU and the GPU according to claim 3, characterized in that: The global buffer includes a plurality of data areas, each of which stores rendering data of a dynamic instance, and the data volume is the size of the data area corresponding to the dynamic instance; The step of reading the corresponding rendering data from the global buffer for rendering according to the initial key identifier and the data amount to obtain an image frame sequence includes: According to the initial key identifier and the data volume, calculate the offset of the data area of ​​the dynamic instance corresponding to the initial key identifier in the global buffer; According to the offset, acquiring rendering data of the dynamic instance in the data area; The dynamic instance is rendered according to the rendering data to obtain an image frame sequence.

5. The data transmission method between a CPU and a GPU according to claim 1, characterized in that: The storing the rendering data into a global buffer comprises: storing the rendering data in a temporary buffer; The corresponding rendering data is retrieved from the temporary buffer according to the transmission command and stored in the global buffer.

6. A data update rendering method between a CPU and a GPU, characterized in that: Applied to a CPU, the method comprises: Acquire scene instance data, and obtain a global rendering data buffer according to the scene instance data, wherein the global rendering data buffer includes rendering data of multiple dynamic instances; Sending rendering data of a plurality of dynamic instances to a GPU, each of the dynamic instances corresponding to an initial key identifier, so that the GPU stores the plurality of rendering data in a global buffer, and renders the plurality of rendering data in the global buffer according to the initial key identifier to obtain an image frame sequence; Collecting the changed rendering data in the current image frame, and obtaining a changed instance buffer according to the changed rendering data, wherein the changed rendering data is the rendering data of the changed instance, and the changed instance is the dynamic instance corresponding to the rendering data with data changes in the current image frame, and each of the changed instances corresponds to a target key identifier; The changed rendering data in the current image frame is sent to the GPU, so that the GPU stores the changed rendering data in a changed local buffer, and dynamically updates the rendering data of the dynamic instance according to the initial key identifier, the target key identifier and the changed rendering data to obtain the updated rendering data, and renders the updated rendering data to obtain the updated image frame sequence.

7. The data updating and rendering method between a CPU and a GPU according to claim 6, characterized in that: The obtaining a global rendering data buffer according to the scene instance data comprises: Generate a data area according to the number of dynamic instances of the scene instance data and the amount of rendering data of the dynamic instances; The rendering data of the dynamic instance is copied to the corresponding data area to obtain a global rendering data buffer.

8. The data updating and rendering method between a CPU and a GPU according to claim 6, characterized in that: The step of obtaining a changed instance buffer according to the changed rendering data includes: Acquire the type and quantity of the changed rendering data, and generate a changed data area according to the type and quantity of the changed rendering data; The changed rendering data is copied to the corresponding changed data area to obtain a changed instance buffer.

9. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; At least one of the programs is executed by at least one of the processors to perform the data update rendering method between the CPU and the GPU as described in any one of claims 1 to 5 or claims 6 to 8.

10. A computer-readable storage medium, characterized in that: A computer program executable by a processor is stored therein, and when the computer program executable by the processor is executed by the processor, it is used to implement the data update rendering method between the CPU and the GPU as described in any one of claims 1 to 5 or claims 6 to 8.