Primitive processing apparatus, method, graphics processor and electronic device

CN122368283BActive Publication Date: 2026-09-22MOORE THREADS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610818149.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-08
Publication Date
2026-09-22
Estimated Expiration
2046-06-08

AI Technical Summary

Technical Problem

现有技术中,将透明图元都归类为复杂度较高的图元,若场景中包括透明物体,则会加大GPU的计算压力,降低了光线追踪加速器的计算资源利用率

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122368283B_ABST
    Figure CN122368283B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of rendering technology, and proposes a primitive processing device, a method, a graphics processing unit and an electronic device. The primitive processing device comprises at least one processing unit; the processing unit is configured to process a primitive according to a type of the primitive when performing ray tracing processing of an i-th ray; and when the type of the primitive is a regular transparent primitive, the processing unit is configured to determine whether the i-th ray intersects the primitive. The primitive processing device provided in the embodiments of the present disclosure can reduce the calculation pressure of a GPU and improve the utilization rate of the calculation resources of the primitive processing device.
Need to check novelty before this filing date? Find Prior Art

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 technology, 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 lower-complexity primitives and using the GPU's general-purpose computing components to process higher-complexity primitives. In existing technologies, transparent primitives are classified as higher-complexity primitives. If the scene includes transparent objects, this increases the computational burden on the GPU and reduces the utilization rate of the ray tracing accelerator's computational resources. 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 present disclosure can reduce the computational burden on the GPU and improve the utilization rate of the computing resources of the primitive processing apparatus.

[0005] According to one aspect of this disclosure, a primitive processing apparatus is provided, the apparatus including at least one processing unit; the processing unit is configured to process the primitive according to the primitive type when performing ray tracing processing of the i-th ray; i is a positive integer; wherein, when the primitive type is a regular transparent primitive, the processing unit is configured to determine whether the i-th ray and the primitive intersect.

[0006] In one possible implementation, when the primitive is a regular transparent primitive, the processing unit is further configured to: calculate the distance between the intersection point and the light source to which the i-th ray belongs when the i-th ray intersects with the primitive; request the GPU's computing unit to determine whether the calculated distance value is valid when the calculated distance value meets a preset condition; and continue processing the primitive when the GPU's computing unit returns a determination result indicating that the calculated distance value is valid.

[0007] In one possible implementation, the calculated distance value is valid when the intersection is opaque.

[0008] In one possible implementation, the device further includes at least one first storage unit, which is used to store the primitive parameters of the primitive whose intersection with the i-th ray is opaque and which is closest to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs; the preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0009] In one possible implementation, the processing unit is configured to: update the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, and update the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0010] In one possible implementation, when the primitive is a regular opaque primitive, the processing unit is configured to: determine whether the i-th ray intersects with the primitive; when the i-th ray intersects with the primitive, calculate the distance between the intersection point and the light source to which the i-th ray belongs; when the calculated distance value satisfies a preset condition, update the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and update the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0011] In one possible implementation, when the primitive type is an irregular primitive, the processing unit is configured to: request the GPU's computing unit to process the primitive; update the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters returned by the GPU's computing unit; and update the minimum distance value stored in the first storage unit corresponding to the i-th ray using the distance value returned by the GPU's computing unit.

[0012] In one possible implementation, the first primitive node is composed of multiple regular transparent primitives. The processing unit is used to: when traversing the first primitive node, obtain the primitive data of all primitives in the first primitive node; the primitive data of each primitive is used to determine whether the i-th ray intersects with the primitive; process multiple primitives in the first primitive node in sequence; when it is determined that the i-th ray does not intersect with the current primitive or when it is determined that the calculated distance value does not meet the preset condition, continue to process the next primitive.

[0013] In one possible implementation, the device further includes at least one second storage unit, and the processing unit is further configured to: when the calculated distance value meets a preset condition, write the order of the graphic element in its respective graphic element node as a pointer into the second storage unit corresponding to the i-th ray; the graphic element node includes multiple graphic elements; after updating the first storage unit corresponding to the i-th ray, determine the graphic element or graphic element node to be processed next according to the value of the pointer.

[0014] In one possible implementation, the processing unit is further configured to, after completing the processing of the last primitive in the primitive node, write the first value as a pointer into the second storage unit corresponding to the i-th ray; the first value is not equal to the order of the primitive in its respective primitive node.

[0015] In one possible implementation, the processing unit is configured to: when the value of the pointer is the first value, determine the next primitive node to be processed; and when the value of the pointer is k and k is not equal to the first value, determine the (k+1)th primitive in the current primitive node to be processed next.

[0016] In one possible implementation, the device includes N first storage units and N second storage units; the i-th ray corresponds to the i-th first storage unit and the i-th second storage unit, where N ≥ i > 0.

[0017] In one possible implementation, the device includes L processing units, L first storage units, and L second storage units; the j-th processing unit corresponds to the j-th first storage unit and the j-th second storage unit, where L ≥ j > 0; when i = L × w + j, the i-th ray corresponds to the j-th processing unit, where w ≥ 0 and is an integer.

[0018] 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 minimum distance value stored in the j-th first storage unit. Then, it clears the j-th first storage unit and the j-th second storage unit and performs ray tracing processing on the next ray corresponding to itself.

[0019] 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.

[0020] In one possible implementation, the transparent primitives of the rule are transparent primitives that can be simplified into fixed mathematical formulas through mathematical modeling.

[0021] In one possible implementation, the primitive parameters include one or more of the following: centroid coordinates, primitive index, address of primitive data in the cache, and primitive attributes.

[0022] 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, the method comprising: when the processing unit performs ray tracing processing on the i-th ray, processing the primitive according to the primitive type; i is a positive integer; wherein, when the primitive type is a regular transparent primitive, processing the primitive according to the primitive type includes determining whether the i-th ray and the primitive intersect.

[0023] In one possible implementation, when the primitive is a regular transparent primitive, processing the primitive according to its type further includes: when the i-th ray intersects with the primitive, calculating the distance between the intersection point and the light source to which the i-th ray belongs; when the calculated distance meets a preset condition, requesting the GPU's computing unit to determine whether the calculated distance is valid; and when the GPU's computing unit returns a determination result indicating that the calculated distance is valid, continuing to process the primitive.

[0024] In one possible implementation, the calculated distance value is valid when the intersection is opaque.

[0025] In one possible implementation, the device further includes at least one first storage unit, which is used to store the primitive parameters of the primitive whose intersection with the i-th ray is opaque and which is closest to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs; the preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0026] In one possible implementation, when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, the primitive is further processed, including: when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0027] In one possible implementation, processing the primitive according to its type further includes: when the primitive is a regular opaque primitive, determining whether the i-th ray intersects with the primitive; when the i-th ray intersects with the primitive, calculating the distance between the intersection point and the light source to which the i-th ray belongs; and when the calculated distance value satisfies a preset condition, updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0028] In one possible implementation, processing the primitive according to its type further includes: when the primitive is an irregular primitive, requesting the GPU's computing unit to process the primitive; updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters returned by the GPU's computing unit, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the distance value returned by the GPU's computing unit.

[0029] In one possible implementation, the first primitive node is composed of multiple regular transparent primitives. The method further includes: when the processing unit traverses to the first primitive node, it obtains the primitive data of all primitives in the first primitive node; the primitive data of each primitive is used to determine whether the i-th ray intersects with the primitive; multiple primitives in the first primitive node are processed sequentially; when it is determined that the i-th ray does not intersect with the current primitive or when it is determined that the calculated distance value does not meet the preset condition, the next primitive is processed.

[0030] In one possible implementation, the device further includes at least one second storage unit, and processing the primitive according to its type further includes: when the calculated distance value meets a preset condition, writing the order of the primitive in its respective primitive node as a pointer into the second storage unit corresponding to the i-th ray; the primitive node includes multiple primitives; after updating the first storage unit corresponding to the i-th ray, determining the primitive or primitive node to be processed next based on the value of the pointer.

[0031] In one possible implementation, processing the primitives according to their type further includes: after processing the last primitive in the primitive node, writing a first value as a pointer into the second storage unit corresponding to the i-th ray; the first value is not equal to the order of the primitive in its respective primitive node.

[0032] In one possible implementation, determining the next primitive or primitive node to be processed based on the value of the pointer includes: when the value of the pointer is the first value, determining the next primitive node to be processed; when the value of the pointer is k and k is not equal to the first value, determining the (k+1)th primitive in the current primitive node to be processed next.

[0033] In one possible implementation, the device includes N first storage units and N second storage units; the i-th ray corresponds to the i-th first storage unit and the i-th second storage unit, where N ≥ i > 0.

