A verification method for a ray tracing module
By randomly generating the positions of triangles and emission points, and determining the emission direction based on these positions, generating excitation signals for intersecting operations of the ray tracing module, it solves the problem of how to fully cover various intersecting and disjoint scenes, achieving more full verification results and better scene coverage.
Patent Information
- Application Number
- CN202510488567.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-04-18
AI Technical Summary
In the ray tracing module, how to ensure that the design can fully cover various intersecting and disintersecting scenarios, and ensure the correctness and efficiency 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, and inputting the ray tracing module for interception operation to verify the adequacy of the results.
The randomness and wide coverage of the scene are achieved, and it can fully cover various intersecting and disjoint scenes, making the verification results more sufficient, and the proportion of intersecting, disjointing and boundary scenes is adjusted through directional random weights.
Smart Images

Figure CN120032035B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of chip design, and particularly 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 function is complex and mainly relies on software implementation. However, in order to improve the overall computing efficiency, some key algorithms, such as intersection calculation, are specifically transplanted into hardware. This design idea is to transfer high-repetition and computationally intensive tasks from software to hardware, thereby significantly improving the rendering speed. In a GPU, the ray tracing block is a small module dedicated to processing ray tracing tasks, and its core function is to perform intersection calculations efficiently. The entire rendering process needs to divide the picture into multiple blocks. The software is responsible for constructing rendering tasks, while the hardware focuses on executing the key calculations in these tasks. In ray tracing, the 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 calculation needs to process the following core elements: origin, direction, primitive objects, and intersection result (hit or miss). Among them, the origin represents the starting point of the ray; the direction represents the propagation direction of the ray, usually described by three components in a three-dimensional coordinate; the primitive objects include geometric bodies such as triangles and / or boxes; the intersection result is the result of judging whether the ray intersects with the target object. If the intersection point exists, it is a hit, otherwise it is a miss.
[0004] In three-dimensional space, how to set the origin, direction, and the position of the object to comprehensively cover various intersection and non-intersection scenarios is the key difficulty in ensuring the design correctness of the ray tracing module. Therefore, there is an urgent need for a verification method that can comprehensively cover various intersection and non-intersection scenarios. 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:
[0006] S100, randomly generate the positions of each primitive, where the primitives include the three vertices of a triangle and the origin; and store the position information of the three vertices of the triangle in memory.
[0007] S200. Obtain an excitation signal for triggering the operation of the ray tracing module based on the position information of the three vertices of the triangle and the emission point, including:
[0008] S210. Obtain the weight parameters of the three vertices of the triangle and their random conditions.
[0009] S220. Randomly generate the weights of the three vertices of the triangle respectively under the constraint of the random conditions.
[0010] S230. Generate barycentric coordinates according to the weights of the three vertices of the triangle and the position information of the three vertices of the triangle.
[0011] S240. Determine the emission direction according to the position information of the emission point and the barycentric coordinates.
[0012] S250. Generate the excitation signal according to the position information of the emission point and the emission direction.
[0013] S300. Input 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, and performs an intersection operation according to the position information of the three vertices of the triangle and the excitation signal to obtain an intersection result.
[0014] The present invention has at least the following beneficial effects:
[0015] The embodiment of the present invention provides a verification method for a ray tracing module, which randomly generates the positions of a triangle and an emission point, randomly generates a barycenter again based on the randomly generated triangle, and determines the emission direction according to the emission point and the barycenter. Its scene is random and has a wide coverage, and can comprehensively cover various intersection and non-intersection scenarios, making the verification result more sufficient; and the proportion of intersection, non-intersection and boundary scenarios can be adjusted through directional random weights. Description of the Drawings
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 It is a flowchart of a verification method for a ray tracing module provided by an embodiment of the present invention;
[0018] Figure 2 It is a schematic diagram of the steps for obtaining an excitation signal provided by an embodiment of the present invention. Detailed Embodiments
[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present invention.
[0020] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present invention have the same meaning as commonly understood by those skilled in the art.
[0021] Please refer to Figure 1 , which shows a flowchart of a verification method for a ray tracing module. The method includes the following steps:
[0022] S100, randomly generate the position information of each primitive. The primitives include the three vertices of a triangle and the emission point; and store the position information of the three vertices of the triangle in memory.
[0023] Among them, the emission point is the starting point of the ray in the ray tracing module, usually represented by coordinates in a three-dimensional coordinate system. It is the reference point for the propagation of the ray, and all rays start from this emission point and propagate along a specific emission direction.
[0024] In one implementation, the step of randomly generating the positions of each primitive includes: obtaining the random range of the three vertices of the triangle, and randomly generating the position information of the three vertices of the triangle according to the random range. In one implementation, the step of obtaining the random range of the three vertices of the triangle includes: randomly generating the random range (Tmin, Tmax), where 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 will be randomly generated between Tmin and Tmax to ensure that the vertex is inside or on the boundary of the cube. This can effectively control the position range of the primitive and avoid exceeding the expected spatial area.
[0025] In one implementation, the random generation algorithm is a linear congruential generator or a Mersenne Twister to reduce the calculation time. Or the random generation algorithm is to use a Sobol sequence or a Halton sequence to generate random numbers to reduce the sampling bias. Other types of random generation algorithms also fall within the protection scope of the present invention.
[0026] S200, obtain the excitation signal that triggers the operation of the ray tracing module according to the position information of the three vertices of the triangle and the emission point.
[0027] Further, please refer toFigure 2 , S200 also includes:
[0028] S210, obtaining the weight parameters of the three vertices of the triangle and their random conditions.
[0029] Among them, the weight parameters of the three vertices of the triangle include: the weight parameter u of the first vertex, the weight parameter v of the second vertex, and the weight parameter w of the third vertex.
[0030] Among them, the position of the barycentric coordinates can be inside the triangle, outside the triangle, on the side of the triangle, or at the vertex of the triangle. The random conditions include the random conditions where the position of the barycentric coordinates is inside the triangle, outside the triangle, on the side of the triangle, and at the vertex of the triangle. Through the configuration of the random conditions, these four position distributions of the barycentric coordinates can be verified, achieving the purpose of full verification.
[0031] In one embodiment, when the random condition is the random condition inside the triangle, the random range of u is configured as (0, 1); the random range of v is configured as (0, (1 - u)); the random range of w is configured as 1 - u - v.
[0032] In one embodiment, when the random condition is the random condition outside the triangle, the random range of u is configured as (-1, 0); the random range of v is configured as (-1, 1); the random range of w is configured as 1 - u - v.
[0033] In one embodiment, when the random condition is the random condition on the side of the triangle, u is configured as 0; the random range of v is configured as (0, 1); the random range of w is configured as 1 - u - v.
[0034] In one embodiment, when the random condition is the random condition at the vertex of the triangle, both u and v are configured as 0; w is configured as 1.
[0035] S220, under the constraint of the random conditions, randomly generate the weights of the three vertices of the triangle respectively.
[0036] In one embodiment, under the random conditions inside the triangle, outside the triangle, on the side of the triangle, and at the vertex of the triangle, the weight values of (u, v, w) are randomly generated respectively.
[0037] S230, generate the barycentric coordinates according to the weights of the three vertices of the triangle and the position information of the three vertices of the triangle.
[0038] Among them, the barycentric coordinate P satisfies: P = uA + vB + wC, where A, B, and C are the coordinates of the three vertices of the triangle respectively.
[0039] As an example, assume that the coordinates of the three vertices of the triangle are A(0, 0, 0), B(1, 0, 0), and C(0, 1, 0) respectively, forming a triangle in a two-dimensional plane. Under the constraint of random conditions inside the triangle, u = 0.5, v = 0.3, w = 0.2, and u + v + w = 1, which satisfies the condition. 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, obtaining the coordinates of point P as (0.3, 0.2, 0), which is located inside the triangle. The magnitudes of the weights u, v, and w determine the distances of point P from each vertex. For example, u = 0.5 indicates that P is closer to A, while v = 0.3 and w = 0.2 indicate that it is closer to B than to 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 weights vary between 0 and 1, point P moves inside the triangle. If there are negative numbers among the weights, point P will be outside the triangle.
[0040] It should be noted that at least four barycentric coordinates are obtained according to the random conditions, and these four barycentric coordinates represent four different scenarios respectively.
[0041] In one implementation, the number of barycentric coordinates randomly obtained under each random condition is configured. By the directional random weights, the proportions of the intersecting, non-intersecting, and boundary scenarios can be adjusted, such as adjusting the proportion of the intersection operations at the vertices or on the common sides.
[0042] S240. Determine the emission direction according to the position information of the emission point and the barycentric coordinate.
[0043] Among them, the emission direction is the propagation direction of the light ray in the ray tracing module. The emission direction is the direction from the emission point to the barycentric coordinate, represented by a vector. This vector describes the direction from the emission point to the target point and the relative magnitude of the direction.
[0044] In one implementation, the steps for obtaining the direction vector OP of the emission direction include: OP = P - O, where P is the position of the barycentric coordinate and O is the position of the emission point; unitize the OP to obtain the direction vector.
[0045] As an example, if the position of P as the barycentric coordinate is (2, 3, 4) and the position of O as the emission point is (1, 1, 1), then OP is (1, 2, 3), and the finally obtained direction vector is (0.267, 0.535, 0.802).
[0046] It should be noted that since there are 4 different scenarios, 4 different emission directions also need to be calculated.
[0047] In one implementation, the positions of the three vertices of the triangle and the position information of the emission 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 emission direction are calculated in parallel using SIMD to obtain the direction vector. Using SIMD instructions can perform operations on multiple data components simultaneously, significantly improving the calculation efficiency, while reducing loops and data movement, and optimizing the calculation performance.
[0048] In one implementation, the triangle vertices and the emission point are stored as a continuous memory block to improve the cache hit rate and thus improve the performance.
[0049] S250, generate the excitation signal according to the position information of the emission point and the emission direction.
[0050] Among them, the excitation signal is an input signal that drives or stimulates the ray tracing module to generate an intersection result.
[0051] In one implementation, the excitation signal includes a set of sub-excitations, and each sub-excitation includes the position information of the emission point and the excitation of one emission direction. The number of sub-excitations is equal to the number of emission directions.
[0052] S300, input 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 intersection operations according to the position information of the three vertices of the triangle and the excitation signal to obtain an intersection result; the intersection result is compared with the expected result to obtain a verification result.
[0053] It should be noted that the intersection result of the ray tracing module is compared with the corresponding expected result respectively. If the two are the same, the verification passes; if there are differences between the two, the verification fails. In one implementation, the expected result is the intersection result of Cmodel.
[0054] Among them, when the barycentric coordinate is inside the triangle, the expected result is that the emission direction intersects with the inside of the triangle. When the barycentric coordinate is outside the triangle, the expected result is that the emission direction does not intersect with the triangle. When the barycentric coordinate is on the side of the triangle, the expected result is that the emission direction intersects with the side of the triangle. When the barycentric coordinate is at the vertex of the triangle, the expected result is that the emission direction intersects with the vertex of the triangle.
[0055] In summary, the embodiment of the present invention provides a verification method for a ray tracing module, which randomly generates the positions of triangles and emission points, randomly generates barycenters again based on the randomly generated triangles, and determines the emission directions according to the emission points and barycenters. Its scene is random and has a wide coverage, capable of comprehensively covering various intersecting and non-intersecting scenarios, making the verification results more sufficient; and the ratio of intersecting, non-intersecting, and boundary scenarios can be adjusted through directional random weights.
[0056] The 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 segment related to a method for implementing a method in the method embodiment. The at least one instruction or the at least one program segment is loaded and executed by the processor to implement the method provided in the above embodiment.
[0057] The embodiment of the present invention also provides an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.
[0058] The embodiment of the present invention also provides a computer program product, which includes program code. When the program product runs on an electronic device, the program code is used to cause the electronic device to execute the steps in the method according to various exemplary embodiments of the present invention described above in this specification.
[0059] Those skilled in the art can clearly understand that for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is used for illustration. In practical applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0060] Although some specific embodiments of the present invention have been described in detail by way of examples, those skilled in the art should understand that the above examples are only for illustration and not for limiting the scope of the present invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the present invention. The scope disclosed by 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