Light ray tracing method and device, graphics processor and electronic device

By dynamically configuring the ray traversal method and combining depth and breadth traversal, the intersection test between rays and the hierarchical bounding volume is optimized, which solves the problem of low ray tracing efficiency and improves GPU performance and resource utilization.

CN122156431APending Publication Date: 2026-06-05MOORE THREADS TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
MOORE THREADS TECH CO LTD
Filing Date
2026-05-06
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing ray tracing technologies, the efficiency of intersecting rays with the bounding volume is low, resulting in a reduced cache hit rate, which affects GPU performance and energy consumption.

Method used

A dynamically configured ray traversal method is adopted, which combines depth traversal and breadth traversal to control the intersection test of rays with the hierarchical bounding volume, and dynamically adjust the control information to optimize performance and resource utilization.

Benefits of technology

It improves cache hit rate, reduces latency and energy consumption, enhances ray tracing efficiency and GPU performance, and achieves a balance between performance, power consumption and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156431A_ABST
    Figure CN122156431A_ABST
Patent Text Reader

Abstract

The application provides a light ray tracing method and device, a graphics processor and an electronic device. The light ray tracing method comprises: obtaining control information; wherein the control information is dynamically configured, and the control information comprises a light ray traversal mode; the light ray traversal mode comprises a depth traversal mode or a breadth traversal mode; the depth traversal mode represents depth traversal of a same light ray on a hierarchical bounding volume; and the breadth traversal mode represents breadth traversal of different light rays on the hierarchical bounding volume; and based on the light ray traversal mode, an intersection test of a first light ray and the hierarchical bounding volume is controlled.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to, but is not limited to, the field of graphics processing technology, and in particular to a ray tracing method and apparatus, a graphics processor, and an electronic device. Background Technology

[0002] The Graphics Processing Unit (GPU) primarily handles complex geometric calculations and rendering tasks. During rendering, the GPU typically employs Ray Tracing (RT) to render the scene. RT is a computer graphics technique that generates realistic images by simulating the propagation path of light rays in a 3D scene. Its core principles include ray emission, intersection detection, recursive tracing, and lighting calculation, enabling it to accurately represent reflection, refraction, and global illumination effects.

[0003] In related technologies, during the RT process, the intersection tests of each ray with the Bounding Volume Hierarchy (BVH) are usually performed in order of age priority (i.e., time order). This may cause the node information that enters the cache first to be squeezed out, reducing the cache hit rate and increasing latency, thereby affecting the ray tracing efficiency and reducing the performance of the GPU. Summary of the Invention

[0004] This application provides a ray tracing method and apparatus, a graphics processor, and an electronic device.

[0005] The technical solution of this application embodiment is implemented as follows: This application provides a ray tracing method, including: Acquire control information; wherein, the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. Depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. Based on the ray traversal method, the intersection test between the first ray and the hierarchical bounding volume is controlled.

[0006] This application provides a ray tracing device, including a configuration unit and a processing unit, wherein: The configuration unit is used to store control information; wherein, the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. Depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. The processing unit is used to obtain the ray traversal mode from the configuration unit; and based on the ray traversal mode, control the intersection test between the first ray and the hierarchical bounding volume.

[0007] This application provides a graphics processor that includes the ray tracing device described above.

[0008] This application provides an electronic device including the aforementioned graphics processor.

[0009] The embodiments of this application have the following beneficial effects: On the one hand, during ray tracing, the intersection tests of subsequent rays with the hierarchical bounding body are controlled according to the ray traversal method. Compared to related solutions that can only perform depth traversal of the hierarchical bounding body sequentially according to time, this application not only performs breadth traversal of the hierarchical bounding body for each ray, allowing more rays to enter the intersection test, that is, this application allows more objects in the cache to perform intersection tests with rays. This ensures that subsequent rays that could have hit the cache will still hit, reducing the possibility of retrieving the object from memory again, greatly increasing the cache hit rate and reducing latency, thereby improving tracing efficiency and reducing energy consumption. Moreover, it can also be compatible with depth traversal of the same ray on the hierarchical bounding body, reducing the possibility that some hardware may be idle due to only being able to perform breadth traversal of different rays on the hierarchical bounding body, thus maximizing GPU performance while improving flexibility. On the other hand, by dynamically configuring control information, the control information is given higher flexibility and controllability, thereby achieving an optimal balance between performance, power consumption, and resource utilization. Attached Figure Description

[0010] Figure 1 A schematic diagram of the implementation process of a ray tracing method provided in this application embodiment. Figure 1 ; Figure 2 This is a schematic diagram of the first component structure of a ray tracing device provided in an embodiment of this application; Figure 3 This is a schematic diagram of the second component structure of a ray tracing device provided in an embodiment of this application; Figure 4 A schematic diagram of the implementation process of a ray tracing method provided in this application embodiment. Figure 2 ; Figure 5 This is a schematic diagram of a ray traversal method and ray tracing provided in an embodiment of this application.

[0011] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation

[0012] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0013] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0014] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0015] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0016] The technical solutions in the embodiments of this application will now be clearly and completely described with reference to the accompanying drawings.

[0017] Figure 1 A schematic diagram of the implementation process of a ray tracing method provided in this application embodiment. Figure 1 ,like Figure 1 As shown, the ray tracing method includes steps S11 and S12, wherein: Step S11: Obtain control information; wherein, the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. Depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. Step S12: Based on the ray traversal method, control the intersection test between the first ray and the layer bounding volume.

[0018] Here, BVH is a common data structure in RT. BVH, based on a tree structure, contains different types of nodes, such as box nodes and primitive nodes. Box nodes are typically internal nodes, such as intermediate nodes or root nodes. Intermediate nodes are nodes other than the root and leaf nodes. Primitive nodes, on the other hand, are leaf nodes that store the basic graphics (i.e., primitives) of the scene, which refers to the rendered virtual 3D environment itself. Primitives can include, but are not limited to, triangles, polygons, points, and line segments. Box nodes contain at least one bounding volume, and leaf nodes contain at least one primitive. Each bounding volume tightly surrounds the primitive in the leaf node, and these bounding volumes are recursively combined into larger bounding volumes, ultimately forming a tree structure. The top of the tree (i.e., the root node) contains only one bounding volume.

[0019] BVH traversal is typically performed in depth-first order, testing whether a ray intersects with box nodes and leaf nodes. In implementation, it first checks if the ray intersects with the bounding box of the root node. If not, the ray doesn't need further investigation of the BVH tree; if it does, it checks if the ray intersects with the root node's child nodes (i.e., intermediate nodes). By recursively checking each box node, the ray will only continue traversing those box nodes that intersect with it, until it reaches a leaf node where the intersection test between the ray and the actual primitive is performed.

[0020] Control information may include, but is not limited to, ray traversal methods and prefetch information.

[0021] The ray traversal method indicates how at least one ray traverses the BVH (Breadth-to-Header). In other words, it indicates how to schedule the rays. This ray traversal method can include, but is not limited to, breadth-first traversal and depth-first traversal. Breadth-first traversal indicates that different rays traverse the BVH extensively, allowing more rays to enter the intersection test; that is, prioritizing intersection tests between different rays and the same object. Breadth-first traversal can include, but is not limited to, first breadth-first traversal and second breadth-first traversal. First breadth-first traversal instructs different rays to traverse the same object sequentially; that is, intersection tests between rays and objects are performed sequentially according to the testing order of the rays; that is, intersection tests are performed between the same object and each ray. Second breadth-first traversal instructs different rays to traverse according to the most recently visited object; that is, intersection tests are performed between the most recently visited object and the nearest ray. The nearest ray is the ray closest to the most recently visited object. The depth-first traversal method performs a depth-first traversal of the BVH using the same ray. In other words, it prioritizes performing a depth-first traversal of the BVH using the same ray, which means performing an intersection test between a ray and different objects in the BVH.

[0022] Prefetch information may include, but is not limited to, prefetch identifiers and prefetch methods. A prefetch identifier indicates whether nodes are prefetched. This identifier may include, but is not limited to, a first identifier and a second identifier. The first identifier indicates that nodes are not prefetched. The second identifier indicates that nodes are prefetched. The prefetch method indicates the node information to be prefetched. This method may include, but is not limited to, sequential prefetching, interval prefetching, and batch prefetching. Sequential prefetching prefetches adjacent nodes consecutively according to their address order. Interval prefetching reads nodes at preset address intervals. Batch prefetching can prefetch nodes according to the same level, traversal path, etc. For example, prefetching multiple nodes at the same level. Another example is prefetching multiple nodes in a certain depth direction.

[0023] The control information can be configured in any suitable way. In some implementations, the control information can be configured using prediction information generated by a pre-trained prediction model. This prediction model can be any suitable neural network model capable of performing this function. In some implementations, the control information can be configured according to the usage scenario. The usage scenario refers to the specific scenario (or application) in which the RT is used. It is understood that different usage scenarios may correspond to the same or different control information. In some implementations, the control information can be pre-defined based on experience.

[0024] The control information can be acquired in any suitable manner. In some implementations, the control information is acquired when the RT (Range Response) enters the BVH (Browser Volume Hatch). In some implementations, the control information is acquired when a new ray is received. In practice, the same control information can be used for the same application (such as a game), or the control information can be dynamically determined based on each frame of the image.

[0025] The first ray includes at least one ray. It can be understood that the first ray refers to the ray that needs to be tested for intersection with the BVH. In implementation, different control information can correspond to different control methods for intersection testing.

[0026] In some implementations, when the control information includes a ray traversal method, the intersection test between the first ray and the BVH is controlled according to the ray traversal method. For example, when the ray traversal method is a depth-first traversal method, the intersection test between each ray and the BVH is performed sequentially according to the current traversal order of each ray in the first ray; when the ray traversal method is a breadth-first traversal method, the intersection test between the first ray and the BVH can be performed based on whether the ray traversal method is a first breadth-first traversal method or a second breadth-first traversal method.

