Verification method of ray tracing module
By randomly generating the positions of triangles and emission points, and randomly generating the center of gravity based on the randomly generated triangles, determining the emission direction, generating excitation signals to input into the ray tracing module, performing interception calculations, solving the problem of how to fully cover intersecting and disjoint scenes in the ray tracing module, realizing full verification of the module and scene proportion adjustment.
Patent Information
- Application Number
- CN202510488567.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-04-18
AI Technical Summary
In the ray tracing module, how to set the emission point, emission direction and object position to fully cover various intersecting and disjoint scenes to ensure the correctness of the module design.
By randomly generating the positions of the triangle and the emission point, and randomly generating the center of gravity based on the randomly generated triangle, determining the emission direction based on the emission point and the center of gravity, generating an excitation signal input to the ray tracing module, and performing interception calculation.
A comprehensive verification of the ray tracing module is achieved, which can cover various intersecting and disjoint scenarios, making the verification results more sufficient, and adjust the proportion of intersecting, disjointing and boundary scenarios through directional random weights.
Smart Images

Figure CN120032035A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of chip design, and in particular to a verification method for a ray tracing module. Background Art
[0002] As one of the core technologies in modern GPU graphics cards, the ray tracing block plays an important role in the field of graphics rendering. Its system functions are complex and mainly rely on software implementation, but in order to improve the overall computing efficiency, some key algorithms, such as intersection calculation, are specially ported to hardware. This design idea is to transfer highly repetitive and computationally intensive tasks from software to hardware, thereby significantly improving the rendering speed. In the GPU, the ray tracing module is a small module dedicated to processing ray tracing tasks, and its core function is to perform intersection calculations efficiently. The entire rendering process requires the screen to be divided into multiple blocks. The software is responsible for building rendering tasks, while the hardware focuses on performing key calculations in these tasks. In ray tracing, intersection calculation is the most basic and important functional module, but its performance and accuracy directly determine the rendering effect and efficiency of the entire system.
[0003] Specifically, the intersection operation needs to process the following core elements: emission point (Origin), emission direction (Direction), primitive objects (Primitive Objects) and intersection result (Hit or Miss), where the emission point represents the starting point of the light; the emission direction represents the propagation direction of the light, usually described by three components in three-dimensional coordinates; primitive objects include geometric bodies such as triangles and / or cubes (box); the intersection result is the result of determining whether the light intersects with the target object. If the intersection point exists, it is Hit, otherwise it is Miss.
[0004] In three-dimensional space, how to set the emission point, emission direction, and object position to fully cover various intersecting and non-intersecting scenarios is the key difficulty in ensuring the correctness of the Ray tracing module design. Therefore, a verification method that can fully cover various intersecting and non-intersecting scenarios is urgently needed. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is: a verification method for a ray tracing module, the method comprising the following steps: S100, randomly generating the position of each primitive, wherein the primitive includes three vertices of a triangle and an emission point; and storing the position information of the three vertices of the triangle into a memory.
[0006] S200, obtaining an excitation signal for triggering a ray tracing module operation according to the position information of the three vertices and the emission point of the triangle, including: S210, obtaining weight parameters of three vertices of the triangle and random conditions thereof.
[0007] S220: Under the constraint of the random condition, randomly generate weights of the three vertices of the triangle respectively.
[0008] S230, generating centroid coordinates according to the weights of the three vertices of the triangle and the position information of the three vertices of the triangle; S240: Determine a transmission direction according to the position information of the transmission point and the center of gravity coordinates.
[0009] S250: Generate the excitation signal according to the position information of the emission point and the emission direction.
[0010] S300, inputting the excitation signal into the ray tracing module; the ray tracing module reads the position information of the three vertices of the triangle in the memory, performs an intersection operation according to the position information of the three vertices of the triangle and the excitation signal, and obtains an intersection result.
[0011] The present invention has at least the following beneficial effects: An embodiment of the present invention provides a verification method for a ray tracing module, which randomly generates the positions of triangles and emission points, and randomly generates the center of gravity based on the randomly generated triangles, and determines the emission direction according to the emission points and the center of gravity. The scene is random and has a wide coverage, and can fully cover various intersecting and non-intersecting scenes, making the verification result more sufficient; and the proportion of intersecting, non-intersecting and boundary scenes can be adjusted through directional random weights. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0013] Figure 1 A flow chart of a verification method for a ray tracing module provided by an embodiment of the present invention; Figure 2 A schematic diagram of the steps of obtaining an excitation signal provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0014] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0015] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present invention have the same meanings as commonly understood by those skilled in the art.
[0016] See also Figure 1 , which shows a flow chart of a verification method for a ray tracing module, the method comprising the following steps: S100, randomly generating position information of each primitive, wherein the primitive includes three vertices of a triangle and an emission point; and storing the position information of the three vertices of the triangle into a memory.
[0017] Among them, the emission point is the starting point of the light in the ray tracing module, which is usually expressed by coordinates in a three-dimensional coordinate system. It is the reference point for light propagation. All light rays start from this emission point and propagate along a specific emission direction.
[0018] In one embodiment, the step of randomly generating the position of each primitive includes: obtaining a random range of three vertices of a triangle, and randomly generating the position information of the three vertices of the triangle according to the random range. In one embodiment, the step of obtaining the random range of the three vertices of the triangle includes: randomly generating the random range (Tmin, Tmax), wherein Tmin is the minimum three-dimensional coordinate in the cube, and Tmax is the maximum three-dimensional coordinate in the cube. Specifically, the three coordinate components of each vertex are randomly generated between Tmin and Tmax to ensure that the vertex is located inside or on the boundary of the cube. In this way, the position range of the primitive can be effectively controlled to avoid exceeding the expected spatial area.
[0019] In one embodiment, the random generation algorithm is a linear congruential generator or a Mersenne Twister to reduce the calculation time. Alternatively, the random generation algorithm uses a Sobol sequence or a Halton sequence to generate random numbers to reduce sampling bias. Other types of random generation algorithms also fall within the scope of protection of the present invention.
[0020] S200, obtaining an excitation signal for triggering a ray tracing module operation according to the position information of the three vertices and the emission point of the triangle.
[0021] For further information, see Figure 2 , S200 also includes: S210, obtaining weight parameters of three vertices of the triangle and random conditions thereof.
[0022] The weight parameters of the three vertices of the triangle include: a weight parameter u of the first vertex, a weight parameter v of the second vertex, and a weight parameter w of the third vertex.
[0023] The position of the barycentric coordinates can be located inside the triangle, outside the triangle, on the edge of the triangle, or at the vertex of the triangle. The random conditions include the random conditions that the position of the barycentric coordinates is located inside the triangle, outside the triangle, on the edge of the triangle, and at the vertex of the triangle. The configuration of the random conditions can make it possible to verify the four position distributions of the barycentric coordinates, thereby achieving the purpose of full verification.
[0024] In one implementation, when the random condition is a random condition located inside a triangle, the random range of u is configured to (0, 1); the random range of v is configured to (0, (1-u)); and the random range of w is configured to 1-uv.
[0025] In one implementation, when the random condition is a random condition located outside the triangle, the random range of u is configured to (-1, 0); the random range of v is configured to (-1, 1); and the random range of w is configured to 1-uv.
[0026] In one implementation, when the random condition is a random condition located on the edge of a triangle, u is configured to be 0; the random range of v is configured to be (0, 1); and the random range of w is configured to be 1-uv.
[0027] In one implementation, when the random condition is a random condition located at a vertex of a triangle, both u and v are configured to be 0; and w is configured to be 1.
[0028] S220: Under the constraint of the random condition, randomly generate weights of the three vertices of the triangle respectively.
[0029] In one implementation, the weight values of (u, v, w) are randomly generated under random conditions inside the triangle, random conditions outside the triangle, random conditions on the edges of the triangle, and random conditions on the vertices of the triangle.
[0030] S230: Generate centroid coordinates according to the weights of the three vertices of the triangle and the position information of the three vertices of the triangle.
[0031] Among them, the centroid coordinates P satisfy: P=uA+vB+wC, where A, B and C are the coordinates of the three vertices of the triangle respectively.
[0032] As an example, assume that the coordinates of the three vertices of a triangle are A(0,0,0), B(1,0,0) and C(0,1,0), which form a triangle in a two-dimensional plane. Under the constraints of random conditions inside the triangle, u=0.5, v=0.3, w=0.2, u+v+w=1 are obtained, which meets the conditions. P=uA+vB+wC, that is, the x coordinate of P is equal to 0.5×0+0.3×1+0.2×0=0.3, the y coordinate of P is equal to 0.5×0+0.3×0+0.2×1=0.2, and the z coordinate of P is equal to 0. The coordinates of point P are (0.3,0.2,0), which is located inside the triangle. The size of the weights u, v, and w determines the distance of point P from each vertex. For example, u=0.5 means that P is closer to A, while v=0.3 and w=0.2 mean that it is closer to B than C. If u=1, then P is at point A; if v=1, P is at point B; if w=1, P is at point C. When the weight changes between 0 and 1, point P moves inside the triangle. If there is a negative number in the weight, point P will be outside the triangle.
[0033] It should be noted that at least four centroid coordinates are obtained according to random conditions, and these four centroid coordinates represent four different scenarios respectively.
[0034] In one embodiment, the number of barycentric coordinates randomly obtained under each random condition is configured. The proportion of intersecting, non-intersecting and boundary scenes can be adjusted by directional random weights, for example, the proportion of intersection operations on vertices or common edges can be adjusted.
[0035] S240: Determine a transmission direction according to the position information of the transmission point and the center of gravity coordinates.
[0036] The emission direction is the propagation direction of the light in the ray tracing module. The emission direction is the direction from the emission point to the barycentric coordinates, represented by a vector. This vector describes the direction from the emission point to the target point and the relative magnitude of the direction.
[0037] In one embodiment, the step of obtaining the direction vector OP of the emission direction includes: OP=PO, where P is the position of the center of gravity coordinates, and O is the position of the emission point; and normalizing the OP to obtain the direction vector.
[0038] As an example, P is the position of the center of gravity coordinates (2, 3, 4), O is the position of the launch point (1, 1, 1), then OP is (1, 2, 3), and the final direction vector is (0.267, 0.535, 0.802).
[0039] It should be noted that, since there are four different scenarios, the emission directions in the four different scenarios also need to be calculated.
[0040] In one implementation, the positions of the three vertices of the triangle and the position information of the launch point are defined as vectors through SIMD (Single Instruction Multiple Data); the three components of the barycentric coordinates are calculated in parallel using SIMD to obtain the barycentric coordinates; the three components of the direction vector of the launch direction are calculated in parallel using SIMD to obtain the direction vector. Using SIMD instructions can perform operations on multiple data components at the same time, significantly improving computing efficiency, while reducing loops and data handling, and optimizing computing performance.
[0041] In one implementation, triangle vertices and emission points are stored as continuous memory blocks to improve cache hit rate and thus improve performance.
[0042] S250: Generate the excitation signal according to the position information of the emission point and the emission direction.
[0043] The excitation signal is an input signal that drives or stimulates the ray tracing module to generate an intersection result.
[0044] In one embodiment, the excitation signal includes a group of sub-excitations, each of which includes position information of an emission point and an excitation in an emission direction. The number of sub-excitations is equal to the number of emission directions.
[0045] S300, inputting the excitation signal into the ray tracing module; the ray tracing module reads the position information of the three vertices of the triangle in the memory, performs an intersection operation according to the position information of the three vertices of the triangle and the excitation signal, and obtains an intersection result; the intersection result is compared with the expected result to obtain a verification result.
[0046] It should be noted that the intersection results of the ray tracing module are compared with the corresponding expected results. If the two are the same, the verification is passed; if the two are different, the verification fails. In one embodiment, the expected result is the intersection result of Cmodel.
[0047] Among them, when the barycentric coordinates are located inside the triangle, the expected result is that the emission direction intersects with the interior of the triangle. When the barycentric coordinates are located outside the triangle, the expected result is that the emission direction does not intersect with the triangle. When the barycentric coordinates are located on the edge of the triangle, the expected result is that the emission direction intersects with the edge of the triangle. When the barycentric coordinates are located at the vertex of the triangle, the expected result is that the emission direction intersects with the vertex of the triangle.
[0048] In summary, an embodiment of the present invention provides a verification method for a ray tracing module, which randomly generates the positions of triangles and emission points, and randomly generates the center of gravity based on the randomly generated triangles, and determines the emission direction according to the emission points and the center of gravity. The scene is random and has a wide coverage, and can fully cover various intersecting and non-intersecting scenes, so that the verification result is more sufficient; and the proportion of intersecting, non-intersecting and boundary scenes can be adjusted through directional random weights.
[0049] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0050] An embodiment of the present invention further provides an electronic device, comprising a processor and the aforementioned non-transitory computer-readable storage medium.
[0051] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0052] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0053] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for verifying a ray tracing module, characterized in that: The method comprises the following steps: S100, randomly generating the position of each primitive, wherein the primitive includes three vertices of a triangle and an emission point; and storing the position information of the three vertices of the triangle into a memory; S200, obtaining an excitation signal for triggering a ray tracing module operation according to the position information of the three vertices and the emission point of the triangle, including: S210, obtaining weight parameters and random conditions of three vertices of the triangle; S220, randomly generating weights of the three vertices of the triangle respectively under the constraint of the random condition; S230, generating centroid coordinates according to the weights of the three vertices of the triangle and the position information of the three vertices of the triangle; S240, determining a transmitting direction according to the position information of the transmitting point and the coordinates of the center of gravity; S250, generating the excitation signal according to the position information of the emission point and the emission direction; S300, inputting the excitation signal into the ray tracing module; the ray tracing module reads the position information of the three vertices of the triangle in the memory, performs an intersection operation according to the position information of the three vertices of the triangle and the excitation signal, and obtains an intersection result; the intersection result is compared with the expected result to obtain a verification result.
2. The method according to claim 1, characterized in that The step of randomly generating the position of each primitive includes: obtaining a random range of three vertices of a triangle, and randomly generating position information of the three vertices of the triangle according to the random range.
3. The method according to claim 1, characterized in that The step of acquiring the random range of the three vertices of the triangle includes: randomly generating the random range (Tmin, Tmax), wherein Tmin is the minimum three-dimensional coordinate in the cube, and Tmax is the maximum three-dimensional coordinate in the cube.
4. The method according to claim 1, characterized in that: The random conditions include random conditions where the positions of the centroid coordinates are located inside the triangle, random conditions outside the triangle, random conditions of the sides of the triangle, and random conditions of the vertices of the triangle.
5. The method according to claim 4, characterized in that When the random condition is a random condition located inside the triangle, the random range of u is configured to (0,1); the random range of v is configured to (0,(1-u)); the random range of w is configured to 1-uv; wherein u is the weight parameter of the first vertex of the triangle, v is the weight parameter of the second vertex of the triangle, and w is the weight parameter of the third vertex of the triangle.
6. The method according to claim 4, characterized in that When the random condition is a random condition located outside the triangle, the random range of u is configured to (-1,0); the random range of v is configured to (-1,1); the random range of w is configured to 1-uv; wherein u is the weight parameter of the first vertex of the triangle, v is the weight parameter of the second vertex of the triangle, and w is the weight parameter of the third vertex of the triangle.
7. The method according to claim 4, characterized in that When the random condition is a random condition located on the edge of a triangle, u is configured to 0; the random range of v is configured to (0,1); the random range of w is configured to 1-uv; wherein u is the weight parameter of the first vertex of the triangle, v is the weight parameter of the second vertex of the triangle, and w is the weight parameter of the third vertex of the triangle.
8. The method according to claim 4, characterized in that When the random condition is a random condition located at the vertex of a triangle, u and v are both configured to 0; w is configured to 1; wherein u is the weight parameter of the first vertex of the triangle, v is the weight parameter of the second vertex of the triangle, and w is the weight parameter of the third vertex of the triangle.
9. The method according to claim 4, characterized in that Configure the number of randomly obtained barycentric coordinates for each random condition.
10. The method according to claim 1, characterized in that The positions of the three vertices of the triangle and the position information of the launch point are defined as vectors through SIMD; the three components of the barycentric coordinates are calculated in parallel by SIMD to obtain the barycentric coordinates; the three components of the direction vector of the launch direction are calculated in parallel by SIMD to obtain the direction vector.
Citation Information
Patent Citations
Rapid ray tracing method and system
CN107300645A
Bait array interference performance analysis method based on one-dimensional range profile
CN112859027A
Displacement micro-grid for ray and path tracking
CN117280387A
Vision-based vehicle positioning method under roadside view angle
CN118351469A
LOD generation method of three-dimensional model with texture
CN118552680A