Prefetching method and device, equipment, storage medium and program product

By dynamically adjusting the prefetch strategy based on the hierarchical information and ray types of the BVH tree during the ray tracing process, the problem of unreasonable prefetch data size and location settings in the existing technology is solved, and the efficiency and resource utilization of ray tracing are improved.

CN118733487AActive Publication Date: 2024-10-01MOORE THREADS TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410742926.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-01
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

In existing ray tracing technology, the data size and storage location of prefetched data are unreasonable, which affects the computing efficiency and resource utilization of the graphics processor, resulting in high memory and cache pressure and low efficiency.

Method used

In the ray tracing process based on the hierarchical bounding volume structure BVH tree, the cache prefetch size and position are determined by obtaining the prefetch parameters (including the hierarchical information of the target node, the light type and the cache encoding set by the user), and the prefetch strategy is dynamically adjusted. , to balance data response efficiency and cache space utilization.

Benefits of technology

By reasonably adjusting the cache prefetch size and location of prefetch operations, data response efficiency and cache space utilization are improved, and the overall efficiency of ray tracing is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733487A_ABST
    Figure CN118733487A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a prefetching method and device, equipment, a storage medium and a program product, and the method comprises the steps: obtaining a prefetching parameter under the condition that the node information of a target node does not exist in a cache module in a process of executing the ray tracing of a current ray based on a BVH tree, the cache prefetching size of second data needing to be prefetched and / or the cache position of the second data in the cache module are / is determined based on the prefetching parameters; and reading the first data including the node information from the main memory to the cache module, and pre-fetching the second data from the main memory to the cache module based on the cache pre-fetching size of the second data and / or the cache position of the second data in the cache module under the condition that the second data exists. By dynamically adjusting the pre-fetching strategy of the pre-fetching operation, the balance between the data response efficiency and the utilization rate of the cache space can be achieved, the data response efficiency can be improved, and the utilization rate of the cache space can also be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to, but is not limited to, the field of data processing technology, and in particular to a pre-fetching method, apparatus, device, storage medium, and program product. Background Art

[0002] In computer graphics, ray tracing is a technique that simulates the travel and reflection of light in three-dimensional space, and is often used to achieve complex light interaction effects such as shadows, reflections, and refractions. However, as the complexity of the scene increases, the amount of data that needs to be processed during ray tracing also increases significantly, putting tremendous pressure on memory and cache. In order to improve the efficiency of ray tracing, researchers have proposed various prefetching strategies, which aim to pre-read data that may be needed to reduce memory access latency and cache misses. However, the data size and storage location settings for prefetched data in related technologies are unreasonable, affecting the computing efficiency and resource utilization of the graphics processor. Summary of the invention

[0003] In view of this, embodiments of the present application at least provide a pre-fetching method, apparatus, device, storage medium, and program product.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] On the one hand, an embodiment of the present application provides a prefetching method, the method comprising: in a ray tracing process of executing a current ray based on a hierarchical bounding volume structure BVH tree, when there is no node information of a target node in a cache module, obtaining prefetching parameters, and determining a cache prefetching size of second data to be prefetched and / or a cache position of the second data in the cache module based on the prefetching parameters; the node information is used to determine whether a bounding box corresponding to the target node intersects with the current ray; reading first data including the node information from a main memory to the cache module, and when there is the second data, prefetching second data from the main memory to the cache module based on the cache prefetching size of the second data and / or the cache position of the second data in the cache module; wherein the prefetching parameters include at least one of the following: the hierarchical information of the target node in the BVH tree, the ray type of the current ray, and the cache encoding set by the user.

[0006] In some embodiments, the hierarchical information of the target node in the BVH tree is used to characterize the spatial locality of the node information of the target node; different types of light correspond to different spatial localities of node information; wherein the cache prefetch size of the second data is positively correlated with the spatial locality; the storage distance is negatively correlated with the spatial locality, and the storage distance is the distance between the cache location and the processor that initiates ray tracing.

[0007] In some embodiments, the cache module includes at least one level of cache units, and different levels of cache units have different distances from the processor; the hierarchical information and / or the light type are used to determine a target cache unit for storing the second data in the at least one level of cache units, and the target cache unit is the cache location.

[0008] In some embodiments, the level information includes at least one of the following: first level information and second level information; the first level information is used to characterize the number of levels between the target node and the root node of the BVH tree, and the second level information is used to characterize the number of levels between the target node and the leaf node of the BVH tree; wherein the number of levels included in the first level information is positively correlated with the spatial locality, and the number of levels included in the second level information is negatively correlated with the spatial locality.

[0009] In some embodiments, the ray type of the current ray includes a principal ray type, a shadow line type, a reflection line type and a refraction line type; wherein, when other prefetch parameters are the same, the cache prefetch size when the ray type of the current ray is the principal ray type or the shadow line type is larger than the cache prefetch size when the ray type of the current ray is the reflection line type or the refraction line type; and / or, when the ray type of the current ray is the principal ray type or the shadow line type, the distance between the cache position and the processor is smaller than the distance between the cache position and the processor when the ray type of the current ray is the reflection line type or the refraction line type.

[0010] In some embodiments, obtaining prefetch parameters and determining the cache prefetch size of second data that needs to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters includes: querying the cache code set by the user for the ray tracing process; determining the cache prefetch size and / or cache position based on the cache code.

[0011] In some embodiments, obtaining prefetch parameters and determining the cache prefetch size of second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters includes: querying the cache code set by the user for the ray tracing process; in the case where there is a cache code set by the user for the ray tracing process, determining the cache prefetch size and / or the cache position based on the cache code; in the case where there is no cache code set by the user for the ray tracing process, obtaining the level information and / or the ray type, and determining the cache prefetch size and / or the cache position based on the level information and / or the ray type.

[0012] In some embodiments, the method further includes: if it is determined that the second data does not exist, not pre-fetching.

[0013] On the other hand, an embodiment of the present application provides a pre-fetching device, the device comprising:

[0014] An acquisition module is used to acquire prefetch parameters when executing ray tracing of the current ray based on the hierarchical bounding volume structure BVH tree, and determine the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters when the node information of the target node does not exist in the cache module; the node information is used to determine whether the bounding box corresponding to the target node intersects with the current ray;

[0015] a read pre-fetch module, configured to read the first data including the node information from the main memory to the cache module, and, when it is determined based on the cache pre-fetch size of the second data that the second data exists, pre-fetch the second data from the main memory to the cache module based on the cache pre-fetch size of the second data and / or the cache position of the second data in the cache module;

[0016] The pre-fetch mode is used to determine at least one of the following: the level information of the target node in the BVH tree, the ray type of the current ray, and the cache encoding set by the user.

[0017] On the other hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0018] On the other hand, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements part or all of the steps in the above method when executed by a processor.

[0019] In an embodiment of the present application, the cache prefetch size and cache position of the second data of each prefetch operation are reasonably adjusted through at least one of the hierarchical information of the target node in the BVH tree, the ray type of the current ray, and the cache encoding set by the user. Then, by dynamically adjusting the prefetch strategy of each prefetch operation, a balance can be achieved between data response efficiency and cache space utilization, which can not only improve data response efficiency as a whole, but also improve cache space utilization.