[0027] In some implementations, when the control information includes prefetch information and ray traversal method, if the prefetch identifier in the prefetch information is a first identifier, then the intersection test between the first ray and BVH can be controlled according to the ray traversal method; if the prefetch identifier in the prefetch information is a second identifier, then the intersection test between the first ray and BVH can be performed according to the ray traversal method and the prefetch method.

[0028] The intersection test of a ray and a bounding box (BVH) can include, but is not limited to, the intersection test of a ray and at least one object in at least one node of the BVH. An object can be the bounding box of a box node or a primitive of a leaf node. Primitives can include, but are not limited to, transparent primitives, opaque primitives, and procedural primitives. Opaque primitives are completely opaque graphic elements. Transparent primitives are primitives with partially or completely transparent areas. Procedural primitives are not predefined geometric data, but rather graphic elements dynamically generated at runtime through code, such as circles and rectangles defined by functions.

[0029] Understandably, when an object is a primitive, it can be a special primitive or any other primitive besides a special primitive. Special primitives refer to primitives whose intersection with the object cannot be determined (i.e., intersection information is pending), such as transparent primitives and procedural primitives. In implementation, the intersection process for special primitives and the update of the ray length (rayT) require a separate computational unit. This computational unit is a core component in RT dedicated to processing special primitives, and it can reside within the GPU. In implementation, this computational unit is used to determine the intersection result between the ray and the special object, and to update rayT. The intersection result can include, but is not limited to, intersection or non-intersection. For example, if the object is a procedural primitive, the intersection result can be solved jointly based on the expression of the procedural primitive and the equation corresponding to the ray. As another example, if the object is a transparent primitive, the intersection result is determined based on the equation corresponding to the ray and the index and vertex position of the transparent primitive. The update of rayT can include: if the intersection result is intersecting, then update rayT based on the intersection point; if the intersection result is disjoint, then use the original rayT as the new rayT. The computing unit and the device executing the ray tracing method can communicate. In implementation, the device executing the ray tracing method can transmit the intersection test results to the computing unit through direct transmission, indirect transmission, shared memory, broadcasting, etc. For example, if the computing unit communicates directly with the device, then the device can send the intersection test results to the computing unit. In implementation, the computing unit can be located inside or outside the device. Thus, when encountering special primitives, intersection calculation and updates are performed through a dedicated computing unit, significantly improving computational efficiency and reducing resource contention, thereby improving the overall efficiency and energy efficiency of ray tracing.

[0030] In some implementations, the intersection test of the first ray with the BVH may include at least the intersection test of the first ray with a first object, which is an object in the BVH, such as a primitive, a bounding box, etc.

[0031] In some implementations, the intersection test between the first ray and the BVH may include at least the intersection test between the target ray and the object to which the target ray intersects. The target ray may be one, some, or all of the first rays. The object to which the target ray intersects is an object in the BVH, such as a primitive or bounding box. The objects to which different rays intersect may be the same or different. In practice, the object to which the target ray intersects may be the same as or different from the first object. It is understood that the object to which a particular ray intersects is the first object.

[0032] The intersection test between a ray and an object is used to determine the result of the intersection test. This result may include, but is not limited to, intersection information and object information. Intersection information characterizes whether a ray and an object intersect. Intersection information may include, but is not limited to, intersection, non-intersection, and pending. Intersection means that the ray and object have an intersection point. In practice, if the intersection information includes intersection, it may also include the intersection point. Non-intersection means that the ray and object do not have an intersection point. Pending means that the ray and object may or may not intersect, requiring further determination. In practice, when the object is found to be a special primitive, the intersection information may be pending. Object information may include, but is not limited to, object attributes, object storage location, primitive index, and primitive vertex data. Object attributes may include, but are not limited to, position, size, color, transparency, and dynamic parameters (such as time, lifecycle, and functions). Object storage location refers to the location of the primitive or bounding box in the cache or memory. Primitive indexes are used to define the connection relationships between the vertices of the object. Primitive vertex data may be the vertex positions of the primitive. Understandably, the indexes and vertex data for most primitives are static, but the indexes and vertex data for procedural primitives are dynamically generated.

[0033] The intersection test results for different objects can include the same or different information. For example, the intersection test results for all objects include both intersection information and object information. Alternatively, the intersection test results for specific primitives include both intersection information and primitive information, while the intersection test results for other objects only include the intersection information.

[0034] In some implementations, steps S11 and S12 described above may be executed by a processing unit in the ray tracing device, and the control information may be stored in the configuration unit of the ray tracing device.

[0035] In some implementations, the processing unit may include a traversal unit and an intersection test unit. The traversal unit obtains control information from the configuration unit, and the intersection test unit controls the intersection test of the first ray with the BVH based on the ray traversal method or the ray traversal method and prefetch information.

[0036] In some implementations, the traversal unit may include a ray scheduling control unit and a node prefetching unit. The ray scheduling control unit obtains the ray traversal mode from the configuration unit, and the node prefetching unit obtains prefetch information from the configuration unit.

[0037] In this embodiment, on the one hand, during ray tracing, the intersection tests of subsequent rays with the hierarchical bounding body are controlled according to the ray traversal method. Compared to related schemes that can only perform depth traversal of the hierarchical bounding body sequentially according to time, this application not only performs breadth traversal of the hierarchical bounding body, allowing more rays to enter the intersection test, but also allows objects in the cache to perform more intersection tests with rays. This ensures that subsequent rays that could have hit the cache will still hit, reducing the possibility of retrieving the object from memory again, greatly increasing the cache hit rate and reducing latency, thereby improving tracing efficiency and reducing energy consumption. Furthermore, it is compatible with depth traversal of the same ray on the hierarchical bounding body, reducing the possibility that some hardware might be idle due to only being able to perform breadth traversal of different rays on the hierarchical bounding body, thus maximizing GPU performance while improving flexibility. On the other hand, by dynamically configuring control information, higher flexibility and controllability are given to the control information, thereby achieving an optimal balance between performance, power consumption, and resource utilization.

[0038] In some embodiments, the ray tracing method further includes step S101, wherein: Step S101: Configure control information based on the usage scenario corresponding to the hierarchical enclosing volume.

[0039] Here, the use case refers to the industry or application corresponding to the BVH in RT. Different use cases can correspond to the same or different control information. For example, the control information for use case A and use case C can be the first control information, while the control information for use case B can be the second control information.

[0040] The method for determining this update identifier can be any suitable method.

[0041] In some implementations, a correspondence between each usage scenario and each control information can be established in advance. Based on this correspondence, the control information corresponding to the usage scenario can be obtained.

[0042] In some implementations, control information can be determined based on the judgment result of whether the usage scenario is a preset usage scenario.

[0043] A preset use case is a pre-defined usage scenario. There can be at least one preset use case. It is understood that the control information under a preset use case is predetermined; for example, a preset use case could be a pre-defined whitelist. Alternatively, a preset use case could be a pre-defined blacklist. In some implementations, several preset use cases and corresponding control information can be pre-defined based on experience, offline testing, reinforcement learning, or any suitable method. Offline testing can involve testing under different control information within the same use case to determine the control information corresponding to that use case, and then using that use case as a preset use case. Reinforcement learning is a machine learning method whose core idea is to allow an agent to learn the optimal policy through trial and error in its interaction with the environment, thereby maximizing long-term cumulative rewards. In implementation, preset use cases are configurable.

[0044] Understandably, if the usage scenario is a preset usage scenario, then the control information under the preset usage scenario will be used as the control information; if the usage scenario is not a preset usage scenario, then other control information (i.e., control information under non-preset usage scenarios) will be used as the control information. Non-preset usage scenarios are usage scenarios other than preset usage scenarios. Control information under non-preset usage scenarios can be control information corresponding to a certain preset usage scenario, or it can be pre-set default control information.

[0045] During implementation, the usage scenario can be compared with various preset usage scenarios to determine whether it matches a preset scenario. This allows for the configuration of control information based on whether it conforms to a preset usage scenario, improving the flexibility, effectiveness, and security of the control information and making its configuration clearer and more controllable.

[0046] In some implementations, once the control information is determined, it can be updated to pre-defined registers, caches, or shared memory.

[0047] In some implementations, step S101 may be performed by the configuration unit.

[0048] In this application embodiment, the control information is dynamically configured according to the usage scenario, which not only improves the flexibility of configuration, but also simplifies the configuration and reduces the resource consumption caused by misconfiguration.

[0049] In some embodiments, the ray tracing method further includes step S102, wherein: Step S102: Configure control information based on the prediction information generated by the trained prediction model.

[0050] Here, the prediction model can be any suitable neural network model capable of performing this function. Before inference, the prediction model can be trained or fine-tuned using a sample set to obtain the trained prediction model.

[0051] In some implementations, the prediction information can be obtained by inputting the relevant information of the current use case into the prediction model. The use case refers to the specific industry or application in which the rendering (RT) is applied. The relevant information can include, but is not limited to, any suitable information such as images, scenes (i.e., the rendered virtual 3D environment itself), names, and keywords. For example, inputting a portion of the scene into the prediction model can yield the prediction information. Another example is inputting the workload data of a frame of image during runtime into the prediction model. This workload data can include, but is not limited to, the number of bounding box tests, the number of primitive intersection tests, the number of ray emissions, the BVH construction time, the node cache hit rate, and the hit rate of various levels of cache within the GPU.

[0052] The control information can be determined in any suitable way. In some implementations, the predicted information can be directly used as the control information. In some implementations, the predicted information can be converted into corresponding configuration information based on the conversion relationship between the predicted information and the control information determined by the current usage scenario. In some implementations, the final control information can be determined based on the predicted information and the control information determined by the current usage scenario. For example, if the predicted information and the control information match (e.g., they are the same, or the similarity exceeds a threshold), the predicted information is used as the final control information; if the configuration information and the identification information do not match, either the predicted information or the control information can be used as the final control information, or the final control information can be further determined based on other information.