[0034] In one possible implementation, the device includes L processing units, L first storage units, and L second storage units; the j-th processing unit corresponds to the j-th first storage unit and the j-th second storage unit, where L ≥ j > 0; when i = L × w + j, the i-th ray corresponds to the j-th processing unit, where w ≥ 0 and is an integer.

[0035] 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 minimum distance value stored in the j-th first storage unit. Then, it clears the j-th first storage unit and the j-th second storage unit and performs ray tracing processing on the next ray corresponding to itself.

[0036] 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.

[0037] In one possible implementation, the transparent primitives of the rule are transparent primitives that can be simplified into fixed mathematical formulas through mathematical modeling.

[0038] In one possible implementation, the primitive parameters include one or more of the following: centroid coordinates, primitive index, address of primitive data in the cache, and primitive attributes.

[0039] The primitive processing apparatus according to an embodiment of this disclosure includes at least one processing unit. The processing unit is used to process primitives according to their type when performing ray tracing processing for the i-th ray. When the primitive type is a regular transparent primitive, the processing unit is used to determine whether the i-th ray intersects with the primitive. The primitive processing apparatus can replace the GPU's computing unit to complete the intersection processing of regular transparent primitives and rays, and determine whether the i-th ray intersects with the primitive, thus reducing the GPU's workload and improving the computational resource utilization of the primitive processing apparatus.

[0040] 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

[0041] 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.

[0042] Figure 1a A schematic diagram of the bounding box hierarchy is shown.

[0043] Figure 1b This diagram illustrates the intersection of light rays and transparent primitives.

[0044] Figure 2 A schematic diagram showing the structure of a prior art ray tracing accelerator.

[0045] Figure 3 A schematic diagram illustrating the flow of a prior art ray tracing algorithm.

[0046] Figure 4 This illustrates an exemplary application scenario of a primitive processing apparatus according to embodiments of the present disclosure.

[0047] Figure 5 A schematic diagram showing the structure of a primitive processing apparatus according to an embodiment of the present disclosure is provided.

[0048] Figure 6a A schematic diagram showing the structure of a primitive processing apparatus including a first storage unit according to an embodiment of the present disclosure is provided.

[0049] Figure 6b A schematic diagram illustrating the workflow of a processing unit according to an embodiment of the present disclosure is shown.

[0050] Figure 7 A schematic diagram showing the structure of a primitive processing apparatus including a second storage unit according to an embodiment of the present disclosure is provided.

[0051] Figure 8 A schematic diagram showing the structure of a primitive processing apparatus including L processing units, N first storage units and N second storage units according to an embodiment of the present disclosure is provided.

[0052] Figure 9 A schematic diagram showing the structure of a primitive processing apparatus including L processing units, L first storage units and L second storage units according to an embodiment of the present disclosure is provided.

[0053] Figure 10 A schematic diagram showing the structure of a processing unit according to an embodiment of the present disclosure is provided.

[0054] Figure 11A schematic diagram illustrating the flow of a primitive processing method according to an embodiment of the present disclosure is shown. Detailed Implementation

[0055] 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.

[0056] 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.

[0057] 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.

[0058] 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.

[0059] 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.

[0060] 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.

[0061] 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.

[0062] 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.

[0063] 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.

[0064] The objects that light rays may illuminate include regular primitives such as triangles, cones, and spheres, as well as irregular primitives of user-defined shapes. Some primitives may also be transparent. To improve traversal speed, ray tracing technology models all objects in the scene as a bounding volume hierarchy (BVH).

[0065] Figure 1a A schematic diagram of the bounding box hierarchy is shown.

[0066] like Figure 1a As shown, the root node corresponds to the entire scene, and child node 0 and child node 1 correspond to two subspaces split from the scene. The subspace corresponding to child node 0 contains only regular opaque primitives and regular transparent primitives. The subspace corresponding to child node 1 contains irregular opaque primitives and regular transparent primitives.

[0067] The leaf nodes of child node 0 are primitive node 0 and primitive node 1. Primitive node 0 is composed of regular opaque primitives (primitive 00-primitive 02) in the subspace corresponding to child node 0. Primitive node 1 is composed of regular transparent primitives (primitive 10-primitive 12) in the subspace corresponding to child node 0.

[0068] The leaf nodes of child node 1 include primitive node 2 and primitive node 3. Primitive node 2 consists of irregular opaque primitives (primitive 20-primitive 23) in the subspace corresponding to child node 1. Primitive node 3 consists of regular transparent primitives (primitive 30-primitive 31) in the subspace corresponding to child node 1.

[0069] When traversing the scene, 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 of that child node. This significantly reduces the number of times ray intersection checks are performed.

[0070] The abundant general-purpose computing units in a GPU can be used to perform the aforementioned traversal and intersection operations. 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 consume general-purpose computing units for extended periods. For example, a single intersection operation between a ray and a primitive might be broken down into multiple instructions within the general-purpose computing unit, making it difficult to allocate idle resources for other tasks. Therefore, to achieve high-performance ray tracing and avoid prolonged consumption of the GPU's general-purpose computing units, custom-designed ray tracing accelerators are often used in GPUs for hardware acceleration.

[0071] When transparent primitives are included in the scene, the rendering method becomes more complex. For each ray, there may be more than one primitive involved in the rendering. The primitive processing device stores only the primitive parameters of the primitive whose intersection with the ray is opaque and whose distance from the light source to which the ray belongs, as well as the distance value between the primitive and the light source.

[0072] Figure 1b This diagram illustrates the intersection of a ray and a transparent primitive. (Example:) Figure 1b As shown, transparent primitives are further divided into partially transparent primitives and fully transparent primitives.

[0073] A fully transparent primitive is completely transparent; when a ray intersects a fully transparent primitive, the intersection point is always transparent. If a ray intersects a fully transparent primitive, the primitive parameters and distance values ​​stored in the primitive processing device do not need to be updated. However, the color of the fully transparent primitive will be superimposed on other primitives that are farther away from the light source along the ray's propagation direction. Therefore, the GPU can retain the primitive parameters of the fully transparent primitive and its distance value from the light source. If, after ray tracing, the distance value stored in the primitive processing device is greater than the distance value between the fully transparent primitive and the light source, then the fully transparent primitive must participate in rendering.

[0074] by Figure 1b For example, primitives A and B are fully transparent, while primitive C is opaque. Primitives A, B, and C all intersect with ray L0, and the colors of primitives A and B are superimposed on primitive C. During ray tracing of ray L0, when processing primitives A and B, it is not necessary to update the primitive parameters and distance values ​​stored in the primitive processing device. However, when processing primitive C, if the distance between primitive C and the light source is smaller than the distance value stored in the primitive processing device, then the primitive parameters and distance values ​​stored in the primitive processing device are updated.

[0075] Partially transparent primitives are partially transparent and partially opaque. When a ray intersects a partially transparent primitive, the intersection point may be transparent or opaque. If the intersection point is transparent, the partially transparent primitive is rendered the same as a fully transparent primitive. If the intersection point is opaque and the distance between the ray and the partially transparent primitive is smaller than the distance value stored in the primitive processing device, the primitive parameters and distance value stored in the primitive processing device are updated.

[0076] by Figure 1b For example, primitive D is a partially transparent primitive; its intersection with ray L1 is opaque, while its intersection with ray L2 is transparent. During ray tracing of ray L1, if the distance between primitive D and the light source is smaller than the distance value stored in the primitive processing device, the primitive parameters and distance value stored in the primitive processing device are updated. During ray tracing of ray L2, it is not necessary to update the primitive parameters and distance value stored in the primitive processing device when processing primitive D.

[0077] Regular primitives can be simplified into fixed mathematical formulas through mathematical modeling, and the intersection of rays and primitives can be obtained through multiplication, addition, and other operations. Acceleration using custom circuits is relatively inexpensive. However, for irregular primitives, user-defined shapes are variable and cannot be normalized to fixed formulas, making acceleration using custom circuits costly. Furthermore, transparent primitives allow the view of primitives behind them, and their transparency needs to be superimposed on the background primitives for further rendering, making the related operations complex and unsuitable for custom circuit implementation. Therefore, custom ray tracing accelerators are typically used to process regular opaque primitives, while GPU general-purpose computing units are used to process irregular primitives (including irregular transparent primitives and irregular opaque primitives) and regular transparent primitives.

[0078] Figure 2 A schematic diagram showing the structure of a prior art ray tracing accelerator.

[0079] like Figure 2 As shown, existing ray tracing accelerators have only one storage unit, which can only store one distance value and one primitive parameter. The ray tracing accelerator uses this storage unit to store the primitive parameters of the primitive whose intersection with the ray is opaque and whose distance to the light source is closest to the ray's source, as well as the distance value between the primitive and the light source.