[0020] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0022] Figure 1 A schematic diagram of an implementation flow of a pre-fetching method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of querying node information in a scenario where a cache module provided in an embodiment of the present application includes two cache units;

[0024] Figure 3 A schematic diagram of a BVH tree provided in an embodiment of the present application;

[0025] Figure 4A A schematic diagram of an implementation flow of determining a cache prefetch size and / or a cache location based on prefetch parameters provided in an embodiment of the present application;

[0026] Figure 4B A schematic diagram of another implementation flow of determining a cache prefetch size and / or a cache location based on prefetch parameters provided in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of a cache scenario of a two-level cache provided in an embodiment of the present application;

[0028] Figure 6 A schematic diagram of the structure of a pre-fetching device provided in an embodiment of the present application;

[0029] Figure 7 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0031] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but 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. The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

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

[0033] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0034] (1) A bounding volume hierarchy (BVH) is a tree structure over a set of geometric objects. The leaf nodes of the tree are all geometric objects wrapped in a bounding volume. These nodes are then grouped into small sets and contained within larger bounding volumes. These, in turn, are also recursively grouped and contained within other larger bounding volumes, ultimately forming a tree structure with a single bounding volume at the top of the tree. The bounding volume hierarchy is used to efficiently support a variety of operations on sets of geometric objects, such as in collision detection and ray tracing.

[0035] (2) Cache Line is a concept in computer architecture and is the smallest data unit of cache. A cache line is a group of data stored in the cache, usually of the same size and consisting of multiple words. When the CPU accesses the main memory, it reads the data from the main memory into the cache. If the size of the cache is an integer multiple of the cache line, the size of each cache line is an integer fraction of the cache size. The introduction of cache lines is to resolve the contradiction between cache capacity and access speed. As the cache capacity increases, the access speed of the cache decreases. In order to increase the access speed of the cache, the cache can be divided into multiple cache lines, each of which is of the same size, so that fast access can be performed between cache lines.

[0036] (3) Cache Miss: When the CPU needs to access the main memory, it will first check whether the data is in the cache. If the data is not in the cache, a Cache Miss occurs. When a cache miss occurs, the CPU needs to read the data from the main memory and store it in the cache. When reading a cache line, the CPU usually reads the entire cache line into the cache, not just the required data. The reason for this is that other data in the cache line may be accessed in the future, so reading the entire cache line into the cache in advance can reduce future cache misses. When reading a cache line, you also need to consider the cache line prefetch strategy. The prefetch strategy is to predict future access patterns based on the data access pattern and read the relevant cache lines into the cache in advance. The correct prefetch strategy can reduce cache misses and improve program performance.

[0037] (4) Spatial Locality: If a piece of data is accessed, the data adjacent to it is likely to be accessed soon. This spatial locality is common in data structures such as arrays and linked lists, as well as continuous memory address access. In computing systems, the spatial limitations of the cache can help predict the data that will be accessed, thereby improving the execution efficiency of the program. Correspondingly, temporal locality means that once a piece of data is accessed, it is likely to be accessed again in the near future. This temporal locality is common in loop programs, recursive functions, and other situations where the same code is repeatedly executed. In computing systems, the temporal limitations of the cache can help predict the data that will be accessed, thereby improving the execution efficiency of the program.

[0038] (5) Ray Tracing: It is a method of presenting three-dimensional (3D) images on a two-dimensional (2D) screen. The process is to calculate the reflection, refraction and shadow effects in the scene by simulating the propagation of light to generate realistic images. Specifically, the ray tracing algorithm generates images by tracing countless rays of light emitted from the observer's eyes. These rays are shot at each surface in the scene one by one and bounce along the first surface they encounter. The algorithm then calculates the reflection, refraction and shadow effects experienced by the light during the bounce process to determine the color of each pixel. Because the ray tracing algorithm requires a lot of computing power, it usually requires high-performance computer hardware and complex algorithm optimization. However, with the continuous development of computer technology, ray tracing has become the mainstream image rendering technology in computer games, film production and other fields.

[0039] (6) Tree: In computer data, a tree is a nonlinear data structure used to represent data with a hierarchical structure. Each node in the tree can contain data and pointers to its child nodes. The root node of the tree is the top-level node and has no parent node, while other nodes have one and only one parent node. The level of a tree refers to the number of nodes on the path from the root node to a certain node. The root node is at level 0 and its level is 0. The level of each node can be obtained by counting the number of nodes on the path from the root node to the node. The depth of a tree refers to the maximum level of the tree. In a binary tree, the depth of the root node is 0, and the depth of each child node is equal to the depth of its parent node plus 1.

[0040] Existing prefetch strategies usually only focus on cache misses, while ignoring the impact of memory access latency. In fact, memory access latency has a great impact on the efficiency of ray tracing. If only cache misses are considered, it may result in unnecessary prefetched data or large data access latency.

[0041] The present application embodiment provides a pre-fetching method, which can be executed by a processor of a computer device. The computer device may refer to a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device), or other device with data processing capabilities.

[0042] Figure 1 A schematic diagram of the implementation flow of a pre-fetching method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes the following steps S101 to S102:

[0043] Step S101, during the ray tracing process of the current light ray based on the hierarchical bounding volume structure BVH tree, when there is no node information of the target node in the cache module, obtain the prefetch parameters, and determine the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters; the node information is used to determine whether the bounding box corresponding to the target node intersects with the current light ray.

[0044] In some embodiments, the ray tracing process of executing the current ray based on the hierarchical bounding volume structure BVH tree can use the BVH tree to determine the object that one (or more, currently using the current ray as an example) ray collides with. Exemplarily, the ray tracing process for the current ray may include: starting the search from the root node of the BVH tree; for each node, calculating whether the current ray has an intersection with the bounding box of the node; if there is no intersection, the current ray will not intersect with the object in the node, and directly jump to the next node for judgment; if the current ray has an intersection with the bounding box of the node, then further determine whether the current ray has an intersection with the corresponding sub-bounding box in the node (the bounding box corresponding to the sub-node corresponding to the node), that is, for each sub-node of the node, calculate whether the current ray has an intersection with the bounding box of the sub-node; repeat the above steps until it is determined whether the object corresponding to the leaf node of the BVH tree has an intersection with the current ray. Through the above steps, the BVH tree can be used to quickly determine the object that a ray collides with, and record the collision information, so as to perform subsequent rendering operations.

[0045] It can be understood that the present application is actually applied to the following scenarios: in the above-mentioned node traversal process for the BVH tree, in order to determine whether the current ray has an intersection with the bounding box corresponding to the node currently traversed, the node information of the currently traversed node is queried from the cache module (the currently traversed node is referred to as the target node in the following embodiment); and when the node information of the target node does not exist in the cache module, the node information of the target node is obtained from the main memory, and the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module are determined based on the prefetch parameters.

[0046] In some embodiments, the pre-fetch parameter includes at least one of the following: level information of the target node in the BVH tree, the ray type of the current ray, and a cache encoding set by a user.