[0053] In some implementations, the workload data of the previous frame during operation can be input into the prediction model to obtain the prediction information of the next frame. In other words, the control information is also dynamically generated along with the workload data of each frame.

[0054] During implementation, once the control information is determined, it can be updated to pre-defined registers, caches, and shared memory.

[0055] In some implementations, step S101 may be performed by the configuration unit.

[0056] In the embodiments of this application, control information is automatically configured based on the information recommended by the trained machine learning model. Compared with manual customization, it can not only adapt to different operating environments, load changes, business needs, etc., but also reduce intervention costs and improve stability and reliability, thereby achieving the effect of higher performance and lower power consumption as more operations are performed.

[0057] In some implementations, the breadth-first traversal method includes a first breadth-first traversal method or a second breadth-first traversal method. The first breadth-first traversal method is used to instruct different rays to traverse the same object sequentially, while the second breadth-first traversal method is used to instruct different rays to traverse according to the most recently visited object.

[0058] Here, breadth-first traversal methods can include, but are not limited to, first breadth-first traversal methods, second breadth-first traversal methods, etc.

[0059] When it is necessary to perform breadth-first traversal of the BVH using different rays, the intersection test between the first ray and the BVH can be further controlled according to the breadth-first traversal method. It is understandable that different breadth-first traversal methods can correspond to different control methods.

[0060] In some implementations, when the ray traversal method is a first breadth-first traversal, and the characterization requires intersecting each ray in the first ray with the same object, the testing order of each ray in the first ray can be determined first, and then the intersecting test of each ray in the first ray with a certain object can be performed according to this testing order. In implementation, the object can be a bounding box in a bounding box node or a primitive in a leaf node. For example, if the first ray includes ray0 and ray1, and the testing order is ray0 first and then ray1, then the intersection test of ray0 and object X can be controlled first. After obtaining the intersection test result of ray0 and object X, the intersection test of ray1 and object X can be controlled to obtain the intersection test result of ray1 and object X.

[0061] In some implementations, when the ray traversal method is the second breadth-first traversal method, it is indicated that the target ray needs to be found based on the most recently visited object. That is, the breadth-first traversal of multiple rays is performed according to the most recently visited object. Therefore, the target ray can be found first, and then the intersection test between the target ray and its corresponding intersection object can be performed. For example, the first ray includes ray0 and ray1. If the target ray is ray1, then ray1 can be controlled to perform an intersection test with its intersection object. After obtaining the intersection test result of ray1 and its intersection object, a new target ray is found based on the most recently visited object, and the intersection test between the new target ray and its intersection object is performed. This process is repeated to complete the intersection test between the first ray and BVH.

[0062] In the embodiments of this application, when performing breadth traversal of different rays, the intersection test between each ray and the layer bounding volume is further controlled according to the ray traversal method to ensure the efficiency and accuracy of the intersection test, further reduce node extrusion and increase cache hit rate.

[0063] In some embodiments, the first ray includes at least two rays; the intersection test of the first ray with the hierarchical enclosure includes the intersection test of the first ray with a first object in the hierarchical enclosure; step S12 includes steps S121 and S122, wherein: Step S121: When the ray traversal method is the first breadth-first traversal method, determine the test order of each ray in the first ray; Step S122: Perform the intersection test between the first object and each ray in the first ray according to the test order of each ray in the first ray; wherein, the first object is an object in the hierarchical bounding volume.

[0064] Here, in the first breadth-first traversal approach, the intersection tests between each ray and the object are performed sequentially according to the testing order of the rays in the first ray. This testing order indicates the order in which the rays in the first ray are arranged. For example, if the first ray includes ray0 and ray1, then the testing order can be ray0 first then ray1, or ray1 first then ray0. As another example, if the first ray includes ray0, ray1, and ray2, then the testing order can be ray0 first then ray1 then ray2, or ray1 first then ray0 then ray2, or ray1 first then ray2 then ray0.

[0065] The test order can be determined in any suitable way. In some embodiments, the test order can be determined based on the order in which the rays in the first ray enter. In some embodiments, the test order can be determined based on the spatial position of the rays in the first ray, that is, according to the degree of spatial adjacency of the rays in the first ray. In some embodiments, the test order can be determined based on the correlation between the rays in the first ray. For example, the test order can be obtained by sorting the rays in the first ray according to the degree of similarity between them and the principal ray.

[0066] The first object is any object in BVH. It can be the bounding box within a bounding box node or a primitive within a leaf node. During implementation, intersection tests are performed sequentially between each ray in the first ray and the first object, following the test order. For example, if the first ray includes ray0, ray1, and ray2, and the first object is the bounding box X, assuming the test order is ray2 first, then ray1, then ray0, then: Perform an intersection test between ray2 and X, and obtain the intersection test results between ray2 and X; Perform an intersection test between ray1 and X to obtain the intersection test results between ray1 and X; Perform an intersection test between ray0 and X to obtain the intersection test results between ray0 and X.

[0067] The intersection test between the ray and the first object is used to determine whether the ray intersects with the first object. In practice, the intersection test between the ray and the object can be found in the specific implementation of step S12 described above.

[0068] It is understandable that the intersection test between the first ray and BVH includes at least the intersection test between the first ray and the first object. In implementation, after completing the intersection test between the first object and the first ray, it is determined whether to continue traversing BVH. If it is necessary to continue traversing BVH, then the intersection test between the second ray and other objects is performed. This second ray can be the first ray, a portion of the first ray, a combination of the first ray and other rays, or the first ray and other rays.

[0069] In some implementations, the processing unit includes a traversal unit and an intersection testing unit. The traversal unit includes a light scheduling control unit. The above step S121 can be executed by the light scheduling control unit, and the above step S122 can be executed by the intersection testing unit.

[0070] In the embodiments of this application, when each ray traverses the same object in sequence, the intersection test between each ray and the object is performed sequentially according to the determined test order. This not only achieves the purpose of making full use of the cache and reducing the possibility that the ray will not hit the target due to the object being squeezed out, but also improves the locality of memory access, reduces memory bandwidth pressure, and improves the overall throughput, thereby improving ray tracing efficiency and performance.

[0071] In some implementations, the step S121 of "determining the test order of each ray in the first ray" includes: determining the test order of each ray in the first ray based on the entry order of each ray in the first ray.

[0072] Here, the entry order can refer to the order in which light rays enter the RT. In practice, light rays can typically enter the RT in either the generation order or the scheduling order.

[0073] The test order refers to the order in which the rays are arranged in the test unit (RT). It is understandable that if the first ray consists of only one ray, the first ray can be directly used as the order of arrangement for that ray; if the first ray consists of at least two rays, then the order of arrangement for each ray needs to be determined.

[0074] The order of the tests can be determined in any suitable way.

[0075] In some implementations, the entry order can be directly used as the testing order; that is, the ray that enters the RT earlier will be scheduled first. For example, if ray0 enters the RT before ray1, then the testing order is ray0 first, then ray1.

[0076] In some implementations, the reverse order of entry can be used as the testing order; that is, rays that enter the RT later will be scheduled first. For example, if ray0 enters the RT before ray1, then the testing order is ray1 first, then ray0.

[0077] During implementation, if at least two light rays enter simultaneously, the test order of the simultaneously entering light rays can be determined by custom, random, or other methods.

[0078] In this embodiment, the test order is determined according to the entry order of each ray, ensuring the logic and controllability of ray tracing and achieving the continuity of the time sequence, so as to render the scene more realistically.

[0079] In some embodiments, after performing an intersection test between the first object and each ray in the first ray, the ray tracing method further includes steps S131 and S132, wherein: Step S131: Based on the intersection test results between the first object and each ray in the first ray, determine the current traversal result of the hierarchical bounding volume; wherein, the current traversal result indicates whether to continue traversing the hierarchical bounding volume; Step S132: If the current traversal result represents the continuation of traversing the hierarchical bounding volume, determine the test order of each ray in the second ray, and perform the intersection test between the second object and each ray in the second ray in sequence according to the test order of each ray in the second ray; wherein, the second object is an object in the hierarchical bounding volume.

[0080] Here, the intersection test result may include, but is not limited to, intersection information, object information, etc. The intersection test result is obtained by performing an intersection test between the ray and the first object. In implementation, please refer to the specific implementation of step S12 above.

[0081] The traversal result of the BVH (Bounding Volume) indicates whether to continue traversing the BVH. The traversal result can include, but is not limited to, the first traversal result, the second traversal result, etc. The first traversal result indicates that traversal of the BVH should continue. The second traversal result indicates that traversal should end. In implementation, traversal stops when a preset termination condition is met (i.e., traversal ends). The termination condition can be any suitable condition for ending traversal. For example, the termination condition could be reaching a preset maximum recursion depth. Another example is finding a specific object. Yet another example is traversing the entire BVH. For yet another example, if the first object is the bounding box of the root node, then when the first ray does not intersect with the bounding box (i.e., the termination condition), the second traversal result can be used as the traversal result of the BVH. It can be understood that when the traversal result of the BVH is the second traversal result, traversal of the BVH stops.

[0082] The current traversal result can be determined in any suitable way.

[0083] In some implementations, a correspondence between each intersection test result and each traversal result can be established in advance. Based on this correspondence, the current traversal result that matches the intersection test result can be obtained.

[0084] In some implementations, the intersection test results of each ray and the first object can be analyzed separately to obtain the traversal result of each ray (i.e., whether the ray continues to traverse the BVH), and then the traversal result of the BVH can be determined based on the traversal results of each ray. For example, by analyzing the intersection information and the object information, if the first object is a preset target object and the first object intersects with the ray, the second traversal result can be used as the traversal result of the ray; if the object is not a preset target object and / or the object does not intersect with the ray, the first traversal result can be used as the traversal result of the ray.