[0080] Figure 3 A schematic diagram illustrating the flow of a prior art ray tracing algorithm.

[0081] like Figure 3As shown, after the ray tracing algorithm starts, the ray tracing accelerator begins traversing the bounding box hierarchy. If the next hop node is a regular opaque primitive, the intersection of that primitive and the ray is processed internally by the ray tracing accelerator. Specifically, the primitive's primitive data (i.e., its primitive parameters) is first read based on the primitive's primitive parameters. Figure 3 The next-hop node data shown includes vertex coordinates, etc., and the distance value stored in the storage unit is read (i.e., Figure 3 The current nearest distance is shown. The primitive and ray are intersected using the primitive's metadata. If they intersect, the distance between the intersection point and the light source is calculated. If the calculated distance is less than the distance stored in the storage unit, it means the ray has hit the primitive, and the storage unit's distance value and primitive parameters need to be updated (i.e.,...). Figure 3 The current nearest distance and primitive parameters are shown, and the bounding box hierarchy can then be traversed. If the calculated distance value is greater than or equal to the distance value stored in the storage unit, it means that the ray and primitive did not match, and the bounding box hierarchy can be traversed again.

[0082] If the next-hop node is neither a regular opaque primitive nor empty (NULL), then the next-hop node is either an irregular primitive or a regular transparent primitive. In this case, the GPU's general-purpose computing unit needs to perform the intersection processing between this primitive and the ray. Specifically, if the next-hop node is an irregular primitive or a regular transparent primitive, the ray tracing accelerator will first request the GPU's general-purpose computing unit to access the memory 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 (i.e., ...), ... Figure 3 The ray tracing accelerator (which reads the current nearest distance and primitive parameters) returns a response signal to the ray tracing accelerator. After receiving the response signal, the ray tracing accelerator stores the primitive parameters of that primitive in a memory unit and requests the GPU's general-purpose computing unit to access that memory unit to read the primitive parameters. Once the GPU's general-purpose computing unit successfully reads the primitive parameters (i.e.,...), it returns a response signal. Figure 3 (Read the primitive parameters of the next hop node in the process) and start the intersection processing of the primitive and the ray (i.e. Figure 3The GPU's general-purpose computing unit performs intersection processing. If the primitive intersects with a ray and the intersection point is in a fully transparent area, or if the primitive does not intersect with a ray, the GPU's general-purpose computing unit returns the primitive parameters and distance value obtained in the first acquisition to the ray tracing accelerator. If the primitive intersects with a ray and the intersection point is in an opaque area, the distance value calculated by the intersection processing is compared with the acquired distance value. If the calculated distance value is less than the acquired distance value, the GPU's general-purpose computing unit returns the calculated distance value and the primitive parameters obtained in the second acquisition to the ray tracing accelerator. If the calculated distance value is greater than the acquired distance value, the GPU's general-purpose computing unit returns the primitive parameters and distance value obtained in the first acquisition to the ray tracing accelerator. The ray tracing accelerator updates the distance value and primitive parameters stored in the storage unit (i.e., ...) based on the distance value and primitive parameters returned by the GPU's general-purpose computing unit. Figure 3 After showing the current nearest distance and primitive parameters, continue traversing the bounding box hierarchy.

[0083] If the next hop node is empty (next hop node == NULL), it means that the bounding box hierarchy has been traversed and the ray tracing process can be terminated.

[0084] The drawbacks of this approach are as follows: A single intersection operation between a ray and a primitive is broken down into multiple instructions within the GPU's general-purpose computing unit (GPCU), resulting in significant time and complexity for the GPCU in processing primitives. Furthermore, each time a regular transparent primitive is encountered, the ray tracing accelerator requests the GPCU to process it and waits for the result before starting to traverse the next primitive. Therefore, if there are many regular transparent primitives, the GPU's workload increases dramatically, leading to longer idle times for the ray tracing accelerator and reduced utilization of its computational resources.

[0085] Furthermore, each primitive node traversed by the ray tracing accelerator contains multiple primitives with the same attributes, such as all being regular transparent primitives or all being regular opaque primitives. In other words, the ray tracing accelerator will continuously traverse multiple regular transparent primitives. Intersection processing of primitives requires primitive data (including vertex coordinates), which is typically stored in a cache with a large bit width, capable of reading the primitive data of multiple primitives at once. The GPU's general-purpose computing unit retrieves the primitive data of a single primitive based on the ray tracing accelerator's request, resulting in wasted cache read bit width.

[0086] 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 reduce the computational burden on the GPU and improve the utilization rate of the computing resources of the primitive processing apparatus. Furthermore, the primitive processing apparatus can also effectively utilize the bit width of the cache.

[0087] Figure 4 This illustrates an exemplary application scenario of a primitive processing apparatus according to embodiments of the present disclosure.

[0088] like Figure 4 As shown, the primitive processing unit can be located in the GPU, serving as a ray tracing accelerator. The GPU's computing units are general-purpose computing components such as GPU cores. The GPU's cache stores primitive data for each primitive in the scene.

[0089] 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. The primitives that make up an object may be one or more of the following: regular transparent primitives, regular opaque primitives, irregular transparent primitives, and irregular opaque primitives.

[0090] Transparent primitives with regularity are those that can be simplified into fixed mathematical formulas through mathematical modeling. Examples include transparent primitives of triangles and transparent primitives of quadrilaterals.

[0091] Regular opaque primitives are those that can be simplified into fixed mathematical formulas through mathematical modeling. Examples include opaque triangles and opaque quadrilaterals.

[0092] Irregular transparent primitives are those that cannot be simplified into fixed mathematical formulas through mathematical modeling, such as transparent primitives with custom shapes.

[0093] Irregular opaque primitives are opaque primitives that cannot be simplified into fixed mathematical formulas through mathematical modeling, such as opaque primitives with custom shapes.

[0094] 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 primitives whose intersection with the ray is opaque and which are closest to the light source to which the ray belongs, and these primitives are then included in the rendering. Furthermore, other primitives along the ray's propagation direction that have transparent intersections with the ray and are even closer to the light source to which the ray belongs are also included in the rendering.

[0095] For each ray, the primitive processing device can store primitive parameters (including barycenter coordinates, primitive index, address of primitive data in the cache, primitive attributes, etc.) of primitives whose intersection with the ray is opaque and which are closest to the light source to which the ray belongs, as well as the minimum distance values ​​between all primitives whose intersection with the ray is opaque and the light source to which the ray belongs.

[0096] The GPU can obtain the bounding box hierarchy based on the primitive distribution in the scene and instruct the primitive processing unit to perform ray tracing on each ray. The primitive processing unit initiates a traversal of the bounding box hierarchy according to the instructions, continuously updating the stored distance values ​​and primitive parameters based on the primitive processing progress during the ray tracing process of each ray. When necessary, it requests assistance from the GPU's computing units to complete the primitive processing.

[0097] After the bounding box hierarchy has been traversed, the primitive processing device can report the stored primitive parameters and minimum distance values ​​to the GPU's computing unit (or request the GPU's computing unit to retrieve the primitive parameters and minimum distance values ​​stored by the primitive processing device). The GPU's computing unit can determine that the primitive corresponding to the primitive parameter, as well as other primitives existing in the direction of ray propagation that are transparent at their intersection with the ray and are closer to the light source to which the ray belongs, all participate in rendering.

[0098] Figure 5 A schematic diagram showing the structure of a primitive processing apparatus according to an embodiment of the present disclosure is provided.

[0099] like Figure 5 As shown, in one possible implementation, the primitive processing apparatus includes at least one processing unit;

[0100] The processing unit is used to process primitives according to their type when performing ray tracing processing for the i-th ray; i is a positive integer;

[0101] When the primitive type is a regular transparent primitive, the processing unit is used to determine whether the i-th ray intersects with the primitive.

[0102] For example, a primitive processing apparatus may include at least one processing unit. Each processing unit can independently process regular opaque primitives and can interact with the computing units of the GPU to request the GPU's computing units to process irregular primitives. Figure 5 Only three processing units are shown, but this disclosure does not limit the specific number of processing units.

[0103] The mapping between rays and processing units can be configured, so that each ray corresponds to one processing unit. Each processing unit can be used to perform ray tracing processing on its corresponding ray. For any processing unit, when performing ray tracing processing on the i-th ray, the primitive can be processed according to the primitive type. Specifically, for regular transparent primitives, the processing unit is used to determine whether the i-th ray intersects with the primitive.

[0104] In this scenario, the primitive processing unit can replace the GPU's computing unit to determine whether the regular transparent primitives intersect with the light rays, thereby reducing the GPU's workload and improving the utilization rate of the primitive processing unit's computing resources.

[0105] The primitive processing apparatus according to an embodiment of this disclosure includes at least one processing unit. The processing unit is used to process primitives according to their type when performing ray tracing processing for the i-th ray. When the primitive type is a regular transparent primitive, the processing unit is used to determine whether the i-th ray intersects with the primitive. The primitive processing apparatus can replace the GPU's computing unit to complete the intersection processing of regular transparent primitives and rays, and determine whether the i-th ray intersects with the primitive, thus reducing the GPU's workload and improving the computational resource utilization of the primitive processing apparatus.

[0106] In one possible implementation, when the primitive type is a regular transparent primitive, the processing unit is also used for:

[0107] When the i-th ray intersects with a primitive, calculate the distance between the intersection point and the light source to which the i-th ray belongs;

[0108] When the calculated distance value meets the preset conditions, the GPU's computing unit is requested to determine whether the calculated distance value is valid.

[0109] If the GPU's computation unit returns a result indicating that the calculated distance value is valid, continue processing the primitives.

[0110] For example, if the primitive is a regular transparent primitive, and the i-th ray intersects with the primitive, the processing unit can further calculate the distance between the intersection point and the light source to which the i-th ray belongs. This method further reduces the GPU load and improves the utilization of the primitive processing device's computing resources.

[0111] The processing unit can determine whether the calculated distance value meets preset conditions. If the calculated distance value does not meet the preset conditions, it directly processes the next primitive. If the calculated distance value meets the preset conditions, it requests the GPU's computing unit to determine whether the calculated distance value is valid. If the GPU's computing unit returns a result indicating that the calculated distance value is valid, it continues processing the current primitive. If the GPU's computing unit returns a result indicating that the calculated distance value is invalid, it directly processes the next primitive.

[0112] In this way, the GPU's computing units can avoid processing unnecessary primitives and the number of interactions with the GPU's computing units can be reduced.

[0113] It should be understood that when the processing unit determines that the current primitive intersects with the i-th ray, it may request the GPU's computing unit to calculate the distance between the intersection point and the light source to which the i-th ray belongs, and the GPU's computing unit will then determine whether the calculated distance value is valid. In this embodiment of the present disclosure, the method for calculating the distance between the intersection point and the light source to which the i-th ray belongs is not limited when the primitive type is a regular transparent primitive.

[0114] In one possible implementation, the calculated distance value is valid when the intersection is opaque.

[0115] The primitive is a regular transparent primitive. Therefore, when the i-th ray intersects with the primitive, the intersection point may be transparent or opaque. If the intersection point is opaque, the calculated distance value is considered valid; if the intersection point is transparent, the calculated distance value is considered invalid.

[0116] When the processing unit determines that a regular transparent primitive intersects with the i-th ray, it also obtains the centroid coordinates of the regular transparent primitive. The GPU's computing unit can determine whether the intersection point is transparent based on the centroid coordinates of the regular transparent primitive and other primitive parameters of the regular transparent primitive. The GPU's computing unit can obtain the regular transparent primitive from the primitive processing device and determine whether the intersection point is transparent based on primitive parameters such as the centroid coordinates, all of which can be implemented based on existing technologies and will not be elaborated here.

[0117] Figure 6a A schematic diagram showing the structure of a primitive processing apparatus including a first storage unit according to an embodiment of the present disclosure is provided.

[0118] like Figure 6a As shown, in one possible implementation, the device further includes at least one first storage unit, which corresponds to the i-th ray and is used to store the primitive parameters of the primitive whose intersection with the i-th ray is opaque and is closest to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs.

[0119] The preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0120] For example, the primitive processing device may further include at least one first storage unit. Depending on the application scenario, the first storage unit can be configured to correspond to a ray or a processing unit. When the first storage unit corresponds to a processing unit, it also corresponds to the ray corresponding to the processing unit. The first storage unit is used to store, when corresponding to the i-th ray, the primitive parameters of the primitive whose intersection with the i-th ray is opaque and which is closest to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs, where i is a positive integer. The bit width of the first storage unit may be equal to the sum of the bit width of the primitive parameters and the bit width of the minimum distance value.