[0047] In some embodiments, the level information of the target node in the BVH tree is used to characterize the spatial locality of the node information of the target node; different ray types correspond to different spatial localities of the node information.

[0048] Among them, the hierarchical information represents the position of the target node in the above-mentioned BVH tree. It can be understood that the position of the target node in the BVH tree is different, and the spatial locality corresponding to the target node is also different; for example, the closer the target node is to the leaf node of the BVH tree, the closer the spatial distance is, and the higher the corresponding spatial locality is; conversely, the closer the target node is to the root node of the BVH tree, the farther the spatial distance is, and the lower the corresponding spatial locality is. Therefore, the hierarchical information of the target node in the BVH tree can be used as the pre-fetch parameter.

[0049] Among them, the current light rays of different light types have different corresponding spatial localities. Generally, in the process of ray tracing, the types of light rays may include: primary ray, shadow ray, reflection ray and refracted ray. Among them, the primary ray is the light emitted from the camera; the shadow ray is the light emitted from the intersection and points to the light source. If this ray does not intersect with any object before pointing to the light source, then the light source has a contribution value to the intersection; otherwise, the intersection is located in the shadow of the light source; for reflected light, if the surface of the object has reflective properties, part of the light will be reflected and continue to move forward in the scene. According to Snell's law, a new ray will be emitted from the intersection; for refracted light, when the surface of the object has refractive properties and is partially transparent, part of the light will enter the object and continue to propagate. According to Snell's law, a new ray will be emitted from the intersection and enter the object. It can be seen that the main ray and the shadow line both point to the same object (camera and light source), and they change in an orderly manner in space, that is, the spatial locality is relatively good, while the reflected ray and the refracted ray are affected by the incident angle and the medium, and can be considered to be disordered in space, that is, the spatial locality is relatively poor. Therefore, the ray type of the current ray can also be used as the pre-fetch parameter.

[0050] It can be understood that the cache prefetch size of the second data is positively correlated with the spatial locality; the storage distance is negatively correlated with the spatial locality, and the storage distance is the distance between the cache location and the processor that initiates ray tracing.

[0051] In an embodiment of the present application, the higher the spatial locality determined based on the level information of the target node in the BVH tree and / or the ray type of the current ray, the higher the correlation between the second data that can be obtained and the first data, and therefore, the larger the cache prefetch size, and accordingly, the shorter the cache distance; on the contrary, the lower the spatial locality determined based on the level information of the target node in the BVH tree and / or the ray type of the current ray, the lower the correlation between the second data that can be obtained and the first data, and therefore, the smaller the cache prefetch size, and accordingly, the longer the cache distance. In other words, the cache prefetch size of the second data is positively correlated with the spatial locality; the storage distance is negatively correlated with the spatial locality, and the storage distance is the distance between the cache location and the processor that initiates ray tracing.

[0052] In some embodiments, the ray type of the current ray includes a principal ray type, a shadow line type, a reflection line type and a refraction line type; wherein, when other prefetch parameters are the same, the cache prefetch size when the ray type of the current ray is the principal ray type or the shadow line type is larger than the cache prefetch size when the ray type of the current ray is the reflection line type or the refraction line type; and / or, when the ray type of the current ray is the principal ray type or the shadow line type, the distance between the cache position and the processor is smaller than the distance between the cache position and the processor when the ray type of the current ray is the reflection line type or the refraction line type.

[0053] In the embodiment of the present application, by obtaining the ray type of the current ray, since different ray types correspond to different spatial localities, a more suitable cache prefetch size and / or cache position can be obtained by considering the ray type of the current ray.

[0054] Among them, the cache encoding set by the user is the encoding information pre-set by the user based on the current graphics processor's operating scenario and the ray tracing algorithm. Different encoding information can correspond to different cache prefetch sizes, and different encoding information can correspond to different cache locations; different encoding information can also correspond to different cache prefetch sizes and different cache locations.

[0055] In some embodiments, when the cache prefetch size of the above-mentioned second data and / or the cache position of the second data in the cache module is determined based on at least two of the above-mentioned prefetch parameters, for example, when the cache prefetch size is determined based on at least two of the above-mentioned prefetch parameters, an embodiment of the present application can set a corresponding weight for each prefetch parameter, determine the corresponding cache prefetch size based on each prefetch parameter, and then, based on the weight corresponding to each prefetch parameter, perform weighted averaging on the corresponding cache prefetch sizes determined by each prefetch parameter to obtain the final cache prefetch size. Exemplarily, if the current cache prefetch size is determined based on the hierarchical information of the target node in the BVH tree, the ray type of the current ray, and the cache coding set by the user, where the cache prefetch size determined based on the hierarchical information is 300 bytes, the cache prefetch size determined based on the ray type is 400 bytes, and the cache prefetch size determined based on the cache coding is 200 bytes, when the weights corresponding to the hierarchical information, ray type, and cache coding are (2, 2, 4) respectively, the weighted average value obtained is 275 bytes, and the final cache prefetch size is set to 275 bytes, or to 300 bytes which is closest to 275 bytes.

[0056] Step S102: read the first data including the node information from the main memory to the cache module, and if the second data exists, prefetch the second data from the main memory to the cache module based on the cache prefetch size of the second data and / or the cache position of the second data in the cache module.

[0057] In the embodiment of the present application, since the current scenario is that the node information of the target node is missing in the cache module, it is necessary to at least read the node information of the target node from the main memory to the cache module in order to continue the node traversal process in the above-mentioned ray tracing process. At the same time, after reading the node information of the target node to the cache module, it can be determined whether the second data exists based on the cache prefetch size of the second data to be prefetched, or it can be determined whether the second data exists based on the cache encoding; if the second data exists, the second data is prefetched from the main memory to the cache module based on the cache prefetch size of the second data and / or the cache position of the second data in the cache module.

[0058] In some embodiments, in the absence of the second data, no pre-fetching is performed.

[0059] Among them, if it is determined based on the cache code that the second data does not exist, pre-fetching may not be performed; if it is determined based on the cache pre-fetch size of the second data that needs to be pre-fetched that the second data does not exist, pre-fetching may not be performed; if it is determined based on the cache code that the second data does not exist and based on the cache pre-fetch size of the second data that needs to be pre-fetched that the second data does not exist, pre-fetching may not be performed.

[0060] In some embodiments, the first data at least includes all node information of the target node, that is, when the node information of the target node is 128 bytes, the data size of the first data is at least 128 bytes. In other embodiments, the first data may include other information, such as node information of other nodes, in addition to the node information of the target node.

[0061] In some implementation scenarios, in the process of reading data from the main memory to the cache module, the data is stored in the cache module in units of cache lines. Therefore, in the case where the data size of the node information of the target node is an integer multiple of the size of the cache line, the above-mentioned first data can be an integer multiple of the size of the cache line, so that the first data (node ​​information of the target node) can be read from the main memory and cached in an integer multiple of cache lines in the cache module. Correspondingly, in the case where the second data needs to be pre-fetched, the second data is also cached in the cache module in the form of the above-mentioned cache line.