[0085] In some implementations, if the traversal result of at least one ray in the first ray indicates that the BVH needs to be traversed further, then the first traversal result can be used as the current traversal result; if the traversal result of each ray in the first ray indicates that the BVH does not need to be traversed further, then the second traversal result can be used as the current traversal result.

[0086] In some implementations, if the traversal result of at least one ray in the first ray indicates that it is not necessary to continue traversing BVH, then the second traversal result can be used as the current traversal result; if the traversal result of each ray in the first ray indicates that it is necessary to continue traversing BVH, then the first traversal result can be used as the current traversal result.

[0087] When continuing to traverse the BVH based on the current traversal result, it is necessary to first determine the second object. The second object and the first object can be different primitives in the same leaf node, or the second object can be a box node or a primitive in another leaf node.

[0088] The second ray can be the first ray, a portion of the first ray, a combination of the first ray and other rays, or the first ray plus other rays. Understandably, each ray in the second ray needs to undergo an intersection test with the second object.

[0089] The intersection test of the second ray is similar to that of the first ray. The intersection test of the second ray is used to determine whether the second object intersects with the second ray. In practice, the intersection test of the ray and the object can be found in the specific implementation of step S12 above.

[0090] It is understandable that after the intersection test between the second ray and the second object is completed, the current traversal result of BVH can be determined based on the intersection test results between the second object and each ray in the second ray. For details, please refer to the specific implementation of step S131 above. Then, according to the current traversal result of BVH, the subsequent intersection test operation is performed (that is, if BVH needs to continue, the next object, the next ray and the test order are determined, and then the intersection test between the next object and each ray in the next ray is performed in sequence according to the test order of each ray in the next ray), and this cycle is repeated until the traversal ends.

[0091] In some implementations, the processing unit includes a traversal unit and an intersection test unit. The traversal unit includes a ray scheduling control unit. The above step S131 can be executed by the ray scheduling control unit, and the above step S132 can be executed jointly by the ray scheduling control unit and the intersection test unit.

[0092] In this embodiment, on the one hand, it is quickly determined whether to continue traversal based on the intersection test results between the object and each ray, to ensure the effectiveness of subsequent traversal, thereby improving traversal efficiency and reducing invalid calculations. On the other hand, when it is necessary to continue traversal, subsequent intersection tests are performed directly to ensure the continuity and effectiveness of ray tracing.

[0093] In some embodiments, the first ray includes at least two rays; the intersection test of the first ray with the hierarchical enclosure includes the intersection test of the target ray in the first ray with the object to be intersected in the hierarchical enclosure; step S12 includes steps S123 and S124, wherein: Step S123: When the ray traversal method is the second breadth-first traversal method, the target ray is determined from the first ray based on the intersection object of the previous node and each ray in the first ray; wherein, the intersection object is an object in the hierarchical bounding volume. Step S124: Perform an intersection test between the target ray and the object to be intersected by the target ray.

[0094] Here, the previous node can refer to the most recently visited node.

[0095] Before performing an intersection test, it is necessary to determine the intersection target of each ray in the first ray, that is, which object the ray will intersect with. The intersection target can be the bounding box in a bounding box node or a primitive in a leaf node. It is understandable that the intersection targets of different rays can be the same or different. For example, the intersection target of ray0 can be the bounding box in node 1, and the intersection target of ray1 can be the bounding box in node 0.

[0096] The target ray can be one, a portion of, or all of the first rays. The method for determining the target ray can be any suitable method.

[0097] In some implementations, the target ray can be determined based on the distance between the previous node and the intersection points of each ray. For example, the ray with the smallest distance can be used as the target ray. Another example is using the ray with a preset distance as the target ray.

[0098] In some implementations, the target ray can be determined based on the distance between the previous node and the nodes containing the intersection objects.

[0099] In some implementations, the target ray can be determined based on the correlation between the previous node and each intersection object. For example, the ray corresponding to the intersection object most relevant to the previous node can be used as the target ray. Another example is using the ray corresponding to the intersection object least relevant to the previous node as the target ray. Yet another example is using the ray with a preset correlation degree as the target ray.

[0100] The intersection test between the target ray and its object is to determine whether the target ray intersects with the object. In practice, the intersection test between the ray and the object can be found in the specific implementation of step S12 above.

[0101] In some implementations, the processing unit includes a traversal unit and an intersection testing unit. The traversal unit includes a light scheduling control unit. The above step S123 can be executed by the light scheduling control unit, and the above step S124 can be executed by the intersection testing unit.

[0102] In the embodiments of this application, when performing breadth traversal of different rays, the ray is selected by combining the intersection objects and the most recently visited objects of each ray, so as to find the ray that is closer to the most recently visited object, thereby maximizing the use of the most recently visited object and further improving the cache hit rate.

[0103] In some implementations, step S123, "determining the target ray from the first ray based on the intersection of the previous node and each ray in the first ray," includes steps S141 and S142, wherein: Step S141: Determine the distance between the previous node and the node containing each intersection object; Step S142: Determine the target ray from the first ray based on each distance.

[0104] Here, the previous node can be the most recently visited node.

[0105] The nodes containing the intersection objects can be the same or different. In practice, the node containing the intersection object can be the previous node or another node. For example, it could be a child node of the previous node.

[0106] In the application, the distance between two nodes can refer to the tree structure distance, which can be the number of edges traversed by the shortest path between the two nodes. This means that the path is unique and must pass through the Lowest Common Ancestor (LCA) of the two nodes. In other words, this distance mainly refers to the difference in the level of the nodes in the BVH (Browser-Village-Helper), which determines the traversal cost; the deeper the node, the longer the time required to access it.

[0107] The target ray can be determined in any suitable way.

[0108] In some implementations, the ray corresponding to the node closest to the previous node is used as the target ray, that is, the ray corresponding to the minimum distance is used as the target ray, where the minimum distance is the smallest value among all distances. In practice, if there are at least two rays corresponding to the minimum distance, then the target ray can be determined according to any suitable method such as entry order, randomness, or custom settings, or all rays corresponding to the minimum distance can be used as the target ray.

[0109] In some implementations, the ray corresponding to the node farthest from the previous node is used as the target ray, that is, the ray corresponding to the maximum distance is used as the target ray, where the maximum distance refers to the maximum value among all distances. In practice, if there are at least two rays corresponding to the maximum distance, then the target ray can be determined by any suitable method such as entry order, randomness, or customization, or all rays corresponding to the maximum distance can be used as the target ray.

[0110] In some implementations, the ray corresponding to the distance that best matches a preset distance is used as the target ray. The preset distance can be any suitable distance that is pre-specified or configured. In practice, if there are at least two rays corresponding to the best-matching distance, the target ray can be determined according to any suitable method such as entry order, randomness, or customization, or all rays corresponding to the preset distances can be used as the target ray.

[0111] In this embodiment, the light source is selected based on the distance between each intersection object and the most recently visited object, thereby improving the rationality and accuracy of the light source selection.

[0112] In some embodiments, step S142 includes step S1421 or step S1422, wherein: Step S1421: If there is only one ray corresponding to the minimum distance, take the ray corresponding to the minimum distance as the target ray; Step S1422: If there are at least two rays corresponding to the minimum distance, determine the target ray from the at least two rays corresponding to the minimum distance.

[0113] Here, we can compare the various distances to determine the minimum distance and the number of minimum distances. It's understandable that the minimum distance can be 0, meaning the node containing the intersection object is the same as its predecessor.

[0114] If there is only one minimum distance, meaning there is only one ray corresponding to the minimum distance, then the ray corresponding to the minimum distance can be used as the target ray.

[0115] If the minimum distance has at least two components, meaning there are at least two light rays corresponding to the minimum distance, then a target light ray needs to be selected from these at least two light rays. The method for determining this target light ray can include, but is not limited to, any suitable method such as entry order, randomness, or custom selection. For example, if the light rays corresponding to the minimum distance include ray0 and ray1, since ray0 enters RT before ray1, the target light ray can be selected based on the entry order, either ray0 (entering RT first) or ray1 (entering RT later). Alternatively, if the light rays corresponding to the minimum distance include ray0 and ray1, either ray0 or ray1 can be randomly selected as the target light ray.

[0116] In this application embodiment, the ray that is closest in spatial distance to the most recently visited object is preferentially selected to minimize the jump span of node access, thereby maximizing the utilization of the most recently visited object and reducing the possibility that subsequent rays will not be able to hit the object due to the most recently visited object being squeezed out.

[0117] In some embodiments, after performing an intersection test on the target ray and the object to which the target ray intersects, the ray tracing method further includes steps S151 and S152, wherein: Step S151: Based on the intersection test results between the intersection object and the target ray, determine the current traversal result of the hierarchical bounding volume; Step S152: Given that the current traversal result represents the continued traversal of the bounding volume, based on the updated previous node and the intersection objects of each ray in the third ray, determine the target ray from the third ray and perform an intersection test between the target ray and the intersection objects of the target ray.

[0118] Here, the intersection test result may include, but is not limited to, intersection information, object information, etc. The intersection test result is obtained by performing an intersection test between the target ray and the object to which it intersects. In implementation, please refer to the specific implementation method of the aforementioned step S12.

[0119] The traversal result of BVH indicates whether to continue traversing BVH. The traversal result can include, but is not limited to, the first traversal result, the second traversal result, etc. The first traversal result indicates that BVH should continue to be traversed. The second traversal result indicates that the traversal ends.

[0120] The current traversal result can be determined in any suitable way.

[0121] In some implementations, a correspondence between each intersection test result and each traversal result can be established in advance. Based on this correspondence, the current traversal result that matches the intersection test result can be obtained.