[0121] Each first storage unit can be an independent storage device, such as static random-access memory (SRAM). Alternatively, the first storage unit can also be a storage area within SRAM. This disclosure does not limit the specific implementation of the first storage unit. Figure 6a Only one first storage unit and its corresponding processing unit are shown, but the specific number of first storage units is not limited in this embodiment.

[0122] If the current primitive does not intersect with the i-th ray, the current primitive does not need to participate in rendering. If the current primitive intersects with the i-th ray and the calculated distance value is greater than or equal to the distance value stored in the first storage unit corresponding to the i-th ray, the primitive corresponding to the primitive parameter stored in the first storage unit of the i-th ray will occlude the current primitive, and the current primitive also does not need to participate in rendering. Based on this, the preset condition can be set as follows: the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0123] In one possible implementation, the processing unit is used to: update the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitives when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, and update the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0124] For example, when the GPU's computation unit returns a judgment result indicating that the calculated distance value is valid, it means that the current primitive is the primitive whose intersection with the i-th ray is opaque and is closest to the light source to which the i-th ray belongs. The first storage unit corresponding to the i-th ray should be updated. That is, the primitive parameters stored in the first storage unit corresponding to the i-th ray are updated using the primitive parameters of the current primitive, and the minimum distance value stored in the first storage unit corresponding to the i-th ray is updated using the calculated distance value.

[0125] In this way, the first storage unit corresponding to the i-th ray always stores the primitive parameters of the primitive whose intersection with the i-th ray is opaque and whose distance to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs, thus ensuring the accuracy of ray tracing.

[0126] In one possible implementation, when the primitive type is a regular opaque primitive, the processing unit is used for:

[0127] Determine whether the i-th ray intersects with the primitive;

[0128] When the i-th ray intersects with a primitive, calculate the distance between the intersection point and the light source to which the i-th ray belongs;

[0129] When the calculated distance value meets the preset conditions, the primitive parameters stored in the first storage unit corresponding to the i-th ray are updated using the primitive parameters of the primitive, and the minimum distance value stored in the first storage unit corresponding to the i-th ray is updated using the calculated distance value.

[0130] For regular opaque primitives, the processing unit can process the primitives in the same way as in the prior art. That is, it determines whether the i-th ray intersects with the primitive. When the i-th ray intersects with the primitive, it calculates the distance between the intersection point and the light source to which the i-th ray belongs. When the calculated distance value meets a preset condition, it directly updates the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and updates the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0131] In one possible implementation, when the primitive type is an irregular primitive, the processing unit is used for:

[0132] Request the GPU's computing units to process primitives;

[0133] The primitive parameters returned by the GPU's computing unit are used to update the primitive parameters stored in the first storage unit corresponding to the i-th ray, and the distance values ​​returned by the GPU's computing unit are used to update the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0134] For irregular primitives, the processing unit can process them in the same way as in existing technologies. That is, it requests the GPU's computing unit to process the primitives. For example, the processing unit sends a first request to the GPU's computing unit. In response to the first request, the GPU's computing unit accesses the first storage unit corresponding to the i-th ray for the first time, obtains the primitive parameters and minimum distance value stored therein, and then returns a response signal to the processing unit. After receiving the response signal, the processing unit stores the primitive parameters of the irregular primitive in the first storage unit corresponding to the i-th ray and sends a second request to the GPU's computing unit. In response to the second request, the GPU's computing unit accesses the first storage unit corresponding to the i-th ray for the second time, obtaining the primitive parameters of the irregular primitive. The GPU's computing unit determines whether the i-th ray and the irregular primitive intersect based on the primitive parameters of the irregular primitive; when the i-th ray and the irregular primitive intersect, it calculates the distance between the intersection point and the light source to which the i-th ray belongs. When the calculated distance value meets a preset condition, the calculated distance value and the primitive parameters of the irregular primitive are returned to the processing unit. If the calculated distance value does not meet the preset conditions, the primitive parameters and minimum distance value obtained during the first access will be returned to the processing unit.

[0135] The processing unit updates the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters returned by the GPU's computing unit, and updates the minimum distance value stored in the first storage unit corresponding to the i-th ray using the distance value returned by the GPU's computing unit.

[0136] In one possible implementation, the first primitive node consists of multiple regular transparent primitives, and the processing unit is used for:

[0137] When traversing to the first primitive node, obtain the primitive data of all primitives in the first primitive node; the primitive data of each primitive is used to determine whether the i-th ray intersects with the primitive;

[0138] Process multiple primitives in the first primitive node in sequence; if it is determined that the i-th ray does not intersect with the current primitive or that the calculated distance value does not meet the preset condition, continue to process the next primitive.