[0062] Among them, the cache prefetch size of the second data can be based on the data size, that is, in bytes; the cache prefetch size of the second data can be based on the minimum data unit in the cache, that is, in cache lines; the cache prefetch size of the second data can be based on the size of the node information of each node, that is, in the number of nodes, for example, the node information of N nodes is prefetched into the cache module as the second data.

[0063] In some embodiments, the cache module includes at least one level of cache units, and different levels of cache units have different distances from the processor; the hierarchical information and / or the light type are used to determine a target cache unit for storing the second data in the at least one level of cache units, and the target cache unit is the cache location.

[0064] The cache module may include at least one level of cache units, and cache units of different levels have different positions in the cache module, that is, different cache units have different distances from the processor. If the cache module includes two cache units, namely a level 1 cache unit and a level 2 cache unit, and the distance between the level 1 cache unit and the processor is smaller than the distance between the level 2 cache unit and the processor, the pre-fetch parameter is used to determine a target cache unit in the two levels of cache units, and cache the second data to the target cache unit.

[0065] In an embodiment of the present application, a target cache unit can be determined in the two levels of cache units based on the prefetch parameters, and the second data can be cached to the target cache unit. In this way, since the hierarchical information of the target node in the BVH tree and / or the ray type of the current ray reflects the spatial locality between the first data and the second data, the cache position of the second data for each prefetch operation can be reasonably adjusted. When the spatial locality is high, the second data can be cached to a cache unit that is closer to the processor that initiates ray tracing. In this way, the data response efficiency can be improved; and when the spatial locality is low, the second data can be cached to a cache unit that is farther away from the processor that initiates ray tracing. In this way, unnecessary occupation of high-performance cache space can be reduced.

[0066] It is understandable that the level of the cache unit in the above-mentioned cache module is used to characterize the priority order of access to the cache unit. The process of querying the node information of the target node in the cache module in step S101 is the process of traversing each cache unit in turn according to the level of each cache unit in the cache module. Correspondingly, in some embodiments, the method further includes: searching for the node information of the target node in the cache units of at least one level in turn according to the level; when the node information of the target node cannot be found in the cache units of at least one level, it is determined that the node information of the target node does not exist in the cache module.

[0067] See also Figure 2 , which shows a schematic diagram of querying node information in a scenario where a cache module includes two cache units. Among them, the cache module 210 includes a first cache unit 211 and a second cache unit 212, and the level of the first cache unit 211 is smaller than the level of the second cache unit 212, that is, the distance between the first cache unit 211 and the processor that initiates ray tracing is smaller than the distance between the second cache unit 212 and the processor that initiates ray tracing. It should be understood that the cache module in the present application may also include other numbers of cache units, and the embodiments of the present application are not limited to this.

[0068] In some implementation scenarios, the ray tracing module 220 sends a node information query request to the cache module 210. In response to the node information query request, the cache module 210 searches for the node information of the target node in the cache units of at least one level in order of the levels (from small to large), that is, first query the node information of the target node in the first cache unit 211, and if the node information is found, the node information of the target node is fed back to the ray tracing module 220; if the node information cannot be found, query the node information of the target node in the second cache unit 212, and if the node information is found, the node information of the target node is fed back to the ray tracing module 220; if the node information cannot be found, determine that the node information of the target node does not exist in the cache module, execute step S101 to obtain prefetch parameters, and determine the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters.

[0069] The above embodiments respectively take determining the target cache unit and determining the pre-fetch cache size as examples to illustrate the influence of the above pre-fetch parameters on the pre-fetch strategy. In some implementation scenarios, the pre-fetch parameters may not only affect the target cache unit for storing the second data, but also affect the pre-fetch cache size of the second data. Exemplarily, there may be a first pre-fetch strategy, a second pre-fetch strategy, and a third pre-fetch strategy, wherein the first pre-fetch strategy is used to pre-fetch 128 bytes of the second data to the above second cache unit, the second pre-fetch strategy is used to pre-fetch 256 bytes of the second data to the above second cache unit, and the third pre-fetch strategy is used to pre-fetch 256 bytes of the second data to the above first cache unit, that is, based on the above pre-fetch parameters, the current pre-fetch strategy can be determined from multiple preset pre-fetch strategies.

[0070] In an embodiment of the present application, the level of spatial locality is estimated through the hierarchical information of the target node in the BVH tree and / or the ray type of the current ray, and then the level of spatial locality between the read first data and the second data to be read is determined. Therefore, the cache prefetch size and cache position of the second data of each prefetch operation can be reasonably adjusted through the hierarchical information of the target node in the BVH tree and / or the ray type of the current ray; thus, by dynamically adjusting the prefetch strategy of each prefetch operation, a balance can be achieved between data response efficiency and cache space utilization, which can not only improve data response efficiency as a whole, but also improve cache space utilization.

[0071] In some implementation scenarios, in order to provide a more fine-grained prefetch control solution, a prefetch strategy can be used to indicate that the second data is cached in cache units of different levels. Please refer to the following embodiments. In some embodiments, the cache module includes at least one level of cache units; the level information of the target node in the BVH tree and / or the ray type of the current ray are used to determine at least one sub-cache unit for storing the second data in the at least one cache unit, and the sub-prefetch size corresponding to each sub-cache unit; wherein the level of at least one of the sub-cache units is negatively correlated with spatial locality, and / or the sub-prefetch size corresponding to at least one of the sub-cache units is positively correlated with spatial locality.

[0072] The following embodiments will illustrate the situation where the level of at least one of the sub-cache units is negatively correlated with the spatial locality.

[0073] In an embodiment of the present application, the level information of the target node in the BVH tree and / or the ray type of the current ray are used to determine at least one cache unit in the at least one cache unit for storing the second data.

[0074] If there is a first prefetch strategy and a second prefetch strategy, wherein the spatial locality determined by the level information and / or the ray type corresponding to the first prefetch strategy is smaller than the spatial locality determined by the level information and / or the ray type corresponding to the second prefetch strategy; then, the comprehensive level of at least one sub-cache unit corresponding to the first prefetch strategy is smaller than the comprehensive level of at least one sub-cache unit corresponding to the second prefetch strategy. The comprehensive level can be determined based on the level of each sub-cache unit and the sub-prefetch size corresponding to each sub-cache unit.

[0075] Exemplarily, if there is a first prefetch strategy (the sub-prefetch size of the second cache unit is 256 bytes), a second prefetch strategy (the sub-prefetch size of the second cache unit is 128 bytes, and the sub-prefetch size of the first cache unit is 128 bytes), and a third prefetch strategy (the sub-prefetch size of the first cache unit is 256 bytes). Based on the principle that the larger the sub-prefetch size, the smaller the corresponding weight, and the smaller the sub-prefetch size, the larger the corresponding weight, 256 bytes can be quantized as weight "1", and accordingly, 128 bytes can be quantized as weight "2", the level of the first cache unit can be quantized as "1", and the level of the second cache unit can be quantized as "2", then it can be determined that the level corresponding to the first prefetch strategy is "2", the comprehensive level corresponding to the second prefetch strategy is "6", and the comprehensive level corresponding to the third prefetch strategy is "1". It can be seen that the lower the above comprehensive level, the more second data can actually be prefetched to the cache unit closer to the processor. Based on the above concept, in order to set a finer-grained prefetch strategy division, different proportions of sub-prefetch sizes (such as 32 bytes, 64 bytes, 128 bytes, etc.) can also be set for the first cache unit and the second cache unit, thereby achieving a finer-grained prefetch strategy division while keeping the same cache prefetch size unchanged.