[0122] In some implementations, the intersection test results of the target ray and its intersecting object can be analyzed to obtain the traversal result of the target ray (i.e., whether the target ray continues to traverse the BVH), and then the traversal result of the BVH can be determined based on the traversal result of the target ray. For example, if the traversal result of the target ray indicates that it needs to continue traversing the BVH, then the first traversal result can be used as the current traversal result of the BVH; if the traversal result of the target ray indicates that it does not need to continue traversing the BVH, then the traversal result of the BVH can be determined based on the traversal results of the other rays in the first ray besides the target ray. That is, if the traversal result of at least one ray in the first ray indicates that it needs to continue traversing the BVH, then the first traversal result can be used as the current traversal result of the BVH; if the traversal result of each ray in the first ray indicates that it does not need to continue traversing the BVH, then the second traversal result can be used as the current traversal result of the BVH.

[0123] The updated previous node can refer to the node where the intersection of the target ray is located.

[0124] When continuing to traverse BVH based on the current traversal result, it is necessary to first determine the new second ray (i.e., the third ray), and then determine the intersection objects of each ray in the new second ray. The intersection objects can be the bounding box in a bounding box node or the primitives in a leaf node.

[0125] The third ray can be the first ray, a portion of the first ray, a portion of the first ray plus other rays, or the first ray plus other rays.

[0126] Understandably, after the intersection test between the target ray and its intersection object is completed, the current traversal result of BVH can be determined based on the result of the intersection test between the target ray and its intersection object. For details, please refer to the specific implementation of step S151 above. Then, based on the current traversal result of BVH, the subsequent intersection test operation is performed (i.e., if BVH needs to continue, a new target ray is selected based on the intersection object of each ray in the new second ray (i.e., the third ray) and the updated previous node, and the intersection test between the new target ray and its intersection object is performed), and this process is repeated until the traversal ends.

[0127] In some implementations, the processing unit includes a traversal unit and an intersection test unit. The traversal unit includes a ray scheduling control unit. The above step S151 can be executed by the ray scheduling control unit, and the above step S152 can be executed jointly by the ray scheduling control unit and the intersection test unit.

[0128] In this embodiment, on the one hand, the intersection test results between the object and the ray are used to quickly determine whether to continue traversal, so as to ensure the effectiveness of subsequent traversal, thereby improving traversal efficiency and reducing invalid calculations. On the other hand, when it is necessary to continue traversal, the intersection objects and the most recently visited objects of each ray are combined to select rays for subsequent intersection tests, so as to ensure the continuity and effectiveness of ray tracing.

[0129] In some embodiments, the first ray includes at least two rays; step S12 includes step S125, wherein: Step S125: When the ray traversal mode is depth traversal mode, determine the current traversal order of each ray in the first ray, and perform the intersection test between each ray in the first ray and the layer bounding volume in turn according to the current traversal order.

[0130] Here, depth-first traversal prioritizes the depth-first traversal of the same ray. In depth-first traversal, the depth-first traversal of each ray is performed sequentially according to the traversal order. That is, the depth-first traversal of one ray is performed first, then another, and so on, until the depth-first traversal of the last ray is performed. The traversal order indicates the order in which the rays are traversed. For example, if the first ray includes ray0 and ray1, the traversal order could be ray0 first then ray1, or ray1 first then ray0. As another example, if the first ray includes ray0, ray1, and ray2, the traversal order could be ray0 first then ray1 then ray2, or ray1 first then ray0 then ray2, or ray1 first then ray2 then ray0.

[0131] The traversal order can be determined in any suitable way.

[0132] In some implementations, the traversal order can be determined based on the entry order of the rays in the first ray. For example, rays that enter RT earlier perform the intersection test with BVH first. Alternatively, rays that enter RT later perform the intersection test with BVH first.

[0133] In some implementations, the traversal order can be determined based on the spatial position of each ray in the first ray; that is, the traversal order is determined according to the spatial proximity of each ray. For example, the traversal order can be obtained by sorting each ray according to its proximity to the principal ray.

[0134] In some implementations, the traversal order can be determined based on the correlation between the rays in the first ray. For example, the traversal order can be obtained by sorting the rays according to their similarity to the principal ray.

[0135] During implementation, the intersection tests of each ray in the first ray with the BVH are performed sequentially according to the traversal order. For example, if the first ray includes ray0, ray1, and ray2, assuming the traversal order is ray0 first, then ray1, then ray2, then: Perform an intersection test between ray0 and BVH to obtain the intersection test results between ray0 and BVH; Perform an intersection test between ray1 and BVH to obtain the intersection test results between ray1 and BVH; An intersection test was performed between ray2 and BVH to obtain the intersection test results.

[0136] For depth-first traversal, the intersection test between a ray and the BVH can include, but is not limited to, the intersection test between a ray and at least one object in the BVH. In implementation, the intersection test between a ray and an object can be found in the specific implementation of step S12 described above.

[0137] In some implementations, the processing unit includes a traversal unit and an intersection test unit. The traversal unit includes a ray scheduling control unit, which determines the current traversal order, and the intersection test unit performs an intersection test between the rays and the BVH.

[0138] In this embodiment, when performing a depth traversal of the same ray, the layer bounding volume is traversed sequentially according to the traversal order of each ray. Compared with the breadth traversal of different rays, the traversal time of a ray to the layer bounding volume is shortened, reducing the possibility of some hardware idle due to excessive traversal time.

[0139] In some implementations, the control information further includes prefetch information, which includes a prefetch identifier indicating whether a node is prefetched, and the node includes at least one object; step S12 includes step S126 or step S127, wherein: Step S126: When the prefetch identifier does not prefetch nodes, control the intersection test between the first ray and the hierarchical bounding volume based on the ray traversal method. Step S127: When the prefetch identifier represents the prefetch node, control the intersection test between the first ray and the hierarchical bounding volume based on the prefetch method and ray traversal method in the prefetch information.

[0140] Here, prefetch information represents whether to prefetch (i.e., prefetch identifier) ​​and how to prefetch (i.e., prefetch method).

[0141] It is understandable that when prefetching is not required, there is no need to focus on how to prefetch. Therefore, the intersection test between the first ray and BVH can be controlled directly according to the ray traversal method. In implementation, please refer to the specific implementation method of the aforementioned step S12.

[0142] When prefetching is required, the prefetching method needs to be considered. The prefetching method indicates the node information to be prefetched. This prefetching method can include, but is not limited to, sequential prefetching, interval prefetching, and batch prefetching. It is understood that the number of nodes to be prefetched can be at least one; in some implementations, the number of nodes to be prefetched can be determined based on factors such as the cache size, node size, and node type. The nodes to be prefetched can be their sibling nodes, child nodes, etc.

[0143] The intersection test of a ray with a BVH (Browser Volume Halo) includes the intersection test of a ray with at least one object in the BVH. Before performing the intersection test between a ray and an object, the object needs to be acquired first. This can be achieved by prefetching, which involves acquiring the node containing the object along with other nodes. For example, before performing the intersection test between a first object and each ray in a first ray, the address of the node containing the first object can be determined first. Then, the address of the prefetch node can be determined according to the prefetch method. Based on the addresses of the node containing the first object and the prefetch node, the node containing the first object and the prefetch node can be retrieved.

[0144] In implementation, after obtaining the node, the intersection test between the first ray and the object in the node is controlled according to the ray traversal method. For details, please refer to the specific implementation of step S12 above.

[0145] In this embodiment, on the one hand, the decision to prefetch is based on the configured prefetch information, giving node prefetching greater flexibility and controllability. On the other hand, when node prefetching is not required, the intersection test between each ray and the hierarchical bounding body is performed directly according to the ray traversal method to ensure the efficiency and accuracy of the intersection test. Furthermore, when node prefetching is required, the intersection test between each ray and the hierarchical bounding body is performed according to the ray traversal method and the prefetching method. Since the relevant objects are retrieved in advance, there is no need to wait for the subsequent object grabbing process, shortening the test time between objects and rays.

[0146] Based on the above embodiments, this application also provides a ray tracing device, which can be located within a GPU. Figure 2 This is a schematic diagram of the first component structure of a ray tracing device provided in an embodiment of this application, as shown below. Figure 2 As shown, the ray tracing device 20 includes a configuration unit 21 and a processing unit 22, wherein: Configuration unit 21 is used to store control information; wherein, the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. Depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. Processing unit 22 is used to obtain the ray traversal mode from the configuration unit; and based on the ray traversal mode, control the intersection test between the first ray and the hierarchical bounding volume.

[0147] Here, the configuration unit can be any suitable hardware unit capable of implementing this function, such as a register, flip-flop, or shared memory. The role of the configuration unit is to pre-configure control information before performing RT (Reaction Time), thereby reducing subsequent waiting time and ensuring the orderliness and correctness of intersection tests for each object.

[0148] The control information may include, but is not limited to, ray traversal methods and prefetch information. Ray traversal methods indicate how at least one ray traverses the BVH. Prefetch information may include, but is not limited to, prefetch flags and prefetch methods. Prefetch flags indicate whether nodes are prefetched. Prefetch methods indicate the node information to be prefetched. These prefetch methods may include, but are not limited to, sequential prefetching, interval prefetching, and batch prefetching. The configuration of this control information can be any suitable method. In some implementations, the control information can be configured using prediction information generated by a pre-trained prediction model. In some implementations, the control information can be configured according to the usage scenario.

[0149] The processing unit can be any suitable hardware or hardware / software combination unit capable of implementing this function. It is the core component in RT used for intersection testing of controlled objects. In RT, the processing unit is mainly responsible for receiving intersection test requests from upstream and performing subsequent intersection tests based on these requests.

[0150] The control information can be acquired in any suitable manner. In some embodiments, the control information is acquired when the RT enters the BVH. In some embodiments, the control information is acquired when a new ray is received. It is understood that the ray traversal method and the prefetch information can be acquired simultaneously or separately as needed, and this application embodiment is not limited to these methods.

[0151] The first ray includes at least one ray. It is understood that the first ray refers to the ray that needs to be tested for intersection with the BVH.

[0152] The intersection test between the first ray and the BVH can include, but is not limited to, the intersection test between the first ray and at least one object in the BVH. In implementation, the processing unit controls the intersection test between the first ray and the BVH, as described in the specific implementation of step S12 above.