[0139] For example, when the processing unit performs ray tracing processing on the i-th ray, it traverses the bounding box hierarchy, such as... Figure 1a As shown, it includes multiple primitive nodes. Each primitive node consists of multiple primitives of the same type. For example, the first primitive node consists of multiple regular transparent primitives.

[0140] As mentioned above, the processing unit is responsible for determining whether a transparent primitive of a rule intersects with the i-th ray, and determining whether a primitive and a ray intersect requires reading primitive data from the cache. Therefore, when traversing to the first primitive node, the processing unit can determine that it needs to determine whether all primitives within the first primitive node intersect with rays. If the cache width allows, the primitive data of all primitives within the first primitive node can be read at once, instead of reading the primitive data of only one primitive at a time, thus effectively utilizing the cache width.

[0141] The processing unit can process multiple primitives in the first primitive node sequentially. When it determines that the i-th ray does not intersect with the current primitive, it does not need to interact with the GPU and directly processes the next primitive. Similarly, when the calculated distance value does not meet preset conditions, it does not need to interact with the GPU and directly processes the next primitive. This method further reduces the interaction between the primitive processing device and the GPU, improving primitive processing efficiency.

[0142] Figure 6b A schematic diagram illustrating the workflow of a processing unit according to an embodiment of the present disclosure is shown.

[0143] like Figure 6b As shown, when the processing unit performs ray tracing processing on the i-th ray, it traverses the bounding box hierarchy and determines whether the next hop node is composed of regular primitives or transparent primitives.

[0144] If the next-hop node is composed of regular opaque primitives, the processing unit can perform intersection processing on each primitive in the next-hop node and the i-th ray (including determining whether the ray and the primitive intersect, and calculating the distance between the intersection point and the light source to which the ray belongs when the ray and the primitive intersect). Find the primitive that is closest to the light source to which the i-th ray belongs among the primitives that intersect with the i-th ray. If the distance between the primitive and the light source to which the i-th ray belongs meets the preset condition, then use the primitive parameters of the primitive and the distance between the primitive and the light source to which the i-th ray belongs to update the first storage unit corresponding to the i-th ray, and then continue to traverse the bounding box hierarchy.

[0145] If the next-hop node consists of regular transparent primitives, the processing unit can traverse the primitives within the next-hop node and perform intersection processing on the current primitive and the i-th ray. When determining that the i-th ray intersects with the current primitive, the distance value between the intersection point and the light source to which the ray belongs can be calculated. If the distance value meets the preset conditions, the GPU's computing unit is requested to determine whether the calculated distance value is valid. If valid, the first storage unit corresponding to the i-th ray is updated based on the primitive parameters of the current primitive and the calculated distance value. Then, it is determined whether the primitives in the current node (the next-hop node becomes the current node when processing the next-hop node) have been traversed. If invalid, it is directly determined whether the primitives in the current node have been traversed. If the primitives in the current node have not been traversed, the next primitive is traversed; if the traversal is complete, the bounding box hierarchy is traversed.

[0146] If the next-hop node is composed of irregular primitives, the GPU's computing unit is requested to perform intersection processing, and the first storage unit is updated based on the GPU's intersection processing result. For example, if the next-hop node is composed of irregular opaque primitives, the GPU's computing unit is requested to traverse the primitives within the next-hop node, perform intersection processing on each primitive and the i-th ray, find the primitive in the next-hop node that intersects with the i-th ray and is closest to the light source to which the i-th ray belongs. If the distance value between the primitive and the light source to which the i-th ray belongs meets a preset condition, the primitive parameters of the primitive and the distance value between the primitive and the light source to which the i-th ray belongs are used to update the first storage unit corresponding to the i-th ray, and then the bounding box hierarchy is traversed again. If the next hop node is composed of irregular transparent primitives, the GPU's computing unit is requested to traverse the primitives within the next hop node, perform intersection processing on each primitive and the i-th ray, find the primitive in the next hop node that intersects with the i-th ray and is closest to the light source to which the i-th ray belongs. If the distance value between the primitive and the light source to which the i-th ray belongs meets the preset condition, and the intersection point between the primitive and the i-th ray is not transparent, then the primitive parameters of the primitive and the distance value between the primitive and the light source to which the i-th ray belongs are used to update the first storage unit corresponding to the i-th ray, and then the bounding box hierarchy is traversed. If the distance value between the primitive and the light source to which the i-th ray belongs does not meet the preset condition, or the intersection point between the primitive and the i-th ray is transparent, then the bounding box hierarchy is directly traversed.

[0147] If the next hop node is empty, it means that the bounding box hierarchy has been traversed and the ray tracing process for the i-th ray can be terminated.

[0148] Figure 7 A schematic diagram showing the structure of a primitive processing apparatus including a second storage unit according to an embodiment of the present disclosure is provided.

[0149] like Figure 7 As shown, the device further includes at least one second storage unit, and the processing unit is further configured to:

[0150] When the calculated distance value meets the preset conditions, the order of the graphic elements in their respective graphic element nodes is written as a pointer to the second storage unit corresponding to the i-th ray; a graphic element node includes multiple graphic elements;

[0151] After updating the first storage unit corresponding to the i-th ray, determine the primitive or primitive node to be processed next based on the pointer value.

[0152] For example, the primitive processing device may further include at least one second storage unit, which can be configured to correspond to a light ray or a processing unit according to the application scenario requirements. Specifically, when the second storage unit corresponds to a processing unit, it also corresponds to the light ray corresponding to the processing unit.

[0153] Each second storage unit can be an independent storage device, such as Static Random-Access Memory (SRAM). Alternatively, the second storage unit can also be a storage area within SRAM. This disclosure does not limit the specific implementation of the second storage unit. Figure 7 Only one second storage unit is shown, but the specific number of second storage units is not limited in the embodiments of this disclosure.

[0154] During the processing of the first primitive node, when the calculated distance value meets the preset conditions, the processing unit, in addition to requesting the GPU's computing unit to determine whether the calculated distance value is valid, also writes the current primitive's order within its respective primitive node as a pointer into the second storage unit corresponding to the i-th ray. After receiving the judgment result from the GPU's computing unit and updating the information stored in the first storage unit corresponding to the i-th ray based on the judgment result, the processing unit can determine which primitive in the primitive node was previously processed based on the pointer value, and determine the primitive or primitive node to be processed next. For example, if the previously processed primitive was already the last primitive in the primitive node, the next primitive node to be processed can be determined. If the previously processed primitive was not the last primitive in the primitive node, the next primitive in the next primitive node to be processed can be determined.

[0155] In this way, it can be ensured that the primitive processing device can traverse all primitives in the first primitive node without omission or repeated traversal.

[0156] The following describes an exemplary method by which the processing unit determines the primitive or primitive node to be processed next based on the value of the pointer.

[0157] In one possible implementation, the processing unit is further configured to, after completing the processing of the last primitive in the primitive node, write the first value as a pointer into the second storage unit corresponding to the i-th ray; the first value is not equal to the order of the primitive in its respective primitive node.

[0158] In one possible implementation, the processing unit is configured to: determine the next primitive node to be processed when the pointer value is the first value; and determine the (k+1)th primitive in the current primitive node to be processed when the pointer value is k and k is not equal to the first value.

[0159] Assume the first value is equal to 0. When the calculated distance value meets the preset condition, the processing unit will write the current primitive's order in the primitive node as a pointer to the second storage unit corresponding to the i-th ray. That is, when any calculated distance value meets the preset condition, the value of the pointer written by the processing unit to the second storage unit corresponding to the i-th ray is not equal to the first value.

[0160] Based on this, after the processing unit completes the processing of the last element in a node composed of regular transparent elements, it can write 0 as a pointer into the second storage unit corresponding to the i-th ray. When the processing unit needs to determine the element or element node to be processed next based on the pointer value, if the pointer value is 0, it can be determined that all elements in the element node have been processed, and the next element node to be processed is the next element node. If the pointer value is k and k is not equal to 0, it can be determined that the elements in the element node have not been processed, and the (k+1)-th element in the element node should be processed next.

[0161] Those skilled in the art should understand that the first value can also be set to other values, as long as the first value is not equal to the order of the graphic element in the graphic element node.

[0162] 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.

[0163] 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.

[0164] In one possible implementation, the transparent primitives of the rules are transparent primitives that can be simplified into fixed mathematical formulas through mathematical modeling.

[0165] Primitives that can be simplified into fixed mathematical formulas through mathematical modeling include, for example, triangular primitives, quadrilateral primitives, circular primitives, and elliptical primitives. Irregular primitives are those that cannot be simplified into fixed mathematical formulas through mathematical modeling, including user-defined shape primitives.