[0076] In the embodiment of the present application, a more fine-grained prefetch strategy can be provided by setting sub-prefetch sizes of different proportions in different cache units while keeping the cache prefetch size unchanged, thereby providing corresponding prefetch strategies for more complex scenarios.

[0077] The following embodiments will illustrate that the sub-prefetch size corresponding to at least one of the sub-cache units is positively correlated with the spatial locality.

[0078] In an embodiment of the present application, the level information of the target node in the BVH tree and / or the ray type of the current ray are used to determine the sub-prefetch size corresponding to at least one of the sub-cache units.

[0079] If there are a first prefetch strategy and a second prefetch strategy, and the spatial locality determined by the level information and / or the light type corresponding to the first prefetch strategy is smaller than the spatial locality determined by the level information and / or the light type corresponding to the second prefetch strategy; then, the comprehensive sub-prefetch size of at least one sub-cache unit corresponding to the first prefetch strategy is larger than the comprehensive sub-prefetch size of at least one sub-cache unit corresponding to the second prefetch strategy.

[0080] Exemplarily, if there are three preset levels, the sub-prefetch sizes corresponding to the first prefetch strategy to the third prefetch strategy can be set in the following manner: the first prefetch strategy (the sub-prefetch size of the second cache unit is 128 bytes, and the sub-prefetch size of the first cache unit is 128 bytes), the second prefetch strategy (the sub-prefetch size of the second cache unit is 256 bytes, and the sub-prefetch size of the first cache unit is 128 bytes), and the third prefetch strategy (the sub-prefetch size of the second cache unit is 256 bytes, and the sub-prefetch size of the first cache unit is 256 bytes). Based on the principle that the smaller the level of the cache unit, the larger the corresponding weight, and the larger the level of the cache unit, the smaller the corresponding weight, the first cache unit can be set to weight "2", and accordingly, the second cache unit can be set to weight "1". It can be determined that the comprehensive sub-prefetch size corresponding to the first prefetch strategy is "384 bytes", the comprehensive sub-prefetch size corresponding to the second prefetch strategy is "512 bytes", and the comprehensive sub-prefetch size corresponding to the third prefetch strategy is "768 bytes". It can be seen that the larger the above sub-prefetch size, the more second data can actually be prefetched to the cache unit closer to the processor.

[0081] In an embodiment of the present application, the present application can provide a finer-grained prefetch strategy by setting different sub-prefetch sizes in different cache units for a prefetch strategy while keeping the cache position unchanged (cached in the same cache unit), thereby providing corresponding prefetch strategies for more complex scenarios.

[0082] In some other implementation scenarios, while the level of at least one of the sub-cache units is negatively correlated with the spatial locality, the sub-prefetch size corresponding to at least one of the sub-cache units is positively correlated with the spatial locality. This application does not limit this.

[0083] In some embodiments, the level information includes at least one of the following: first level information and second level information; the first level information is used to characterize the number of levels between the target node and the root node of the BVH tree, and the second level information is used to characterize the number of levels between the target node and the leaf node of the BVH tree; wherein the number of levels included in the first level information is positively correlated with the spatial locality, and the number of levels included in the second level information is negatively correlated with the spatial locality.

[0084] In some embodiments, the first level information can be directly used as the level information; the second level information can be directly used as the level information; and comprehensive level information can be determined based on the first level information and the second level information to serve as the level information of the target node in the BVH tree.

[0085] See also Figure 3The BVH tree diagram is shown. If the first level information is used as the level information, the first level information is used to characterize the number of levels between the target node and the root node of the BVH tree, and the first level information corresponding to each node (the level information of the node in the BVH tree) is shown in Table 1.

[0086] Table 1

[0087] node First level information Node A 0 Node B 1 Node C 1 Node D 2 Node E 2 Node F 3 Node G 3 Node H 3 Node I 3 Node J 2 Node K 2

[0088] Among them, if the second level information is used as the level information, the second level information is used to characterize the number of levels between the target node and the leaf node of the BVH tree, and the second level information corresponding to each node (the level information of the node in the BVH tree) is shown in Table 2.

[0089] Table 2

[0090] node Second level information Node A 2 Node B 2 Node C 1 Node D 1 Node E 1 Node F 0 Node G 0 Node H 0 Node I 0 Node J 0 Node K 0

[0091] Among them, if the comprehensive hierarchical information determined by the first hierarchical information and the second hierarchical information is used as the hierarchical information, since the number of levels included in the first hierarchical information is positively correlated with the spatial locality, and the number of levels included in the second hierarchical information is negatively correlated with the spatial locality, the difference between the first hierarchical information and the second hierarchical information can be used as the comprehensive hierarchical information, and the comprehensive hierarchical information is positively correlated with the spatial locality. The comprehensive hierarchical information corresponding to each node (the hierarchical information of the node in the BVH tree) is shown in Table 3.

[0092] Table 3

[0093] node First level information Second level information Comprehensive level information Node A 0 2 -2 Node B 1 2 -1 Node C 1 1 0 Node D 2 1 1 Node E 2 1 1 Node F 3 0 3 Node G 3 0 3 Node H 3 0 3 Node I 3 0 3 Node J 2 0 2 Node K 2 0 2

[0094] It can be seen that in Table 3, compared with Table 1 and Table 2, by combining the first-level information and the second-level information, it is possible to effectively distinguish "nodes F to I" from "nodes J and K"; it is also possible to effectively distinguish the differences in the positions of nodes A, B, and C in the BVH tree.

[0095] In an embodiment of the present application, by obtaining first-level information characterizing the number of levels between the target node and the root node of the BVH tree, and / or second-level information characterizing the number of levels between the target node and the leaf nodes of the BVH tree, and then using the level information of the target node as the level information, the position of the target node in the BVH tree can be accurately characterized, so that the obtained level information can accurately reflect the level of spatial locality, providing a data basis for subsequently determining the cache prefetch size of the second data and / or the cache position of the second data in the cache module.

[0096] The following are respectively Figure 4A and Figure 4B Solutions for determining the cache prefetch size and / or cache position based on cache coding are described respectively.

[0097] Figure 4A The present invention provides a schematic diagram of an implementation flow of determining a cache prefetch size and / or cache location based on prefetch parameters, which can be executed by a processor of a computer device. Figure 1 , Figure 1 S101 in can be updated to S401 to S402, which will be combined with Figure 4A The steps shown are explained.

[0098] Step S401: In a ray tracing process for determining collision information of a current ray based on a hierarchical bounding volume structure BVH tree, if node information of a target node does not exist in a cache module, query a cache code set by a user for the ray tracing process.