[0153] In some implementations, if the prefetch information representation is not extracted, the intersection test between the first ray and the BVH can be controlled according to the ray traversal method.

[0154] In some implementations, if the prefetch information represents the prefetched node, the intersection test between the first ray and the BVH can be controlled according to the ray traversal method and the prefetch method.

[0155] In some implementations, the processing unit may include, but is not limited to, a traversal unit and an intersection testing unit. These internal units manage and optimize the intersection testing of objects. The traversal unit can be any suitable hardware or hardware / software combination unit capable of implementing this function. It is responsible for the traversal control of the BVH (Browser Volume Hierarchy), improving resource utilization while reducing traversal time. The intersection testing unit can also be any suitable hardware or hardware / software combination unit capable of implementing this function. It is mainly responsible for the intersection testing of boxes and primitives. In implementation, the intersection testing unit is used to retrieve objects from the cache unit; determine the intersection test results between rays and objects; and return the intersection test results to the traversal unit. The traversal unit is used to control the intersection testing of each ray with each object.

[0156] In this embodiment, on the one hand, during ray tracing, the intersection tests of subsequent rays with the hierarchical bounding body are controlled according to the ray traversal method. Compared to related schemes that can only perform depth traversal of the hierarchical bounding body sequentially according to time, this application not only performs breadth traversal of the hierarchical bounding body, allowing more rays to enter the intersection test, but also allows objects in the cache to perform more intersection tests with rays. This ensures that subsequent rays that could have hit the cache will still hit, reducing the possibility of retrieving the object from memory again, greatly increasing the cache hit rate and reducing latency, thereby improving tracing efficiency and reducing energy consumption. Furthermore, it is compatible with depth traversal of the same ray on the hierarchical bounding body, reducing the possibility that some hardware might be idle due to only being able to perform breadth traversal of different rays on the hierarchical bounding body, thus maximizing GPU performance while improving flexibility. On the other hand, by dynamically configuring control information, higher flexibility and controllability are given to the control information, thereby achieving an optimal balance between performance, power consumption, and resource utilization.

[0157] In some embodiments, the ray tracing device 20 further includes a caching unit, and the processing unit 22 includes a traversal unit and an intersection testing unit, wherein: the traversal unit is used to determine the address of the target node, the target node being a node in the hierarchical bounding volume; send the address of the target node to the caching unit; the caching unit is used to cache the target node obtained from the storage unit based on the address of the target node; send the target object in the target node to the intersection testing unit; and the intersection testing unit is used to control the intersection test between the first ray and the target object based on the ray traversal method.

[0158] Here, the cache unit can be any suitable unit capable of storing nodes in BVH. In implementation, the cache unit can communicate with the storage unit to retrieve objects from the storage unit. In implementation, the cache unit sends the address of the node to the storage unit, which retrieves the object based on its address and then returns it to the cache unit. The storage unit can be any suitable unit capable of implementing BVH storage. In some embodiments, the storage unit can be located within or outside the ray tracing device. In implementation, the storage unit can be located in on-chip memory on the GPU or in external memory outside the GPU.

[0159] The traversal unit communicates with at least the cache unit and the intersection test unit.

[0160] The address of a node can be determined in any suitable way. In some implementations, the address of a node can be determined based on its hierarchical information (i.e., its position in the BVH), index, pointer, etc. In practice, the address of each node mainly depends on its storage method in memory and the construction process. For example, if all nodes in the BVH are stored in a contiguous array, the address of a node can be directly calculated based on its index in the array; this storage method facilitates caching and memory optimization. Another example is when using dynamic memory, where each node points to its child nodes via pointers, and the address of the node is its physical address in memory; this result offers greater flexibility during construction and traversal. Yet another example is that the node structure can contain pointers to parent and sibling nodes; these pointers can then be used to determine the address of a node during traversal.

[0161] In some implementations, a data transfer relationship exists between the traversal unit and the computation unit. After receiving the ray or updated rayT sent by the computation unit, the traversal unit forwards the ray or updated rayT to the intersection test module for subsequent intersection testing. This separate design helps decouple the ray update and intersection test logic, improving overall tracking efficiency.

[0162] The number of target nodes can be at least one. For example, when the prefetch information indicates that nodes should not be prefetched, there can be one target node. When the prefetch information indicates that nodes should be prefetched, there can be at least two target nodes. In implementation, the number of target nodes can be determined based on factors such as the size of the buffer unit, the size of the node, and the type of the node. The target node includes at least one target object for intersecting with the first ray, such as a first object, a second object, or an intersection object.

[0163] After receiving the node address from the traversal unit, the caching unit forwards the node address to the storage unit. The storage unit then reads the node based on its address and returns it to the caching unit, thus achieving the retrieval of the node object. The node content may include, but is not limited to, information about the bounding volumes and primitives. In some implementations, the caching unit can send the entire node content to the intersection test unit, or it can send it in batches. That is, the number of target objects can be at least one.

[0164] The intersection test unit communicates with at least the cache unit, the traversal unit, and the configuration unit. In implementation, when the intersection test unit receives the target object, it can immediately or sequentially perform the intersection test of the target object. The process by which the intersection test unit controls the intersection test of the first ray and the BVH can be found in the specific implementation of step S12 above.

[0165] In this embodiment, the processing unit is subdivided into a traversal unit and an intersection test unit. The traversal unit determines the node address and initiates the acquisition of node data. Then, the intersection test unit is responsible for performing the intersection test between the hierarchical bounding volume and the ray. Finally, the traversal unit controls the subsequent intersection test. Through the collaborative work of these two units, the coherence and efficiency of the entire processing flow are ensured, thereby achieving efficient automated ray tracing.

[0166] In some implementations, the traversal unit includes a ray scheduling control unit and a node prefetching unit, and the control information also includes prefetching information; the node prefetching unit is used to determine the address of the target node based on the prefetching information; the ray scheduling control unit is used to schedule each ray in the first ray to the intersection test unit based on the ray traversal method.

[0167] Here, prefetch information may include, but is not limited to, prefetch identifiers and prefetch methods. The prefetch identifier indicates whether nodes are prefetched. The prefetch method may include, but is not limited to, sequential prefetching, interval prefetching, and batch prefetching.

[0168] The number of target nodes can be at least one.

[0169] When the prefetch flag indicates that nodes are not prefetched, the number of target nodes can be one. That is, if the current node is taken as the target node, then the address of the current node can be determined based on its hierarchical information (i.e., its position in BVH), index, pointer, etc. The current node refers to the node that needs to be obtained for the test.

[0170] When the prefetch flag indicates that nodes are prefetched, the number of target nodes can be at least two: the current node and other nodes. Understandably, the number of target nodes can be determined based on factors such as the size of the cache unit, the size of the node, and the type of the node. In implementation, the address of the current node can be determined first, and then the addresses of other target nodes can be further determined based on the address of the current node and the prefetching method. For example, if the prefetching method is batch prefetching, then all other nodes at the same level as the current node can be used as target nodes.

[0171] In RT, the arrangement of the rays in the first ray can be any suitable method.

[0172] In some implementations, if the ray traversal method is a breadth-first traversal method, each ray in the first ray can be scheduled to the intersection test unit sequentially, in batches, or all at once. Alternatively, the scheduling can be further determined according to the specific traversal method (i.e., the first breadth-first traversal method or the second breadth-first traversal method).

[0173] In some implementations, if the ray traversal method is a depth-first traversal, each ray in the first ray can be sequentially scheduled to the intersection test unit according to a defined traversal order. For example, the first ray is first scheduled to the intersection test unit. After the intersection test unit completes the intersection test of the first ray with the BVH, the second ray is scheduled to the intersection test unit. After the intersection test unit completes the intersection test of the second ray with the BVH, the third ray is scheduled to the intersection test unit, and so on, until all rays are scheduled.

[0174] In this embodiment, on the one hand, extracting the nodes required for prefetching based on prefetch information can not only shorten the testing time but also reduce the interaction frequency between the cache unit and the storage unit, greatly improving device performance and reducing backend load. On the other hand, scheduling rays based on the ray traversal method improves the rationality of ray scheduling, thereby significantly improving the cache hit rate and computational efficiency of BVH, achieving the goal of optimizing ray tracing.

[0175] In some implementations, the breadth-first traversal method includes a first breadth-first traversal method or a second breadth-first traversal method. The first breadth-first traversal method is used to instruct different rays to traverse the same object sequentially, while the second breadth-first traversal method is used to instruct different rays to traverse according to the most recently visited object.

[0176] In some embodiments, the first ray includes at least two rays; the intersection test of the first ray with the hierarchical bounding body includes the intersection test of the first ray with a first object in the hierarchical bounding body; the processing unit 22 is used to determine the test order of each ray in the first ray when the ray traversal mode is the first breadth traversal mode; and to perform the intersection test of the first object with each ray in the first ray in sequence according to the test order of each ray in the first ray; wherein, the first object is an object in the hierarchical bounding body.

[0177] In some embodiments, the processing unit 22 is used to determine the testing order of each ray in the first ray based on the entry order of each ray in the first ray.

[0178] In some embodiments, after performing the intersection test between the first object and each ray in the first ray, the processing unit 22 is further configured to determine the current traversal result of the hierarchical bounding body based on the intersection test result between the first object and each ray in the first ray; wherein the current traversal result indicates whether to continue traversing the hierarchical bounding body; if the current traversal result indicates that the hierarchical bounding body should continue to be traversed, the testing order of each ray in the second ray is determined, and the intersection test between the second object and each ray in the second ray is performed sequentially according to the testing order of each ray in the second ray; wherein the second object is an object in the hierarchical bounding body.

