Ray tracing method and device, and image rendering system
By immediately sending cross-processor requests after determining the intersection point of the light in the graphics processor and optimizing the interception process, the problem of low parallel rendering efficiency of multi-GPUs is solved, and efficient multi-GPU parallel image rendering is achieved.
Patent Information
- Application Number
- PCT/CN2024/139367
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-08
- Filing Date
- 2024-12-13
- Publication Date
- 2025-08-14
AI Technical Summary
When multi-GPUs render super large scenes in parallel, the existing technology is inefficient and cannot meet the needs of real-time image rendering.
The intersection point between the light ray and the target bounding box is determined by the first graphics processor. If the intersection data is not saved, the cross-processor interception request is immediately sent to reduce the waiting time, the cross-processor task is preferred, the request is merged to reduce the number of interactions, and the light ray interception unit is used to accelerate the interception of the light ray.
It greatly reduces the overall time-consuming of multi-GPU parallel ray interception tasks, improves the efficiency of multi-GPU parallel image rendering, and meets the requirements of real-time image rendering.
Smart Images

Figure CN2024139367_14082025_PF_FP_ABST
Abstract
Description
A ray tracing method, device and image rendering system
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of the People's Republic of China on February 8, 2024, with application number 202410176915.1 and application name "A ray tracing method, device and image rendering system", the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of image rendering technology, and in particular to a ray tracing method, device and image rendering system. Background Art
[0004] In fields involving computer graphics, such as film, animation, and design, ray tracing technology is often used to render images. Ray tracing technology can realistically simulate real-world lighting effects and can also handle complex lighting scenarios such as indoor, outdoor, and natural landscapes. Therefore, ray tracing technology has been widely used in the field of computer graphics.
[0005] When rendering images, a graphics processing unit (GPU) is typically used to perform ray tracing. However, when rendering a very large scene containing a large amount of geometric data, a single GPU cannot fully load all the geometric data. In this case, multiple GPUs can be used to collaboratively perform ray tracing.
[0006] How to achieve efficient parallel rendering of large scenes by multiple GPUs is an urgent problem to be solved. Summary of the Invention
[0007] The present application provides a ray tracing method, device, and image rendering system that can improve the efficiency of image rendering performed in parallel by multiple GPUs.
[0008] In a first aspect, the present application provides a ray tracing method, which can be performed by a first graphics processor in an image rendering system, or a chip, chip system, or circuit in the first graphics processor. The image rendering system may include multiple graphics processors, and the first graphics processor can be any one of the multiple graphics processors. The multiple graphics processors in the image rendering system are used to perform ray tracing based on specified scene data.
[0009] The ray tracing method provided herein may include: a first graphics processor determining, for a first ray in a scene, a first target bounding box that intersects with the first ray. If the first target bounding box is not stored in the first graphics processor, that is, if the first graphics processor does not store the geometry data for the first target bounding box, the first graphics processor sends a first request to a target graphics processor, where the first target bounding box is stored in the target graphics processor, i.e., the target graphics processor stores the geometry data for the first target bounding box. The first request is a first cross-processor intersection request, instructing the target graphics processor to perform intersection processing on the first ray. After sending the first request, the intersection task for other rays in the scene may continue. For example, the first graphics processor may determine, for a second ray in the scene, a second target bounding box that intersects with the second ray, and determine second intersection information based on the second ray and the second target bounding box. The second intersection information refers to the intersection information between the second ray and the geometry within the second target bounding box. After sending the first request, the first graphics processor may also receive first intersection information returned by the target graphics processor in response to the first request. The first intersection information refers to the intersection information between the first ray and the geometry within the first target bounding box. During the execution process, the first graphics processor may receive the first intersection information returned by the target graphics processor before determining the second intersection information, or may receive the first intersection information returned by the target graphics processor after determining the second intersection information, or may receive the first intersection information returned by the target graphics processor after determining the intersection information of multiple rays.
[0010] In the ray tracing method provided by the present application, after the first graphics processor determines that no geometric data in the target bounding box intersecting with the first ray is saved, it can initiate a cross-processor intersection request. There is no need to wait for all ray intersection tasks in a pass to be completed, and then analyze which part of the ray needs to pass through the cross-processor ray intersection task to determine the intersection information, and then initiate a cross-processor intersection request, as in related technologies. For example, the first graphics processor of the present application can send a cross-processor intersection request for the first ray before obtaining the intersection information of the second ray, thereby reducing waiting delays, significantly reducing the overall time consumption of multi-GPU parallel ray intersection tasks, and improving the efficiency of multi-GPU parallel ray intersection, thereby improving the efficiency of multi-GPU parallel image rendering, so that cross-processor ray intersection can meet the needs of real-time image rendering.
[0011] In one optional implementation, multiple graphics processors in an image rendering system are configured to perform ray tracing based on specified scene data. The scene data may include multiple geometric bodies and multiple bounding boxes, each of which contains geometric data for a portion of the multiple geometric bodies in the scene data.
[0012] In one possible implementation, the first graphics processor stores geometric data for a second target bounding box and identification information of graphics processors corresponding to the remaining bounding boxes, excluding the second target bounding box, among a plurality of bounding boxes. The graphics processor corresponding to any of the remaining bounding boxes is the graphics processor storing the geometric data for that bounding box. If the first graphics processor does not store geometric data for the first target bounding box, the target graphics processor can be quickly and accurately determined based on the identification information of the graphics processor corresponding to the first target bounding box, and a first cross-processor intersection request can be sent to the target graphics processor.
[0013] In one possible implementation, before determining a target bounding box intersecting the first ray based on the first ray, the first graphics processor may generate multiple ray intersection tasks and save the multiple ray intersection tasks to a task queue of a ray intersection unit. The multiple ray intersection tasks include a ray intersection task for the first ray. In other words, the ray intersection task for the first ray executed by the first graphics processor may be the ray intersection task generated by the first graphics processor. The first graphics processor may save the generated ray intersection task to the task queue of the ray intersection unit in the first graphics processor, and the ray intersection unit executes the ray intersection task.
[0014] In one possible implementation, the first graphics processor may further receive a second request sent by a second graphics processor, which may also be referred to as a second cross-processor intersection request. The second graphics processor is any graphics processor among the multiple graphics processors other than the first graphics processor. A ray intersection task for a third ray indicated by the second cross-processor intersection request is saved to a task queue of a ray pursuit intersection unit. For the ray intersection task of the third ray, information about a third intersection point of the third ray is determined by the ray pursuit intersection unit. In other words, the first graphics processor may receive the cross-processor ray intersection task and save the received cross-processor ray intersection task to the task queue of the ray pursuit intersection unit in the first graphics processor, so that the ray pursuit intersection unit executes the ray intersection task.
[0015] In one possible implementation, the first graphics processor may execute a ray intersection task for a first ray in a task queue via a ray intersection unit to obtain a first target bounding box that intersects with the first ray. The ray intersection unit in the first graphics processor may execute the ray intersection tasks in the task queue according to a set task priority. The task priority of the ray intersection tasks is determined based on the graphics processor that generates the ray intersection tasks. For example, the task priority of the ray intersection tasks may be such that the priority of the ray intersection tasks generated by the graphics processor is higher than the priority of the ray intersection tasks across processors, or the task priority of the ray intersection tasks may be such that the priority of the ray intersection tasks across processors is higher than the priority of the ray intersection tasks generated by the graphics processor.
[0016] The ray tracing intersection unit in the first graphics processor executes ray intersection tasks in the task queue according to the set task priority. This can prioritize the efficiency of executing ray intersection on some graphics processors based on actual needs. For example, if the task priority of the ray intersection tasks is: the priority of the cross-processor ray intersection task is higher than the priority of the ray intersection task generated by the graphics processor itself, the ray tracing intersection unit in the first graphics processor will prioritize executing the cross-processor ray intersection task. This can shorten the time required for other graphics processors to execute cross-processor intersection requests, which is beneficial to improving the overall efficiency of multiple GPUs in executing ray tracing tasks.
[0017] In one possible implementation, the first graphics processor may determine, through a ray intersection unit, whether the first graphics processor stores geometric data in a first target bounding box. If the first graphics processor does not store geometric data in the first target bounding box, the first graphics processor may generate a first cross-processor intersection request for the first ray through the ray intersection unit, and the first graphics processor sends the first cross-processor intersection request to the target graphics processor.
[0018] The ray intersection unit is used to determine whether the geometric data in the first target bounding box is stored in the first graphics processor, and to generate a first cross-processor intersection request for the first ray. The ray intersection unit can accelerate the execution of the above operations through hardware, which is conducive to improving the efficiency of executing the ray intersection task.
[0019] In one possible implementation, the first graphics processor may send one or more cross-processor intersection requests to the target graphics processor at a time via a cross-processor message; the one or more cross-processor intersection requests may include the first cross-processor intersection request described above; that is, the first graphics processor may batch together and send multiple cross-processor intersection requests with the same target graphics processor to reduce the number of interactions between graphics processors.
[0020] In one possible implementation, the first cross-processor intersection request carries some or all of the following information: the starting point of the first ray, the direction of the first ray, the identification of the destination GPU, the identification of the source GPU, and the identification of the first destination bounding box; the source GPU is the GPU that generated the ray intersection task for the first ray. The starting point and direction of the first ray are used to facilitate the ray intersection calculation by the destination GPU. The identification of the destination GPU ensures that the cross-processor intersection request is correctly sent to the destination GPU. The identification of the source GPU is used to assist the destination GPU in returning the intersection information to the GPU that sent the cross-processor intersection request, or in other words, to the GPU that generated the ray intersection task for the second ray.
[0021] In one possible implementation, the first intersection information may include: the first ray has no intersection with the geometry in the first target bounding box; or, the first intersection information may include: the identifier of the target geometry that intersects with the first ray in the geometry contained in the first target bounding box, and the intersection position of the first ray and the target geometry.
[0022] In one possible implementation, the target graphics processor also stores texture data of the geometry within the first target bounding box. When the first intersection information includes the intersection position of the first ray and the target geometry, the first intersection information may also include texture data of the intersection position of the first ray and the target geometry. The first graphics processor may determine the material of the intersection position based on the texture data of the intersection position of the first ray and the target geometry, thereby determining the subsequent propagation direction of the first ray.
[0023] In one possible implementation, when the first intersection information includes the intersection location of the first ray and the target geometric object, the first intersection information may also include shading information of the intersection location. Since shading information is relatively short, including shading information in the first intersection information can reduce bandwidth usage.
[0024] In one possible implementation, after receiving the first intersection point information of the first request, if there are unfinished tasks in the warp to which the ray intersection task for the first ray belongs, the first intersection point information is saved. A warp includes multiple ray intersection tasks; each of the multiple ray intersection tasks indicates that intersection point information has been determined for a ray; an unfinished task refers to a ray intersection task that has not yet obtained intersection point information. After all ray intersection tasks in the warp have obtained intersection point information, the first graphics processor may process the intersection point information of the multiple ray intersection tasks in the warp.
[0025] In the above implementation, the ray intersection task is executed in units of thread bundles, without having to wait for the ray intersection tasks of a larger execution unit, a pass, to be completed before continuing execution. This can reduce waiting delays and further improve the overall efficiency of ray tracing.
[0026] In another possible implementation, if some ray intersection tasks in the first warp have obtained intersection information, and some ray intersection tasks in the second warp have obtained intersection information, a new warp is obtained based on some or all of the ray intersection tasks in the first warp and the second warp that have obtained intersection information.
[0027] In the above implementation, in order to avoid the ray intersection task that has obtained the intersection information in the same thread bundle from waiting for the ray intersection task that has not obtained the intersection information for a long time, the thread bundles can be reorganized during the execution process to avoid too many thread bundles entering the waiting state, which is beneficial to improving the efficiency of executing the ray intersection task in the form of thread bundles.
[0028] In one possible implementation, the first graphics processor further stores a geometric model of the geometric body within the first target bounding box; the accuracy of the geometric model is lower than the accuracy of the geometric data. After sending a first inter-processor intersection request to a target graphics processor, if the first graphics processor does not receive intersection point information returned by the target graphics processor in response to the first inter-processor intersection request within a set time period, the first graphics processor may use intersection point information determined based on the geometric model of the geometric body within the first target bounding box as the first intersection point information.
[0029] In the above implementation, if no response is received from the target graphics processor to the first cross-processor intersection request within the set time, the first graphics processor can determine an approximate intersection result based on the low-precision geometric model of the target bounding box stored in the graphics processor, so as to avoid waiting for a long time for the target graphics processor to respond to the first cross-processor intersection request, and being unable to continue to perform subsequent operations.
[0030] In one possible implementation, if there are multiple first target bounding boxes, and each of the multiple first target bounding boxes corresponds to a different graphics processor, the first graphics processor may respectively determine the target graphics processor corresponding to each of the multiple first target bounding boxes, and send a first cross-processor intersection request to each of the determined multiple target graphics processors.
[0031] In the above implementation, when a ray passes through multiple bounding boxes, cross-processor intersection requests can be sent to multiple graphics processors at the same time, changing the one-to-one sending of cross-processor intersection requests to a one-to-many sending of cross-processor intersection requests. Multiple graphics processors can simultaneously execute the received cross-processor ray intersection tasks, thereby reducing the latency caused by multiple graphics processors executing cross-processor ray intersection one by one, further improving the efficiency of cross-processor ray intersection.
[0032] In an optional implementation, the first ray intersection task and the second ray intersection task belong to the same thread bundle; the first ray intersection task indicates determining intersection information for the first ray; the second ray intersection task indicates determining intersection information for the second ray.
[0033] In the above implementation, even if the first ray intersection task and the second ray intersection task belong to the same warp, there is no need to wait for determining the intersection point information of the second ray before initiating a cross-processor intersection request for the first ray.
[0034] In a second aspect, the present application provides a ray tracing device, which can be applied to a first graphics processor among multiple graphics processors in an image rendering system; the ray tracing device includes:
[0035] A first intersection unit is configured to determine, based on the first ray, a first target bounding box intersecting the first ray;
[0036] a communication unit, configured to send a first request to a target graphics processor when the geometric data of the first target bounding box is not stored in the first graphics processor, the geometric data of the first target bounding box being stored in the target graphics processor;
[0037] a second intersection unit, configured to determine a second target bounding box intersecting the second ray based on the second ray, and determine second intersection point information based on the second ray and the second target bounding box;
[0038] The communication unit is further configured to receive first intersection information of the first request; the first intersection information is determined based on the first ray and the first target bounding box.
[0039] In a possible implementation, multiple graphics processors are used to perform ray tracing based on specified scene data; the scene data includes multiple geometric bodies and multiple bounding boxes, and each of the multiple bounding boxes contains geometric body data of a portion of the multiple geometric bodies.
[0040] In a possible implementation, the first ray intersection task and the second ray intersection task belong to the same thread warp; the first ray intersection task instructs determination of intersection information for the first ray; and the second ray intersection task instructs determination of intersection information for the second ray.
[0041] In one possible implementation, the first graphics processor stores geometric data of the second target bounding box and identification information of graphics processors corresponding to the remaining bounding boxes except the second target bounding box among the plurality of bounding boxes; the graphics processor corresponding to any of the remaining bounding boxes is the graphics processor storing the geometric data of any bounding box; and the communication unit is further configured to:
[0042] When the geometric data of the first target bounding box is not stored in the first graphics processor, the target graphics processor is determined according to the identification information of the graphics processor corresponding to the first target bounding box.
[0043] In one possible implementation, the above-mentioned device may further include: a task generation unit, which is used to generate multiple ray intersection tasks before determining the target bounding box that intersects with the first ray in the scene, and save the multiple ray intersection tasks to the task queue of the ray intersection unit; the multiple ray intersection tasks include a ray intersection task for the first ray.
[0044] In one possible implementation, the communication unit may further be configured to: receive a second cross-processor intersection request sent by a second graphics processor, where the second graphics processor is any graphics processor among the multiple graphics processors except the first graphics processor; and save a ray intersection task for a third ray indicated by the second cross-processor intersection request to a task queue of the ray intersection unit, so that the ray intersection unit executes the ray intersection task for the third ray.
[0045] In one possible implementation, the first intersection unit can be used to execute the ray intersection task for the first ray in the task queue through the ray pursuit intersection unit to obtain a first target bounding box that intersects with the first ray; the ray pursuit intersection unit in the first graphics processor can execute the ray intersection task in the task queue according to the set task priority; wherein the task priority of the ray intersection task is determined based on the graphics processor that generates the ray intersection task.
[0046] In one possible implementation, the first intersection unit can also be used to determine, through the ray pursuit intersection unit, whether the geometric data in the first target bounding box is stored in the first graphics processor; if the geometric data in the first target bounding box is not stored in the first graphics processor, generate a first cross-processor intersection request for the first ray through the ray pursuit intersection unit.
[0047] In a possible implementation, the communication unit may be further configured to send one or more cross-processor interleaving requests to the target graphics processor at a time through a cross-processor message; the one or more cross-processor interleaving requests may include the first cross-processor interleaving request.
[0048] In one possible implementation, the first cross-processor intersection request carries some or all of the following information: the starting point position of the first ray, the direction of the first ray, identification information of the target graphics processor, an identifier of the first target bounding box, and identification information of the source graphics processor; the source graphics processor refers to the graphics processor that generates the ray intersection task for the first ray.
[0049] In one possible implementation, the first intersection information may include: the first ray has no intersection with the geometry in the first target bounding box; or, the first intersection information may include: the identifier of the target geometry that intersects with the first ray in the geometry contained in the first target bounding box, and the intersection position of the first ray and the target geometry.
[0050] In one possible implementation, the target graphics processor also stores texture data of the geometry in the first target bounding box; when the first intersection information includes the intersection position of the first ray and the target geometry, the first intersection information may also include texture data of the intersection position of the first ray and the target geometry.
[0051] In a possible implementation, when the first intersection information includes the intersection position of the first ray and the target geometric body, the first intersection information may further include shading information of the intersection position.
[0052] In one possible implementation, the ray tracing device may further include an intersection information processing unit, which is configured to save the first intersection information if there is an unfinished task in the thread bundle to which the ray intersection task for the first ray belongs; the thread bundle includes multiple ray intersection tasks; the unfinished task refers to a ray intersection task that has not obtained intersection information; and after all ray intersection tasks in the thread bundle have obtained intersection information, the intersection information of the multiple ray intersection tasks in the thread bundle is processed.
[0053] In one possible implementation, the intersection information processing unit may be further configured to, if some ray intersection tasks in the first thread bundle have obtained intersection information and some ray intersection tasks in the second thread bundle have obtained intersection information, obtain a new thread bundle based on some or all of the ray intersection tasks in the first thread bundle and the second thread bundle that have obtained intersection information.
[0054] In one possible implementation, the first graphics processor further stores a geometric model of the geometric body within the first target bounding box; the accuracy of the geometric model is lower than the accuracy of the geometric data. The second intersection unit may be further configured to, after sending the first cross-processor intersection request to the target graphics processor, use intersection information determined based on the geometric model of the geometric body within the first target bounding box as the first intersection information if no intersection information is returned from the target graphics processor in response to the first cross-processor intersection request within a set time period.
[0055] In one possible implementation, the communication unit may also be configured to, if there are multiple first target bounding boxes, respectively correspond to different graphics processors, determine the target graphics processor corresponding to each of the multiple first target bounding boxes, and send a first cross-processor intersection request to each of the multiple determined target graphics processors.
[0056] In a third aspect, the present application provides an image rendering system, which includes multiple graphics processors; the multiple graphics processors are used to perform ray tracing based on specified scene data; each of the multiple graphics processors is used to execute any one of the methods provided in the first aspect above.
[0057] In a fourth aspect, the present application provides a graphics processor, which is a first graphics processor and is applied to an image rendering system including multiple graphics processors.
[0058] The first graphics processor includes a subroutine execution unit and a ray tracing unit;
[0059] The subroutine execution unit is used for transmitting the ray intersection task for the first ray and the ray intersection task for the second ray to the ray intersection unit;
[0060] The optical pursuit intersection unit is used to perform the following steps:
[0061] receiving a ray intersection task for a first ray, and determining, based on the first ray, a first target bounding box intersecting with the first ray;
[0062] When the geometric data of the first target bounding box is not stored in the first graphics processor, a first request is sent to the target graphics processor, and the geometric data of the first target bounding box is stored in the target graphics processor;
[0063] receiving a ray intersection task for a second ray, determining a second target bounding box intersecting with the second ray based on the second ray, and determining second intersection point information based on the second ray and the second target bounding box;
[0064] The subroutine execution unit is further configured to receive first intersection information of the first request; the first intersection information is determined based on the first ray and the first target bounding box.
[0065] In a fifth aspect, the present application provides a chip comprising a processor and a memory; the memory stores a computer program or instructions; the processor is used to execute the computer program or instructions stored in the memory, so that the chip executes any one of the methods provided in the first aspect above.
[0066] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to enable a computer to execute any one of the ray tracing methods provided in the first aspect.
[0067] In a seventh aspect, an embodiment of the present application provides a computer program product comprising computer-executable instructions, wherein the computer-executable instructions are used to enable a computer to execute any one of the ray tracing methods provided in the first aspect.
[0068] The technical effects that can be achieved in any of the second to seventh aspects can refer to the description of the beneficial effects in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] FIG1 is a schematic diagram of an image rendering system provided by an embodiment of the present application;
[0070] FIG2 is a schematic diagram of a ray tracing principle provided by an embodiment of the present application;
[0071] FIG3 is a schematic diagram of the interaction between various graphics processors when executing a ray tracing method provided by an embodiment of the present application;
[0072] FIG4 is a schematic diagram of a hierarchical bounding box structure provided in an embodiment of the present application;
[0073] FIG5 is a schematic diagram of an axis-aligned bounding box structure provided in an embodiment of the present application;
[0074] FIG6 is a schematic diagram of a bounding box relationship between various graphics processors provided in an embodiment of the present application;
[0075] FIG7 is a schematic diagram of hardware interaction between graphics processors when executing a ray tracing method provided by an embodiment of the present application;
[0076] FIG8 is a schematic diagram of light traversal provided in an embodiment of the present application;
[0077] FIG9 is a schematic diagram of the interaction between graphics processors when executing a ray tracing method for a fourth ray according to an embodiment of the present application;
[0078] FIG10 is a schematic diagram of hardware interaction between graphics processors when executing a ray tracing method for a fourth ray according to an embodiment of the present application;
[0079] FIG11 is a schematic diagram of the internal structure of a graphics processor provided in an embodiment of the present application;
[0080] FIG12 is a structural block diagram of a ray tracing device provided in an embodiment of the present application;
[0081] FIG13 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0082] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings. The terms used in the implementation methods of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application.
[0083] Before introducing the specific solutions provided by the embodiments of the present application, some of the terms in the present application are explained to facilitate understanding by those skilled in the art, and the terms in the present application are not limited.
[0084] (1) Ray tracing: Ray tracing is used to simulate the light propagation process in which light is emitted from the camera to objects in the scene, and then undergoes reflection, refraction, scattering and other interactions. Ray tracing takes into account the interaction between light and objects, and can produce realistic shadows, reflections, refractions and other effects, simulating all natural phenomena related to the interaction between objects and surfaces in the real physical world.
[0085] (2) Bounding volume hierarchies (BVH): BVH is a data structure that can be used in ray tracing tasks to divide objects in the scene into small, reusable areas and organize these areas into layers. In the scene, each object is contained in a "bounding volume", which can be a geometric shape such as a sphere or a cube. These bounding volumes can be nested in each other to form a hierarchical structure, in which higher-level bounding volumes completely contain lower-level bounding volumes. The BVH structure can be used to accelerate ray tracing by avoiding ray-object intersection tests for all objects, thereby improving performance.
[0086] (3) Axis-aligned bounding box (AABB): An AABB is a geometric shape used to describe the geometry of an object or scene. It can be a cube or a cuboid, where all sides of the AABB are parallel to the coordinate axes. In a BVH, an AABB can be used to quickly determine whether an object intersects with a traced ray, thereby reducing the number of ray-object intersection tests and improving rendering efficiency.
[0087] In the embodiments of the present application, "multiple" refers to two or more. In view of this, in the embodiments of the present application, "multiple" can also be understood as "at least two". "At least one" can be understood as one or more, for example, one, two or more. For example, including at least one means including one, two or more, and does not limit which ones are included. For example, including at least one of A, B and C, then the included ones may be A, B, C, A and B, A and C, B and C, or A, B and C. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the previous and subsequent associated objects are in an "or" relationship.
[0088] Unless otherwise specified, ordinal numbers such as "first" and "second" in the embodiments of the present application are used to distinguish multiple objects and are not used to limit the order, timing, priority or importance of multiple objects.
[0089] FIG1 shows a schematic diagram of an image rendering system provided by an embodiment of the present application. The ray tracing method provided by an embodiment of the present application can be applied to the image rendering system 100 shown in FIG1 . The image rendering system 100 may include multiple GPUs. In some embodiments, the image rendering system 100 can be understood as an image rendering device. For example, the image rendering system 100 can be an electronic device such as a computer or server. As shown in FIG1 , the image rendering system 100 may include GPUs 110, 120, and 130. The multiple GPUs in the image rendering system 100 can collaboratively perform image rendering tasks. For example, when the scene to be rendered is relatively simple and contains relatively little geometric data of objects, a single GPU can perform the image rendering task. However, when the scene to be rendered is relatively complex and contains a large amount of geometric data of objects, the image rendering process involves a large number of image computation tasks and requires the storage and processing of a large amount of data. Since a single GPU has limited computing resources and video memory capacity, it cannot handle complex image rendering tasks. Therefore, multiple GPUs can be utilized to collaboratively perform image rendering tasks to avoid excessive load on a single GPU during the rendering process, which can lead to performance degradation, while also expanding video memory capacity. For example, for extremely large scenes containing large amounts of geometric data, multiple GPUs can be used to collaboratively perform image rendering tasks.
[0090] In some embodiments, the image rendering system 100 may further include a central processing unit (CPU) 140, a memory 150, and a bus 160. The memory 150 may be a storage medium such as a hard disk, a mobile hard disk, or a magnetic disk. The GPU 110, GPU 120, GPU 130, CPU 140, and memory 150 are connected via a bus 160, which may transmit data between the GPUs, CPU 140, and memory 150. The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, and the like.
[0091] Multiple GPUs can collaboratively perform image rendering tasks under the control of CPU140. For example, during the image rendering process, CPU140 can be used to divide the overall scene data that needs to be rendered according to the number of GPUs, and send each divided scene data to a different graphics processor, so that each GPU can save part of the scene data. For example, if the image rendering system 100 shown in Figure 1 includes three GPUs, the CPU can divide the overall scene data into three parts, and send the three parts of scene data to GPU110, GPU120 and GPU130 respectively. In another embodiment, if the image rendering system includes six GPUs, the CPU can divide the overall scene data into six parts and send them to the six GPUs respectively. For example, the division method can be to divide according to the user density in the scene, or to divide the overall scene evenly, which is not limited in this application. The memory 150 can save the overall scene data, and can also save the rendering results output by each GPU during the image rendering process.
[0092] It should be noted that in the embodiments of the present application, an image rendering system may include more GPUs, or fewer GPUs, and there may also be multiple central processing units or memories. The same thing is that multiple GPUs and at least one central processing unit and memory are all connected through a bus, and the specific number is not limited in this application.
[0093] In one possible embodiment, the image rendering system may include multiple image rendering devices, different GPUs may be located in different image rendering devices, and central processing units and memories may also be located in different image rendering devices. These different image rendering devices may form an image rendering device cluster, that is, multiple GPUs may be set on different image rendering devices in an image rendering device cluster. The individual image rendering devices in the image rendering device cluster may be connected via a network, wherein the network may be a wireless local area network, a metropolitan area network, or other network connection method. In addition, each image processor, central processing unit, and memory may also be deployed in a cloud server or cloud server cluster using the above method, which is not limited in this application.
[0094] During image rendering, ray tracing can be used to achieve more realistic rendering results. Ray tracing is a computer graphics rendering technique widely used in fields requiring a high degree of realism, such as film special effects, animation production, and architectural visualization design. Ray tracing produces high-quality renderings, resulting in photo-realistic images.
[0095] The principle of ray tracing is shown in Figure 2. A ray is emitted from the eye point toward the pixels on the image plane, and the intersection point of the nearest object with the ray is found. If the surface at the intersection point is a scattering surface, the color produced by the light source directly illuminating the intersection point is determined. If the surface at the intersection point is a mirror or a refractive surface, the direction of reflection or refraction is determined, and another ray is traced in the direction of reflection or refraction. This process is repeated recursively until the ray escapes the scene to be rendered, or the set maximum recursion depth is reached. Through ray tracing, the color value of each pixel on the imaging plane can be obtained, and the final image can be rendered based on the color value of each pixel.
[0096] The process of collaboratively executing image rendering tasks by multiple GPUs includes collaboratively executing ray tracing tasks by multiple GPUs. At present, the efficiency of collaborative execution of ray tracing tasks by multiple GPUs is relatively low. In order to improve the efficiency of collaborative execution of ray tracing tasks by multiple GPUs so that multiple GPUs can efficiently perform image rendering, an embodiment of the present application provides a ray tracing method. The ray tracing method can be executed by an image rendering system. Taking the image rendering system as the image rendering system 100 shown in Figure 1 as an example, the image rendering system includes 3 GPUs, wherein GPU110 is referred to as GPU1 hereinafter, GPU120 is referred to as GPU2 hereinafter, and GPU130 is referred to as GPU3 hereinafter.
[0097] FIG3 exemplarily shows a flowchart of the interaction between various GPUs in the process of executing the ray tracing method provided in an embodiment of the present application. GPU1, GPU2 and GPU3 shown in FIG3 can perform ray tracing based on specified scene data. Among them, the specified scene data can be scene data corresponding to the picture to be rendered. The scene data includes multiple geometric bodies. For example, all objects that need to be rendered in the overall scene corresponding to the picture to be rendered (i.e., the objects mentioned above) can be abstracted into different geometric bodies in advance to obtain multiple geometric bodies, each of which has corresponding geometric body data. The geometric body data can also be called geometric body mesh data. Mesh is a collection of a point (point or vertex), a normal vector (normal vector), and a face. Mesh can define the shape of a three-dimensional (3D) object. Among them, the overall scene corresponding to the picture to be rendered can be a 3D scene, that is, ray tracing can be used to render images of 3D scenes. The scene data containing the geometric body data of all geometric bodies in the overall scene can be pre-stored in a memory, which can be a hard disk or a disk. The scene data has not yet been segmented and can also be called overall scene data.
[0098] Ray tracing involves ray intersection, which involves determining the intersection points between rays and objects in the scene. The more complex the scene and the greater the number of objects, the longer the ray intersection takes. In embodiments of the present application, ray intersection can be accelerated by constructing a bounding volume (BVH). A BVH uses geometrically simple AABB bounding boxes to approximate complex geometric structures. An exemplary BVH structure is shown in Figure 4 , which includes four bounding boxes numbered 1, 2, 3, and 4. These four bounding boxes are hierarchically arranged in a data structure tree, with each box connected to different root nodes. The four bounding boxes can be AABBs, and Figure 5 illustrates the structure of two of the four AABBs. As shown in Figure 5 , each bounding box contains multiple triangles, which are used to represent the geometry in the scene data. The internal structure of the remaining two AABBs in the four bounding boxes can also refer to the structure shown in Figure 5 . The two bounding boxes shown in Figure 5 do not overlap, but in other embodiments, different bounding boxes may overlap partially. In some embodiments, a large bounding box may contain a smaller bounding box nested within it. The BVH uses a data structure tree to categorize and subdivide objects in the scene. When performing ray intersection, the calculation is first performed on the bounding boxes, and each bounding box is sequentially determined to determine whether it intersects with the ray. The bounding box hit by the ray is then determined. A more detailed judgment is then made on the bounding box hit by the ray, and the bounding boxes below it are gradually determined, until the triangle intersecting with the ray is determined. Compared to directly performing ray intersection on all geometric objects in the scene data, this process can significantly reduce the number of triangles required to calculate the nearest intersection point for each ray, reducing the amount of calculation.
[0099] In an embodiment of the present application, the CPU can obtain pre-saved overall scene data from a hard disk or disk. The overall scene data includes the geometric data of all geometric bodies in the overall scene, and can also include the texture data of the geometric bodies. Before performing ray tracing, multiple bounding boxes can be generated based on the geometric data of the geometric bodies in the overall scene data, and each bounding box includes the geometric data of part of the geometric bodies in the overall scene data. Among them, each bounding box can adopt the above-mentioned AABB bounding box. The geometric data of any geometric body may include part or all of the following information: the vertex coordinates of the geometric body, the normal vector of the vertex, the UV coordinates of the vertex, and other information. Based on the geometric data of the geometric body, ray intersection and ray tracing can be performed. Before performing ray tracing on the overall scene data, the CPU can segment the overall scene data. The CPU can segment the overall scene data to be rendered according to the number of GPUs to obtain multiple copies of scene data. Each of the segmented scene data may include at least one bounding box.
[0100] Due to the limited storage space of each GPU, for very large scenes, each GPU may not be able to save the geometric data of all geometric bodies in the scene. Therefore, after the CPU divides the overall scene data, it can distribute the obtained multiple copies of scene data to multiple GPUs for storage. Each copy of the scene data includes at least one bounding box. That is, each GPU can save the geometric data in at least one bounding box, and different GPUs can save the geometric data in different bounding boxes. The multiple bounding boxes in different GPUs can form a distributed BVH structure. The multiple bounding boxes belong to the same root node, which can be called the scene root node. Through the above process, the CPU and multiple GPUs jointly construct a distributed BVH structure. Using the distributed BVH structure, each GPU saves the geometric data of a portion of the bounding box, and multiple GPUs jointly save the geometric data of all geometric bodies in the entire scene, which helps to achieve image rendering of very large scenes and improve the picture quality of image rendering of very large scenes. The above preprocessing operation for constructing the distributed BVH structure only needs to be performed once during offline rendering or scene loading of real-time games, and the resulting distributed BVH structure can be provided to all rays.
[0101] After the CPU distributes multiple copies of scene data to multiple GPUs, each GPU stores the geometric data of a portion of the bounding boxes among the multiple bounding boxes, as well as the identification (ID) information of the GPU corresponding to each of the remaining bounding boxes, wherein the identification information of the GPU corresponding to any bounding box is the identification information of the GPU that stores the geometric data in the bounding box; in other words, each GPU stores the identifications of all bounding boxes, wherein the identifications of a portion of the bounding boxes correspond to the geometric data stored in the bounding boxes, and the identifications of the other portion of the bounding boxes correspond to the identification information of the GPU. For example, taking an image rendering system including three GPUs as an example, assuming that the entire scene data is segmented, each portion of the obtained scene data includes a bounding box, and the bounding boxes in the three portions of scene data are bounding box 1, bounding box 2, and bounding box 3 respectively. The CPU distributes the three bounding boxes to GPU1, GPU2, and GPU3. As shown in Figure 6, bounding box 1, bounding box 2, and bounding box 3 belong to the same scene root node. GPU1 stores the geometric data of bounding box 1, GPU2 stores the geometric data of bounding box 2, and GPU3 stores the geometric data of bounding box 3. Specifically, GPU1 stores the identifiers of three bounding boxes, where the identifier of bounding box 1 corresponds to the geometric data stored in bounding box 1, the identifier of bounding box 2 corresponds to the identification information of GPU2, and the identifier of bounding box 3 corresponds to the identification information of GPU3. This can also be understood as GPU1 storing pointers corresponding to bounding boxes 2 and 3. The pointer corresponding to bounding box 2 points to GPU2, indicating that the geometric data of bounding box 2 is stored in GPU2, and the pointer corresponding to bounding box 3 points to GPU3, indicating that the geometric data of bounding box 3 is stored in GPU3. Similarly, GPU2 also stores the identifiers of three bounding boxes, among which the identifier of bounding box 1 corresponds to the identification information of GPU1, the identifier of bounding box 2 corresponds to the geometric data in bounding box 2, and the identifier of bounding box 3 corresponds to the identification information of GPU3; it can also be understood that GPU2 stores pointers corresponding to bounding box 1 and bounding box 3, the pointer corresponding to bounding box 1 points to GPU1, indicating that the geometric data in bounding box 1 is stored in GPU1, and the pointer corresponding to bounding box 3 points to GPU3, indicating that the geometric data in bounding box 3 is stored in GPU3. GPU3 also stores the identifiers of three bounding boxes, among which the identifier of bounding box 1 corresponds to the identification information of GPU1, the identifier of bounding box 2 corresponds to the identification information of GPU2, and the identifier of bounding box 3 corresponds to the geometric data in bounding box 3. It can also be understood that GPU3 stores bounding box 1 and the pointer corresponding to bounding box 1, the pointer corresponding to bounding box 1 points to GPU1, indicating that the geometric data in bounding box 1 is stored in GPU1, and the pointer corresponding to bounding box 2 points to GPU2, indicating that the geometric data in bounding box 2 is stored in GPU2.
[0102] It should be noted that, in the above embodiment, each GPU stores the geometric data in one bounding box. In other embodiments, some GPUs may store the geometric data in multiple bounding boxes, as well as the identification information of the GPUs corresponding to the remaining bounding boxes. For example, assuming that the overall scene data includes 5 bounding boxes, GPU1 may store the geometric data in bounding boxes 1 and 4, GPU2 may store the geometric data in bounding boxes 2 and 5, and GPU3 may store the geometric data in bounding box 3. In another embodiment, if all the geometric data in all the bounding boxes corresponding to a certain scene is relatively small, all the geometric data in all the bounding boxes may be stored in each GPU.
[0103] After the CPU and multiple GPUs jointly construct the BVH structure, the GPU can execute the ray tracing method according to the process shown in Figure 3. Figure 3 mainly uses GPU1 as an example to illustrate the method. The method may include the following steps:
[0104] S301 : GPU 1 determines, for a ray a in a scene, a target bounding box A that intersects with the ray a.
[0105] When multiple GPUs collaborate to perform ray tracing tasks, there are multiple rays in the scene to be rendered by each GPU, and each ray corresponds to a ray intersection task. Therefore, each GPU will perform multiple ray intersection tasks. In some embodiments, the GPU can generate a ray intersection task by executing a program, and the program can be a program developed using a parallel programming language. For example, taking GPU1 as an example, as shown in Figure 7, GPU1 may include multiple program execution units, and each program execution unit may include multiple subroutine execution units and ray tracing intersection units. Among them, the program execution unit can generate multiple ray intersection tasks according to the part of the scene that it needs to render by executing program instructions, and each ray intersection task corresponds to a ray. The ray tracing intersection unit can perform ray intersection tasks through hardware acceleration, so it can also be called a ray tracing intersection hardware acceleration unit.
[0106] A subroutine execution unit within a program execution unit of GPU 1 can save the ray intersection tasks generated by the executed program to a task queue of the ray intersection unit within the program execution unit. For example, the subroutine execution unit can save multiple ray intersection tasks to the task queue of the ray intersection unit in the order in which they were generated. The ray intersection unit can sequentially read the ray intersection tasks from the task queue of the ray intersection unit and execute the read ray intersection tasks.
[0107] Taking ray a among multiple rays as an example, the multiple ray intersection tasks generated by the subroutine execution unit of GPU1 include a ray intersection task for ray a. Ray a can be any ray among the multiple rays. The subroutine execution unit saves the ray intersection task for ray a to the task queue of the ray intersection unit. When the ray intersection unit reads the ray intersection task for ray a from the task queue, it executes the ray intersection task for ray a and determines the target bounding box A that intersects with ray a in the ray intersection task from the multiple bounding boxes. For example, the ray intersection unit can determine the target bounding box A that intersects with ray a from the above-mentioned bounding box 1, bounding box 2, and bounding box 3.
[0108] If it is determined that the target bounding box A intersecting with the light ray a is the bounding box 1 and the GPU 1 stores the geometric data of the geometric body in the bounding box 1 , the GPU 1 may continue to execute step S302 .
[0109] S302 : GPU 1 determines the intersection result of ray a.
[0110] After the ray tracing intersection unit in GPU1 determines that the target bounding box A is the bounding box 1 stored in GPU1, the ray tracing intersection unit can continue to perform ray intersection on ray a in the bounding box 1, that is, determine the intersection information of ray a and the geometric body contained in the bounding box 1, and generate the intersection result of ray a. The intersection result of ray a includes the intersection information of ray a and the geometric body in the target bounding box A. Therefore, the intersection result of ray a can also be called the intersection information of ray a. Each geometric body in the bounding box 1 can be represented by one or more triangular facets, and each triangular facet carries a unique identifier to distinguish it from other triangular facets. Among them, a triangular facet can be a planar geometric figure composed of three vertices. In the process of ray tracing, a triangular facet can be used as a basic geometric primitive to represent a complex three-dimensional model. It can be understood that a triangular facet can also be other polygonal facets. The specific shape of the polygonal facets is not limited in this application.
[0111] If ray a has no intersection with any of the triangles contained in bounding box 1, then the intersection information can be determined as ray a has no intersection with the geometry in bounding box 1, indicating that ray a has reached the maximum recursive depth and disappeared, or that ray a has escaped the scene. In this case, the intersection information obtained is that ray a has no intersection with the geometry in target bounding box A. If ray a has an intersection with a certain triangle contained in bounding box 1, then the geometry represented by the triangle can be used as the target geometry intersecting with ray a, the identifier of the triangle can be used as the identifier of the target geometry intersecting with ray a, and the intersection position of ray a with the triangle can be obtained. Thus, the intersection information of ray a and the geometry in target bounding box A can be obtained. The intersection information can include: the identifier of the target geometry intersecting with ray a in the geometry contained in target bounding box A, and the intersection position of ray a with the target geometry. The intersection position refers to the coordinates of the intersection of ray a and the target geometry, and can include the coordinates of the x-axis, y-axis, and z-axis at the intersection.
[0112] In some embodiments, GPU 1 can store geometric data and texture data for the geometric objects within bounding box 1. When target bounding box A is bounding box 1, the intersection information can also include texture data for the intersection of ray a and the target geometric object. The texture data at the intersection can be used to determine the material at the intersection, namely, whether the intersection is a mirrored surface, a refractive surface, or a scattering surface. Based on the material at the intersection, the subsequent propagation direction of the ray can be determined.
[0113] In some embodiments, after determining the intersection position of light ray a and the target geometric body, the ray pursuit intersection unit in GPU1 can also determine the shading information of the intersection position, that is, the intersection information can also include: the shading information of the intersection position of light ray a and the target geometric body. Shading is an important link in image rendering, which determines the visual effect and appearance of the final rendered image. During the shading process, the lighting model can be used to perform lighting calculations on the object to determine the brightness and color of each pixel on the surface of the object. In an embodiment of the present application, GPU1 can use the BRDF (bidirectional reflectance distribution function) lighting model to determine the shading information of the intersection position based on information such as the material of the intersection position and the light source in the scene. When rendering an image, the pixels at the intersection can be rendered according to the shading information of the intersection position.
[0114] In an embodiment of the present application, GPU1 can perform the ray intersection task for ray a through hardware or hardware threads in the ray intersection unit. Since the speed of executing the ray intersection task through hardware is much faster than the speed of executing the ray intersection task through software, the unit that executes the ray intersection task in the ray intersection unit can also be called a hardware acceleration unit.
[0115] Through the above process, the ray intersection task for ray a is completed. The following description uses ray b among the multiple rays as an example. The multiple ray intersection tasks generated by the subroutine execution unit program in GPU 1 also include a ray intersection task for ray b. Ray b can also be any other ray among the multiple rays.
[0116] S303 : GPU 1 determines, for light ray b in the scene, a target bounding box B that intersects with the light ray b.
[0117] The subroutine execution unit generates a ray intersection task for ray b by executing the program. The subroutine execution unit saves the ray intersection task for ray a to the task queue of the ray intersection unit. The ray intersection unit reads the ray intersection tasks from the task queue and executes them sequentially. When a ray intersection task for ray b is read from the task queue, it executes the ray intersection task for ray b and determines, from the multiple bounding boxes, a target bounding box B that intersects with ray b in the ray intersection task. For example, the ray intersection unit may determine the target bounding box B that intersects with ray b from the aforementioned bounding boxes 1, 2, and 3.
[0118] S304 , GPU1 determines that the GPU does not contain the geometric data in the target bounding box B, and generates a first cross-processor intersection request.
[0119] If it is determined that the target bounding box B that intersects with ray b is bounding box 2, since the geometric data in bounding box 2 is not stored in GPU1, the ray pursuit intersection unit in GPU1 can determine that bounding box 2 corresponds to GPU2 based on the identification information of the GPU corresponding to bounding box 2 stored in GPU1, that is, it can be determined that the target GPU corresponding to target bounding box B is GPU2. Therefore, GPU1 can generate a first cross-processor intersection request for ray b through the ray pursuit intersection unit. The first cross-processor intersection request may carry some or all of the following information: the starting position of ray b, the direction of ray b, the identification information of the target GPU, the identification information of the source GPU, and the context information. The context information may include the identification of the target bounding box and may also include other information. The starting position and direction of ray b, and the identification of the target bounding box are to facilitate the target GPU to perform ray intersection calculations. The starting position of ray b may be a position within the scene or a position outside the scene. If the starting point of ray b is a certain position within the scene, the first cross-processor intersection request carries the coordinate information of the position; if the starting point of ray b is a certain position outside the scene, such as the viewpoint position, the first cross-processor intersection request can carry pre-set coordinate information, and the pre-set coordinate information also includes the coordinates of the x-axis, y-axis and z-axis, that is, the position outside the scene can be represented by the pre-set coordinate information. The direction of ray b can include vectors relative to the x-axis, y-axis and z-axis respectively. The target GPU obtains the information of the target bounding box and can directly calculate based on the starting point position and direction of ray b and the geometric data in the target bounding box. The identification information of the target GPU can ensure that the cross-processor intersection request can be correctly sent to the target GPU; the identification information of the source GPU is used to assist the target GPU in returning the intersection result to the GPU that sent the cross-processor intersection request, or in other words, to the GPU that generated the ray intersection task for ray b.
[0120] Taking the example of the geometric data of the target bounding box B intersecting with the light ray b being stored in GPU2, the first cross-processor intersection request generated by GPU1 may include: the starting position of the light ray b, the direction of the light ray b, the identification information of GPU1 (source GPU) and the identification information of GPU2 (target GPU).
[0121] S305 : GPU1 sends a first cross-processor intersection request to GPU2.
[0122] For example, as shown in FIG7 , each GPU is provided with a communication module, which may include a sending module and a communication receiving module. After the ray intersection unit in GPU 1 generates a first cross-processor intersection request for ray b, the communication sending module in GPU 1 may send the first cross-processor intersection request to GPU 2. The communication sending module in GPU 1 may send the first cross-processor intersection request to GPU 2 via a bus; alternatively, the communication sending module in GPU 1 may send the first cross-processor intersection request to GPU 2 via an inter-GPU communication network.
[0123] In some embodiments, GPU1 can send cross-processor intersection requests to other GPUs in batches. For example, GPU1 can send one or more cross-processor intersection requests to GPU2 in a batch through a cross-processor message. For example, in the ray intersection task generated by GPU1, there may be multiple ray intersection tasks whose target bounding boxes correspond to GPU2, that is, there may be multiple cross-processor intersection requests whose target GPUs are all GPU2 in the same time period. At this time, GPU1 can send multiple cross-processor intersection requests to GPU2 in a batch. Compared with sending one cross-processor intersection request each time, sending multiple cross-processor intersection requests at a time can save communication resources and improve the efficiency of data transmission. At the same time, since the GPU is a highly parallel processor, transmitting multiple requests at a time can meet the needs of parallel computing and improve computing efficiency. It should be noted that the sending condition can be set to send a cross-processor intersection request to the target GPU once for every 100 cross-processor intersection requests with the same target GPU, or the sending condition can be set to send the same cross-processor intersection request with the target GPU to the target GPU every millisecond, where the number of items in each batch or the time interval between each batch can also be other values, which are not limited in this application.
[0124] After generating the first cross-processor intersection request, GPU1 may send the first cross-processor intersection request together with other cross-processor intersection requests whose target GPU is GPU2 to GPU2 through the communication module.
[0125] S306 : GPU2 determines an intersection result for ray b in response to the received first cross-processor intersection request.
[0126] GPU2 receives a cross-processor intersection request from GPU1 and can save the ray intersection task indicated by the cross-processor intersection request to the task queue of GPU2's ray intersection unit. As shown in Figure 7, GPU2 can receive the cross-processor intersection request sent by GPU1 via a communication module in GPU2. After receiving the cross-processor intersection request, the communication module in GPU2 can transmit the cross-processor intersection request to a subroutine execution unit in GPU2 for processing. The subroutine execution unit parses each received cross-processor intersection request to obtain the ray intersection task indicated by each cross-processor intersection request. The obtained ray intersection tasks are saved to the task queue of GPU2's ray intersection unit, including the ray intersection task for ray b indicated by the first cross-processor intersection request. The ray intersection unit in GPU2 can read the ray intersection task from the task queue. When a ray intersection task for ray b is read, the ray intersection task for ray b is executed to determine the intersection result for ray b. The intersection result for ray b can also be referred to as the intersection point information of ray b.
[0127] It should be noted that multiple GPUs in the image rendering system execute ray tracing tasks in parallel. That is, when GPU1 generates multiple ray intersection tasks based on the portion of the scene it needs to render, GPU2 also generates multiple ray intersection tasks based on the portion of the scene it needs to render. GPU2 then stores the generated ray intersection tasks in the task queue of GPU2's ray tracing unit. In other words, the task queue of GPU2's ray tracing unit stores both ray intersection tasks generated by GPU2 and ray intersection tasks sent to GPU2 by GPU1 or other GPUs. GPU2's ray tracing unit can execute ray intersection tasks in the task queue according to a set task priority. The task priority of a ray intersection task is determined by the graphics processor that generated the ray intersection task. For example, in an optional embodiment, the task queue of the ray tracing unit can be configured to prioritize ray intersection tasks for that GPU. That is, for GPU2's ray tracing unit, ray intersection tasks generated by GPU2 have a higher task priority than ray intersection tasks sent to GPU2 by other GPUs, and GPU2's ray tracing unit prioritizes executing ray intersection tasks generated by GPU2 in the task queue. In another optional embodiment, the task queue of the ray intersection unit can be configured to prioritize the scheduling of ray intersection tasks of remote GPUs, wherein the remote GPU refers to other GPUs other than this GPU. That is to say, for the ray intersection unit of GPU2, the task priority of the ray intersection tasks sent by other GPUs to GPU2 is higher than the ray intersection tasks generated by GPU2, and the ray intersection unit of GPU2 prioritizes the execution of the ray intersection tasks sent by other GPUs to GPU2 in the task queue. In some embodiments, the remote GPUs can also be prioritized. For example, for GPU2, it can be set that the task priority of the ray intersection tasks sent by GPU1 to GPU2 is higher than the ray intersection tasks sent by GPU3 to GPU2; or it can be set that the task priority of the ray intersection tasks sent by GPU3 to GPU2 is higher than the ray intersection tasks sent by GPU1 to GPU2. For multiple GPUs in the image rendering system, the task priority rules corresponding to different GPUs may be different, and this application does not limit this.
[0128] The ray tracing intersection unit in the GPU executes ray intersection tasks in the task queue according to the set task priority. This can prioritize the efficiency of ray intersection execution on certain GPUs based on actual needs. For example, if the task priority rule prioritizes ray intersection tasks on remote GPUs, the time required to execute cross-processor intersection requests can be shortened, which helps improve the overall efficiency of multi-GPU ray tracing tasks.
[0129] When the ray intersection unit in GPU2 reads the ray intersection task for ray b from the task queue, it executes the ray intersection task for ray b, determines the intersection information between ray b and the geometric body contained in bounding box 2, and generates the intersection result for ray b.
[0130] S307 , GPU2 sends the intersection result of ray b to GPU1 .
[0131] As shown in Figure 7, after determining the intersection result for ray b, the ray intersection unit in GPU2 can return the intersection result for ray b to GPU1 via the communication transmission module in GPU2 based on the source GPU identification information carried in the first cross-processor intersection request, that is, the identification information of GPU1. In some embodiments, GPU2 can also batch the intersection results obtained for multiple rays whose source GPU is GPU1 and send them to GPU1 to reduce the number of interactions between GPUs.
[0132] Similar to the intersection result for ray a described above, the intersection result for ray b may include information about the intersection of ray b and the geometry within target bounding box B. The intersection information may indicate that ray b has no intersection with the geometry within target bounding box B. Alternatively, the intersection information may include the identifier of the target geometry within the geometry within target bounding box B that intersects with ray b, as well as the location of the intersection between ray b and the target geometry.
[0133] In some embodiments, GPU2 can save the geometric data of the geometry in bounding box 2 and the texture data of the geometry in bounding box 2. When the target bounding box B of ray b is bounding box 2, the intersection information in the intersection result for ray b can also include the texture data of the intersection position of ray b and the target geometry. For example, in addition to carrying information such as the intersection position, the intersection result for ray b can also add a payload field, and the texture data of the intersection position of ray b and the target geometry can be carried in the payload field. The texture data of the intersection position is carried in the intersection result and returned to the source GPU, so that the source GPU can determine the material at the intersection based on the texture data of the intersection position, which can avoid the subsequent source GPU separately requesting the target GPU to send the texture data of the intersection position, thereby reducing subsequent cross-GPU interactions.
[0134] In some embodiments, when the ray intersection unit in GPU2 performs the ray intersection task for ray b indicated by the first cross-GPU intersection request, after determining the intersection position of ray b and the target geometry, it can also determine the shading information of the intersection position. That is, the intersection information in the intersection result for ray b may include: the identifier of the target geometry that intersects with ray b in the geometry contained in the target bounding box, the intersection position of ray b and the target geometry, and the shading information of the intersection position of ray b and the target geometry. The shading information may include the material properties of the intersection position, the lighting information of the intersection position, and other content. The shading information can also be carried in the payload field. Bringing the shading information of the intersection position back to the source GPU in the intersection result for ray b can also reduce subsequent cross-GPU interactions; since the shading information is short, carrying the shading information in the intersection information of ray b can reduce bandwidth usage.
[0135] In some embodiments, after sending the first cross-processor intersection request, GPU1 may continue to perform ray intersection tasks for other rays. For example, when performing the ray intersection task for ray c described below, GPU1 may receive the intersection result for ray b returned by GPU2 after obtaining the intersection results for one or more other rays. In other words, step S307 may be performed after step S308 or step S309. After receiving the intersection result for ray b from GPU2, GPU1 may save the intersection result for ray b to a register or video memory within GPU1.
[0136] Through the above process, the ray intersection task for ray b is completed.
[0137] S308 : GPU 1 determines, for the light ray c in the scene, a target bounding box C that intersects with the light ray c.
[0138] In some embodiments, the multiple ray intersection tasks generated by the subroutine execution unit in the GPU 1 may further include a ray intersection task for ray c. Here, ray c may also be any one of the multiple rays.
[0139] S309 , GPU1 determines that the GPU does not contain the geometric data in the target bounding box C, and generates a second cross-processor intersection request.
[0140] If the target bounding box C intersecting with ray c is determined to be bounding box 3, since the geometric data of bounding box 3 is not stored in GPU 1, the ray pursuit intersection unit in GPU 1 can determine that bounding box 3 corresponds to GPU 3 based on the identification information of the GPU corresponding to bounding box 3 stored in GPU 1. In other words, the target GPU corresponding to target bounding box C is determined to be GPU 3. Therefore, GPU 1 can generate a second cross-processor intersection request for ray c through the ray pursuit intersection unit, and the target GPU of the second cross-processor intersection request is GPU 3.
[0141] S310 : GPU1 sends a second cross-processor intersection request to GPU3 .
[0142] S311: GPU 3 determines an intersection result for ray c in response to the received second cross-processor intersection request. The intersection result for ray c may also be referred to as intersection point information of ray c.
[0143] S312: GPU3 sends the intersection result of ray c to GPU1.
[0144] The process of GPU1 and GPU3 processing the second cross-processor intersection request can refer to the process of GPU1 and GPU2 processing the first cross-processor intersection request, which will not be repeated here.
[0145] In some embodiments, after sending the second cross-processor intersection request, GPU1 may continue to perform ray intersection tasks for other rays. GPU1 may receive the intersection result for ray c returned by GPU3 after obtaining the intersection results of one or more other rays.
[0146] In some optional embodiments, after generating multiple ray intersection tasks, the subroutine execution unit in GPU 1 may obtain the intersection results corresponding to each of the multiple ray intersection tasks and perform subsequent processing based on the intersection results corresponding to each of the multiple ray intersection tasks. For example, the subroutine execution unit may save the intersection results corresponding to each of the multiple ray intersection tasks to video memory, so that GPU 1 can perform shading and image rendering based on the intersection results corresponding to each of the multiple ray intersection tasks.
[0147] In related technologies, when performing ray tracing, ray intersection tasks are executed at the granularity of a pass. A pass performs a set number of ray bounces, where the set number of bounces can range from 1 to N, where N is an integer greater than 1. In each pass, the rays can be intersected to determine the objects they pass through and their related attribute information. For example, assuming a screen with a resolution of 1080p (1920*1080), each pixel on the screen will emit a ray into the scene. Therefore, a ray bounce in a pass can have approximately 2 million ray intersection tasks, each of which can be executed by a thread in the GPU. In the related art, for GPU1, GPU1 executes each ray intersection task in a pass in turn, finds whether the ray in a ray intersection task intersects with the bounding box saved in GPU1, and if it is determined that the ray intersects with the bounding box saved in GPU1, then it continues to determine which geometric body in the bounding box the ray intersects with. If it is determined that the ray does not intersect with the bounding box saved in GPU1, but intersects with the bounding box saved in another GPU, then the other GPU is used as the target GPU, the identifier of the target GPU corresponding to the ray intersection task is recorded, and the next ray intersection task in the pass is returned to continue execution, and the iteration is repeated until all ray intersection tasks in the pass are completed. After all ray intersection tasks in a pass are completed, GPU1 can execute the program through the subroutine execution unit to analyze which rays intersect with the bounding box saved in GPU1, and the intersection results need to be determined through cross-processor ray intersection tasks. For rays that do not intersect with the bounding boxes stored in GPU1, GPU1 can send cross-GPU intersection requests to the target GPUs corresponding to each ray intersection task based on the identifiers of the target GPUs corresponding to the recorded ray intersection tasks, and wait for the intersection results returned by each target GPU to complete the ray intersection task of a pass. In related technologies, since the GPU needs to wait for all ray intersection tasks in a pass to be completed before initiating a cross-GPU intersection request through the program execution unit, and the waiting time for each target GPU to return the intersection results is also long, the cross-GPU communication delay is significant. This method of processing ray crossings as a whole by executing the program by the subroutine execution unit is time-consuming and has low parallel efficiency.
[0148] In an embodiment of the present application, after determining that the geometric data in the target bounding box of a certain ray is not stored in the GPU, the GPU can initiate a cross-processor intersection request without waiting for all ray intersection tasks in a pass to be completed. The subroutine execution unit then executes the program for analysis to determine which part of the ray needs to pass through the cross-processor ray intersection task to determine the intersection result, and then initiates the cross-processor intersection request. After initiating the cross-processor intersection request, the GPU can continue to execute the next or next ray intersection tasks while waiting for the target GPU to return the intersection result of the cross-processor intersection request. The cross-GPU communication delay caused by waiting for the target GPU to return the intersection result is hidden by the pipeline for processing the ray intersection task. Compared with the method of the subroutine execution unit executing the program to process the ray crossing as a whole, the overall time consumption of executing the ray intersection task can be greatly reduced, the efficiency of parallel execution of ray intersection can be improved, and the cross-GPU execution of ray intersection can meet the needs of real-time image rendering, providing a possible implementation solution for multi-GPU parallel real-time image rendering.
[0149] The embodiments of the present application are applied to the scenario where multiple GPUs execute ray tracing tasks in parallel. The purpose of executing ray tracing tasks in parallel is to allow multiple GPUs to share the computational load of the ray tracing process, reduce the load on each GPU, and accelerate the execution of ray tracing tasks. The performance indicators used to measure the parallel execution of ray tracing tasks include acceleration ratio and efficiency. Among them, the acceleration ratio is used to measure the benefits of executing ray tracing tasks in parallel. Assuming that the time required to execute a ray tracing task using a single GPU is Ts, and the time required to execute the ray tracing task using p GPUs in parallel is Tp, then the acceleration ratio S = Ts / Tp. If the acceleration ratio S = p, the acceleration ratio is linear, indicating that the execution speed increases with the increase in the number of processors. This is only an ideal state. In actual use, the actual acceleration ratio S < p. Since some time is wasted when the processor is idle and the communication between the GPUs, the situation where S = p is almost impossible to achieve. Efficiency is a performance indicator used to evaluate whether the processor is fully utilized when executing a task. Assuming that the parallel efficiency is E, E = S / p. The efficiency of a solution with a linear acceleration ratio (in an ideal state) is E = 1. In actual use, the actual situation E < 1. If E<<1, that is, E is much smaller than 1, it indicates that the current parallel solution is a problematic and inefficient parallel solution. Compared with the method of having the subroutine execution unit execute the program to process the ray tracing as a whole, the ray tracing method provided by the embodiment of the application has significantly improved speedup and efficiency. Specifically, the parallel efficiency can be increased from 20% to over 80%.
[0150] In the related art, when the scene to be rendered is a very large scene containing a large amount of geometric data, and a single GPU cannot completely load all the geometric data in the very large scene, there is also a solution to reduce the data precision of the geometry in the bounding box to reduce the geometric data of the very large scene. However, the ray intersection result obtained based on this solution is an approximate result with low accuracy, resulting in low picture quality of the image rendered based on the ray intersection result. Compared with reducing the geometric data of the very large scene by reducing the data precision of the geometry in the bounding box, the ray tracing method provided in the embodiment of the present application uses a higher precision of the geometric data in the bounding box, or in other words, the bounding box of the embodiment of the present application still stores high-precision geometric data, so the accuracy of the ray intersection result obtained is higher, which can improve the picture quality of the rendered image.
[0151] In some embodiments of the present application, multiple ray intersection tasks in a pass can be divided into multiple warps for execution. Each warp can contain multiple threads, each of which is used to process a single ray intersection task. For example, each warp can contain 32 threads, each of which can process 32 ray intersection tasks. This 32 threads is for example only, and the present application does not limit the specific number of ray intersection tasks that each warp can process.
[0152] In some embodiments, since each warp includes multiple ray intersection tasks, if a warp has unfinished tasks, the obtained intersection results of the warp are saved, where the unfinished tasks refer to ray intersection tasks that have not obtained intersection results. For example, if there is a ray intersection task a among multiple ray intersection tasks in bundle A, GPU1 has already sent a cross-processor intersection request for ray intersection task a to GPU3 but has not yet received the intersection result for ray intersection task a from GPU3. In this case, the intersection results or other context information of other ray intersection tasks in bundle A can be temporarily saved in registers or video memory in GPU1, and bundle A can be suspended, waiting for the intersection result for ray intersection task a to be returned by GPU3. While bundle A is suspended, other bundles can be scheduled and executed. If GPU1 receives the intersection result for ray intersection task a from GPU3 and all intersection results for the ray intersection tasks in bundle A have been obtained, bundle A can be resumed. GPU1 can then calculate the intersection results of the multiple ray intersection tasks in bundle A to obtain the ray tracing result. While bundle A is suspended, the GPU can schedule and execute other bundles to reduce waiting time and streamline the process of executing ray intersection tasks. Furthermore, in the above embodiment, ray intersection tasks can be temporarily stored in the task queue of the ray tracing unit, and the ray tracing unit can execute the ray intersection tasks in the task queue according to the set task priority. Assuming that the task priority rule of GPU3's ray tracing unit is to prioritize scheduling ray intersection tasks of remote GPUs, GPU3's ray tracing unit will prioritize executing the cross-GPU ray intersection tasks sent by GPU1 and return the intersection results of the ray intersection tasks more quickly. This can shorten the time required to execute cross-processor intersection requests and reduce the suspension duration of the thread bundle to which the ray intersection task belongs, thereby improving the overall efficiency of multi-GPU ray tracing tasks.
[0153] In the above embodiment, the GPU stores identification information of the GPUs corresponding to the remaining bounding boxes except for the bounding box stored by the GPU itself. In other embodiments, in addition to the above information, the GPU may also store geometric models of the geometric bodies in the remaining bounding boxes, wherein the precision of the geometric models is lower than the precision of the geometric data; that is, the GPU may store low-precision models of the geometric bodies in the remaining bounding boxes. For example, if the geometric data of the geometric body in bounding box 1 is stored in GPU1, then the GPU may also store a low-precision model of the geometric body in bounding box 2, identification information of the GPU corresponding to bounding box 2, and a low-precision model of the geometric body in bounding box 3, and identification information of the GPU corresponding to bounding box 3. Similarly, if the geometric data of the geometry in bounding box 2 is saved in GPU2, the low-precision model of the geometry in bounding box 1, the identification information of the GPU corresponding to bounding box 1, and the low-precision model of the geometry in bounding box 3, and the identification information of the GPU corresponding to bounding box 3 can also be saved in GPU2; if the geometric data of the geometry in bounding box 3 is saved in GPU3, the low-precision model of the geometry in bounding box 1, the identification information of the GPU corresponding to bounding box 1, and the low-precision model of the geometry in bounding box 2, and the identification information of the GPU corresponding to bounding box 2 can also be saved in GPU3.
[0154] After sending the first cross-processor intersection request to GPU2, GPU1 waits for a set time. If, after the set time, GPU1 receives an intersection result for the first cross-processor intersection request from GPU2, GPU1 uses the intersection result as the intersection result for the second ray. If, after waiting for the set time, GPU1 still does not receive an intersection result for the first cross-processor intersection request from GPU2, GPU1 may determine an approximate intersection result based on the geometric model of the geometry within the target bounding box stored on GPU1, and use the intersection result determined based on the low-precision geometric model within the target bounding box as the intersection result for the second ray, thereby preventing other ray intersection tasks in the same thread bundle from being unable to continue subsequent calculations due to waiting for the intersection result for the second ray.
[0155] In some embodiments, to prevent the majority of ray intersection tasks in the same warp from waiting for a long time for the intersection results of a few cross-processor ray intersection tasks, warps can be reorganized during the execution of ray tracing tasks. That is, ray intersection tasks between different warps can be recombined to generate new warps. For example, if some ray intersection tasks in a first warp have already obtained intersection results, and some ray intersection tasks in a second warp have already obtained intersection results, a new warp can be generated based on some or all of the ray intersection tasks in the first and second warps that have already obtained intersection results. Alternatively, if some tasks in the first warp are unfinished, and some tasks in the second warp are unfinished, a new warp can be generated based on some or all of the unfinished tasks in the first and second warps. For example, suppose there are 32 ray intersection tasks in thread bundle 1 of GPU1, among which 12 ray intersection tasks have initiated cross-processor intersection requests and need to wait for other GPUs to complete the cross-GPU intersection tasks and return the intersection results, while the remaining 20 ray intersection tasks have already obtained the intersection results; there are also 32 ray intersection tasks in thread bundle 2 of GPU1, among which 6 ray intersection tasks have initiated cross-processor intersection requests and need to wait for other GPUs to complete the cross-GPU intersection tasks and return the intersection results, while the remaining 26 ray intersection tasks have already obtained the intersection results; there are also 32 ray intersection tasks in thread bundle 3 of GPU1, among which 14 ray intersection tasks have initiated cross-processor intersection requests and need to wait for other GPUs to complete the cross-GPU intersection tasks and return the intersection results, while the remaining 18 ray intersection tasks have already obtained the intersection results. Then, all ray intersection tasks that need to wait for other GPUs to complete cross-GPU intersection tasks and return intersection results can be extracted from thread bundle 1, thread bundle 2, and thread bundle 3 to form a new thread bundle 3. The ray intersection tasks that have obtained intersection results in the original thread bundle 3 are randomly assigned to thread bundle 1 and thread bundle 2, so that the number of ray intersection tasks in thread bundle 1 and thread bundle 2 is the same as before the reorganization, both 32. In this way, there is no need to perform cache operations on thread bundle 1 and thread bundle 2. While performing cache operations on thread bundle 3, subsequent operations can continue to be performed on thread bundle 1 and thread bundle 2, thereby improving the efficiency of executing ray intersection tasks in the form of thread bundles and avoiding too many thread bundles from entering the cache state. Among them, the reorganization method is not limited in this application, and the ray intersection tasks in different thread bundles can be reorganized according to actual needs.
[0156] In the above embodiment, taking each ray of light performing one ray crossing as an example, that is, each ray of light executes one cross-processor intersection request. In large urban scenes, generally, one ray crossing can meet the requirements. However, when scene segmentation is used in some high-precision small-scale scenes or complex scenes, some rays of light may perform multiple ray crossings. For one ray of light, multiple cross-processor intersection requests may be executed, and executing multiple cross-processor intersection requests one by one will increase the latency. Therefore, in some embodiments, if there are multiple target bounding boxes that intersect with a certain ray of light, and the multiple target bounding boxes correspond to different GPUs, the source GPU can respectively determine the target GPU corresponding to each of the multiple target bounding boxes, and send cross-processor intersection requests to the determined multiple target GPUs.
[0157] Using GPU 1 as an example, the subroutine execution unit in GPU 1 generates multiple ray intersection tasks, including one for ray d. As shown in Figure 8 , ray d can pass through bounding box 1 and enter bounding box 2 and bounding box 3. The processing for ray d, as shown in Figure 9 , may include the following steps:
[0158] S901 : GPU 1 determines, for a ray d in a scene, a target bounding box that intersects with the ray d.
[0159] The subroutine execution unit of GPU 1 generates a ray intersection task for ray d by executing the program. The subroutine execution unit saves this ray intersection task to the task queue of the ray intersection unit. The ray intersection unit reads the ray intersection tasks from the task queue and executes them sequentially. When the ray intersection task for ray d is read from the task queue, it executes the ray intersection task for ray d and determines the target bounding box that intersects with ray d in the ray intersection task from bounding boxes 1, 2, and 3. It is determined that both bounding boxes 2 and 3 intersect with ray d, indicating that the target bounding box includes bounding boxes 2 and 3.
[0160] S902 : GPU1 generates a third cross-processor intersection request and a fourth cross-processor intersection request respectively according to the identifiers of the GPUs corresponding to the two target bounding boxes.
[0161] Based on the identifier of the GPU corresponding to bounding box 2, GPU1 determines that the target GPU corresponding to bounding box 2 is GPU2, and generates a third cross-processor intersection request. This request includes the starting position of ray d, the direction of ray d, the identifier of GPU2 (the target GPU), and the identifier of GPU1 (the source GPU). Furthermore, based on the identifier of the GPU corresponding to bounding box 3, GPU1 determines that the target GPU corresponding to bounding box 3 is GPU3, and generates a fourth cross-processor intersection request. This request includes the starting position of ray d, the direction of ray d, the identifier of GPU3 (the target GPU), and the identifier of GPU1 (the source GPU).
[0162] S903: GPU1 sends a third cross-processor intersection request to GPU2.
[0163] S904 : GPU1 sends a fourth cross-processor intersection request to GPU3 .
[0164] As shown in Figure 10, the communication module of GPU 1 sends inter-processor intersection requests to GPU 2 and GPU 3. The order of steps S903 and S904 can be interchanged, or the two steps can be performed simultaneously.
[0165] S905 : GPU2 determines an intersection result R1 for ray d in response to the received third cross-processor intersection request.
[0166] S906 , GPU2 returns the intersection result R1 of ray d to GPU1 .
[0167] S907 : GPU3 determines an intersection result R2 for ray d in response to the received fourth cross-processor intersection request.
[0168] S908 : GPU3 returns the intersection result R2 of ray d to GPU1 .
[0169] S909 , GPU1 determines to obtain an intersection result for light d according to the received intersection results R1 and R2 .
[0170] GPU1 may first receive the intersection result R1 returned by GPU2, or may first receive the intersection result R2 returned by GPU3. In some embodiments, GPU1 may use both the intersection result R1 and the intersection result R2 as the intersection results for ray d, determine the ray propagation path based on the intersection results R1 and R2, and perform ray tracing. In other embodiments, GPU1 may determine the closer of the two intersection points based on the intersection point positions carried in the intersection result R1 and the intersection point positions carried in the intersection result R2, and use the intersection result corresponding to the closer intersection point as the intersection result for ray d. The intersection result for ray d may also be referred to as the intersection point information of ray d.
[0171] In the above embodiment, in the case where a ray passes through multiple bounding boxes, cross-processor intersection requests can be sent to multiple GPUs at the same time, changing the sending of cross-processor intersection requests from one-to-one to one-to-many. Multiple GPUs can execute the received cross-GPU ray intersection tasks at the same time, thereby reducing the delay caused by multiple GPUs executing cross-GPU ray intersection one by one, and further improving the efficiency of cross-GPU ray intersection.
[0172] The above embodiments are all explained by taking GPU1 generating multiple ray intersection tasks as an example. When executing ray tracing tasks, multiple GPUs in the image rendering system execute ray tracing tasks in parallel, and multiple ray intersection tasks can be generated. Any GPU can refer to the process executed by the above GPU1 to process the multiple ray intersection tasks generated.
[0173] In combination with the above method embodiments, the embodiments of the present application also provide an image rendering system. The image rendering system may include multiple GPUs. The internal structure of the image rendering system may be as shown in Figure 1, including a CPU and multiple GPUs. The multiple GPUs may execute ray tracing tasks and image rendering tasks in parallel under the control of the CPU. The internal structures of the multiple GPUs may be the same. In one embodiment, it is assumed that the image rendering system includes n GPUs. Figure 11 exemplarily shows the internal structure of each GPU. As shown in Figure 11, each GPU may include a communication module and multiple program execution units. The multiple program execution units may execute programs for ray tracing tasks in parallel, so the program execution units may also be called parallel program execution units. Each program execution unit may include a ray tracing intersection unit module and multiple subroutine execution units. For example, each GPU may include about 100 program execution units, and each program execution unit may include 4 subroutine execution units and one ray tracing intersection unit. As shown in Figure 11, the four subroutine execution units are S1, S2, S3 and S4 respectively. The above-mentioned program execution unit can be referred to as a streaming multiprocessor or a stream processor, and the subroutine execution unit can be referred to as a sub-streaming multiprocessor or a sub-stream processor. The ray tracing intersection unit can be referred to as a ray tracing core or a ray tracing core or a ray tracing core acceleration unit. Each subroutine execution unit executes one thread bundle at a time, and a thread bundle can contain 32 threads. When executing a ray tracing task, each thread can correspond to a ray intersection task. In a program execution unit, the subroutine execution unit can save the ray intersection task to the task queue of the ray tracing intersection unit in the program execution unit. The ray tracing intersection unit can read the corresponding task queue and execute the ray intersection task in the task queue. Each GPU can also include a video memory (not shown in Figure 11). The video memory can be used to store data. The BVH structure constructed by the CPU and multiple GPUs can be saved in the video memory of each GPU, and the geometric data of a part of the bounding boxes of the multiple bounding boxes of the overall scene data and the identification information of the GPU corresponding to each bounding box in the remaining bounding boxes are saved in the BVH structure. In some embodiments, the communication module in the GPU may include a communication receiving module and a communication sending module, wherein the communication receiving module in a GPU can receive information sent by other GPUs and can also send information to other components in the GPU; the communication sending module in a GPU can receive cross-GPU intersection tasks generated by the GPU and send them to other GPUs.
[0174] Taking GPU1 as an example, the identifiers of multiple bounding boxes, such as bounding box 1, bounding box 2, and bounding box 3, are stored in GPU1's video memory. The identifier of bounding box 1 corresponds to the geometric data stored in bounding box 1, the identifier of bounding box 2 corresponds to the identification information of GPU 2, the identifier of bounding box 3 corresponds to the identification information of GPU 3, and so on. During the execution of a ray tracing task, the communication module in GPU1 can receive cross-GPU ray intersection tasks sent by other GPUs and save the cross-GPU ray intersection tasks to the task queue of the ray tracing unit. The ray tracing unit can read the ray intersection tasks in the task queue of the ray tracing unit according to the set task priority, execute the ray intersection tasks through hardware, determine the intersection information, and return the determined intersection information to the source GPU that sent the cross-GPU ray intersection task via the communication sending module. During the execution of a ray tracing task, the subroutine execution unit in GPU1 can also generate multiple ray intersection tasks and save the multiple ray intersection tasks to the task queue of the ray tracing unit. The ray pursuit intersection unit can read the ray intersection tasks in the task queue of the ray pursuit intersection unit according to the set task priority, and execute the ray intersection tasks through hardware to determine the target bounding box of the ray intersection task. If the geometric data in the target bounding box is saved in the video memory of GPU1, the intersection information is continued to be determined and the intersection information is returned to the subroutine execution unit. If the geometric data in the target bounding box is not saved in the video memory of GPU1, a cross-GPU ray intersection task can be generated based on the identification information of the target GPU corresponding to the target bounding box, and the cross-GPU ray intersection task is sent to the corresponding target GPU through the communication sending module, and then the intersection information returned by the target GPU is received through the communication receiving module, and the intersection information is returned to the subroutine execution unit.
[0175] In conjunction with the above-described method embodiments, embodiments of the present application also provide a graphics processor. The internal structure of the graphics processor can refer to the structure of any GPU shown in FIG11 and will not be further described here. The graphics processor can be used to execute ray tracing tasks in parallel with other graphics processors in an image rendering system, performing ray tracing based on specified scene data. The scene data may include multiple geometric bodies and multiple bounding boxes; each of the multiple bounding boxes contains geometric data of a portion of the geometric bodies in the scene data. A subroutine execution unit in the graphics processor can be used to transmit a ray intersection task for a first ray to a ray pursuit intersection unit. The ray pursuit intersection unit in the graphics processor can be used to perform the following steps: upon receiving a ray intersection task for the first ray, determine, based on the first ray, a first target bounding box that intersects with the first ray; when the geometric data of the first target bounding box is not stored in the first graphics processor, send a first request to a target graphics processor, where the geometric data of the first target bounding box is stored; upon receiving a ray intersection task for a second ray, determine, based on the second ray, a second target bounding box that intersects with the second ray, and determine second intersection information based on the second ray and the second target bounding box. The subroutine execution unit is further configured to receive first intersection information of the first request; the first intersection information is determined based on the first ray and the first target bounding box.
[0176] In conjunction with the above-described method embodiments, embodiments of the present application also provide a ray tracing device. This ray tracing device can be applied to any one of the multiple GPUs in the image rendering system shown in FIG1 . This ray tracing device can be used to implement the functions of the above-described method embodiments, thereby achieving the beneficial effects of the above-described method embodiments. As shown in FIG12 , the ray tracing device 1200 may include a first intersection unit 1201, a communication unit 1202, and a second intersection unit 1203.
[0177] The first intersection unit 1201 may be configured to determine, based on the first ray, a first target bounding box intersecting with the first ray.
[0178] The communication unit 1202 may be configured to send a first request to a target graphics processor when the geometric data of the first target bounding box is not stored in the first graphics processor, and the geometric data of the first target bounding box is stored in the target graphics processor.
[0179] The second intersection unit 1203 may determine a second target bounding box intersecting with the second ray based on the second ray, and determine second intersection point information based on the second ray and the second target bounding box.
[0180] The communication unit 1202 may also be configured to receive first intersection information of the first request; the first intersection information is determined based on the first ray and the first target bounding box.
[0181] It should be noted that, in some embodiments, the first intersection unit 1201 can be used to execute any step in the ray tracing method, the communication unit 1202 can be used to execute any step in the ray tracing method, and the second intersection unit 1203 can be used to execute any step in the ray tracing method. The steps that the first intersection unit 1201, the communication unit 1202, and the second intersection unit 1203 are responsible for implementing can be specified as needed. The first intersection unit 1201, the communication unit 1202, and the second intersection unit 1203 each implement different steps in the ray tracing method to achieve the full functionality of the ray tracing device.
[0182] The functional modules in the embodiments of the present application may be integrated into a GPU, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional units.
[0183] Based on the same technical concept as the above-mentioned method embodiments, the present application also provides a chip. This chip can be used to implement the functions implemented by the GPU in the method embodiments shown in Figures 3 or 9 above, and can be applied to any GPU, thereby achieving the beneficial effects of the above-mentioned method embodiments; that is, the internal structure of the GPU can be as shown in Figures 7 or 11, or the GPU can include the chip shown in Figure 13.
[0184] In some embodiments, the chip 1300 may be structured as shown in FIG13 , including a processor 1301 and a memory 1302 connected to the processor 1301. The processor 1301 and the memory 1302 may be interconnected via a bus. The processor 1301 may be a general-purpose processor, such as a microprocessor, or other conventional processor. The bus may be a PCI bus or an EISA bus. Buses may be divided into address buses, data buses, and control buses.
[0185] Among them, the memory 1302 can be used to store software programs and modules, and the processor 1301 executes various functional applications and data processing of the chip 1300 by running the software programs and modules stored in the memory 1302, such as the communication method provided in the embodiment of the present application.
[0186] The memory 1302 may primarily include a program storage area and a data storage area. The program storage area may store an operating system, at least one application program, and the like; the data storage area may be used to store user data, etc. Furthermore, the memory 1302 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state memory device.
[0187] The processor 1301 in chip 1300 is configured to execute computer instructions or programs stored in memory 1302 to perform the functions of any of the above-described method embodiments. In some embodiments, processor 1301 may include one or more processing units, which may be independent devices or integrated into one or more processors. Processor 1301 may also include a controller that generates operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.
[0188] In one embodiment, the chip 1300 may further include a communication module, which may be used to communicate with other GPUs.
[0189] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the chip. In other embodiments of this application, the chip may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The components shown in the illustrations may be implemented in hardware, software, or a combination of software and hardware.
[0190] The present application also provides a computer program product comprising computer-executable instructions. In one embodiment, the computer-executable instructions are used to enable a computer to perform the functions of the above method embodiment.
[0191] Computer-executable instructions can be stored in a computer-readable storage medium. The present application also provides a computer-readable storage medium having executable instructions stored therein. In one embodiment, the computer-executable instructions are used to cause a computer to perform the functions of the above method embodiment.
[0192] The computer-readable storage medium provided in the embodiments of the present application may be a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of computer-readable storage medium known in the art.
[0193] Computer-executable instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, or magnetic tape; an optical medium such as a digital video disc (DVD); or a semiconductor medium such as a solid-state drive.
[0194] In the various embodiments of the present application, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, including a series of steps or units. The method, system, product or device is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0195] Although the present application has been described with reference to specific features and embodiments thereof, it is apparent that various modifications and combinations thereof may be made without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are intended to be illustrative only of the solutions defined by the appended claims and are to be construed as covering any and all modifications, variations, combinations or equivalents within the scope of the present application.
[0196] Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include these modifications and variations.
Claims
1. A ray tracing method, characterized in that: A first graphics processor among a plurality of graphics processors applied to an image rendering system; the method comprising: Based on the first ray, determining a first target bounding box intersecting the first ray; When the first graphics processor does not store the geometric data of the first target bounding box, sending a first request to a target graphics processor, where the geometric data of the first target bounding box is stored; Determine a second target bounding box intersecting the second ray based on the second ray, and determine second intersection point information based on the second ray and the second target bounding box; First intersection information of the first request is received; the first intersection information is determined based on the first ray and the first target bounding box.
2. The method according to claim 1, characterized in that The multiple graphics processors are used to perform ray tracing based on specified scene data; the scene data includes multiple geometric bodies and multiple bounding boxes, and each bounding box of the multiple bounding boxes contains geometric body data of a portion of the multiple geometric bodies.
3. The method according to claim 2, characterized in that The first graphics processor stores geometric data of the second target bounding box and identification information of graphics processors corresponding to the remaining bounding boxes except the second target bounding box among the plurality of bounding boxes; The graphics processor corresponding to any bounding box among the remaining bounding boxes is a graphics processor that stores geometric data in any bounding box; The method further comprises: When the geometric data of the first target bounding box is not stored in the first graphics processor, the target graphics processor is determined according to identification information of the graphics processor corresponding to the first target bounding box.
4. The method according to any one of claims 1 to 3, characterized in that Before determining, based on the first ray, a first target bounding box intersecting with the first ray, the method further includes: A plurality of ray intersection tasks are generated, and the plurality of ray intersection tasks are saved in a task queue of a ray intersection unit; the plurality of ray intersection tasks include a ray intersection task for the first ray.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: receiving a second request sent by a second graphics processor; the second graphics processor being any graphics processor among the plurality of graphics processors except the first graphics processor; saving the ray intersection task for the third ray indicated by the second request to a task queue of a ray intersection unit; Based on the ray intersection task of the third ray, third intersection point information of the third ray is determined by the ray intersection unit.
6. The method according to claim 4 or 5, characterized in that The determining of a first target bounding box intersecting the first ray includes: The ray intersection task for the first ray in the task queue is executed by the ray intersection unit to obtain a first target bounding box that intersects with the first ray; the ray intersection unit executes the ray intersection task in the task queue according to the set task priority; the task priority of the ray intersection task is determined according to the graphics processor that generates the ray intersection task.
7. The method according to any one of claims 1 to 6, characterized in that The sending a first request to the target graphics processor includes: A first request for the first ray is generated by the ray intersection unit, and the first request is sent to the target graphics processor.
8. The method according to any one of claims 1 to 7, characterized in that The sending a first request to the target graphics processor includes: At least one request is sent to the target graphics processor via a cross-processor message; the at least one request includes the first request.
9. The method according to any one of claims 1 to 8, characterized in that The first request carries part or all of the following information: the starting point position of the first ray, the direction of the first ray, the identification information of the target graphics processor, the identification information of the source graphics processor, and the identification of the first target bounding box; the source graphics processor is the graphics processor that generates the ray intersection task for the first ray.
10. The method according to any one of claims 1 to 9, characterized in that The first intersection information includes: the first ray has no intersection with the geometric body in the first target bounding box; or The first intersection point information includes: an identifier of a target geometric body intersecting with the first ray in a geometric body contained in the first target bounding box, and a position of an intersection point between the first ray and the target geometric body.
11. The method according to claim 10, characterized in that The target graphics processor also stores texture data of the geometry in the first target bounding box; when the first intersection information includes the intersection position of the first ray and the target geometry, the first intersection information also includes texture data of the intersection position of the first ray and the target geometry.
12. The method according to claim 10 or 11, characterized in that When the first intersection information includes the intersection position of the first ray and the target geometric body, the first intersection information also includes shading information of the intersection position.
13. The method according to claim 4, characterized in that After receiving the first intersection information of the first request, the method further includes: If there is an unfinished task in the thread bundle to which the ray intersection task for the first ray belongs, saving the first intersection point information; the thread bundle includes multiple ray intersection tasks; the unfinished task refers to a ray intersection task for which no intersection point information has been obtained; After waiting for all the ray intersection tasks in the thread warp to obtain the intersection point information, the intersection point information of the multiple ray intersection tasks in the thread warp is processed.
14. The method according to claim 4, characterized in that The method further comprises: If some ray intersection tasks in the first warp have obtained intersection information, and some ray intersection tasks in the second warp have obtained intersection information, a new warp is obtained based on the ray intersection tasks in the first warp and the second warp that have obtained intersection information.
15. The method according to any one of claims 1 to 14, characterized in that The first graphics processor further stores: a geometric model of the geometric body in the first target bounding box; the accuracy of the geometric model is lower than the accuracy of the geometric data; After sending the first request to the target graphics processor, the method further includes: If the intersection information returned by the target graphics processor in response to the first request is not received within a set time period, the first intersection information is determined according to a geometric model of the geometric body in the first target bounding box.
16. The method according to any one of claims 1 to 15, characterized in that There are multiple first target bounding boxes; and sending a first request to a target graphics processor includes: respectively determining a target graphics processor corresponding to each first target bounding box among a plurality of first target bounding boxes; The first request is sent to each of the determined multiple target graphics processors.
17. The method according to any one of claims 1 to 16, characterized in that The first ray intersection task and the second ray intersection task belong to the same thread warp; the first ray intersection task indicates determining first intersection information based on the first ray; the second ray intersection task indicates determining second intersection information based on the second ray.
18. A ray tracing device, characterized in that: A first graphics processor among a plurality of graphics processors used in an image rendering system; the device comprises: A first intersection unit, configured to determine, based on the first ray, a first target bounding box intersecting the first ray; a communication unit, configured to send a first request to a target graphics processor when the geometric data of the first target bounding box is not stored in the first graphics processor, the geometric data of the first target bounding box being stored in the target graphics processor; a second intersection unit, configured to determine a second target bounding box intersecting the second ray based on the second ray, and determine second intersection point information based on the second ray and the second target bounding box; The communication unit is further configured to receive first intersection information of the first request; the first intersection information is determined based on the first ray and the first target bounding box.
19. The device according to claim 18, characterized in that The multiple graphics processors are used to perform ray tracing based on specified scene data; the scene data includes multiple geometric bodies and multiple bounding boxes, and each bounding box of the multiple bounding boxes contains geometric body data of a portion of the multiple geometric bodies.
20. The device according to claim 19, characterized in that The first graphics processor stores geometric data of the second target bounding box and identification information of graphics processors corresponding to the remaining bounding boxes except the second target bounding box; the graphics processor corresponding to any of the remaining bounding boxes is the graphics processor storing the geometric data of any of the bounding boxes; and the communication unit is further configured to: When the geometric data of the first target bounding box is not stored in the first graphics processor, the target graphics processor is determined according to identification information of the graphics processor corresponding to the first target bounding box.
21. An image rendering system, characterized in that: The method comprises a plurality of graphics processors; the plurality of graphics processors are used to perform ray tracing based on specified scene data; each of the plurality of graphics processors is used to execute the method according to any one of claims 1 to 17.
22. A chip, characterized in that: The chip comprises a processor and a memory; the memory stores a computer program or instruction; the processor is used to execute the computer program or instruction stored in the memory, so that the chip executes the method according to any one of claims 1 to 17.
23. A graphics processor, characterized in that: The graphics processor is a first graphics processor, which is applied to an image rendering system including multiple graphics processors; The first graphics processor includes a subroutine execution unit and a ray tracing unit; The subroutine execution unit is used to transmit the ray intersection task for the first ray and the ray intersection task for the second ray to the ray intersection unit; The optical intersection unit is configured to perform the following steps: receiving a ray intersection task for a first ray, and determining, based on the first ray, a first target bounding box intersecting with the first ray; When the first graphics processor does not store the geometric data of the first target bounding box, sending a first request to a target graphics processor, where the geometric data of the first target bounding box is stored; receiving a ray intersection task for a second ray, determining a second target bounding box intersecting with the second ray based on the second ray, and determining second intersection point information based on the second ray and the second target bounding box; The subroutine execution unit is further configured to receive first intersection information of the first request; The first intersection point information is determined based on the first ray and the first target bounding box.
24. A computer-readable storage medium, characterized in that The storage medium stores a computer program or instruction, and when the computer program or instruction is executed on a computer, the method according to any one of claims 1 to 17 is implemented.
25. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 17.
Citation Information
Patent Citations
BVH construction method and device for GPU and storage medium
CN113034338A
GPU-based octree Boolean operation acceleration intersection method
CN114283244A
Image rendering method and related equipment thereof
CN115908683A
Rendering method, electronic equipment and computer readable storage medium
CN116051713A
Traversal device for incoherant ray tracing
WO2022169378A1