[0099] Among them, the cache code set by the user for the ray tracing process is set by the user in advance based on the scene information of ray tracing. In an embodiment of the present application, the scene information of the ray tracing can be the object information and light source information that need to be rendered in the current rendering scene, etc. Objects with different numbers / surface materials and light sources with different positions / intensities correspond to different rendering scenes. Therefore, the user can set different cache codes for different scenes, and then set the corresponding cache prefetch size and / or cache position for different scenes through the cache code; the scene information of the ray tracing can also be the mode scene of the current computer device, for example, performance mode or power saving mode, etc. For the performance mode, a larger cache prefetch size and / or a cache position closer to the processor can be set, and for the power saving mode, a smaller cache prefetch size and / or a cache position farther from the processor can be set. By setting different cache codes for different scene information and then adopting different prefetch strategies, different cache prefetch sizes and / or cache positions can be used for data prefetch operations in different rendering scenes / device mode scenes.

[0100] In an embodiment of the present application, the above-mentioned algorithm information may include at least one of the following: traversal algorithm information for traversing the BVH tree, a ray generation algorithm for the current ray during ray tracing, a calculation algorithm for calculating whether there is an intersection between the bounding box corresponding to the current ray and the target node during ray tracing, and an algorithm for determining whether the current ray finally intersects with a geometric object in the scene, etc.

[0101] In some embodiments, the user sets different cache codes for different scene information and / or algorithm information. Based on the scene information and algorithm information in the current ray tracing process, the cache code corresponding to the current ray tracing process can be determined from the preset cache codes.

[0102] Exemplarily, the scene of the current ray tracing process is determined by scene information and algorithm information. The process of querying the cache encoding set by the user for the ray tracing process based on the scene information and / or algorithm information of the ray tracing process can be determined by the relationship table shown in Table 4.

[0103] Table 4

[0104] Scene Information Algorithm Information Cache Encoding Scene Information A Algorithm InformationA 00 Scene Information B Algorithm InformationA 00 Scene Information C Algorithm InformationA 00 Scene Information D Algorithm InformationA 00 Scene Information A Algorithm Information B 01 Scene Information B Algorithm Information B 01 Scene Information C Algorithm Information B 10 Scene Information D Algorithm Information B 10 Scene Information A Algorithm Information C 11 Scene Information B Algorithm Information C 11 Scene Information C Algorithm Information C none Scene Information D Algorithm Information C none

[0105] It can be seen that a combination of scene information and algorithm information corresponds to at most one cache encoding, that is, a cache encoding can be determined based on the scene information and algorithm information of the current ray tracing process.

[0106] In some embodiments, a combination of scene information and algorithm information may not have a corresponding cache code; such as "scene information C and algorithm information C" and "scene information D and algorithm information C" in Table 1 above, the scenes of these two ray tracing processes do not have corresponding cache codes.

[0107] Step S402: Determine the cache prefetch size and / or cache location based on the cache code.

[0108] In some embodiments, the cache prefetch size and / or cache position corresponding to the above cache encoding may be stored in a mapping relationship table.

[0109] Exemplarily, taking the case where the cache codes include 4 and different preset levels correspond to different information codes, the above mapping relationship table can be presented in the form of Table 5. It can be understood that one information code corresponds to only one preset level, and one preset level can correspond to one or more information codes, which is not limited in this application.

[0110] Table 5

[0111]

[0112] Exemplarily, when the information code is determined to be "01" based on Table 4, the cache prefetch size and cache position matching the information code "01" can be determined to be "128 bytes stored in the second cache unit" based on Table 5.

[0113] Figure 4BThe present invention provides a schematic diagram of an implementation flow of determining a cache prefetch size and / or cache location based on prefetch parameters, which can be executed by a processor of a computer device. Figure 1 , Figure 1 S101 in can be updated to S403 to S405, which will be combined with Figure 4B The steps shown are explained.

[0114] Step S403: query the cache code set by the user for the ray tracing process.

[0115] Step S404: in the case where there is a cache code set by the user for the ray tracing process, determine the cache prefetch size and / or cache position based on the cache code.

[0116] The specific implementation of the above step S403 may refer to the description of step S401 in the above embodiment. Accordingly, in the case where there is a cache code set by the user for the ray tracing process, the specific implementation of "determining the cache prefetch size and / or cache position based on the cache code" may refer to the description of step S402 in the above embodiment. The description will not be repeated here.

[0117] Step S405: In the absence of cache coding set by the user for the ray tracing process, obtain the level information and / or the ray type, and determine the cache prefetch size and / or cache location based on the level information and / or the ray type.

[0118] In the current embodiment, if the user has not set the corresponding information encoding for the current ray tracing process (that is, there is no cache encoding set by the user for the ray tracing process), it is necessary to obtain the level information and / or the ray type, and determine the cache prefetch size and / or cache location based on the level information and / or the ray type.

[0119] Among them, the hierarchical information represents the position of the target node in the above-mentioned BVH tree. It can be understood that the position of the target node in the BVH tree is different, and the spatial locality corresponding to the target node is also different; specifically, the closer the target node is to the leaf node of the BVH tree, the closer the distance in space is, and the higher the corresponding spatial locality is; conversely, the closer the target node is to the root node of the BVH tree, the farther the distance in space is, and the lower the corresponding spatial locality is. The current light of different light types has different corresponding spatial localities. Usually, in the process of ray tracing, the types of light can include: main rays, shadow lines, reflection lines and refraction lines. Both the main rays and shadow lines point to the same object (camera and light source), and they change in an orderly manner in space, that is, the spatial locality is relatively good, while the reflection lines and refraction lines are affected by the incident angle and the medium, and can be considered to be disordered in space, that is, the spatial locality is relatively poor.

[0120] The following describes the application of the pre-fetching method provided in the embodiment of the present application in a practical scenario.

[0121] In one implementation scenario, the cache prefetch size (including several cache lines) and the cache level (destination level, indicating which level of cache to prefetch, corresponding to the cache location in the above embodiment) can be adjusted according to the level of the hierarchical bounding volume structure tree (BVH tree level, corresponding to the first level information in the above embodiment).

[0122] In the normal ray tracing process, when accessing the BVH tree, the closer to the leaf node, the better the spatial locality. Therefore, a larger cache prefetch size can be set when a cache miss occurs (i.e., a few more cache lines are read), and the cache (unit) closer to the ray tracing initiator module (corresponding to the processor initiating ray tracing in the above embodiment) can be prefetched.

[0123] In another implementation scenario, the cache prefetch size and cache level may be adjusted according to the type of ray in the ray tracing process.

[0124] In general, different types of light have different spatial localities. The types of light include, but are not limited to, primary rays, shadow rays, reflection rays, and refracted rays.

[0125] Among them, since the main rays are all emitted from the camera's perspective, the spatial locality of the main rays passing through adjacent pixels is relatively better; the shadow lines emitted to the same light source will also have good spatial locality; in contrast, the reflected rays and refracted rays are affected by the incident angle and the medium, and can be considered to be spatially disordered.

[0126] Based on the above considerations, in the embodiments of the present application, a larger cache prefetch size may be set for the main rays and shadow lines according to the type of light, but a smaller cache prefetch size may be set or no prefetch may be performed for the reflected rays and refracted rays.