[0179] In some implementations, the first ray includes at least two rays; the intersection test of the first ray with the hierarchical bounding body includes the intersection test of the target ray in the first ray with the intersection object in the hierarchical bounding body; the processing unit 22 is used to determine the target ray from the first ray based on the previous node and the intersection objects of each ray in the first ray when the ray traversal mode is the second breadth traversal mode; wherein the intersection object is an object in the hierarchical bounding body; and to perform the intersection test of the target ray and the intersection object of the target ray.

[0180] In some implementations, the processing unit 22 is configured to determine the distance between the previous node and the node containing each intersection object; and to determine the target ray from the first ray based on each distance.

[0181] In some embodiments, the processing unit 22 is configured to, when the number of rays corresponding to the minimum distance is one, use the ray corresponding to the minimum distance as the target ray; wherein the minimum distance is the minimum value among all distances; and when the number of rays corresponding to the minimum distance is at least two, determine the target ray from the at least two rays corresponding to the minimum distance.

[0182] In some implementations, after performing an intersection test between the target ray and the object of intersection of the target ray, the processing unit 22 is further configured to determine the current traversal result of the hierarchical bounding volume based on the intersection test result between the object of intersection of the target ray and the target ray; if the current traversal result indicates that the hierarchical bounding volume should be traversed again, the target ray is determined from the third ray based on the updated previous node and the object of intersection of each ray in the third ray, and an intersection test between the target ray and the object of intersection of the target ray is performed.

[0183] In some embodiments, the first ray includes at least two rays; the processing unit 22 is used to determine the current traversal order of each ray in the first ray when the ray traversal mode is depth traversal mode, and to perform the intersection test between each ray in the first ray and the layer bounding body in sequence according to the current traversal order.

[0184] In some implementations, the control information further includes prefetch information, which includes a prefetch identifier indicating whether a node is prefetched in advance, and the node includes at least one object; the processing unit 22 is configured to control the intersection test of the first ray and the hierarchical bounding body based on the ray traversal method when the prefetch identifier indicates that the node is not prefetched in advance; and to control the intersection test of the first ray and the hierarchical bounding body based on the prefetch method and the ray traversal method in the prefetch information when the prefetch identifier indicates that the node is prefetched in advance.

[0185] In some implementations, the processing unit 22 is also used to configure control information based on the prediction information generated by the trained prediction model; or, to configure control information based on the usage scenario corresponding to the hierarchical enclosing volume.

[0186] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0187] The technical solution of this application is described in detail below.

[0188] Ray tracing is a graphics rendering technique that differs from traditional rasterization rendering. Ray tracing simulates the propagation of light rays in a scene, including their intersection, reflection, refraction, and occlusion, ultimately determining the color of each pixel. This method can simulate the physical properties of lighting in the real world, resulting in more realistic visual effects. Its basic process includes: 1. Light rays are emitted from the camera position and enter the scene; 2. Determine whether the light ray intersects with geometric primitives in the scene; 3. Find the pixel hit point closest to the camera; 4. Calculate the color of the hit point; 5. Generate secondary rays as needed, for example: a. Shadow rays: Point the light from the intersection of rays towards the light source and see if the light is blocked to determine if you are in a shadow; b. Reflected rays: If the surface is smooth (such as a mirror), reflected rays will be generated and continue to track, even tracking content outside the scene; c. Refracted light rays: If an object is transparent (such as glass or liquid), it will generate refracted light rays that pass through the object; 6. Perform recursive operations on the above steps as needed; 7. Summarize all the tracked light information and calculate the final color of the pixel.

[0189] In practice, primitives are organized into spatial data structures to accelerate the efficiency of intersection calculation.

[0190] Hierarchical bounding volumes are a commonly used data structure. They are based on a tree structure and contain different types of nodes, including but not limited to internal / box nodes and leaf / primitive nodes.

[0191] BVH traversal is a depth-first tree traversal, which is performed by testing whether rays intersect with intermediate box nodes and leaf primitive nodes. Node information is retrieved from the global memory via on-chip cache through the ray scheduling control module.

[0192] The drawback of the existing solution is that the node capture and intersection test of the ray are performed according to age priority (i.e., time order), selecting the ray that enters the ray tracing module first for processing. This depth-first approach may capture more box nodes and leaf nodes in the same depth direction of the same ray, which may cause the node information that entered the cache earlier to be squeezed out. As a result, the node information that could have been captured by the subsequent ray may become missing, and the information needs to be captured from outside the node cache again, which increases the latency, affects the ray tracing execution efficiency and increases energy consumption.

[0193] The technical solution of this application aims to overcome the shortcomings of the above-mentioned solutions, improve the efficiency of ray tracing scheduling and the utilization rate of cache units, and minimize energy consumption.

[0194] like Figure 3As shown, the device provided in this application (corresponding to the aforementioned ray tracing device) mainly includes a program execution module 30, a hierarchical bounding volume traversal module 31 (corresponding to the aforementioned traversal unit), a node cache 32 (corresponding to the aforementioned cache unit), an accelerated data structure 33 (corresponding to the aforementioned storage unit), a configuration register control module 34 (corresponding to the aforementioned configuration unit), and an intersection test module 35 (corresponding to the aforementioned intersection test unit). The hierarchical bounding volume traversal module 31 includes a ray scheduling control module and a node reading and prefetching module (corresponding to the aforementioned node prefetching unit), and the intersection test module 35 includes a primitive intersection test module and a box intersection test module.

[0195] Program execution module 30 (corresponding to the aforementioned calculation unit): responsible for sending light into the layer bounding volume traversal module 31 and executing software-defined programs, including but not limited to processing opaque primitives and procedural primitives; Hierarchical bounding volume traversal module 31: responsible for traversal control, in which the ray scheduling control module is responsible for controlling the scheduling strategy according to the configuration register control module 34: depth priority for the same ray or breadth priority for different rays; the node reading and prefetching module prefetches nodes according to the register configuration control module 34. Node cache 32: Responsible for receiving node acquisition from the hierarchical bounding volume traversal module 31, storing the retrieved nodes, and sending the node information to the intersection test module 35; Accelerating Data Structure 33: Storing hierarchical bounding volume data, including but not limited to intermediate box nodes and leaf primitive nodes; Configuration register control module 34: used to configure the ray scheduling strategy (corresponding to the aforementioned ray traversal method) and node information prefetching (corresponding to the aforementioned prefetching information); Intersection Test Module 35: Responsible for intersection testing of boxes and primitives; among which, the Box Intersection Test Module is responsible for box intersection testing, and the Primitive Intersection Test Module is responsible for primitive intersection testing.

[0196] The processing flow of this device is as follows: The program execution module 30 sends the light rays to the hierarchical bounding volume traversal module 31. The latter (i.e., the hierarchical bounding volume traversal module) calculates the address for accessing the accelerated data structure and accesses the accelerated data structure 33 via the node cache 32. The accelerated data structure 33 sends the node data to the intersection test module 35. The intersection test module 35 returns the box or primitive intersection test result to the hierarchical bounding volume traversal module 31. The hierarchical bounding volume traversal module 31 determines whether to continue traversing based on the intersection test result, or if all traversals have been completed, it returns the data to the program execution module 30.

[0197] The ray scheduling control module in the hierarchical bounding volume traversal module 31 controls whether to use depth-first traversal with the same ray or breadth-first traversal with different rays, based on the configuration register control module 34. The node reading and prefetching module determines whether node information needs to be prefetched and the prefetching method based on the configuration register control module 34.

[0198] like Figure 4 As shown, the ray tracing method includes: Step S40: Light generation; Step S41: Selection and control of hierarchical bounding volume traversal strategy; Step S42, Node prefetch control; Step S43: Obtain nodes from the hierarchical bounding volume and cache them; Step S44: Traverse intermediate nodes; Step S45: Traverse the leaf nodes; Step S46: Determine whether the graphic element is a programmed graphic element or a transparent graphic element. If yes, proceed to step S47; otherwise, proceed to step S48. Step S47: Program execution; Step S48: Continue to find the intersection traversal; Step S49: Determine whether the hierarchical enclosing volume has been traversed. If yes, proceed to step S410; otherwise, proceed to step S41. Step S410: After the traversal ends, return the final result.

[0199] like Figure 5 As shown, this BVH includes 21 nodes, i.e., 0-20. For ray0 (ray 0) and ray1 (ray 1), the ray number represents the order in which they enter the ray tracing module; the smaller the number, the earlier they enter. That is, ray0 enters the ray tracing module first. Assuming that only one ray can be scheduled at a time, and the scheduling is performed serially, requiring the intersection result to be returned before scheduling the next ray, then: If the age-first strategy is used (corresponding to the aforementioned depth-first traversal method), then ray0 will traverse the entire BVH first, followed by ray1 traversing the entire BVH, that is: The traversal proceeds as follows: ray0 enters the intersection test with node 0 (hit), ray0 enters the intersection test with node 1 (hit), ray0 enters the intersection test with node 5, ..., ray0 enters the intersection test with node 2 (miss), ray0 enters the intersection test with node 3 (miss), ray0 enters the intersection test with node 4 (miss), and the traversal ends. Therefore, the traversal path of ray0 is: 0->1->5->6->7->8->2->3->4. The traversal proceeds as follows: ray1 enters the intersection test with node 0 (hit), ray1 enters the intersection test with node 1 (miss), ray1 enters the intersection test with node 2 (miss), ray1 enters the intersection test with node 3 (miss), ray1 enters the intersection test with node 4 (miss), and the traversal ends. Therefore, the traversal path of ray1 is: 0->1->2->3->4.

[0200] If a round-robin strategy is used (corresponding to the first breadth-first traversal method mentioned above), then the intersection tests of ray0 and ray1 with each node are performed in sequence. That is, first, the intersection test of ray0 with node 0 is performed, then the intersection test of ray1 with node 0 is performed, then the intersection test of ray0 with node 1 is performed, then the intersection test of ray1 with node 1 is performed, and so on, until the intersection tests of all rays with BVH are completed.