[0166] Those skilled in the art should understand that the classification criteria for regular and irregular primitives should not be limited to the examples 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, and vice versa.

[0167] 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 are used to determine whether the intersection is transparent. 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 the primitive type is a regular transparent primitive, a regular opaque primitive, an irregular primitive, etc.

[0168] 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 and the type of primitive can be distinguished based on the primitive parameters. The embodiments of this disclosure do not limit the specific content of the primitive parameters.

[0169] Figure 8 A schematic diagram showing the structure of a primitive processing apparatus including L processing units, N first storage units and N second storage units according to an embodiment of the present disclosure is provided.

[0170] like Figure 8 As shown, in one possible implementation, the device includes N first storage units and N second storage units;

[0171] The i-th ray corresponds to the i-th first storage unit and the i-th second storage unit, where N ≥ i > 0.

[0172] For example, suppose the primitive processing device includes L processing units. If there are N rays requiring ray tracing, these N rays can be assigned to the L processing units, so that each ray corresponds to one processing unit, and each processing unit performs ray tracing on its corresponding ray. The rays can be dynamically allocated based on the real-time load of the processing units, resulting in a more balanced load across them. Alternatively, the correspondence between processing units and rays can be pre-set. This embodiment does not limit the specific method for determining the correspondence between rays and processing units. Rays can be dynamically allocated or the correspondence between rays and processing units can be pre-set by any device in the scene with processing capabilities (such as a GPU computing unit or a central processing unit).

[0173] The primitive processing device may include N first storage units and N second storage units. The i-th ray corresponds to the i-th first storage unit and the i-th second storage unit. That is, for each ray, there is a one-to-one correspondence between a first storage unit and a second storage unit. The correspondence between the first storage units, the second storage units, and the rays can be preset and does not need to be allocated.

[0174] Therefore, when the current primitive is a regular transparent primitive and the calculated distance value meets the preset conditions, the processing unit corresponding to the i-th ray can write the order of the current primitive in the primitive node as a pointer into the i-th second storage unit, and request the GPU's computing unit to determine whether the calculated distance value is valid. Based on the judgment result of the GPU's computing unit, after updating the information stored in the first storage unit corresponding to the i-th ray (which is now the i-th first storage unit), the primitive or primitive node to be processed next can be determined according to the pointer stored in the i-th second storage unit.

[0175] Since each ray has a corresponding first storage unit and a second storage unit, the primitive processing device can ensure that there are no read / write conflicts when L processing units perform ray tracing simultaneously. Furthermore, each processing unit can directly begin ray tracing of the next ray after completing the ray tracing of one ray, allowing the primitive processing device to continuously perform ray tracing of multiple rays in a pipeline manner.

[0176] Assuming N is an integer multiple of L, if N rays are evenly distributed among L processing units, then Figure 8 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.

[0177] In one possible implementation, at least two first memory cells are distributed on the chip in a 3D stacked manner; at least two second memory cells are distributed on the chip in a 3D stacked manner.

[0178] 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.

[0179] The bit width of the second storage unit is the same as the bit width of the pointer. N second storage units are stacked into N / L layers, and each layer includes L second storage units.

[0180] 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.

[0181] The value of L can be configured according to the application scenario requirements. To increase the degree of parallelism, the value of L can be increased. This embodiment of the disclosure does not impose restrictions on the specific values ​​of L and N.

[0182] Because of the stacked structure, the chip area occupied by multiple stacked first memory cells is the same as that of a single first memory cell. Therefore, the chip area occupied by multiple stacked second memory cells is the same as that of a single second memory cell, which can reduce the chip area occupied.

[0183] Figure 9 A schematic diagram showing the structure of a primitive processing apparatus including L processing units, L first storage units and L second storage units according to an embodiment of the present disclosure is provided.

[0184] like Figure 9 As shown, in one possible implementation, the device includes L processing units, L first storage units, and L second storage units;

[0185] The j-th processing unit corresponds to the j-th first storage unit and the j-th second storage unit, where L≥j>0;

[0186] When i = L × w + j, the i-th ray corresponds to the j-th processing unit, and w ≥ 0 and is an integer.

[0187] For example, a primitive processing device may include L processing units, L first storage units, and L second storage units. The j-th processing unit automatically corresponds to the j-th first storage unit and the j-th second storage unit.

[0188] When there are N rays requiring ray tracing, these N rays can be assigned to L processing units, with each ray corresponding to one processing unit. Each processing unit is responsible for performing ray tracing on its corresponding ray. For example, if the ray is the L×w+j-th ray to be traced (i = L×w+j, w ≥ 0 and is an integer), it corresponds to the j-th processing unit. In other words, 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 the processing units.