[0127] In some other implementation scenarios, the cache prefetch size and cache level may be determined based on a cache hint (corresponding to the cache encoding in the above embodiment) provided by a user.

[0128] Among them, users can actively provide corresponding cache prefetch size and cache level according to different rendering scenarios and algorithms.

[0129] The above are methods for determining cache prefetch size and cache level in various implementation scenarios. In order to facilitate understanding of the above implementation scenarios, the above implementation scenarios will be exemplarily described below.

[0130] In some implementation scenarios, for the levels of the hierarchical bounding volume structure tree, the level information of each node in the hierarchical bounding volume structure tree can be directly added to the node information during the process of constructing the hierarchical bounding volume structure tree. The level information of the hierarchical bounding volume structure tree can include first level information, which indicates the level of the node from the root node; the level information of the hierarchical bounding volume structure tree can include second level information, which indicates the level of the node from the leaf node (the second level information can be called Level To Leaf, abbreviated as LTL).

[0131] See also Figure 3 The hierarchical bounding volume structure tree includes nodes A to K, wherein node A is the root node and nodes F to K are leaf nodes.

[0132] Wherein, when the level information includes the first level information, the first level information corresponding to node A is 0; the first level information corresponding to node B and node C is 1; the first level information corresponding to nodes D, E, J and K is 2; and the first level information corresponding to nodes F, G, H and I is 3. When the level information includes the second level information, the second level information corresponding to nodes F, G, H, I, J and K is 0; the second level information corresponding to nodes C, D and E is 1; and the second level information corresponding to nodes A, B and 2 is 2.

[0133] There are usually multiple levels of cache in the hardware to cache the node information of each node. In traditional design, each cache miss requires reading a cache line of fixed length. Figure 5 , Figure 5 The schematic diagram of the cache scene of the two-level cache is shown. The hierarchical bounding volume structure tree is stored in the main memory. During the ray tracing process, that is, the process of determining whether the ray to be detected intersects with a certain object, each node in the hierarchical bounding volume structure tree will be traversed in turn. In this way, the node information of each node of the hierarchical bounding volume structure tree needs to be cached from the main memory. Figure 5 , the node information of the nodes of the hierarchical bounding volume structure tree can be cached in the first-level cache and the second-level cache (corresponding to at least one level of cache units in the above embodiment); in this way, when traversing to the target node during ray tracing, it can be determined whether the node information of the target node exists in the first-level cache first; if the node information of the target node does not exist in the first-level cache, determine whether the node information of the target node exists in the second-level cache; if the node information of the target node does not exist in the second-level cache, there is a cache miss, and the cache line corresponding to the node information of the target node is read from the main memory into the cache. In the above process, if the node information of the target node exists in the first-level cache, based on the node information of the target node, it is determined whether the ray intersects with the bounding box corresponding to the target node, and then the next traversed node is determined. It can be understood that Figure 5 The cache scenario in is only one implementation scenario of the present application. The embodiments of the present application can also be applied to other multi-level cache scenarios such as three-level cache.

[0134] In some embodiments, the cache prefetch size can be determined according to the hierarchical information of the target node currently being accessed. Exemplarily, taking the hierarchical information as the second hierarchical information above, each cache line is 128Byte and the size of each BVH node is 128Byte as an example, if the second hierarchical information LTL of the target node is 0, not only the currently missing 128Bytes are read, but also an additional 128Bytes (a total of 256Bytes) can be prefetched to the L1 cache; if the second hierarchical information LTL of the target node is 1, the currently missing 128Bytes are read, and an additional 128Bytes are prefetched to the L2 cache.

[0135] In some embodiments, the size threshold of the BVH node, the cache prefetch size, and the cache level may be made hardware configurable to increase flexibility.

[0136] In other implementation scenarios, for the ray type, the module that initiates ray tracing needs to pass the ray type information to the downstream L1 cache. The L1 cache can determine the cache prefetch size and cache level based on the ray type information.

[0137] In some embodiments, the ray type may include: main ray, shadow ray, reflection ray and refraction ray, a total of 4 ray types, which can be encoded by 2 bits to obtain a 2-bit type code. The module that initiates ray tracing needs to pass the 2-bit type code to the downstream L1 cache. The L1 cache can determine the cache prefetch size and cache level based on the 2-bit type code.

[0138] In some other implementation scenarios, the cache hint provided by the user may be encoded to obtain a cache code, and then the hardware (cache) may execute corresponding hardware behavior based on the cache code.

[0139] In order to facilitate understanding of the above implementation scenarios, the following uses 4 types of cache prompt information, namely 2-bit encoding, as an example for explanation. Of course, the present application can also be applied to implementation scenarios of other numbers of cache prompt information. As shown in Table 6, different cache encodings correspond to different hardware behaviors.

[0140] Table 6

[0141]

[0142] Based on the above embodiments, in ray tracing, a lower hardware cost is used in exchange for higher cache space locality to improve cache performance. Through the node information of the BVH tree and the type of light, the cache module can adaptively adjust the pre-fetch size and the level of cache unit to be pre-fetched.

[0143] In an embodiment of the present application, the cache can adjust the size of memory access or prefetch to a certain level of cache according to node information of the BVH tree, such as the current level or the level from the leaf; the cache can also adjust the size of memory access or prefetch to a certain level of cache according to the type of light; the cache can also actively provide relevant information for prefetching based on the cache hint provided by the user; in addition, the size of memory access, prefetch to a certain level, and the corresponding BVH threshold can all be hardware configurable; there is one or more levels of cache in the ray tracing operation; the module that initiates ray tracing can be a CPU / GPU / dedicated hardware module.

[0144] Based on the foregoing embodiments, an embodiment of the present application provides a pre-fetch device, which includes the units included and the modules included in the units, and can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0145] Figure 6 A schematic diagram of the structure of a pre-fetching device provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the pre-fetching device 600 includes: an acquisition module 610 and a read pre-fetching module 620, wherein:

[0146] The acquisition module 610 is used to acquire prefetch parameters when executing the ray tracing of the current ray based on the hierarchical bounding volume structure BVH tree, and determine the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters when the node information of the target node does not exist in the cache module; the node information is used to determine whether the bounding box corresponding to the target node intersects with the current ray;

[0147] A read prefetch module 620 is used to read the first data including the node information from the main memory to the cache module, and if the second data exists, prefetch the second data from the main memory to the cache module based on the cache prefetch size of the second data and / or the cache position of the second data in the cache module; wherein the prefetch parameters include at least one of the following: the level information of the target node in the BVH tree, the ray type of the current ray, and the cache encoding set by the user.

[0148] In some embodiments, the hierarchical information of the target node in the BVH tree is used to characterize the spatial locality of the node information of the target node; different types of light correspond to different spatial localities of node information; wherein the cache prefetch size of the second data is positively correlated with the spatial locality; the storage distance is negatively correlated with the spatial locality, and the storage distance is the distance between the cache location and the processor that initiates ray tracing.

[0149] In some embodiments, the cache module includes at least one level of cache units, and different levels of cache units have different distances from the processor; the hierarchical information and / or the light type are used to determine a target cache unit for storing the second data in the at least one level of cache units, and the target cache unit is the cache location.