[0201] If we use the strategy of finding the light closest to the last visited node (corresponding to the second breadth-first traversal method mentioned above), then each time we determine the nodes that ray0 and ray1 need to visit, we select ray0 or ray1 based on the nodes that the two rays need to visit and the last visited node, that is: First, perform an intersection test between ray0 and node 0; Since ray0 needs to access node 1 and ray1 needs to access node 0, and the last accessed node was node 0, ray1 is closer, so ray1 is scheduled to access node 0. Since ray0 needs to access node 1 and ray1 needs to access node 1, and the last accessed node was node 0, ray0 and ray1 are the same. At this time, ray0 can be scheduled to access node 1. Since ray0 needs to access node 5 and ray1 needs to access node 1, and the last accessed node was node 1, ray1 is closer, so ray1 is scheduled to access node 1. Since ray0 needs to access node 5 and ray1 needs to access node 2, and the last accessed node was node 1, ray1 is closer, so ray1 is scheduled to access node 2. ...and so on, until all the intersection tests between the rays and the BVH are completed.

[0202] Assuming the cache space can only hold 2 nodes, during the entire traversal, for node 0: If the age priority strategy is used: node 0 will be squeezed out when ray0 tries to retrieve node 5, and ray1 will need to read it again when it tries to retrieve node 0 later. If the round robin strategy or the light strategy of finding the closest node to the last visited node is used: node 0 will only be retrieved once during the entire intersection test.

[0203] The "age-priority" scheduling method has the advantage of allowing earlier-arriving rays to finish faster and return to the program execution module, which can then execute other instructions after receiving the result. The disadvantage is that when the traversal path of a ray is long and scattered, it can lead to frequent node expulsion and a decrease in cache hit rate.

[0204] The scheduling approach, which prioritizes allowing more light to enter the intersection test, has the advantage of reducing node squeezing, allowing retrieved nodes to be used more frequently, and increasing cache hit rate. The disadvantage is that the program execution module takes longer to obtain the ray intersection results, potentially leaving it idle.

[0205] The choice of ray scheduling depth and breadth, as well as the prefetching control of node information, can have varying impacts on the final ray tracing efficiency, primarily depending on the physical location of the rays and the acceleration structure. Specific implementation requires software configuration based on the specific workload. 1. Based on workload analysis and operation, configuration is directly handled by the software driver (i.e., the software that drives the registers); 2. Through reinforcement learning systems, configuration can be performed directly via software drivers or in real time based on overall performance feedback.

[0206] The benefit of this solution is that the system can effectively configure ray scheduling control strategies and node information prefetching according to actual conditions, thereby maximizing system performance. The system can configure the ray scheduling control strategies and node information prefetching of the ray tracing module, reducing the outflow of node information from the node cache, increasing the overall cache hit rate, and thus maximizing system performance while reducing energy consumption.

[0207] The technical advantage of this solution is that it allows for flexible configuration of the scheduling strategy and node information prefetching strategy of the hierarchical bounding volume traversal control module. It can be configured by software based on workload analysis or by automatic control after machine learning, achieving the effect of higher performance and lower power consumption with more operation.

[0208] It should be noted that, in the embodiments of this application, if the above methods are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of software products. These software products are stored in a storage medium and include several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0209] This application provides a graphics processor including any of the aforementioned ray tracing devices. In some embodiments, the graphics processor may further include the aforementioned computing unit and / or storage unit.

[0210] This application provides an electronic device including the aforementioned graphics processor. The electronic device can be various types of terminals such as laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or it can be implemented as a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0211] It should be noted that the descriptions of the processor and device embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the processor and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0212] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0213] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0214] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0215] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0216] In addition, each functional unit in the embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0217] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0218] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.

[0219] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A ray tracing method, characterized in that, include: Acquire control information; wherein the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. The depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and the breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. Based on the ray traversal method, the intersection test between the first ray and the layer bounding volume is controlled.

2. The ray tracing method according to claim 1, characterized in that, The breadth-first traversal method includes a first breadth-first traversal method or a second breadth-first traversal method. The first breadth-first traversal method is used to instruct different rays to traverse the same object in sequence, while the second breadth-first traversal method is used to instruct different rays to traverse according to the most recently visited object.

3. The ray tracing method according to claim 1, characterized in that, The first ray includes at least two rays; the intersection test of the first ray with the hierarchical enclosing body includes the intersection test of the first ray with a first object in the hierarchical enclosing body; The method of controlling the intersection test between the first ray and the hierarchical bounding volume based on the ray traversal method includes: When the ray traversal method is the first breadth-first traversal method, determine the testing order of each ray in the first ray; According to the testing order of each ray in the first ray, the intersection test between the first object and each ray in the first ray is performed sequentially; wherein, the first object is an object in the hierarchical enclosing volume.

4. The ray tracing method according to claim 3, characterized in that, Determining the testing order of each ray in the first ray includes: The testing order of each ray in the first ray is determined based on the entry order of each ray.

5. The ray tracing method according to claim 3, characterized in that, After performing the intersection test between the first object and each ray in the first ray, the ray tracing method further includes: Based on the intersection test results between the first object and each ray in the first ray, the current traversal result of the hierarchical bounding volume is determined; wherein, the current traversal result indicates whether to continue traversing the hierarchical bounding volume; If the current traversal result indicates that the hierarchical bounding volume continues to be traversed, the test order of each ray in the second ray is determined, and the intersection test between the second object and each ray in the second ray is performed in sequence according to the test order of each ray in the second ray; wherein, the second object is an object in the hierarchical bounding volume.

6. The ray tracing method according to claim 1, characterized in that, The first ray includes at least two rays; the intersection test of the first ray with the hierarchical enclosing body includes the intersection test of the target ray in the first ray with the object to be intersected in the hierarchical enclosing body; The method of controlling the intersection test between the first ray and the hierarchical bounding volume based on the ray traversal method includes: When the ray traversal method is the second breadth-first traversal method, the target ray is determined from the first ray based on the intersection object of the previous node and each ray in the first ray; wherein, the intersection object is an object in the hierarchical bounding volume; Perform an intersection test between the target ray and the object to which the target ray intersects.

7. The ray tracing method according to claim 6, characterized in that, The step of determining the target ray from the first ray based on the intersection of the previous node and each ray in the first ray includes: Determine the distance between the previous node and the node containing each intersection object; The target ray is determined from the first ray based on each of the distances.

8. The ray tracing method according to claim 7, characterized in that, Determining the target ray from the first ray based on each of the distances includes: If there is only one ray corresponding to the minimum distance, then the ray corresponding to the minimum distance is taken as the target ray; wherein, the minimum distance is the minimum value among all the distances. When the number of rays corresponding to the minimum distance is at least two, the target ray is determined from the at least two rays corresponding to the minimum distance.

9. The method according to claim 6, characterized in that, After performing the intersection test between the target ray and the object of intersection of the target ray, the ray tracing method further includes: Based on the intersection test results between the intersection object of the target ray and the target ray, the current traversal result of the hierarchical bounding volume is determined; If the current traversal result indicates that the hierarchical bounding volume is to be traversed again, the target ray is determined from the third ray based on the updated previous node and the intersection objects of each ray in the third ray, and the intersection test of the target ray and the intersection objects of the target ray is performed.

10. The ray tracing method according to claim 1, characterized in that, The first ray comprises at least two rays; The method of controlling the intersection test between the first ray and the hierarchical bounding volume based on the ray traversal method includes: When the ray traversal method is the depth traversal method, the current traversal order of each ray in the first ray is determined, and the intersection test between each ray in the first ray and the layer bounding volume is performed in sequence according to the current traversal order.

11. The ray tracing method according to claim 1, characterized in that, The control information also includes prefetch information, which includes a prefetch identifier. The prefetch identifier indicates whether a node is prefetched in advance, and the node includes at least one object. The method of controlling the intersection test between the first ray and the hierarchical bounding volume based on the ray traversal method includes: In the case where the prefetch identifier represents nodes that are not prefetched, the intersection test between the first ray and the hierarchical bounding volume is controlled based on the ray traversal method. When the prefetch identifier represents the prefetch node, the intersection test between the first ray and the hierarchical bounding volume is controlled based on the prefetch method in the prefetch information and the ray traversal method.

12. The ray tracing method according to any one of claims 1 to 11, characterized in that, The ray tracing method also includes: The control information is configured based on the prediction information generated by the trained prediction model. or, Configure the control information based on the usage scenario corresponding to the hierarchical enclosing body.

13. A ray tracing device, characterized in that, It includes a configuration unit and a processing unit, wherein: A configuration unit is used to store control information; wherein the control information is dynamically configured, and the control information includes ray traversal mode, which includes depth traversal mode or breadth traversal mode. The depth traversal mode represents performing depth traversal of the same ray on the hierarchical bounding volume, and the breadth traversal mode represents performing breadth traversal of different rays on the hierarchical bounding volume. The processing unit is configured to obtain the ray traversal method from the configuration unit and, based on the ray traversal method, control the intersection test between the first ray and the hierarchical bounding volume.

14. The ray tracing device according to claim 13, characterized in that, The ray tracing device further includes a buffer unit, and the processing unit includes a traversal unit and an intersection testing unit, wherein: The traversal unit is used to determine the address of the target node, which is a node in the hierarchical enclosing body; and to send the address of the target node to the cache unit. The caching unit is used to cache the target node obtained from the storage unit based on the address of the target node; and send the target object in the target node to the intersection test unit. The intersection test unit is used to control the intersection test between the first ray and the target object based on the ray traversal method.

15. The ray tracing device according to claim 14, characterized in that, The traversal unit includes a light scheduling control unit and a node prefetching unit, and the control information also includes prefetching information; The node prefetching unit is used to determine the address of the target node based on the prefetching information; The light scheduling control unit is used to schedule each ray in the first light ray to the intersection test unit based on the light traversal method.

16. A graphics processor, characterized in that, The ray tracing device includes any one of claims 13 to 15.

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