[0189] Light can be dynamically allocated based on the real-time load of the processing units, resulting in a more balanced load on each unit. Alternatively, the correspondence between processing units and light can be preset; however, this embodiment does not limit the specific method for determining this correspondence. Any device in the scene with processing capabilities (such as a GPU's computing unit or a central processing unit) can dynamically allocate light or preset the correspondence between light and processing units.

[0190] 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 second storage unit also correspond to the i-th ray at this time, if the current primitive is a regular transparent primitive and the calculated distance value meets the preset conditions, the j-th processing unit can write the order of the current primitive in the primitive node as a pointer into the j-th second storage unit and request the GPU's computing unit to determine whether the calculated distance value is valid. Based on the judgment result of the GPU's computing unit, after updating the information stored in the first storage unit corresponding to the i-th ray (which is now the j-th first storage unit), the primitive or primitive node to be processed next can be determined based on the pointer stored in the j-th second storage unit.

[0191] Since each processing unit has a corresponding first storage unit and a second storage unit, the primitive processing device can guarantee that there are no read / write conflicts when L processing units perform ray tracing simultaneously. Furthermore, the number of first and 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.

[0192] 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 minimum distance value stored in the j-th first storage unit. Then, it clears the j-th first storage unit and the j-th second storage unit and performs ray tracing processing on the next ray corresponding to itself.

[0193] For example, since the j-th processing unit automatically corresponds to the j-th first storage unit and the j-th second storage unit, and the j-th processing unit may also correspond to multiple rays, this means that multiple rays corresponding to the j-th processing unit use the same (j-th) first storage unit and the same (j-th) second storage unit for ray tracing. Based on this, 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, the j-th processing unit can clear the j-th first storage unit and the j-th second storage unit before performing ray tracing on its next corresponding ray. This method avoids incorrectly using the primitive parameters, distance values, and pointers obtained from the ray tracing of the previous ray when ray tracing the next ray, ensuring the accuracy of the ray tracing results.

[0194] It should be understood that, in Figure 9 In the example, assuming N is an integer multiple of L, if N rays are evenly distributed among L processing units, then... Figure 9 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.

[0195] The value of L can be configured according to the application scenario requirements. If it is desired to increase the degree of parallelism, the value of L can be increased; if it is desired to reduce the area overhead of hardware resources, the value of L can be decreased; the specific value of L is not limited in the embodiments of this disclosure.

[0196] Figure 10 A schematic diagram showing the structure of a processing unit according to an embodiment of the present disclosure is provided.

[0197] like Figure 10 As shown, the processing unit may include a front-end and back-end interaction subunit, a traversal subunit, and a calculation subunit.

[0198] The front-end and back-end interaction subunit is responsible for interacting with the GPU's computing unit and with the first and second storage units.

[0199] 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 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 target ray.

[0200] After completing the intersection process, the computation subunit can return the result to the traversal subunit. If the primitive is a regular opaque primitive, the traversal subunit updates the first storage unit corresponding to the target ray based on the result, and then continues traversal. If the primitive is a regular transparent primitive, the traversal subunit writes the pointer to the second storage unit and notifies the front-end / back-end interaction subunit, which then requests the GPU's computation unit to determine if the calculated distance value is valid. The GPU's computation unit returns the determination result to the front-end / back-end interaction subunit, which forwards the result to the traversal subunit. The traversal subunit updates the first storage unit corresponding to the target ray based on the determination result and the calculated distance value, and then continues traversal based on the pointer value in the second storage unit.

[0201] After the GPU's computing unit completes the intersection process, it can return the intersection result to the front-end and back-end interaction subunit. The front-end and back-end interaction subunit then updates the first storage unit corresponding to the target ray based on the result.

[0202] The following is combined with Figure 10 The example given is how a primitive processing device, comprising one processing unit, one first storage unit, and one second storage unit, works in collaboration with the GPU's computing unit to implement ray tracing of the i-th ray.

[0203] In this example, the GPU's compute unit sends light-up data and a "start" instruction to the processing unit to instruct the processing unit to begin bounding box hierarchy work (see [link]). Figure 1a The front-end and back-end interaction subunit in the processing unit distributes the "start" instruction 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 calculation subunit. The calculation subunit performs intersection processing between the root node and the i-th ray based on the obtained address.

[0204] In the following example, the intersection process includes determining whether a ray hits a primitive / node and calculating the distance between the intersection point and the light source. A ray hitting a primitive / node means that the ray intersects with the primitive / node, and the distance between the intersection point and the light source is smaller than that of any other primitive / node already traversed.

[0205] Assuming the intersection of the root node and the i-th ray results in the i-th ray hitting the root node, the traversal sub-unit begins to traverse the root node and obtains the address of child node 0. The obtained address is then sent to the computation sub-unit, which performs the intersection of child node 0 and the i-th ray based on the obtained address.

[0206] Assuming that the intersection of child node 0 and the i-th ray results in the i-th ray hitting child node 0, the traversal sub-unit begins to traverse child node 0 and obtains the primitive parameters of primitive node 0. It is found that primitive node 0 is composed of regular opaque primitives, and the obtained primitive parameters are sent to the computation sub-unit.

[0207] like Figure 1a As shown, primitive node 0 includes primitive 00, primitive 01, and primitive 02. The computation subunit sequentially performs intersection processing on primitive 00, primitive 01, and primitive 02 with the i-th ray. Assuming that the i-th ray hits both primitive 00 and primitive 02, and the distance value between primitive 00 and the light source to which the i-th ray belongs is smaller, the computation subunit reports the primitive parameters of primitive 00 and the corresponding distance value of primitive 00 to the traversal subunit.

[0208] The traversal sub-unit writes the primitive parameters and corresponding distance values ​​of primitive 00 into the first storage unit. At the same time, the traversal sub-unit continues to traverse child node 0 and obtains the primitive parameters of primitive node 1 within it. It finds that primitive node 1 is composed of regular transparent primitives and sends the obtained primitive parameters to the calculation sub-unit.

[0209] like Figure 1a As shown, primitive node 1 includes primitive 10, primitive 11, and primitive 12. The computation subunit sequentially performs intersection processing on primitive 10, primitive 11, and primitive 12 with the i-th ray. If the ray does not hit primitive 10, it continues to perform intersection processing on primitive 11 with the i-th ray. If the i-th ray hits primitive 11, the computation subunit stops the intersection processing and reports the primitive parameters of primitive 11, the corresponding distance value, and the order of primitive 11 in primitive node 1 as a pointer (value 2) to the traversal subunit. The traversal subunit sends an assistance judgment request to the GPU general computing unit through the front-end and back-end interaction subunit, and writes the pointer to the second storage unit.

[0210] After responding to the assistance request, the GPU's computing unit reads the primitive parameters and distance values ​​of primitive 00 and primitive parameters of primitive 11 from the first storage unit through the front-end and back-end interaction subunit. The GPU's computing unit records the primitive parameters and determines whether the intersection of primitive 11 and the ray is transparent based on the primitive parameters. If the intersection of primitive 11 and the ray is not transparent, the distance value between the intersection and the light source is determined to be valid. The determination result and the primitive parameters of primitive 11 are returned to the front-end and back-end interaction subunit. The front-end and back-end interaction subunit updates the primitive parameters stored in the first storage unit to the primitive parameters of primitive 11 based on the determination result and the primitive parameters of primitive 11, updates the distance value stored in the first storage unit to the distance value between the intersection and the light source, and then sends a "start" command to the traversal subunit.

[0211] The traversal sub-unit responds to the "start" instruction by reading the pointer in the second storage unit. Since the pointer value is not 0, the traversal sub-unit does not traverse the next hop node, but instead issues an instruction to the calculation sub-unit to continue the intersection processing of the remaining primitives in the current node. At the same time, it increments the pointer value by 1 (the value is 3) and passes it to the calculation sub-unit.

[0212] The computation subunit determines the next primitive node in primitive node 1 to be processed based on the pointer value 3, which is primitive 12. The computation subunit performs intersection processing on primitive 12 and the ray. If primitive 12 does not match the ray, the computation subunit can write 0 as a pointer to the second storage unit. After reading the pointer value 0 from the traversal subunit, it determines that primitive node 1 has been processed, continues to obtain the address of child node 1, and sends the obtained address to the computation subunit. The computation subunit performs intersection processing on child node 1 and the i-th ray based on the obtained address.

[0213] Assuming the intersection result of child node 1 and the i-th ray is that the i-th ray hits child node 1, the traversal of child units begins to traverse child node 1 and obtains the primitive parameters of primitive node 2. It is found that primitive node 2 is composed of irregular opaque primitives. Then, the distance value and primitive parameters of primitive 11 are read from the first storage unit corresponding to the i-th ray, and a data reporting request is sent to the computing unit of the GPU.

[0214] In response to the data reporting request, the GPU's computing unit obtains the primitive parameters and distance values ​​of primitive 11 from the front-end and back-end interaction subunits, and sends a response signal to notify the front-end and back-end interaction subunits that it has completed data reading. The front-end and back-end interaction subunits then continue to send data reporting requests to the GPU's computing unit.

[0215] In response to the data reporting request, the GPU's computing unit obtains the primitive parameters of primitive node 2 from the front-end / back-end interaction subunit. Based on the primitive parameters of primitive node 2, it sequentially performs intersection processing on primitives 20, 21, 22, and 23 in primitive node 2 with the i-th ray. Assuming the i-th ray hits primitive 23, it returns the primitive parameters of primitive 23 and the corresponding distance value to the front-end / back-end interaction subunit. The front-end / back-end interaction subunit writes the primitive parameters of primitive 23 and the corresponding distance value to the first storage unit and notifies the traversal subunit to continue traversal.

[0216] The sub-unit continues to traverse child node 1 and obtains the primitive parameters of primitive node 3. It is found that primitive node 3 is composed of regular transparent primitives. The obtained primitive parameters are sent to the calculation sub-unit.

[0217] like Figure 1aAs shown, primitive node 3 includes primitive 30 and primitive 31. The computation subunit sequentially performs intersection processing on primitive 30, primitive 31, and the i-th ray. If the i-th ray does not hit primitive 30, it continues to perform intersection processing on primitive 31 and the i-th ray. If the i-th ray does not hit primitive 31, it notifies the traversal subunit that the i-th ray did not hit primitive node 3. The traversal subunit continues traversing, finds that the next hop node is empty, and reports to the front-end and back-end interaction subunits that the traversal of the bounding box hierarchy has ended. The front-end and back-end interaction subunits read the primitive parameters and distance values ​​stored in the first storage unit and report them to the GPU's computation unit along with the end signal. At this point, the entire ray tracing computation task is completed.

[0218] 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.

[0219] 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.

[0220] This disclosure also proposes a primitive processing method. Figure 11 A schematic diagram illustrating the flow of a primitive processing method according to an embodiment of the present disclosure is shown.

[0221] like Figure 11 As shown, in one possible implementation, the method is applied to a primitive processing apparatus, the apparatus including at least one processing unit, and the method includes:

[0222] Step S11: When the processing unit performs ray tracing processing on the i-th ray, it processes the primitive according to the primitive type; i is a positive integer.

[0223] When the primitive type is a regular transparent primitive, the primitive processing according to the primitive type includes determining whether the i-th ray intersects with the primitive.

[0224] In one possible implementation, when the primitive is a regular transparent primitive, processing the primitive according to its type further includes: when the i-th ray intersects with the primitive, calculating the distance between the intersection point and the light source to which the i-th ray belongs; when the calculated distance meets a preset condition, requesting the GPU's computing unit to determine whether the calculated distance is valid; and when the GPU's computing unit returns a determination result indicating that the calculated distance is valid, continuing to process the primitive.

[0225] In one possible implementation, the calculated distance value is valid when the intersection is opaque.

[0226] In one possible implementation, the device further includes at least one first storage unit, which is used to store the primitive parameters of the primitive whose intersection with the i-th ray is opaque and which is closest to the light source to which the i-th ray belongs, as well as the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs; the preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

[0227] In one possible implementation, when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, the primitive is further processed, including: when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0228] In one possible implementation, processing the primitive according to its type further includes: when the primitive is a regular opaque primitive, determining whether the i-th ray intersects with the primitive; when the i-th ray intersects with the primitive, calculating the distance between the intersection point and the light source to which the i-th ray belongs; and when the calculated distance value satisfies a preset condition, updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters of the primitive, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the calculated distance value.