[0150] In some embodiments, the level information includes at least one of the following: first level information and second level information; the first level information is used to characterize the number of levels between the target node and the root node of the BVH tree, and the second level information is used to characterize the number of levels between the target node and the leaf node of the BVH tree; wherein the number of levels included in the first level information is positively correlated with the spatial locality, and the number of levels included in the second level information is negatively correlated with the spatial locality.

[0151] In some embodiments, the ray type of the current ray includes a principal ray type, a shadow line type, a reflection line type and a refraction line type; wherein, when other prefetch parameters are the same, the cache prefetch size when the ray type of the current ray is the principal ray type or the shadow line type is larger than the cache prefetch size when the ray type of the current ray is the reflection line type or the refraction line type; and / or, when the ray type of the current ray is the principal ray type or the shadow line type, the distance between the cache position and the processor is smaller than the distance between the cache position and the processor when the ray type of the current ray is the reflection line type or the refraction line type.

[0152] In some embodiments, the acquisition module 610 is further used to: query the cache code set by the user for the ray tracing process; and determine the cache prefetch size and / or cache location based on the cache code.

[0153] In some embodiments, the acquisition module 610 is also used to: query the cache code set by the user for the ray tracing process; in the case where there is a cache code set by the user for the ray tracing process, determine the cache prefetch size and / or cache location based on the cache code; in the case where there is no cache code set by the user for the ray tracing process, obtain the level information and / or the ray type, and determine the cache prefetch size and / or cache location based on the level information and / or the ray type.

[0154] In some embodiments, the read pre-fetch module 620 is further configured to not pre-fetch if it is determined that the second data does not exist.

[0155] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0156] It should be noted that in the embodiment of the present application, if the above-mentioned pre-fetching method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0157] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0158] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0159] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0160] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0161] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0162] Figure 7 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the hardware entity of the computer device 700 includes: a processor 701 and a memory 702, wherein the memory 702 stores a computer program that can be run on the processor 701, and the processor 701 implements the steps in the method of any of the above embodiments when executing the program.

[0163] The memory 702 stores computer programs that can be run on the processor. The memory 702 is configured to store instructions and applications executable by the processor 701. It can also cache data to be processed or processed by the processor 701 and various modules in the computer device 700 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0164] When the processor 701 executes the program, the steps of any of the above pre-fetching methods are implemented. The processor 701 generally controls the overall operation of the computer device 700.

[0165] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the pre-fetching method of any of the above embodiments.

[0166] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0167] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application are not specifically limited.

[0168] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0169] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0170] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

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

[0172] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0173] In addition, all functional units in the embodiments of the present 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 above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.

[0174] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0175] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A pre-fetching method, characterized in that: The method comprises: In the process of executing ray tracing of the current ray based on the hierarchical bounding volume structure BVH tree, when the node information of the target node does not exist in the cache module, a prefetch parameter is obtained, and a cache prefetch size of second data to be prefetched and / or a cache position of the second data in the cache module are determined based on the prefetch parameter; the node information is used to determine whether the bounding box corresponding to the target node intersects with the current ray; Reading first data including the node information from the main memory to the cache module, and if the second data exists, pre-fetching second data from the main memory to the cache module based on the cache pre-fetch size of the second data and / or the cache position of the second data in the cache module; The pre-fetch parameters include at least one of the following: level information of the target node in the BVH tree, the ray type of the current ray, and a cache code set by a user.

2. The method according to claim 1, characterized in that The level information of the target node in the BVH tree is used to characterize the spatial locality of the node information of the target node; different ray types correspond to different spatial localities of the node information; Among them, the cache prefetch size of the second data is positively correlated with the spatial locality; the storage distance is negatively correlated with the spatial locality, and the storage distance is the distance between the cache location and the processor that initiates ray tracing.

3. The method according to claim 2, characterized in that The cache module includes at least one level of cache units, and the distances between cache units of different levels and the processor are different; the hierarchical information and / or the light type are used to determine a target cache unit for storing the second data in the at least one level of cache units, and the target cache unit is the cache location.

4. The method according to claim 2, characterized in that: The level information includes at least one of the following: first level information and second level information; the first level information is used to represent the number of levels between the target node and the root node of the BVH tree, and the second level information is used to represent the number of levels between the target node and the leaf node of the BVH tree; The number of levels included in the first-level information is positively correlated with the spatial locality, and the number of levels included in the second-level information is negatively correlated with the spatial locality.

5. The method according to claim 2, characterized in that: The ray type of the current ray includes a principal ray type, a shadow ray type, a reflection ray type and a refraction ray type; Wherein, when other pre-fetch parameters are the same, the cache pre-fetch size when the ray type of the current ray is the main ray type or the shadow line type is greater than the cache pre-fetch size when the ray type of the current ray is the reflection line type or the refraction line type; and / or, When the ray type of the current ray is the main ray type or the shadow line type, the distance between the cache position and the processor is less than the distance between the cache position and the processor when the ray type of the current ray is the reflection line type or the refraction line type.

6. The method according to any one of claims 1 to 5, characterized in that: The obtaining of the prefetch parameters, and determining the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters, includes: Query the cache encoding set by the user for the ray tracing process; The cache prefetch size and / or cache location is determined based on the cache encoding.

7. The method according to any one of claims 1 to 5, characterized in that: The obtaining of the prefetch parameters, and determining the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters, includes: Query the cache encoding set by the user for the ray tracing process; In the case where there is a cache code set by a user for the ray tracing process, determining the cache prefetch size and / or cache position based on the cache code; In the absence of cache encoding set by a user for the ray tracing process, the level information and / or the ray type are obtained, and the cache prefetch size and / or cache location are determined based on the level information and / or the ray type.

8. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If it is determined that the second data does not exist, no pre-fetching is performed.

9. A pre-fetching device, characterized in that: The device comprises: An acquisition module is used to acquire prefetch parameters when executing ray tracing of the current ray based on the hierarchical bounding volume structure BVH tree, and determine the cache prefetch size of the second data to be prefetched and / or the cache position of the second data in the cache module based on the prefetch parameters when the node information of the target node does not exist in the cache module; the node information is used to determine whether the bounding box corresponding to the target node intersects with the current ray; a read pre-fetch module, configured to read the first data including the node information from the main memory to the cache module, and, when it is determined based on the cache pre-fetch size of the second data that the second data exists, pre-fetch the second data from the main memory to the cache module based on the cache pre-fetch size of the second data and / or the cache position of the second data in the cache module; The pre-fetch mode is used to determine at least one of the following: the level information of the target node in the BVH tree, the ray type of the current ray, and the cache encoding set by the user.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps in the method according to any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 8 are implemented.

12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Efficient caching of resource states for shared functions of graphics processing unit three-dimensional pipelines

    CN115858411A

  • Data scheduling method and device based on ray tracing, equipment and storage medium

    CN116049032A

  • Displacement micro-grid for ray and path tracking

    CN117280387A

  • Accelerated ray tracing using shallow bounding volume hierarchies

    US20100053162A1

  • Texture processor based ray tracing acceleration method and system

    US20190197761A1