Primitive processing apparatus, method, graphics processor and electronic device
Patent Information
- Application Number
- CN202610821484.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2046-06-08
AI Technical Summary
然而,现有技术中,GPU的通用计算部件处理不规则图元时,光线追踪加速器必须等待,降低了计算资源的利用率以及光线追踪效率
[0031]根据本公开实施例的图元处理装置包括至少一个处理单元、至少一个第一存储单元、多个第二存储单元;处理单元用于对光线进行光线追踪处理,其中:在当前节点是不规则图元时,将不规则图元的图元参数存入对应于光线且空闲的一个第二存储单元后,继续处理下一节点,并请求GPU的计算单元使用不规则图元的图元参数对不规则图元和光线进行求交处理;在第一距离值满足第一预设条件时,更新对应于光线的第一存储单元存储的距离值和图元参数;第一距离值由GPU的计算单元进行求交处理得到。在此情况下,图元处理装置处理到的节点是不规则图元时,在请求GPU计算单元对不规则图元和光线进行求交处理后,无需停滞计算并等待GPU的计算单元返回距离值和图元参数,可以直接开始处理下一节点,提高计算资源的利用率;GPU的计算单元处理不规则图元时,图元处理装置可以处理其他节点,提高光线追踪效率。
Smart Images

Figure CN122368284B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of rendering technology, and in particular to a primitive processing apparatus, method, graphics processor, and electronic device. Background Technology
[0002] Ray tracing is a rendering technique that simulates how light travels and interacts in a 3D scene, with the goal of generating physically highly realistic images. It mimics the behavior of light in the real world, from its emission from a light source, to its reflection and refraction on the surface of an object, and finally to its entry into the human eye (or camera).
[0003] For ray tracing, the relationship between a ray and all objects in the space it illuminates can be modeled as a bounding box hierarchy. A traversal algorithm is then used to find the intersections between the ray and all objects in space, thus obtaining the image of the object illuminated by the ray. To achieve high-performance ray tracing, custom-designed ray tracing accelerators are often used in graphics processing units (GPUs) for hardware acceleration. This involves using ray tracing accelerators to process regular primitives and using the GPU's general-purpose computing components to process irregular primitives. However, in current technologies, when the GPU's general-purpose computing components process irregular primitives, the ray tracing accelerator must wait, reducing the utilization of computing resources and the efficiency of ray tracing. Summary of the Invention
[0004] In view of this, the present disclosure proposes a primitive processing apparatus, method, graphics processor, and electronic device. The primitive processing apparatus of the embodiments of the present disclosure can work in parallel with the computing unit of the GPU, thereby improving the utilization of computing resources and ray tracing efficiency.
[0005] According to one aspect of this disclosure, a primitive processing apparatus is provided, the apparatus comprising at least one processing unit, at least one first storage unit, and a plurality of second storage units; the processing unit is configured to perform ray tracing processing on rays, wherein: when the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit corresponding to the ray and which is idle, and the next node is processed, and the GPU computing unit is requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray; when a first distance value satisfies a first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU computing unit performing the intersection processing.
[0006] In one possible implementation, the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the ray; the processing unit is used to, when the first distance value satisfies the first preset condition, use the first distance value to cover the distance value stored in the first storage unit corresponding to the ray, and use the primitive parameters of the irregular primitive to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0007] In one possible implementation, the processing unit is further configured to: when the first distance value satisfies the first preset condition, update the primitive parameters stored in the first storage unit corresponding to the ray, and then clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive; when the first distance value does not satisfy the first preset condition, clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive.
[0008] In one possible implementation, the processing unit is further configured to, after completing the processing of all nodes included in the bounding box hierarchy and confirming that all second storage units corresponding to the ray have been cleared, notify the GPU's computing unit to obtain the primitive parameters and distance values stored in the first storage unit corresponding to the ray, or report the primitive parameters and distance values stored in the first storage unit corresponding to the ray to the GPU's computing unit.
[0009] In one possible implementation, the processing unit is further configured to: when the current node is a regular primitive, use the primitive parameters of the regular primitive to perform intersection processing on the regular primitive and the ray; when the second distance value obtained by the intersection processing satisfies the second preset condition, update the distance value and primitive parameters stored in the first storage unit corresponding to the ray, and then continue processing the next node.
[0010] In one possible implementation, the second preset condition is: the second distance value is less than the distance value stored in the first storage unit corresponding to the ray; the processing unit is used to, when the second distance value satisfies the second preset condition, use the second distance value to cover the distance value stored in the first storage unit corresponding to the ray, and use the primitive parameters corresponding to the rule primitives to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0011] In one possible implementation, the processing unit includes a front-end / back-end interaction subunit, a traversal subunit, and a calculation subunit. The front-end / back-end interaction subunit is configured to receive the first distance value and, when the first distance value satisfies the first preset condition, update the distance value and primitive parameters stored in the first storage unit corresponding to the ray. The calculation subunit is configured to perform intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive and output the second distance value to the traversal subunit. The traversal subunit is configured to update the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value satisfies the second preset condition.
[0012] In one possible implementation, the device includes N first storage units and N groups of second storage units, each group of second storage units including M second storage units, where N>0 and M>1; when the light is the i-th light to be tracked, it corresponds to the i-th first storage unit and the i-th group of second storage units, where N≥i>0.
[0013] In one possible implementation, the device includes L processing units, L first storage units, and L groups of second storage units, each group of second storage units including M second storage units, where L>0 and M>1; the j-th processing unit corresponds to the j-th first storage unit and the j-th group of second storage units, where L≥j>0; when the light ray is the L×k+j-th light ray to be tracked, it corresponds to the j-th processing unit, where k≥0 and is an integer.
[0014] In one possible implementation, when the j-th processing unit corresponds to multiple rays, after completing the ray tracing processing of the current ray and waiting for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit, the j-th first storage unit is cleared, and ray tracing processing is performed on the next ray corresponding to itself.
[0015] In one possible implementation, when there are multiple processing units and multiple rays, different processing units correspond to different rays, and different processing units perform ray tracing processing in parallel.
[0016] In one possible implementation, the regular primitives are primitives that can be simplified into fixed mathematical formulas through mathematical modeling; the irregular primitives are primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling.
[0017] According to another aspect of this disclosure, a primitive processing method is provided, the method being applied to a primitive processing apparatus, the apparatus including at least one processing unit, at least one first storage unit, and a plurality of second storage units; the method includes: using the processing unit to perform ray tracing processing on rays, wherein: when the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit corresponding to the ray and which is idle, then the next node is processed, and the GPU's computing unit is requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray; when a first distance value satisfies a first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit performing the intersection processing.
[0018] In one possible implementation, the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the ray; when the first distance value satisfies the first preset condition, updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray includes: when the first distance value satisfies the first preset condition, using the first distance value to cover the distance value stored in the first storage unit corresponding to the ray, and using the primitive parameters of the irregular primitive to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0019] In one possible implementation, the method further includes: when the first distance value satisfies the first preset condition, updating the primitive parameters stored in the first storage unit corresponding to the ray, and then using the processing unit to clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive; when the first distance value does not satisfy the first preset condition, using the processing unit to clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive.
[0020] In one possible implementation, the method further includes: after the processing unit completes the processing of all nodes included in the bounding box hierarchy and confirms that all second storage units corresponding to the ray have been cleared, notifying the GPU's computing unit to obtain the primitive parameters and distance values stored in the first storage unit corresponding to the ray, or reporting the primitive parameters and distance values stored in the first storage unit corresponding to the ray to the GPU's computing unit.
[0021] In one possible implementation, the method further includes: when the current node is a regular primitive, the processing unit uses the primitive parameters of the regular primitive to perform intersection processing on the regular primitive and the ray; when the second distance value obtained by the intersection processing satisfies the second preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated, and then the next node is processed.
[0022] In one possible implementation, the second preset condition is: the second distance value is less than the distance value stored in the first storage unit corresponding to the ray; when the second distance value obtained by the intersection process satisfies the second preset condition, updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray includes: when the second distance value satisfies the second preset condition, using the second distance value to cover the distance value stored in the first storage unit corresponding to the ray, and using the primitive parameters corresponding to the regular primitive to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0023] In one possible implementation, the processing unit includes a front-end / back-end interaction subunit, a traversal subunit, and a calculation subunit. The step of updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the first distance value satisfies a first preset condition includes: the front-end / back-end interaction subunit receives the first distance value and updates the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the first distance value satisfies the first preset condition; the step of performing intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive includes: the calculation subunit performs intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive and outputs the second distance value to the traversal subunit; the step of updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value obtained from the intersection processing satisfies a second preset condition includes: the traversal subunit updates the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value satisfies the second preset condition.
[0024] In one possible implementation, the device includes N first storage units and N groups of second storage units, each group of second storage units including M second storage units, where N>0 and M>1; when the light is the i-th light to be tracked, it corresponds to the i-th first storage unit and the i-th group of second storage units, where N≥i>0.
[0025] In one possible implementation, the device includes L processing units, L first storage units, and L groups of second storage units, each group of second storage units including M second storage units, where L>0 and M>1; the j-th processing unit corresponds to the j-th first storage unit and the j-th group of second storage units, where L≥j>0; when the light ray is the L×k+j-th light ray to be tracked, it corresponds to the j-th processing unit, where k≥0 and is an integer.
[0026] In one possible implementation, the method further includes: when the j-th processing unit corresponds to multiple rays, after completing the ray tracing processing of the current ray and waiting for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit, clearing the j-th first storage unit and performing ray tracing processing on the next ray corresponding to itself.
[0027] In one possible implementation, when there are multiple processing units and multiple rays, different processing units correspond to different rays, and different processing units perform ray tracing processing in parallel.
[0028] In one possible implementation, the regular primitives are primitives that can be simplified into fixed mathematical formulas through mathematical modeling; the irregular primitives are primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling.
[0029] According to another aspect of this disclosure, a graphics processor is provided, including the primitive processing apparatus described in any of the preceding claims.
[0030] According to another aspect of this disclosure, an electronic device is provided, including the graphics processor described above.
[0031] According to an embodiment of this disclosure, a primitive processing apparatus includes at least one processing unit, at least one first storage unit, and a plurality of second storage units. The processing unit is used to perform ray tracing processing on rays, wherein: when the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit corresponding to the ray and which is idle, and then the next node is processed. The processing unit requests the GPU's computing unit to perform intersection processing on the irregular primitive and the ray using the primitive parameters of the irregular primitive; when the first distance value meets a first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit performing intersection processing. In this case, when the node processed by the primitive processing apparatus is an irregular primitive, after requesting the GPU's computing unit to perform intersection processing on the irregular primitive and the ray, there is no need to stop the calculation and wait for the GPU's computing unit to return the distance value and primitive parameters. The processing unit can directly start processing the next node, improving the utilization rate of computing resources. While the GPU's computing unit is processing the irregular primitive, the primitive processing apparatus can process other nodes, improving ray tracing efficiency.
[0032] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0033] The accompanying drawings, which are included in and form part of this specification, illustrate exemplary embodiments, features, and aspects of this disclosure together with the specification and serve to explain the principles of this disclosure.
[0034] Figure 1 A schematic diagram of the bounding box hierarchy is shown.
[0035] Figure 2 A schematic diagram showing the structure of a prior art ray tracing accelerator.
[0036] Figure 3 A schematic diagram illustrating the flow of a prior art ray tracing algorithm.
[0037] Figure 4 This illustrates an exemplary application scenario of a primitive processing apparatus according to embodiments of the present disclosure.
[0038] Figure 5 A schematic diagram showing the structure of a primitive processing apparatus according to an embodiment of the present disclosure is provided.
[0039] Figure 6 A schematic diagram illustrating the workflow of a processing unit according to an embodiment of the present disclosure is shown.
[0040] Figure 7 A schematic diagram illustrating a primitive processing apparatus and a GPU computing unit processing primitives according to embodiments of the present disclosure is shown.
[0041] Figure 8 This diagram illustrates the processing primitives of general computing components in existing ray tracing accelerators and GPUs.
[0042] Figure 9 A schematic diagram showing the structure of a primitive processing apparatus including N first storage units and N groups of second storage units according to an embodiment of the present disclosure is provided.
[0043] Figure 10 A schematic diagram showing the structure of a primitive processing apparatus including L first storage units and L groups of second storage units according to an embodiment of the present disclosure is provided.
[0044] Figure 11 A schematic diagram showing the structure of a processing unit according to an embodiment of the present disclosure is provided.
[0045] Figure 12 A schematic diagram illustrating the flow of a primitive processing method according to an embodiment of the present disclosure is shown. Detailed Implementation
[0046] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0047] As used herein, the terms “comprising,” “including,” “having,” or variations thereof are open-ended and include one or more of the stated features, integrals, elements, steps, components, or functions, but do not exclude the presence or addition of one or more other features, integrals, elements, steps, components, functions, or groups thereof.
[0048] When an element is referred to as “connected,” “coupled,” “responding,” or a variation thereof relative to another element, it may be directly connected, coupled, or responding to another element, or there may be an intermediate element present.
[0049] Although the terms first, second, third, etc., may be used herein to describe various elements / operations, these elements / operations should not be limited by these terms. These terms are only used to distinguish one element / operation from another. Therefore, without departing from the teachings of the inventive concept, a first element / operation in some embodiments may be referred to as a second element / operation in other embodiments.
[0050] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0051] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.
[0052] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant regions.
[0053] In the GPU's geometry processing pipeline, ray tracing technology can calculate complex optical phenomena such as global illumination, soft shadows, precise reflection / refraction, and ambient occlusion with remarkable realism and naturalness. However, because a single line of sight can generate countless secondary rays that need to be traced, this technology also introduces a huge amount of computation.
[0054] Ray tracing requires traversing the entire scene. If there are few objects in the scene, such as only a few cubes, the primitives constituting the scene are few, and traversing the entire scene is faster. However, when there are many objects in the scene, the primitives constituting the scene may be many, and traversing the entire scene is slower.
[0055] To improve traversal speed, ray tracing technology models all objects in the scene as a bounding volume hierarchy (BVH). Figure 1 A schematic diagram of the bounding box hierarchy is shown.
[0056] like Figure 1 As shown, the root node a0 corresponds to the entire scene, and child nodes b0 and b1 correspond to the two subspaces split from the scene. The leaf nodes c0 (regular primitives) and c1 (irregular primitives) of child node b0 are primitives in the subspace corresponding to child node b0. The leaf nodes c2 (regular primitives), c3 (irregular primitives), c4 (regular primitives), and c5 (irregular primitives) of child node b1 are primitives in the subspace corresponding to child node b1.
[0057] When traversing the bounding box hierarchy, first check if the root node intersects with a ray. If the root node intersects with a ray, then further check if each child node intersects with a ray. If a ray does not intersect with a child node, then the ray will naturally not intersect with the leaf nodes of that child node. If a ray intersects with a child node, then further check if the ray intersects with the leaf nodes within the bounding box of that child node. This significantly reduces the number of times ray intersection checks are performed.
[0058] The abundant general-purpose computing units in a GPU can be used to perform the aforementioned traversal and intersection processing. However, because these general-purpose computing units cannot perfectly match the parameters of ray tracing, their efficiency is often low. Furthermore, the massive computational demands of ray tracing often occupy these general-purpose computing units for extended periods, making it difficult to allocate idle resources for other tasks. Therefore, to achieve high-performance ray tracing and avoid prolonged occupation of the GPU's general-purpose computing units, custom-designed ray tracing accelerators are often used in GPUs for hardware acceleration. For all objects traversed by the rays, the computation of user-defined primitives and irregular primitives such as transparent primitives is complex, and the corresponding customized hardware circuitry introduces significant area and power consumption. Therefore, ray tracing technology often employs a combination of ray tracing accelerators and GPU general-purpose computing units. Specifically, the ray tracing accelerator is used for intersection processing of regular primitives and rays, while the GPU's general-purpose computing units are used for intersection processing of irregular primitives and rays.
[0059] The purpose of ray tracing is to find the primitive closest to the light source along the direction of ray propagation. Therefore, when traversing the bounding box hierarchy, with the current node being a primitive, the distance between the primitive and the ray is obtained by intersecting the primitive and the ray. This distance is compared with the minimum distance between the primitive and the light source that has already been traversed, and the smaller distance value and its corresponding primitive parameters (including barycenter coordinates, primitive index, the address of primitive data in the cache, primitive attributes, etc.) are retained. After all nodes have been traversed, the primitive corresponding to the retained primitive parameters is the primitive closest to the ray.
[0060] Figure 2 A schematic diagram showing the structure of a prior art ray tracing accelerator.
[0061] like Figure 2 As shown, the existing ray tracing accelerator 100 has only one storage unit (storage unit 1001), which can only store one distance value and one primitive parameter. The ray tracing accelerator 100 uses storage unit 1001 to store the distance value and primitive parameters. The stored distance value is the minimum distance between the traversed primitives and the light source. The stored primitive parameters are the primitive parameters of the primitives closest to the light source. The GPU's general-purpose computing unit 110 can only access storage unit 1001 to obtain primitive parameters and distance values.
[0062] Figure 3 A schematic diagram illustrating the flow of a prior art ray tracing algorithm.
[0063] like Figure 3As shown, after the ray tracing algorithm starts, the ray tracing accelerator begins traversing the bounding box hierarchy (S100). When it reaches the next hop node, it determines whether the next hop node is a regular primitive (S110). If the next hop node is a regular primitive, the intersection processing between the primitive and the ray is performed inside the ray tracing accelerator (S120). Specifically, the primitive's primitive data is read based on its primitive parameters, and the distance value stored in the storage unit is read. The primitive data is used to perform intersection processing between the primitive and the ray. If they intersect, the distance value between the intersection point and the light source is calculated. Next, based on the result of the intersection processing, it is determined whether the ray hits the primitive (S130). If the calculated distance value is less than the distance value stored in the storage unit, it means that the ray hits a primitive, and this primitive becomes the primitive closest to the light source. The calculated distance value becomes the minimum distance between the traversed primitive and the light source. The distance value and primitive parameters stored in the storage unit need to be updated based on the primitive parameters of this primitive and the calculated distance value (S140). After that, other nodes in the bounding box hierarchy can continue to be traversed. If the calculated distance value is greater than or equal to the distance value stored in the storage unit, or if the primitive and the ray do not intersect, it means that the ray did not hit the primitive, and other nodes in the bounding box hierarchy can continue to be traversed.
[0064] If the next-hop node is not a regular primitive, it further checks whether the next-hop node is empty (S150). If the next-hop node is empty, it means the bounding box hierarchy traversal is complete, and ray tracing ends. If the next-hop node is not empty, it means the next-hop node is an irregular primitive, and the GPU's general-purpose computing unit is requested to complete the intersection processing of the irregular primitive and the ray (S160). The GPU's general-purpose computing unit responds to the request and performs intersection processing on the primitive and the ray. Specifically, if the next-hop node is an irregular primitive, the ray tracing accelerator first requests the GPU's general-purpose computing unit to access the storage unit to read the distance value and primitive parameters. After the GPU's general-purpose computing unit successfully reads the distance value and primitive parameters, it returns a response signal to the ray tracing accelerator. After receiving the response signal, the ray tracing accelerator stores the primitive parameters of the irregular primitive in the storage unit and requests the GPU's general-purpose computing unit to access the storage unit to read the primitive parameters of the irregular primitive. After the GPU's general-purpose computing unit successfully reads the primitive parameters of the irregular primitive, it begins the intersection processing of the irregular primitive and the ray. During intersection processing, the primitive's metadata is first read based on its primitive parameters. This metadata is then used to perform intersection processing on the primitive and the ray. If they intersect, the distance between the intersection point and the light source is calculated. Next, the result of the intersection processing determines whether the ray hits the primitive. If the distance calculated is less than the obtained distance, the ray hits the primitive, and the GPU's general-purpose computing unit returns the calculated distance and the second obtained primitive parameters to the ray tracing accelerator. If the calculated distance is greater than or equal to the obtained distance, or if the irregular primitive does not intersect with the ray, the ray does not hit the primitive, and the GPU's general-purpose computing unit returns the first obtained primitive parameters and the first obtained distance to the ray tracing accelerator. The ray tracing accelerator updates the distance and primitive parameters stored in the memory unit based on the distance and primitive parameters returned by the GPU's general-purpose computing unit (S170), and then continues traversing other nodes in the bounding box hierarchy.
[0065] This interaction mechanism ensures that, regardless of whether it is a ray tracing accelerator or a GPU general computing component, when comparing the calculated distance value after intersection processing, the object being compared is the minimum distance between the traversed primitive and the light source. Thus, at the end of the bounding box hierarchy traversal, the primitive closest to the light source can be obtained.
[0066] The drawbacks of this approach are as follows: Communication between the ray tracing accelerator and the GPU's general-purpose computing unit (GPCU) involves not only data dependencies but also instruction scheduling within the GPU. Data writing and intersection processing can only proceed after instructions are queued. Therefore, each communication between the ray tracing accelerator and the GPU's GPCU has a relatively long latency. From the moment the ray tracing accelerator requests the GPU's GPCU to access the memory unit to obtain distance values and primitive parameters until it receives the returned distance values and primitive parameters, the ray tracing accelerator is in a state of computational stagnation and waiting, which significantly reduces its performance. If the GPU's GPCU is executing complex instructions, it will also incur latency, further exacerbating the performance issues of the ray tracing accelerator and reducing the utilization of computing resources and primitive processing efficiency.
[0067] In view of this, the present disclosure proposes a primitive processing apparatus, method, graphics processor, and electronic device. The primitive processing apparatus of the embodiments of the present disclosure can work in parallel with the computing unit of the GPU, thereby improving the utilization of computing resources and ray tracing efficiency.
[0068] Figure 4 This illustrates an exemplary application scenario of a primitive processing apparatus according to embodiments of the present disclosure.
[0069] like Figure 4 As shown, the primitive processing device 200 can be located in the GPU as a ray tracing accelerator. The GPU's computing unit 210 consists of general-purpose computing components such as GPU cores. The GPU's cache 220 stores primitive data in the scene.
[0070] Users may want to use the GPU to render images of a scene from a specific viewpoint. The scene may include multiple objects, each composed of multiple primitives. These primitives may be regular or irregular. The scene may include at least one light source. Each light source emits at least one ray. To reduce rendering costs, ray tracing is performed on each ray to identify the primitive closest to the light source along the ray's propagation direction for rendering.
[0071] During the ray tracing process of each ray, the primitive processing device 200 can store the minimum distance value between the traversed primitive and the light source, as well as the primitive parameters corresponding to the distance value (including barycenter coordinates, primitive index, address of primitive data in the cache, primitive attributes, etc.).
[0072] The GPU can obtain the bounding box hierarchy based on the primitive distribution in the scene, and can instruct the primitive processing device 200 to start traversing the bounding box hierarchy at the beginning of ray tracing for each ray. After starting the traversal of the bounding box hierarchy, the primitive processing device 200 processes the nodes in the bounding box hierarchy sequentially. If the current node is a regular primitive, the primitive processing device 200 accesses the cache 220 to obtain the primitive's primitive data, and uses the primitive's primitive data to perform intersection processing with the ray. If the current node is an irregular primitive, the primitive processing device 200 requests the GPU's computing unit 210 to perform intersection processing with the primitive and the ray. When the GPU's computing unit 210 performs intersection processing with the primitive and the ray, it can access the cache 220 to obtain the primitive's primitive data, use the primitive's primitive data to perform intersection processing with the ray, and return the result of the intersection processing to the primitive processing device 200.
[0073] The primitive processing device 200 continuously updates the stored distance values and primitive parameters based on the results of the intersection processing. After the primitive processing device 200 has completed the update of the stored distance values and primitive parameters based on the intersection processing results of all primitives, the primitive closest to the light source in the direction of light propagation can be determined based on the primitive parameters stored in the primitive processing device 200.
[0074] Figure 5 A schematic diagram showing the structure of a primitive processing apparatus according to an embodiment of the present disclosure is provided.
[0075] like Figure 5 As shown, in one possible implementation, the primitive processing device includes at least one processing unit 2000, at least one first storage unit 2001, and a plurality of second storage units 2002.
[0076] Processing unit 2000 is used to perform ray tracing processing on rays, wherein:
[0077] When the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit 2002 that corresponds to the ray and is idle. Then, the next node is processed, and the GPU's computing unit is requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray.
[0078] When the first distance value meets the first preset condition, the distance value and primitive parameters stored in the first storage unit 2001 corresponding to the light are updated; the first distance value is obtained by the GPU's computing unit through intersection processing.
[0079] For example, a primitive processing apparatus may include at least one processing unit for performing ray tracing processing on rays. During ray tracing processing, the processing unit can independently perform intersection processing between regular primitives and rays, and can also interact with the computing unit of the GPU to request the GPU's computing unit to perform intersection processing between irregular primitives and rays. Figure 5 Only one processing unit 2000 is shown, but the specific number of processing units is not limited in the embodiments of this disclosure.
[0080] If there are multiple rays in the application scenario and the primitive processing device includes multiple primitives, the correspondence between the processing unit and the rays can be configured, and the processing unit is used to perform ray tracing processing on its corresponding ray.
[0081] The primitive processing device may further include at least one first storage unit, which can be configured to correspond to rays or processing units according to application requirements. When the first storage unit is configured to correspond to a processing unit, it also corresponds to the ray associated with that processing unit. The first storage unit stores distance values and primitive parameters, and its bit width can be equal to the sum of the bit width of the primitive parameters and the bit width of the distance value. Specifically, when the first storage unit corresponds to the i-th ray, the stored distance value is the minimum distance between the primitives traversed during the ray tracing of the i-th ray and the light source to which the i-th ray belongs; the stored primitive parameters are the primitive parameters of the primitives traversed during the ray tracing of the i-th ray that are closest to the light source to which the i-th ray belongs.
[0082] Each first storage cell can be an independent storage device, such as static random-access memory (SRAM). Alternatively, each first storage cell can be a storage region within an independent storage device. This disclosure does not limit the specific form of the first storage cell.
[0083] The primitive processing device may further include multiple second storage units. Depending on the application scenario, the second storage units can be configured to correspond to rays or processing units. When a second storage unit is configured to correspond to a processing unit, it also corresponds to the ray associated with that processing unit. The second storage unit stores primitive parameters, and its bit width can be equal to the bit width of the primitive parameters. Specifically, when the second storage unit corresponds to the i-th ray, the stored primitive parameters are the primitive parameters of the irregular primitives traversed during the ray tracing process of the i-th ray.
[0084] Each second memory cell can be an independent memory device, such as SRAM. Alternatively, each second memory cell can be a memory region within an independent memory device. This disclosure does not limit the specific form of the second memory cell.
[0085] Figure 5 Only one first storage unit 2001 and three second storage units 2002 are shown, but the specific number of first storage units and second storage units is not limited in the embodiments of this disclosure.
[0086] The following example illustrates the ray tracing process of the processing unit by performing ray tracing on the i-th ray (i is a positive integer).
[0087] The processing unit processes the bounding box hierarchy in sequence (see...). Figure 1 The system includes multiple nodes. When processing node c1, since node c1 is an irregular primitive, its primitive parameters are stored in a second storage unit corresponding to the i-th ray that is currently idle. Then, the system can continue processing the next node. Simultaneously, the system requests the GPU's computing unit to use the primitive parameters of node c1 to perform intersection processing between node c1 and the i-th ray. The GPU's computing unit can respond to the request by accessing the second storage unit to obtain the primitive parameters of node c1, and can perform intersection processing between node c1 and the i-th ray based on the obtained primitive parameters, returning the result of the intersection processing to the primitive processing device.
[0088] If, when processing node c1, all the second storage units corresponding to the i-th ray are not in an idle state, then we can wait until an idle second storage unit corresponding to the i-th ray appears, then store the primitive parameters of node c1, and at the same time request the GPU's computing unit to use the primitive parameters of node c1 to perform intersection processing between node c1 and the i-th ray.
[0089] When the GPU's computing unit performs intersection processing on node c1 and the i-th ray, it first determines whether node c1 and the i-th ray intersect. If they intersect, it calculates the distance value between the light source to which node c1 and the i-th ray belong, for example, a first distance value. The intersection processing result returned by the GPU's computing unit to the primitive processing device includes the first distance value.
[0090] The processing unit determines whether the first distance value meets the first preset condition. If the first distance value meets the first preset condition, node c1 is considered to be the closest among the traversed primitives to the light source of the i-th ray, and the distance value and primitive parameters stored in the first storage unit corresponding to the i-th ray are updated. If the first distance value does not meet the first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the i-th ray are not updated.
[0091] Figure 6 A schematic diagram illustrating the workflow of a processing unit according to an embodiment of the present disclosure is shown.
[0092] like Figure 6As shown, the processing unit begins ray tracing processing for the i-th ray, traversing the bounding box hierarchy (S200), and determines whether the current node is a regular primitive (S210). If the current node is a regular primitive, the processing unit performs intersection processing between the primitive and the i-th ray (S220). The execution method of S220 is the same as that of S120 in the prior art, and will not be described again here. Next, based on the result of the intersection processing, it is determined whether the i-th ray hits a primitive (S230). The execution method of S230 is the same as that of S130 in the prior art, and will not be described again here. If the i-th ray hits a primitive, the distance value and primitive parameters stored in the first storage unit corresponding to the i-th ray need to be updated according to the primitive parameters of the primitive and the calculated distance value (S240). After that, the traversal of other nodes in the bounding box hierarchy can continue. If the i-th ray does not hit a primitive, the traversal of other nodes in the bounding box hierarchy can continue.
[0093] If the current node is not a regular primitive, then check if the current node is empty (S250). If the current node is not empty, it means that the current node is an irregular primitive, and check if there is a free second storage unit corresponding to the i-th ray (S260). If there is a free second storage unit corresponding to the i-th ray, then store the primitive parameters of the irregular primitive into a free second storage unit corresponding to the i-th ray (S270), and then continue to traverse the bounding box hierarchy to process the next node. At the same time, request the GPU's computing unit to perform intersection processing on the irregular primitive and the i-th ray (S280).
[0094] In this case, when the primitive processing device traverses to an irregular primitive, after requesting the GPU computing unit to perform intersection processing on the irregular primitive and the i-th ray, it does not need to stop the calculation and wait for the GPU computing unit to return the result of the intersection processing. It can directly start processing the next node. While the GPU computing unit is processing the irregular primitive, the primitive processing device can process other nodes.
[0095] Figure 7 A schematic diagram illustrating a primitive processing apparatus and a GPU computing unit processing primitives according to embodiments of the present disclosure is shown.
[0096] like Figure 7 As shown, assuming the primitive processing device includes one processing unit, the application scenario requires ray tracing of a single ray. Both the processing unit 2000 and the GPU's computing unit 210 can process one primitive per cycle. The communication time between the processing unit 2000 and the GPU's computing unit 210 is negligible. The bounding box hierarchy is as follows: Figure 1 As shown. It is known that child nodes b0 and b1 both intersect with the ray.
[0097] In the first cycle T1, processing unit 2000 performs intersection processing on c0 (regular primitive) and the ray.
[0098] In the second cycle T2, the processing unit 2000 requests the GPU's computing unit 210 to perform intersection processing on c1 (irregular primitive) and the ray, and performs intersection processing on c2 (regular primitive) and the ray itself. The GPU's computing unit 210 performs intersection processing on c1 (irregular primitive) and the ray.
[0099] In the third cycle T3, the processing unit 2000 requests the GPU's computing unit 210 to perform intersection processing on c3 (irregular primitive) and the ray, and performs intersection processing on c4 (regular primitive) and the ray itself. The GPU's computing unit 210 performs intersection processing on c3 (irregular primitive) and the ray.
[0100] In the fourth cycle T4, the processing unit 2000 requests the GPU's computing unit 210 to perform intersection processing on c5 (irregular primitive) and the ray. The GPU's computing unit 210 performs intersection processing on c5 (irregular primitive) and the ray.
[0101] As can be seen, ignoring the communication time between the processing unit and the GPU's computing unit, the solution in this embodiment only requires 4 cycles to complete the process. Figure 1 The nodes shown.
[0102] Figure 8 This diagram illustrates the processing primitives of general computing components in existing ray tracing accelerators and GPUs.
[0103] like Figure 8 As shown, the application scenario requires ray tracing of a single ray. Both the ray tracing accelerator 100 and the GPU's general-purpose computing unit 110 can process one primitive per cycle. The communication time between the ray tracing accelerator 100 and the GPU's general-purpose computing unit 110 is negligible. The bounding box hierarchy is as follows: Figure 1 As shown. It is known that child nodes b0 and b1 both intersect with the ray.
[0104] In the first cycle T1, the ray tracing accelerator 100 performs intersection processing on c0 (the regular primitive) and the ray.
[0105] In the second cycle T2, the ray tracing accelerator 100 requests the GPU's general computing unit 110 to perform intersection processing on c1 (irregular primitive) and the ray, then pauses and waits. The GPU's computing unit 110 performs intersection processing on c1 (irregular primitive) and the ray.
[0106] In the third cycle T3, the ray tracing accelerator 100 resumes operation and performs intersection processing on c2 (regular primitive) and the ray.
[0107] In the fourth cycle T4, the ray tracing accelerator 100 requests the GPU's general computing unit 110 to perform intersection processing on c3 (irregular primitive) and the ray, then pauses and waits. The GPU's general computing unit 110 performs intersection processing on c3 (irregular primitive) and the ray.
[0108] In the 5th cycle T5, the ray tracing accelerator 100 resumes operation and performs intersection processing on c4 (regular primitive) and the ray.
[0109] In the 6th cycle T6, the ray tracing accelerator 100 requests the GPU's general computing unit 110 to perform intersection processing on c5 (irregular primitive) and the ray, then pauses and waits. The GPU's computing unit performs intersection processing on c5 (irregular primitive) and the ray.
[0110] It is evident that, neglecting the communication time between the ray tracing accelerator and the GPU's general computing components, the existing solution requires six cycles to complete the process. Figure 1 The nodes shown.
[0111] Compare Figure 7 and Figure 8 It can be seen that the primitive processing device of this embodiment operates continuously for 3 out of 4 cycles, while the existing ray tracing accelerator cannot operate continuously for 6 cycles, with 3 cycles in a state of stagnation. Furthermore, the primitive processing device of this embodiment operates in parallel with the GPU's computing unit for 2 cycles, while the existing ray tracing accelerator cannot operate in parallel with the GPU's general-purpose computing unit. Moreover, in practical applications, the communication time between the primitive processing device and the GPU's computing unit, and the communication time between the ray tracing accelerator and the GPU's general-purpose computing unit, cannot be ignored. The existing ray tracing accelerator transmits a larger amount of data and more data transfers between itself and the GPU's general-purpose computing unit, which inevitably further increases the duration of the ray tracing accelerator's stagnation.
[0112] Therefore, the primitive processing apparatus of the present disclosure improves the utilization of computing resources and the efficiency of primitive processing.
[0113] According to an embodiment of this disclosure, a primitive processing apparatus includes at least one processing unit, at least one first storage unit, and a plurality of second storage units. The processing unit is used to perform ray tracing processing on rays, wherein: when the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit corresponding to the ray and which is idle, and then the next node is processed. The processing unit requests the GPU's computing unit to perform intersection processing on the irregular primitive and the ray using the primitive parameters of the irregular primitive; when the first distance value meets a first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit performing intersection processing. In this case, when the node processed by the primitive processing apparatus is an irregular primitive, after requesting the GPU's computing unit to perform intersection processing on the irregular primitive and the ray, there is no need to stop the calculation and wait for the GPU's computing unit to return the distance value and primitive parameters. The processing unit can directly start processing the next node, improving the utilization rate of computing resources. While the GPU's computing unit is processing the irregular primitive, the primitive processing apparatus can process other nodes, improving ray tracing efficiency.
[0114] In one possible implementation, when there are multiple processing units and multiple rays, different processing units correspond to different rays, and different processing units perform ray tracing processing in parallel.
[0115] For example, when there are multiple processing units and multiple rays, the multiple processing units of the primitive processing device can work in parallel, each performing ray tracing processing on its corresponding ray. In practical applications, if the total number of processing units in the primitive processing device is greater than the total number of rays, the same number of processing units can be selectively activated based on the total number of rays. In this case, the primitive processing device is more efficient.
[0116] In one possible implementation, regular primitives are primitives that can be simplified into fixed mathematical formulas through mathematical modeling; irregular primitives are primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling.
[0117] Primitives that can be simplified into fixed mathematical formulas through mathematical modeling include, for example, triangular primitives, quadrilateral primitives, circular primitives, and elliptical primitives. Primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling include user-defined shape primitives and transparent primitives. Those skilled in the art should understand that the classification criteria for regular and irregular primitives should not be limited to the examples mentioned above. As long as the hardware computing resource cost supporting the intersection processing of a certain type of primitive with rays does not exceed a preset threshold, it can be classified as a regular primitive; otherwise, it can be classified as an irregular primitive.
[0118] In one possible implementation, the primitive parameters include one or more of the following: barycenter coordinates, primitive index, address of primitive data in the cache, and primitive attributes. The barycenter coordinates can be obtained after intersection processing. The primitive index and the address of primitive data in the cache can be used to access the cache to retrieve primitive data, and the primitive attributes can be used to distinguish whether a primitive is a regular or irregular primitive.
[0119] Those skilled in the art should understand that in practical applications, the primitive parameters may include more or less content, as long as the primitive data can be obtained from the primitive parameters and it is possible to distinguish whether the primitive is a regular primitive or an irregular primitive. The embodiments of this disclosure do not limit the specific content of the primitive parameters.
[0120] Figure 9 A schematic diagram showing the structure of a primitive processing apparatus including N first storage units and N groups of second storage units according to an embodiment of the present disclosure is provided.
[0121] like Figure 9 As shown, in one possible implementation, the primitive processing device 200 includes N first storage units 2001 and N groups of second storage units 2002, each group of second storage units 2002 including M second storage units 2002, where N>0 and M>1;
[0122] When the ray is the i-th ray to be tracked, it corresponds to the i-th first storage unit 2001 and the i-th group of second storage units 2002, where N≥i>0.
[0123] For example, when there are multiple processing units and multiple rays need to be ray-traced, the rays can be assigned to multiple processing units, so that each ray corresponds to one processing unit, and each processing unit is used to perform ray tracing on its corresponding ray.
[0124] The primitive processing device may include N first storage units and N groups of second storage units. When N is greater than or equal to the total number of rays, the i-th ray automatically corresponds to the i-th first storage unit and the i-th group of second storage units. That is, each ray exclusively occupies one first storage unit and one group of second storage units. There is a known correspondence between rays and the first and second storage units, and the correspondence between processing units and the first and second storage units is determined based on the allocation of rays to the processing units.
[0125] Each group of second storage units comprises M second storage units, where M > 1. Figure 9 In the example, M=3. Therefore, even if N=1, the primitive processing device includes multiple second storage units.
[0126] When the i-th ray corresponds to the j-th processing unit, the j-th processing unit performs ray tracing on the i-th ray. Since the i-th ray corresponds to the i-th group of second storage units and the i-th first storage unit, when the current node is an irregular primitive, the j-th processing unit can store the primitive parameters of the irregular primitive into an empty second storage unit in the i-th group of second storage units, and then continue processing the next node. It also requests the GPU's computing unit to obtain the primitive parameters stored in the second storage unit and perform intersection processing on the irregular primitive and the i-th ray.
[0127] Since each ray has a corresponding first storage unit and a set of second storage units, the primitive processing device can ensure that there are no read / write conflicts when L processing units simultaneously read and write to the first and second storage units. Furthermore, after each processing unit completes the ray tracing processing of one ray, it can directly begin the ray tracing processing of the next ray, enabling the primitive processing device to continuously perform ray tracing processing of multiple rays in a pipeline manner.
[0128] Assuming N is an integer multiple of L, if N rays are evenly distributed among L processing units, then Figure 9 The primitive processing device shown takes approximately N / L times longer to complete ray tracing of N rays than a single processing unit takes to complete ray tracing of one ray.
[0129] Figure 10 A schematic diagram showing the structure of a primitive processing apparatus including L first storage units and L groups of second storage units according to an embodiment of the present disclosure is provided.
[0130] like Figure 10 As shown, in one possible implementation, the primitive processing device 200 includes L processing units 2000, L first storage units 2001, and L groups of second storage units 2002, each group of second storage units 2002 including M second storage units 2002, where L>0 and M>1.
[0131] The j-th processing unit 2000 corresponds to the j-th first storage unit 2001 and the j-th group of second storage units 2002, where L≥j>0;
[0132] When the ray is the L×k+jth ray to be tracked, it corresponds to the jth processing unit 2000, where k≥0 and is an integer.
[0133] For example, a primitive processing device may include L processing units, L first storage units, and L groups of second storage units. The j-th processing unit automatically corresponds to the j-th first storage unit and the j-th group of second storage units.
[0134] When there are N rays requiring ray tracing, these N rays are allocated to L processing units, so that each ray corresponds to one processing unit, and each processing unit performs ray tracing on its corresponding ray. For example, if the ray is the L×k+j-th ray to be traced, it corresponds to the j-th processing unit. That is, there is a known correspondence between processing units and the first and second storage units; the correspondence between rays and the first and second storage units is determined based on the ray allocation to processing units. Each group of second storage units includes M second storage units, where M>1. Figure 10 In the example, M=3. Therefore, even if L=1, the primitive processing device includes multiple second storage units.
[0135] When the i-th ray corresponds to the j-th processing unit, the j-th processing unit performs ray tracing on the i-th ray. Since the j-th first storage unit and the j-th group of second storage units also correspond to the i-th ray at this time, when the current node is an irregular primitive, the j-th processing unit can store the primitive parameters of the irregular primitive into an empty second storage unit in the j-th group of second storage units, and then continue processing the next node. It also requests the GPU's computing unit to obtain the primitive parameters stored in the second storage unit and perform intersection processing on the irregular primitive and the i-th ray.
[0136] Since each processing unit has a corresponding first storage unit and a set of second storage units, the primitive processing device can guarantee that there are no read / write conflicts when L processing units simultaneously read and write to the first and second storage units. Furthermore, the number of first storage units and the number of sets of second storage units can be less than N. Even when N is large and the chip area is limited, the hardware storage resources required by the primitive processing device can be kept within a small range, saving on hardware storage space overhead.
[0137] In one possible implementation, when the j-th processing unit corresponds to multiple rays, it completes the ray tracing processing of the current ray and waits for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit. Then, it clears the j-th first storage unit and performs ray tracing processing on the next ray corresponding to itself.
[0138] For example, since the j-th processing unit automatically corresponds to the j-th first storage unit and the j-th group of second storage units, and the j-th processing unit may also correspond to multiple rays, this means that the j-th processing unit uses the same (j-th) first storage unit and the same (j-th group of second storage units) for ray tracing of its corresponding multiple rays. Based on this, the j-th processing unit can clear the j-th first storage unit after completing the ray tracing of the current ray and waiting for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit, and then perform ray tracing of its corresponding next ray. This method avoids the incorrect use of primitive parameters and distance values obtained from the ray tracing of the previous ray when performing ray tracing of the subsequent ray, ensuring the accuracy of the ray tracing results.
[0139] Assuming N is an integer multiple of L, if N rays are evenly distributed among L processing units, then Figure 10 The time taken for the primitive processing device shown to complete ray tracing processing of N rays is approximately N / L times the sum of the time taken for a single processing unit to complete ray tracing processing of one ray and the time interval between a single processing unit completing ray tracing processing of two rays.
[0140] In one example, the primitive processing device is located on the chip. To reduce the chip area, at least two first memory cells can be arranged on the chip in a prior art 3D stacking manner. Similarly, at least two second memory cells can be arranged on the chip in a prior art 3D stacking manner.
[0141] For example, the bit width of the first storage cell is the sum of the bit width of the primitive parameter and the bit width of the distance value. N first storage cells are stacked into N / L layers, and each layer includes L first storage cells.
[0142] The bit width of the second storage cell is the bit width of the primitive parameter. N groups of second storage cells are stacked into N / L layers, and each layer includes L groups of second storage cells.
[0143] It should be understood that the number of layers after the first storage unit is stacked and the number of first storage units included in each layer can be set according to the application scenario requirements, and the number of layers after the second storage unit is stacked and the number of groups of second storage units included in each layer can be set according to the application scenario requirements.
[0144] The values of L and M can be configured according to the application scenario requirements. For example, to increase the degree of parallelism, the value of L can be increased; to reduce the area overhead of hardware storage resources, the value of M can be decreased; if there are many irregular primitives and it is desired to reduce waiting time, the value of M can be increased. This disclosure does not limit the specific values of L, N, and M.
[0145] The following describes an exemplary method for processing rule primitives by the processing unit.
[0146] In one possible implementation, the processing unit is further configured to perform intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive when the current node is a regular primitive.
[0147] When the second distance value obtained from the intersection process satisfies the second preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated, and then the next node is processed.
[0148] As mentioned above, when the current node is a regular primitive, the intersection process between this primitive and the i-th ray can be completed within the processing unit (see above and...). Figure 6 (See the relevant description of step S220 in the text). In one example, step S220 includes: reading the metadata of the regular primitive according to the primitive parameters of the regular primitive; reading the distance value stored in the first storage unit corresponding to the i-th ray; determining whether the regular primitive intersects with the i-th ray based on the read metadata; and calculating the distance value (second distance value) between the regular primitive and the light source to which the i-th ray belongs. This process can be implemented based on existing technology and will not be described in detail here.
[0149] The processing unit can determine whether the i-th ray hits the primitive based on the result of the intersection processing (see above and...). Figure 6 (See the relevant description of step S230 in the text). In one example, step S230 includes: the processing unit determining whether the second distance value satisfies the second preset condition. When the second distance value satisfies the second preset condition, it is considered that the regular primitive is the one among the traversed primitives that is closest to the light source to which the i-th ray belongs (i.e., the i-th ray hits the primitive).
[0150] When the i-th ray hits a primitive, the processing unit can update the distance value and primitive parameters stored in the first storage unit corresponding to the i-th ray based on the primitive parameters of the primitive and the calculated distance value (i.e., the second distance value). (See above and...) Figure 6 (See the relevant description of step S240 in the text). If the second distance value does not meet the second preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the i-th ray will not be updated.
[0151] In one possible implementation, the second preset condition is: the second distance value is less than the distance value stored in the first storage unit corresponding to the light ray;
[0152] The processing unit is configured to, when the second distance value meets the second preset condition, use the second distance value to overwrite the distance value stored in the first storage unit corresponding to the ray, and use the primitive parameters corresponding to the regular primitives to overwrite the primitive parameters stored in the first storage unit corresponding to the ray.
[0153] For example, the second preset condition could be that the second distance value is less than the distance value stored in the first storage unit corresponding to the light.
[0154] When a regular primitive intersects with the i-th ray and the second distance value is less than the distance value stored in the first storage unit corresponding to the i-th ray, it indicates that the i-th ray hits the regular primitive, and the regular primitive is the primitive closest to the i-th ray. Therefore, step S240 may include: the processing unit uses the second distance value to cover the distance value stored in the first storage unit corresponding to the i-th ray, and uses the primitive parameters of the regular primitive to cover the primitive parameters stored in the first storage unit corresponding to the i-th ray, ensuring that the first storage unit corresponding to the i-th ray always stores the minimum distance value between the traversed primitive and the light source, and the primitive parameters of the traversed primitive closest to the light source.
[0155] The following describes an exemplary way in which the computing unit of the GPU operates, and an exemplary way in which the processing unit updates the first storage unit.
[0156] In one possible implementation, the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the light ray;
[0157] The processing unit is configured to, when the first distance value meets the first preset condition, use the first distance value to cover the distance value stored in the first storage unit corresponding to the light, and use the primitive parameters of the irregular primitive to cover the primitive parameters stored in the first storage unit corresponding to the light.
[0158] For example, in response to a request, the GPU's computing unit reads the primitive parameters of the irregular primitive from the second storage unit of the primitive processing device and performs intersection processing between the ray and the irregular primitive. Specifically, this includes reading the primitive data of the irregular primitive based on its primitive parameters, determining whether the irregular primitive intersects with the ray based on the primitive data, and if the irregular primitive intersects with the ray, calculating the distance value (i.e., the first distance value) between the irregular primitive and the light source to which the ray belongs.
[0159] While the GPU's computation unit performs intersection processing on irregular primitives and rays, the processing unit is also processing other primitives. As mentioned above, the processing unit can process regular primitives independently. This means that after the processing unit requests the GPU's computation unit to perform intersection processing on the irregular primitives and rays based on the primitive parameters of the irregular primitives, before the GPU's computation unit returns the first distance value, the distance value stored in the first storage unit corresponding to the ray may have already been updated by the processing unit to a smaller distance value. If the first distance value is used to update the distance value in the first storage unit corresponding to the ray at this time, it will cause the first storage unit to store an incorrect distance value.
[0160] Therefore, to ensure that the first storage unit corresponding to the ray always stores the minimum distance value between the traversed primitives and the light source, after receiving the first distance value returned by the GPU's computing unit, the processing unit can compare the distance value stored in the first storage unit corresponding to the ray with the first distance value returned by the GPU's computing unit. If the first distance value is less than the distance value stored in the first storage unit corresponding to the ray (satisfying the first preset condition), it is determined that the irregular primitive is the traversed primitive closest to the ray. The primitive parameters and distance value in the first storage unit corresponding to the ray need to be updated, and the first distance value is used to overwrite the distance value stored in the first storage unit corresponding to the ray. The primitive parameters of the irregular primitive are found from the second storage unit, and the primitive parameters of the irregular primitive are used to overwrite the primitive parameters stored in the first storage unit corresponding to the ray. The GPU's computing unit does not need to transmit the primitive parameters to the processing unit, nor does it need to participate in the primitive parameter update process.
[0161] For example, suppose the j-th processing unit is used to perform ray tracing processing for the i-th ray, and the bounding box hierarchy is as follows: Figure 1 As shown. In the first cycle, after processing c0 (a regular primitive), the processing unit obtains a distance value of 10 and stores the distance value 10 and the primitive parameters of c0 into the first storage unit corresponding to the i-th ray. In the second cycle, after processing c2 (a regular primitive), the j-th processing unit obtains a distance value of 3 and updates the distance value stored in the first storage unit corresponding to the i-th ray to 3 and the stored primitive parameters to the primitive parameters of c2. After this, the j-th processing unit receives a distance value of 5 obtained from the GPU's computing unit processing c1 (an irregular primitive). By comparing the distance values, it finds that 5 > 3, and will not use the primitive parameters of c1 to overwrite the primitive parameters of c2 stored in the first storage unit corresponding to the i-th ray, nor will it use the distance value 5 to overwrite the distance value 3.
[0162] In this way, it can be ensured that the first storage unit always stores the minimum distance value between the traversed primitives and the light source to which the ray belongs. Furthermore, the GPU's computing unit only needs to return the distance value, without needing to return the primitive parameters, which reduces the data transfer cost between the GPU's computing unit and the primitive processing device.
[0163] In one example, the GPU's computing unit can directly return the first distance value to the processing unit after calculating it.
[0164] Since the processing unit does not directly update the first storage unit after receiving the first distance value, but instead first compares the distance values and updates the first storage unit only when the first preset condition is met, the GPU's computing unit does not need to obtain the distance value from the primitive processing device. After calculating the first distance value, it does not need to compare the distance values and can directly return the first distance value to the processing unit. In this case, the GPU's computing unit does not need to obtain the distance value from the first storage unit, reducing the data transmission cost between the GPU's computing unit and the primitive processing device.
[0165] In one example, the GPU's computing unit can record the minimum distance value it calculates. After calculating the first distance value, it compares the first distance value with the minimum distance value it calculates. If the first distance value is smaller, it returns the first distance value to the processing unit; otherwise, it notifies the processing unit that the primitive parameters used to calculate the first distance value are invalid.
[0166] If the first distance value is greater than the minimum distance value calculated by the GPU's computing unit, it means that the first distance value must be greater than the distance value stored in the first storage unit corresponding to the ray at this time, and there is no need to update the first storage unit corresponding to the ray. Therefore, after calculating the first distance value, the GPU's computing unit can compare the first distance value with its own calculated minimum distance value. If the first distance value is smaller, it returns the first distance value to the processing unit; otherwise, it notifies the processing unit that the primitive parameters used to calculate the first distance value are invalid. In this case, the data transmission cost between the GPU's computing unit and the primitive processing device is further reduced.
[0167] In one example, the GPU's computing unit, in response to a request, also retrieves a distance value from a first storage unit corresponding to the ray. After calculating the first distance value, it compares the first distance value with the retrieved distance value. If the first distance value is smaller, it returns the first distance value to the processing unit; otherwise, it notifies the processing unit that the primitive parameters used to calculate the first distance value are invalid.
[0168] If the first distance value is greater than the acquired distance value, it means that the first storage unit corresponding to the ray does not need to be updated. Therefore, after calculating the first distance value, the GPU's computing unit can compare the first distance value with the acquired distance value. If the first distance value is smaller, it returns the first distance value to the processing unit; otherwise, it notifies the processing unit that the primitive parameters used to calculate the first distance value are invalid. In this case, the data transfer cost between the GPU's computing unit and the primitive processing device is further reduced.
[0169] In one possible implementation, the processing unit is further configured to, when the first distance value satisfies the first preset condition, update the primitive parameters stored in the first storage unit corresponding to the ray, and then clear the second storage unit corresponding to the ray and storing irregular primitive parameters.
[0170] When the first distance value does not meet the first preset condition, the second storage unit corresponding to the light ray and storing the primitive parameters of the irregular primitive is cleared.
[0171] Taking the ray tracing process of the i-th ray as an example, assuming the processing unit stores the primitive parameters of irregular primitive 1 in the second storage unit corresponding to the i-th ray, the GPU's computing unit uses the primitive parameters of irregular primitive 1 to complete the intersection processing between irregular primitive 1 and the i-th ray, and returns the first distance value to the processing unit. The processing unit will determine whether the first distance value meets the first preset condition. If the first distance value meets the first preset condition, it will obtain the primitive parameters of irregular primitive 1 from the second storage unit corresponding to the i-th ray, and use the primitive parameters of irregular primitive 1 to overwrite the primitive parameters stored in the first storage unit corresponding to the i-th ray. Afterwards, the primitive parameters of irregular primitive 1 will not be used in the ray tracing process of the i-th ray, and the second storage unit corresponding to the i-th ray and storing the primitive parameters of irregular primitive 1 can be cleared. When the first distance value does not meet the first preset condition, it indicates that the first distance value is invalid. The primitive parameters stored in the first storage unit corresponding to the i-th ray do not need to be updated. Instead, the second storage unit corresponding to the i-th ray and storing the primitive parameters of irregular primitive 1 can be cleared directly. In this way, useless data in the second storage unit can be cleared in a timely manner, increasing the number of idle second storage units, reducing the waiting time of the processing unit nodes, and improving ray tracing efficiency.
[0172] If the processing unit receives a notification from the GPU's computing unit indicating that the primitive parameters used to calculate the first distance value are invalid, the processing unit can directly clear the second storage unit containing the invalid primitive parameters based on the notification.
[0173] In one possible implementation, the processing unit is further configured to, after completing the processing of all nodes included in the bounding box hierarchy and confirming that all second storage units corresponding to rays have been cleared, notify the GPU's computing unit to obtain the primitive parameters and distance values stored in the first storage unit corresponding to rays, or report the primitive parameters and distance values stored in the first storage unit corresponding to rays to the GPU's computing unit.
[0174] For example, if there are still unemptied second storage units in the second storage unit corresponding to the i-th ray, it indicates that there are still irregular primitives that have not been processed. Therefore, as... Figure 6As shown, during the ray tracing process of the i-th ray, after determining that the current node is empty, the processing unit can check whether all the second storage units corresponding to the i-th ray have been cleared (S290). Once all the second storage units corresponding to the i-th ray have been cleared, the ray tracing process for the i-th ray is confirmed to be complete. At this time, an end signal can be output to notify the GPU's computing unit to retrieve the primitive parameters and distance values stored in the first storage unit corresponding to the ray. The GPU's computing unit responds to the end signal by retrieving the primitive parameters and distance values stored in the first storage unit corresponding to the i-th ray. Alternatively, the processing unit can report the primitive parameters and distance values stored in the first storage unit corresponding to the ray to the GPU's computing unit.
[0175] In this case, it can be guaranteed that the primitive parameters and distance values obtained by the GPU's computing unit are indeed the minimum distance between the traversed primitives and the light source, and the primitive parameters of the primitive closest to the light source.
[0176] Figure 11 A schematic diagram showing the structure of a processing unit according to an embodiment of the present disclosure is provided.
[0177] like Figure 11 As shown, the processing unit 2000 may include a front-end and back-end interaction subunit 300, a traversal subunit 301, and a calculation subunit 302.
[0178] The front-end and back-end interaction subunit 300 is used to receive a first distance value and, when the first distance value meets a first preset condition, update the distance value and primitive parameters stored in the first storage unit 2001 corresponding to the light ray.
[0179] The calculation subunit 302 is used to perform intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive; and outputs the second distance value to the traversal subunit 301;
[0180] The traversal subunit 301 is used to update the distance value and primitive parameters stored in the first storage unit 2001 corresponding to the light when the second distance value meets the second preset condition.
[0181] The front-end and back-end interaction subunit is responsible for interacting with the GPU computing unit 210, the first storage unit 2001, and the second storage unit 2002.
[0182] The traversal subunit is responsible for traversing the bounding box hierarchy. If a regular primitive is encountered, it requests the computation subunit to perform intersection processing between the regular primitive and the target ray. If an irregular primitive is encountered, it notifies the front-end / back-end interaction subunit, which then requests the GPU's computation unit to perform intersection processing between the irregular primitive and the corresponding ray.
[0183] The calculation subunit uses the primitive parameters of the regular primitive to perform intersection processing on the regular primitive and the ray; and outputs the second distance value obtained from the intersection processing to the traversal subunit. The traversal subunit is responsible for updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value meets the second preset condition.
[0184] After the GPU's computing unit completes the intersection process, it can return the first distance value to the front-end and back-end interaction subunit. The front-end and back-end interaction subunit receives the first distance value and, when the first distance value meets the first preset condition, updates the distance value and primitive parameters stored in the first storage unit corresponding to the ray.
[0185] The following is combined Figure 11 An example is given where the primitive processing apparatus includes two second storage units corresponding to the i-th ray, and the processing unit and the computing unit of the GPU work together to implement ray tracing of the i-th ray.
[0186] In this example, the GPU's computing unit sends ray data and a "start" command to the processing unit to instruct the processing unit to begin traversing the bounding box hierarchy. The front-end and back-end interaction subunit in the processing unit distributes the "start" command to the traversal subunit. The traversal subunit obtains the address of the root node of the bounding box hierarchy and sends the obtained address to the computing subunit. The computing subunit performs intersection processing between the root node and the i-th ray based on the obtained address.
[0187] Assuming the intersection of the root node and the ray results in the i-th ray hitting the root node, the traversal sub-unit starts traversing the root node a0 and obtains the address of its child node b0. The obtained address is sent to the calculation sub-unit, which then performs the intersection of the child node b0 and the i-th ray based on the obtained address.
[0188] Assuming the intersection result of child node b0 and the i-th ray is that the i-th ray hits child node b0, the traversal sub-unit starts traversing child node b0 and obtains the primitive parameters of the leaf node c0 (regular primitive). The obtained primitive parameters are sent to the calculation sub-unit, which performs the intersection processing of c0 and the i-th ray based on the obtained primitive parameters.
[0189] Assuming the intersection of ray c0 and the i-th ray results in the i-th ray hitting c0, the traversal subunit stores the primitive parameters of c0 and the distance value (second distance value) between c0 and the light source into the first storage unit corresponding to the i-th ray. Simultaneously, the traversal subunit obtains the next-hop node as c1 (an irregular primitive). At this point, both second storage units corresponding to the i-th ray are idle. The traversal subunit writes the primitive parameters of c1 into one of the second storage units, then continues traversing the root node a0, obtaining the address of child node b1, and sending the obtained address to the calculation subunit. The calculation subunit performs the intersection processing between child node b1 and the i-th ray based on the obtained address. At this point, the number of idle second storage units corresponding to the i-th ray decreases to 1. Simultaneously, the traversal subunit initiates a data reporting request to the front-end and back-end interaction subunits. The front-end and back-end interaction subunit then sends a data reporting request to the GPU's computing unit, and reads the distance value from the first storage unit corresponding to the i-th ray and the primitive parameters of irregular primitive 1 from the second storage unit corresponding to the i-th ray.
[0190] Assuming the intersection of child node b1 and the i-th ray results in the i-th ray hitting child node b1, the traversal sub-unit begins traversing child node b1 and obtains the primitive parameters of c2 (a regular primitive). These primitive parameters are then sent to the computation sub-unit, which performs the intersection of c2 and the i-th ray based on these parameters. Simultaneously, the GPU's computation unit responds to the data reporting request by obtaining the primitive parameters and distance value of c1 from the front-end / back-end interaction sub-unit. The GPU's computation unit then performs the intersection of c1 and the i-th ray. Assuming the intersection of c1 and the i-th ray results in the i-th ray hitting c1 (the i-th ray intersects c1, and the calculated distance between the light source and c1 (the first distance value) is less than the obtained distance value), the GPU's computation unit returns the calculated distance value to the front-end / back-end interaction sub-unit. The front-end and back-end interaction subunits compare the received distance value with the distance value stored in the first storage unit corresponding to the i-th ray. If the received distance value is smaller, the front-end and back-end interaction subunits write the received distance value into the distance value field of the first storage unit corresponding to the i-th ray, write the primitive parameter of c1 into the primitive parameter field of the first storage unit corresponding to the i-th ray, and clear the primitive parameter of c1 stored in the second storage unit corresponding to the i-th ray. At this time, the number of idle second storage units corresponding to the i-th ray increases to 2.
[0191] Assuming the intersection of c2 and the i-th ray results in the i-th ray not hitting c2, the traversal subunit continues to traverse child node b1, obtaining the primitive parameters of c3 (irregular primitive). After writing the primitive parameters of c3 into a free second storage unit corresponding to the i-th ray, the traversal subunit continues to obtain the primitive parameters of c4 (regular primitive) and sends them to the computation subunit. The computation subunit performs intersection processing between c4 and the i-th ray based on the obtained primitive parameters. At this point, the number of free second storage units corresponding to the i-th ray decreases to 1. Simultaneously, the traversal subunit initiates a data reporting request to the front-end / back-end interaction subunit. The front-end / back-end interaction subunit then initiates a data reporting request to the GPU's computation unit, reading the distance value from the first storage unit corresponding to the i-th ray and the primitive parameters of c3 from the second storage unit corresponding to the i-th ray.
[0192] Assuming the intersection of c4 and the i-th ray results in the i-th ray hitting c4, the traversal submodule stores the primitive parameters of c4 and the distance value (second distance value) between c4 and the light source into the first storage unit corresponding to the i-th ray. Simultaneously, the traversal submodule obtains the next-hop node as c5 (irregular primitive). At this point, the number of free second storage units corresponding to the i-th ray is 1. After writing the primitive parameters of c5 into the free second storage unit corresponding to the i-th ray, the traversal submodule finds that the next-hop node is empty and notifies the front-end / back-end interaction subunit that the traversal is complete. At this point, the number of free second storage units corresponding to the i-th ray is 0, and the front-end / back-end interaction subunit enters a waiting state. Meanwhile, the GPU's computing unit responds to the data reporting request and obtains the primitive parameters and distance value of c3 from the front-end / back-end interaction subunit. The GPU's computing unit then performs the intersection of c3 and the i-th ray. The GPU's computing unit returns the intersection result of c3 and the i-th ray to the front-end / back-end interaction subunit.
[0193] Assuming the intersection of c3 and the i-th ray results in the i-th ray not hitting c3, the front-end / back-end interaction subunit clears the primitive parameters of c3 stored in the second storage unit corresponding to the i-th ray, and the number of idle second storage units corresponding to the i-th ray increases to 1. Subsequently, the front-end / back-end interaction subunit initiates a data reporting request to the GPU's computing unit, reading the distance value from the first storage unit corresponding to the i-th ray and the primitive parameters of c5 from the second storage unit corresponding to the i-th ray. In response to the data reporting request, the GPU's computing unit obtains the primitive parameters and distance value of c5 from the front-end / back-end interaction subunit. The GPU's computing unit then performs the intersection of c5 and the i-th ray. The GPU's computing unit returns the intersection result of c5 and the i-th ray to the front-end / back-end interaction subunit.
[0194] Assuming the intersection result of c5 and the i-th ray is that the i-th ray hits c5, the intersection result of c5 and the i-th ray includes the calculated distance value (first distance value). The front-end and back-end interaction subunit compares the received distance value with the distance value stored in the first storage unit corresponding to the i-th ray. If the received distance value is smaller, the front-end and back-end interaction subunit writes the received distance value into the distance value field of the first storage unit corresponding to the i-th ray, writes the primitive parameters of c5 into the primitive parameter field of the first storage unit corresponding to the i-th ray, and clears the primitive parameters of c5 stored in the second storage unit corresponding to the i-th ray.
[0195] At this point, the number of available second storage units corresponding to the i-th ray increases to 2. The front-end and back-end interaction subunit reads the primitive parameters from the first storage unit corresponding to the i-th ray and reports them, along with the end signal, to the GPU's computing unit. Based on the primitive parameters, the GPU computing unit determines that c5 is the primitive closest to the light source of the i-th ray. Thus, the ray tracing processing for the i-th ray is complete.
[0196] This disclosure also proposes a graphics processor, including the primitive processing apparatus described above. For example... Figure 4 As shown, the graphics processor may also include a GPU computing unit and cache, etc. This disclosure does not limit the specific structure of the graphics processor.
[0197] This disclosure also proposes an electronic device including the graphics processor described above. The electronic device may be a terminal device or a server; this disclosure does not limit the specific type of electronic device.
[0198] This disclosure also proposes a primitive processing method. Figure 12 A schematic diagram illustrating the flow of a primitive processing method according to an embodiment of the present disclosure is shown.
[0199] like Figure 12 As shown, in one possible implementation, the method is applied to a primitive processing apparatus, the apparatus including at least one processing unit, at least one first storage unit, and a plurality of second storage units;
[0200] The method includes: performing ray tracing processing on the light using a processing unit, wherein:
[0201] When the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit that corresponds to the ray and is idle (step S10), and the next node is processed (step S20). The GPU's computing unit is then requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray (step S30).
[0202] When the first distance value meets the first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit through intersection processing (step S40).
[0203] In one possible implementation, the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the ray; when the first distance value satisfies the first preset condition, updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray includes: when the first distance value satisfies the first preset condition, using the first distance value to cover the distance value stored in the first storage unit corresponding to the ray, and using the primitive parameters of the irregular primitive to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0204] In one possible implementation, the method further includes: when the first distance value satisfies the first preset condition, updating the primitive parameters stored in the first storage unit corresponding to the ray, and then using the processing unit to clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive; when the first distance value does not satisfy the first preset condition, using the processing unit to clear the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive.
[0205] In one possible implementation, the method further includes: after the processing unit completes the processing of all nodes included in the bounding box hierarchy and confirms that all second storage units corresponding to the ray have been cleared, notifying the GPU's computing unit to obtain the primitive parameters and distance values stored in the first storage unit corresponding to the ray, or reporting the primitive parameters and distance values stored in the first storage unit corresponding to the ray to the GPU's computing unit.
[0206] In one possible implementation, the method further includes: when the current node is a regular primitive, the processing unit uses the primitive parameters of the regular primitive to perform intersection processing on the regular primitive and the ray; when the second distance value obtained by the intersection processing satisfies the second preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated, and then the next node is processed.
[0207] In one possible implementation, the second preset condition is: the second distance value is less than the distance value stored in the first storage unit corresponding to the ray; when the second distance value obtained by the intersection process satisfies the second preset condition, updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray includes: when the second distance value satisfies the second preset condition, using the second distance value to cover the distance value stored in the first storage unit corresponding to the ray, and using the primitive parameters corresponding to the regular primitive to cover the primitive parameters stored in the first storage unit corresponding to the ray.
[0208] In one possible implementation, the processing unit includes a front-end / back-end interaction subunit, a traversal subunit, and a calculation subunit. The step of updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the first distance value satisfies a first preset condition includes: the front-end / back-end interaction subunit receives the first distance value and updates the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the first distance value satisfies the first preset condition; the step of performing intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive includes: the calculation subunit performs intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive and outputs the second distance value to the traversal subunit; the step of updating the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value obtained from the intersection processing satisfies a second preset condition includes: the traversal subunit updates the distance value and primitive parameters stored in the first storage unit corresponding to the ray when the second distance value satisfies the second preset condition.
[0209] In one possible implementation, the device includes N first storage units and N groups of second storage units, each group of second storage units including M second storage units, where N>0 and M>1; when the light is the i-th light to be tracked, it corresponds to the i-th first storage unit and the i-th group of second storage units, where N≥i>0.
[0210] In one possible implementation, the device includes L processing units, L first storage units, and L groups of second storage units, each group of second storage units including M second storage units, where L>0 and M>1; the j-th processing unit corresponds to the j-th first storage unit and the j-th group of second storage units, where L≥j>0; when the light ray is the L×k+j-th light ray to be tracked, it corresponds to the j-th processing unit, where k≥0 and is an integer.
[0211] In one possible implementation, the method further includes: when the j-th processing unit corresponds to multiple rays, after completing the ray tracing processing of the current ray and waiting for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit, clearing the j-th first storage unit and performing ray tracing processing on the next ray corresponding to itself.
[0212] In one possible implementation, when there are multiple processing units and multiple rays, different processing units correspond to different rays, and different processing units perform ray tracing processing in parallel.
[0213] In one possible implementation, the regular primitives are primitives that can be simplified into fixed mathematical formulas through mathematical modeling; the irregular primitives are primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling.
[0214] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation of the methods can be referred to the description of the apparatus embodiments above, which will not be repeated here for the sake of brevity.
[0215] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0216] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A primitive processing device, characterized in that, The device includes at least one processing unit, at least one first storage unit, and multiple second storage units; The processing unit is used to perform ray tracing processing on the light, wherein: When the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit that corresponds to the ray and is idle. Then, the next node is processed, and the GPU's computing unit is requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray. When the first distance value meets the first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit performing the intersection process, and the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the ray.
2. The apparatus according to claim 1, characterized in that, The processing unit is configured to, when the first distance value satisfies the first preset condition, use the first distance value to cover the distance value stored in the first storage unit corresponding to the light ray, and use the primitive parameters of the irregular primitive to cover the primitive parameters stored in the first storage unit corresponding to the light ray.
3. The apparatus according to claim 1 or 2, characterized in that, The processing unit is also used for, When the first distance value meets the first preset condition, after updating the primitive parameters stored in the first storage unit corresponding to the ray, the second storage unit corresponding to the ray and storing the primitive parameters of the irregular primitive is cleared. When the first distance value does not meet the first preset condition, the second storage unit corresponding to the light ray and storing the primitive parameters of the irregular primitive is cleared.
4. The apparatus according to claim 1 or 2, characterized in that, The processing unit is also used for, After processing all nodes in the bounding box hierarchy and confirming that all second storage units corresponding to the ray have been cleared, the GPU's computing unit is notified to obtain the primitive parameters and distance values stored in the first storage unit corresponding to the ray, or the primitive parameters and distance values stored in the first storage unit corresponding to the ray are reported to the GPU's computing unit.
5. The apparatus according to claim 1 or 2, characterized in that, The processing unit is also used for, When the current node is a regular primitive, the primitive parameters of the regular primitive are used to perform intersection processing on the regular primitive and the ray; When the second distance value obtained from the intersection process satisfies the second preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated, and then the next node is processed.
6. The apparatus according to claim 5, characterized in that, The second preset condition is: the second distance value is less than the distance value stored in the first storage unit corresponding to the light ray; The processing unit is configured to, when the second distance value satisfies the second preset condition, use the second distance value to overwrite the distance value stored in the first storage unit corresponding to the ray, and use the primitive parameters corresponding to the rule primitive to overwrite the primitive parameters stored in the first storage unit corresponding to the ray.
7. The apparatus according to claim 5, characterized in that, The processing unit includes a front-end / back-end interaction subunit, a traversal subunit, and a calculation subunit. The front-end and back-end interaction subunit is used to receive the first distance value and update the distance value and primitive parameters stored in the first storage unit corresponding to the light when the first distance value meets the first preset condition. The computational subunit is used to perform intersection processing on the regular primitive and the ray using the primitive parameters of the regular primitive; The second distance value is then output to the traversal subunit. The traversal subunit is used to update the distance value and primitive parameters stored in the first storage unit corresponding to the light ray when the second distance value meets the second preset condition.
8. The apparatus according to claim 1, characterized in that, The device includes N first storage units and N groups of second storage units, each group of second storage units including M second storage units, where N>0 and M>1; When the light ray is the i-th light ray to be tracked, it corresponds to the i-th first storage unit and the i-th group of second storage units, where N≥i>0.
9. The apparatus according to claim 1, characterized in that, The device includes L processing units, L first storage units, and L groups of second storage units, each group of second storage units including M second storage units, where L>0 and M>1; The j-th processing unit corresponds to the j-th first storage unit and the j-th group of second storage units, where L≥j>0; When the light ray is the L×k+jth light ray to be tracked, it corresponds to the jth processing unit, where k≥0 and is an integer.
10. The apparatus according to claim 9, characterized in that, When the j-th processing unit corresponds to multiple rays, it completes the ray tracing processing of the current ray and waits for the GPU's computing unit to obtain the primitive parameters and distance values stored in the j-th first storage unit. Then, it clears the j-th first storage unit and performs ray tracing processing on the next ray corresponding to itself.
11. The apparatus according to claim 1 or 2, characterized in that, When there are multiple processing units and multiple rays, different processing units correspond to different rays, and different processing units perform ray tracing processing in parallel.
12. The apparatus according to claim 1 or 2, characterized in that, Regular primitives are primitives that can be simplified into fixed mathematical formulas through mathematical modeling; The irregular primitives are those that cannot be simplified into fixed mathematical formulas through mathematical modeling.
13. A graphics processor, characterized in that, The primitive processing apparatus includes any one of claims 1-12.
14. An electronic device, characterized in that, Includes the graphics processor as described in claim 13.
15. A primitive processing method, characterized in that, The method is applied to a primitive processing device. The device includes at least one processing unit, at least one first storage unit, and multiple second storage units; The method includes: performing ray tracing processing on the light using the processing unit, wherein: When the current node is an irregular primitive, the primitive parameters of the irregular primitive are stored in a second storage unit that corresponds to the ray and is idle. Then, the next node is processed, and the GPU's computing unit is requested to use the primitive parameters of the irregular primitive to perform intersection processing on the irregular primitive and the ray. When the first distance value meets the first preset condition, the distance value and primitive parameters stored in the first storage unit corresponding to the ray are updated; the first distance value is obtained by the GPU's computing unit performing the intersection process, and the first preset condition is: the first distance value is less than the distance value stored in the first storage unit corresponding to the ray.
Citation Information
Patent Citations
Particle class numerical simulation acceleration method and system based on ray tracing
CN115526769A
Ray tracing processor
CN118661197A