[0229] In one possible implementation, processing the primitive according to its type further includes: when the primitive is an irregular primitive, requesting the GPU's computing unit to process the primitive; updating the primitive parameters stored in the first storage unit corresponding to the i-th ray using the primitive parameters returned by the GPU's computing unit, and updating the minimum distance value stored in the first storage unit corresponding to the i-th ray using the distance value returned by the GPU's computing unit.

[0230] In one possible implementation, the first primitive node is composed of multiple regular transparent primitives. The method further includes: when the processing unit traverses to the first primitive node, it obtains the primitive data of all primitives in the first primitive node; the primitive data of each primitive is used to determine whether the i-th ray intersects with the primitive; multiple primitives in the first primitive node are processed sequentially; when it is determined that the i-th ray does not intersect with the current primitive or when it is determined that the calculated distance value does not meet the preset condition, the next primitive is processed.

[0231] In one possible implementation, the device further includes at least one second storage unit, and processing the primitive according to its type further includes: when the calculated distance value meets a preset condition, writing the order of the primitive in its respective primitive node as a pointer into the second storage unit corresponding to the i-th ray; the primitive node includes multiple primitives; after updating the first storage unit corresponding to the i-th ray, determining the primitive or primitive node to be processed next based on the value of the pointer.

[0232] In one possible implementation, processing the primitive according to its type further includes: after processing the last primitive in the primitive node, writing a first value as a pointer into the second storage unit corresponding to the i-th ray; the first value is not equal to the order of the primitive in its respective primitive node.

[0233] In one possible implementation, determining the next primitive or primitive node to be processed based on the value of the pointer includes: when the value of the pointer is a first value, determining the next primitive node to be processed; when the value of the pointer is k and k is not equal to the first value, determining the (k+1)th primitive in the current primitive node to be processed next.

[0234] In one possible implementation, the device includes N first storage units and N second storage units; the i-th ray corresponds to the i-th first storage unit and the i-th second storage unit, where N ≥ i > 0.

[0235] In one possible implementation, the device includes L processing units, L first storage units, and L second storage units; the j-th processing unit corresponds to the j-th first storage unit and the j-th second storage unit, where L ≥ j > 0; when i = L × w + j, the i-th ray corresponds to the j-th processing unit, where w ≥ 0 and is an integer.

[0236] 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 minimum distance value stored in the j-th first storage unit. Then, it clears the j-th first storage unit and the j-th second storage unit and performs ray tracing processing on the next ray corresponding to itself.

[0237] 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.

[0238] In one possible implementation, the transparent primitives of the rule are transparent primitives that can be simplified into fixed mathematical formulas through mathematical modeling.

[0239] In one possible implementation, the primitive parameters include one or more of the following: centroid coordinates, primitive index, address of primitive data in the cache, and primitive attributes.

[0240] 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.

[0241] 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.

[0242] 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; The processing unit is used to process the primitive according to its type when performing ray tracing processing for the i-th ray; i is a positive integer; Wherein, when the type of the primitive is a regular transparent primitive, the processing unit is used to determine whether the i-th ray intersects with the primitive; when the i-th ray intersects with the primitive, the processing unit calculates the distance between the intersection point and the light source to which the i-th ray belongs; when the calculated distance meets a preset condition, the processing unit requests the GPU's computing unit to determine whether the calculated distance is valid; when the GPU's computing unit returns a determination result indicating that the calculated distance is valid, the processing of the primitive continues. The device further includes at least one first storage unit, which corresponds to the i-th ray and is used to store the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs; The preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

2. The apparatus according to claim 1, characterized in that, The calculated distance value is valid when the intersection point is opaque.

3. The apparatus according to claim 1, characterized in that, The first storage unit corresponding to the i-th ray is used to store the primitive parameters of the primitive whose intersection with the i-th ray is opaque and whose distance to the light source to which the i-th ray belongs is closest.

4. The apparatus according to claim 3, characterized in that, The processing unit is used for: When the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, the primitive parameters of the primitive are updated using the primitive parameters of the primitive, and the minimum distance value stored in the first storage unit corresponding to the i-th ray is updated using the calculated distance value.

5. The apparatus according to claim 3, characterized in that, When the type of the graphic element is a regular opaque graphic element, the processing unit is used to: Determine whether the i-th ray and the primitive intersect; When the i-th ray intersects with the primitive, calculate the distance between the intersection point and the light source to which the i-th ray belongs; When the calculated distance value meets the preset conditions, the primitive parameters of the primitive corresponding to the i-th ray are updated using the primitive parameters of the primitive, and the minimum distance value of the first storage unit corresponding to the i-th ray is updated using the calculated distance value.

6. The apparatus according to claim 3, characterized in that, When the type of the graphic element is an irregular graphic element, the processing unit is used for: The GPU's computing unit is requested to process the primitives; The primitive parameters returned by the GPU's computing unit are used to update the primitive parameters stored in the first storage unit corresponding to the i-th ray, and the distance values ​​returned by the GPU's computing unit are used to update the minimum distance value stored in the first storage unit corresponding to the i-th ray.

7. The apparatus according to claim 1, characterized in that, The first primitive node consists of multiple regular transparent primitives, and the processing unit is used for: When traversing to the first primitive node, obtain the primitive data of all primitives in the first primitive node; the primitive data of each primitive is used to determine whether the i-th ray intersects with the primitive; Process multiple primitives in the first primitive node sequentially; If it is determined that the i-th ray does not intersect with the current primitive or that the calculated distance value does not meet the preset conditions, continue processing the next primitive.

8. The apparatus according to claim 1, characterized in that, The device further includes at least one second storage unit, and the processing unit is further configured to: When the calculated distance value meets the preset conditions, the order of the graphic element in its respective graphic element node is written as a pointer into the second storage unit corresponding to the i-th ray; After updating the first storage unit corresponding to the i-th ray, the primitive or primitive node to be processed next is determined according to the value of the pointer.

9. The apparatus according to claim 8, characterized in that, The processing unit is further configured to, after completing the processing of the last graphic element in the graphic element node, write the first value as a pointer into the second storage unit corresponding to the i-th ray; the first value is not equal to the order of the graphic element in its respective graphic element node.

10. The apparatus according to claim 9, characterized in that, The processing unit is used for, When the pointer value is the first value, determine the next primitive node to be processed; When the pointer value is k and k is not equal to the first value, determine the (k+1)th element in the current element node to be processed next.

11. The apparatus according to claim 8, characterized in that, The device includes N first storage units and N second storage units; The i-th ray corresponds to the i-th first storage unit and the i-th second storage unit, where N ≥ i > 0.

12. The apparatus according to claim 8, characterized in that, The device includes L processing units, L first storage units, and L second storage units; The j-th processing unit corresponds to the j-th first storage unit and the j-th second storage unit, where L≥j>0; When i = L × w + j, the i-th ray corresponds to the j-th processing unit, and w ≥ 0 and is an integer.

13. The apparatus according to claim 12, 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 minimum distance value stored in the j-th first storage unit. Then, it clears the j-th first storage unit and the j-th second storage unit and performs ray tracing processing on the next ray corresponding to itself.

14. The apparatus according to claim 1, 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.

15. The apparatus according to claim 1, characterized in that, The transparent primitives of the rules are transparent primitives that can be simplified into fixed mathematical formulas through mathematical modeling.

16. The apparatus according to claim 3, characterized in that, The primitive parameters include one or more of the following: centroid coordinates, primitive index, address of primitive data in the cache, and primitive attributes.

17. A graphics processor, characterized in that, The graphic element processing apparatus includes any one of claims 1-16.

18. An electronic device, characterized in that, Includes the graphics processor of claim 17.

19. A primitive processing method, characterized in that, The method is applied to a primitive processing apparatus, the apparatus including at least one processing unit, the method comprising: When performing ray tracing processing on the i-th ray, the processing unit processes the primitive according to its type; i is a positive integer. Wherein, when the type of the primitive is a regular transparent primitive, processing the primitive according to the primitive type includes determining whether the i-th ray intersects with the primitive; when the i-th ray intersects with the primitive, calculating the distance value between the intersection point and the light source to which the i-th ray belongs; when the calculated distance value meets a preset condition, requesting the GPU's computing unit to determine whether the calculated distance value is valid; when the judgment result returned by the GPU's computing unit indicates that the calculated distance value is valid, continuing to process the primitive; The device further includes at least one first storage unit, which corresponds to the i-th ray and is used to store the minimum distance value between all primitives whose intersection with the i-th ray is opaque and the light source to which the i-th ray belongs; The preset condition is that the calculated distance value is less than the minimum distance value stored in the first storage unit corresponding to the i-th ray.

Citation Information

Patent Citations

  • Hardware acceleration for ray tracing primitives that share vertices

    US20210390759A1