Coarse-grained depth culling method and device in graphics rendering pipeline

By adaptively selecting the culling granularity and depth range calculation method according to the depth gradient information of the primitive, the problem of insufficient efficiency caused by the fixed depth culling granularity in the existing technology is solved, and the depth culling efficiency of the graphics rendering pipeline is improved.

CN117392295BActive Publication Date: 2024-09-06GLENFLY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210784793.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-05
Publication Date
2024-09-06
Estimated Expiration
2042-07-05

AI Technical Summary

Technical Problem

In the existing technology, the deletion granularity of depth deletion is fixed, which results in insufficient elimination of primitives with large depth gradient values. At the same time, the calculation amount of primitives with small depth gradient values ​​is not optimized enough, which affects the efficiency of the graphics rendering pipeline.

Method used

Adaptively select the deletion granularity according to the depth gradient information of the primitive, divide the primitive into multiple test blocks, and select the appropriate depth range calculation method based on the depth gradient information of the test block to determine whether to eliminate the test block and improve the efficiency of depth elimination. .

Benefits of technology

By adaptively adjusting the elimination granularity and depth range calculation method, the efficiency of depth elimination is improved, the problem of insufficient elimination or excessive calculation is avoided, and the overall work efficiency of the graphics rendering pipeline is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117392295B
    Figure CN117392295B
Patent Text Reader

Abstract

The present application relates to the field of graphics drawing technology, and provides a method and device for coarse-grained depth culling in a graphics drawing pipeline. The present application adaptively adjusts the culling granularity through the depth gradient information corresponding to the primitive and flexibly selects the depth range calculation method of the test block, which can find the best balance between the amount of calculation and the calculation accuracy, so that it can be used to replace the first part of the current culling method, and the coarse-grained depth culling part can play the best effect, thereby improving the overall work efficiency of the graphics drawing pipeline.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graphics rendering technology, and in particular to a coarse-grained depth culling method and device in a graphics rendering pipeline. Background Art

[0002] In order to meet the increasing quality requirements of the visual interface and further enhance the visual experience, 3D rendering scenes are becoming increasingly complex. Depth culling is indispensable to ensure processing efficiency while meeting related requirements.

[0003] In complex rendering scenes, it is inevitable that objects will block each other. Objects far from the viewpoint are usually invisible or only partially visible because they are blocked by nearby objects. For the blocked parts, depth culling can be used to remove them from the graphics drawing pipeline in advance, thereby ensuring the effectiveness of the pixels (or sampling points in pixels) involved in drawing on the graphics pipeline to the greatest extent.

[0004] Therefore, in the graphics rendering pipeline, the traditional depth culling method is to experiment with the depth value of each pixel or each sampling point in the pixel, and cull the pixels that do not meet the conditions (such as being far away from the viewpoint) one by one. In addition, considering that the pixel shader may update the depth value of each pixel, the traditional depth culling is performed after the pixel shader.

[0005] In order to improve the rendering efficiency of the pixel shader, the current technology proposes a concept of "outputting conservative depth values" in the pixel shader, so as to complete the depth culling in advance before the pixel shader in the graphics rendering pipeline as much as possible, so that only the visible part of the viewpoint will enter the pixel shader, thereby improving the working efficiency of the pixel shader. At the same time, in order to improve the efficiency of depth culling, the current technology also provides a coarse-grained culling algorithm based on a fixed culling granularity.

[0006] Therefore, the current technology of depth culling can include three parts:

[0007] The first part: the coarse-grained culling part after rasterization and before the pixel shader. The culling granularity of this part is fixed (for example, fixed to 8×8 pixels). Its function is to use coarse-grained culling to reduce the amount of calculation before introducing high-precision depth culling such as per-pixel / sampling point;

[0008] The second part: after the first part is culled and before the pixel shader, in order to cull the invalid part as much as possible before inputting the pixel into the pixel shader, thus reducing the burden of the pixel shader;

[0009] Part 3: After the pixel shader, it is used to handle the scene where the pixel shader needs to output a non-conservative depth value. In this scenario, the depth value of each pixel interpolated from the depth value of the primitive vertex cannot be used anymore.

[0010] However, for the first part of the current technology, the fixed culling granularity, on the one hand, will result in insufficient culling of primitives with larger depth gradient values, and on the other hand, will fail to optimize the amount of calculation to the greatest extent for primitives with smaller depth gradient values. Summary of the invention

[0011] Based on this, it is necessary to provide a coarse-grained depth culling method and device in a graphics rendering pipeline to address the above technical issues.

[0012] In a first aspect, the present application provides a coarse-grained depth culling method in a graphics rendering pipeline.

[0013] The method comprises:

[0014] According to the depth gradient information corresponding to the primitive, a corresponding culling granularity is selected to divide the primitive into a plurality of test blocks;

[0015] For each test block, according to the depth gradient information corresponding to the test block, a corresponding depth range calculation method is selected to calculate the depth range corresponding to the test block;

[0016] For each test block, obtain the background depth range corresponding to the test block, and determine whether to remove the test block according to the comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block;

[0017] The test blocks that are not eliminated are sent to the subsequent graphics drawing pipeline.

[0018] In a second aspect, the present application also provides a coarse-grained depth culling device in a graphics rendering pipeline. The device comprises:

[0019] A test block segmentation module is used to select a corresponding culling granularity to segment the primitive into a plurality of test blocks according to the depth gradient information corresponding to the primitive;

[0020] A depth range calculation module is used to select a corresponding depth range calculation method for each test block according to the depth gradient information corresponding to the test block to calculate the depth range corresponding to the test block;

[0021] A rejection judgment module is used to obtain, for each test block, a background depth range corresponding to the test block, and judge whether to reject the test block according to a comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block;

[0022] The post-processing module is used to send the unrejected test blocks to the subsequent graphics drawing pipeline.

[0023] The coarse-grained depth culling method and device in the above-mentioned graphics drawing pipeline adaptively selects a suitable culling granularity according to the depth gradient information corresponding to the primitive, divides the primitive into multiple test blocks according to its culling granularity, and then performs depth culling on each test block in turn, which can effectively improve the efficiency of depth culling, thereby not causing the primitives with large depth changes to be insufficiently culled due to the fixed selection of too large culling granularity, nor will the calculation amount increase and reduce the culling efficiency due to the fixed selection of too small culling granularity, and when calculating the depth range of each test block, it will also adaptively select a suitable calculation method according to its depth gradient information to ensure the accuracy of the calculated depth range, which can further improve the culling efficiency. This scheme can find the best balance between the amount of calculation and the calculation accuracy by adaptively adjusting the culling granularity through the depth gradient information corresponding to the primitive and flexibly selecting the depth range calculation method of the test block, so as to replace the first part of the current culling method, and give full play to the optimal effect of the coarse-grained depth culling part, thereby improving the overall work efficiency of the graphics drawing pipeline. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 A schematic diagram of an example of depth culling;

[0025] Figure 2 A diagram of the graphics pipeline for current technology that includes three parts of depth culling;

[0026] Figure 3 A schematic diagram of a graphics drawing pipeline including the depth culling solution of the present application;

[0027] Figure 4 A schematic diagram of a pixel block;

[0028] Figure 5 A diagram of an application environment of a coarse-grained depth culling method in a graphics rendering pipeline in one embodiment;

[0029] Figure 6 A schematic diagram of a flow chart of a coarse-grained depth culling method in a graphics rendering pipeline in an embodiment;

[0030] Figure 7 A schematic diagram of a test block segmentation primitive in an example;

[0031] Figure 8 Schematic diagram of the depth range calculation for a test block in one example;

[0032] Fig. 9 A schematic diagram of a process for using and updating a background depth range in one embodiment;

[0033] Fig.10 A schematic diagram of depth cropping in an example;

[0034] Fig.11 A schematic diagram of a flow chart of a coarse-grained depth culling method in a graphics rendering pipeline in an embodiment;

[0035] Fig.12 It is a structural block diagram of a coarse-grained depth culling device in a graphics rendering pipeline in one embodiment. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0037] Some keywords involved in this application and their English counterparts: graphics pipeline, depth reject, adaptive, pixel, sample, pixel shader, pixel tile, sample tile, depth range, primitive, background.

[0038] First, the unavoidable mutual occlusion between objects in the complex rendering scene mentioned in the background technology is explained. Among them, objects far away from the viewpoint are generally invisible or only partially visible because they are blocked by nearby objects. Figure 1 The two triangles are intertwined, the dark triangle is partially blocked by the light triangle, and the light triangle is also partially blocked by the dark triangle. Through depth culling, all the mutually blocked parts are culled to ensure that the displayed result meets the actual effect seen by the human eye.

[0039] Then, in Figure 2 A schematic diagram of a graphics drawing pipeline that includes three parts of depth culling in current technology is shown, wherein the first part is the coarse-grained culling part (or coarse-grained culling module) after rasterization and before the pixel shader. Currently, the culling granularity of this part (module) is fixed, such as 8×8 pixels. Its function is to reduce the amount of calculation by using coarse-grained culling before introducing high-precision depth culling such as pixel-by-pixel / sampling point.

[0040] The present application takes into account that the culling granularity in the first part of the current technology is fixed, which may have certain defects: for primitives with large depth gradient values, the fixed culling granularity will lead to insufficient culling, and for some primitives with small depth culling values, the fixed culling granularity fails to optimize the amount of calculation to the greatest extent. For this purpose, a coarse-grained depth culling method in a graphics drawing pipeline is provided to improve the depth culling efficiency in various scenarios. The method can be adaptively adjusted according to the depth information of each primitive, and when calculating the depth range of each test block, a suitable depth range calculation method can also be selected according to the specific depth information of the primitive.

[0041] like Figure 3 The figure shows a schematic diagram of a graphics drawing pipeline including the depth culling solution of the present application. The present application replaces the "first part coarse-grained depth culling" part (module) in the figure with an adaptive coarse-grained depth culling part (module). The purpose is to select a culling granularity and depth range calculation method that best suits each different primitive, so as to find an optimal balance between culling efficiency and computational complexity. Therefore, before enabling subsequent high-precision (pixel or sampling point granularity) depth culling work, by flexibly adjusting the culling granularity, the culling work of a piece of adjacent pixels (sampling points) can be completed with only one calculation. In the graphics drawing pipeline including the depth culling solution of the present application, only the pixel tiles (pixel tiles) or sampling tiles (sample tiles) that have not been culled by the "adaptive coarse-grained depth culling" part (module) can enter the subsequent pipeline for further processing.

[0042] Among them, for the pixel block (sampling point block), refer to Figure 4 , a pixel block (sampling point block) refers to a set of pixels (sampling points) of a certain size and adjacent in spatial position, and the size can be 8×8 pixels (sampling points), 8×16 pixels (sampling points), 16×8 pixels (sampling points), 16×16 pixels (sampling points), etc. The culling granularity selected by the "adaptive coarse-grained depth culling" part (module) of this application for a certain primitive can be greater than, equal to, or less than the pixel block (sampling point block).

[0043] In the "Adaptive coarse-grained depth culling" part (module) of this application, the culling granularity can be flexibly adjusted. For any primitive, a suitable culling granularity can be selected and the culling work of all test blocks (several pixel blocks / sampling point blocks of the selected culling granularity) covered by the primitive can be completed at this granularity. For the test blocks that cannot be culled by the "Adaptive coarse-grained depth culling" part (module) of this application, they will be transmitted to the subsequent pipeline, and fine culling at the pixel / sampling point level will be performed in the "second / third part depth culling" part (module).

[0044] like Figure 5 The application environment of the coarse-grained depth culling method in the graphics rendering pipeline provided by the present application is shown, which can be called an adaptive coarse-grained depth culling module. The application environment specifically shows the internal structure of the module, including the following parts:

[0045] P1. Register pool, which can be used to record all register information required by the module, which may include depth gradient threshold information (which can be used to select culling granularity, depth range calculation method), optional culling granularity, depth clipping information, depth test information, etc.

[0046] P2. Internal cache, which can be used to cache background depth range data and can be updated in real time by this module to ensure the validity of the data.

[0047] P3. The culling granularity selector can select the culling granularity suitable for each primitive according to the specific information carried by the primitive, and divide the primitive into several test blocks accordingly.

[0048] P4. Adaptive depth range calculator can select a suitable method to calculate the depth range of each test block based on the input depth seed value, depth gradient value and other information.

[0049] P5. A coarse-grained depth clipper can perform depth clipping on each test block and remove test blocks outside the viewing cone in advance.

[0050] P6. Coarse-grained depth tester, for each test block, can combine the depth information in the internal cache to perform a depth range test, remove the test blocks that do not meet the test, and send the test blocks that meet the test to the subsequent pipeline.

[0051] Based on this, in one embodiment, Figure 6 As shown, the present application provides a coarse-grained depth culling method in a graphics rendering pipeline, comprising the following steps:

[0052] Step S601 : According to the depth gradient information corresponding to the primitive, a corresponding culling granularity is selected to divide the primitive into a plurality of test blocks.

[0053] In this step, for any primitive, such as Figure 7 As shown, the P3 culling granularity selector can select a corresponding culling granularity from the optional culling granularities according to the calculated depth gradient information corresponding to the primitive, and cut the primitive according to the selected culling granularity, thereby dividing it into multiple test blocks.

[0054] The culling granularity may be selected / determined according to the horizontal and vertical depth gradient values ​​of the primitives. In one embodiment, the depth gradient information corresponding to the primitives may include the horizontal depth gradient value and the vertical depth gradient value of the primitives. Step S601 specifically includes:

[0055] Obtain a preset depth gradient threshold range; select a horizontal culling granularity and a vertical culling granularity corresponding to the primitive according to the comparison results of the horizontal depth gradient value and the vertical depth gradient value with the depth gradient threshold range; obtain a corresponding culling granularity according to the horizontal culling granularity and the vertical culling granularity; and divide the primitive into multiple test blocks according to the corresponding culling granularity.

[0056] Specifically, the P3 rejection granularity selector can determine / set the depth gradient threshold range [slope_threshold_min, slope_threshold_max] for subsequent comparison based on the previous experimental results, and then select the corresponding horizontal rejection granularity x_reject_size and vertical rejection granularity y_reject_size from the optional rejection granularities in the horizontal and vertical directions according to the comparison results of the horizontal depth gradient value and the vertical depth gradient value with the depth gradient threshold range [slope_threshold_min, slope_threshold_max]. Therefore, the P3 rejection granularity selector obtains the final corresponding rejection granularity x_reject_size*y_reject_size based on the selected horizontal rejection granularity x_reject_size and vertical rejection granularity y_reject_size, and performs primitive cutting according to the rejection granularity x_reject_size*y_reject_size.

[0057] Furthermore, in one embodiment, the selection of the above-mentioned horizontal and vertical removal granularities specifically includes:

[0058] For the horizontal direction, if the horizontal depth gradient value is less than the minimum threshold of the depth gradient threshold range, a large rejection granularity is selected from the optional rejection granularity as the horizontal rejection granularity; if the horizontal depth gradient value is within the depth gradient threshold range, a medium rejection granularity is selected from the optional rejection granularity as the horizontal rejection granularity; if the horizontal depth gradient value is greater than the maximum threshold of the depth gradient threshold range, a small rejection granularity is selected from the optional rejection granularity as the horizontal rejection granularity.

[0059] Specifically, for the horizontal direction, if the horizontal depth gradient value is less than the minimum threshold slope_threshold_min of the depth gradient threshold range, a larger rejection granularity such as 16, 32, etc. is selected from the optional rejection granularities as the horizontal rejection granularity x_reject_size; if the horizontal depth gradient value is within the depth gradient threshold range [slope_threshold_min, slope_threshold_max], a compromise rejection granularity such as 8 is selected from the optional rejection granularities as the horizontal rejection granularity x_reject_size; if the horizontal depth gradient value is greater than the maximum threshold slope_threshold_max of the depth gradient threshold range, a smaller rejection granularity such as 2, 4, etc. is selected from the optional rejection granularity as the horizontal rejection granularity x_reject_size.

[0060] In addition, for the vertical direction, if the vertical depth gradient value is less than the minimum threshold of the depth gradient threshold range, a large rejection granularity is selected from the optional rejection granularities as the vertical rejection granularity; if the vertical depth gradient value is within the depth gradient threshold range, a medium rejection granularity is selected from the optional rejection granularity as the vertical rejection granularity; if the vertical depth gradient value is greater than the maximum threshold of the depth gradient threshold range, a small rejection granularity is selected from the optional rejection granularity as the vertical rejection granularity.

[0061] Similar to the horizontal selection, for the vertical direction, if the vertical depth gradient value is less than the minimum threshold slope_threshold_min of the depth gradient threshold range, a larger rejection granularity such as 16 or 32 can be selected as the vertical rejection granularity y_reject_size; if the vertical depth gradient value is within the depth gradient threshold range [slope_threshold_min, slope_threshold_max], a compromise rejection granularity such as 8 can be selected as the horizontal rejection granularity x_reject_size; if the vertical depth gradient value is greater than the maximum threshold slope_threshold_max of the depth gradient threshold range, a smaller rejection granularity such as 2 or 4 can be selected as the vertical rejection granularity y_reject_size.

[0062] Therefore, the P3 rejection granularity selector finally obtains the rejection granularity x_reject_size*y_reject_size, cuts the primitive according to the selected x_reject_size*y_reject_size, and outputs the cut test blocks to the subsequent processing unit for depth culling one by one. Only the test blocks that are not culled will be sent to the subsequent drawing pipeline for further high-precision depth culling and rendering.

[0063] Step S602 : for each test block, according to the depth gradient information corresponding to the test block, a corresponding depth range calculation method is selected to calculate the depth range corresponding to the test block.

[0064] In this step, the P4 adaptive depth range calculator will calculate the depth range (primitive_range) for each test block. The P4 adaptive depth range calculator can use a variety of depth range calculation methods to calculate the depth range of the test block, and can select different depth range calculation methods for different test blocks to calculate their depth ranges. Specifically, the corresponding depth range calculation method can be selected according to the depth gradient information corresponding to the test block, and the depth range corresponding to the test block can be calculated according to the selected depth range calculation method.

[0065] For the selection of the depth range calculation method for each test block, in one embodiment, step S602 specifically includes:

[0066] Determine whether the depth gradient value corresponding to the test block is greater than the preset threshold value; if so, select the bounding box method from the optional depth range calculation method to calculate the depth range corresponding to the test block; if not, select the test block method from the optional depth range calculation method to calculate the depth range corresponding to the test block.

[0067] refer to Figure 8 In this embodiment, when calculating the depth range of each test block, the optional depth range calculation methods may include two methods, one is the test block method, and the other is the bounding box method. Among them, the test block method refers to selecting two vertices from the four vertices of the test block to calculate the minimum value primitive_range.min and the maximum value primitive_range.max of the depth range primitive_range; the bounding box method further narrows the range, and selects two vertices from the four vertices of the bounding box where the primitive in the test block is located to calculate the minimum value primitive_range.min and the maximum value primitive_range.max of the depth range primitive_range. Relatively speaking, the bounding box method has one more step of bounding box judgment in the calculation process, but the calculated depth range primitive_range is more accurate. Therefore, when this embodiment judges that the depth gradient value corresponding to the test block is greater than the preset threshold value (exceeding the threshold value selected in advance according to the experiment), that is, when the depth gradient value is large, the bounding box method will be automatically selected to calculate the depth range primitive_range, otherwise the test block method will be selected to calculate the depth range primitive_range.

[0068] Among them, for the test block method, further, the above-mentioned selecting the test block method from the optional depth range calculation methods to calculate the depth range corresponding to the test block specifically includes:

[0069] According to the depth gradient growth direction of the test block in the horizontal and vertical directions, two vertices are selected from the four vertices of the test block, and the depth range corresponding to the test block is calculated based on the two vertices.

[0070] like Figure 8 The left half corresponds to the calculation of the depth range using the test block method using MSAA2x as an example, that is, directly selecting two vertices from the four vertices of the test block to calculate the depth range. Among them, P1 to P4 are the four vertices of the test block. According to the depth gradient growth direction (x / y depth gradient growth direction) of the test block in the horizontal and vertical directions, according to the criteria for selecting vertices when calculating the depth range as shown in Table 1 below, P1 is selected to interpolate and calculate the minimum value primitive_range.min of the depth range primitive_range, and P4 is selected to calculate the maximum value primitive_range.max of the depth range primitive_range.

[0071]

[0072] Table 1

[0073] Among them, for the bounding box method, further, the above-mentioned selecting the bounding box method from the optional depth range calculation methods to calculate the depth range corresponding to the test block specifically includes:

[0074] According to the depth gradient growth direction of the test block in the horizontal and vertical directions, two vertices are selected from the four vertices of the bounding box where the primitive is located in the test block, and the depth range corresponding to the test block is calculated based on the two vertices.

[0075] like Figure 8 The right half corresponds to the calculation of the depth range using the bounding box method using MSAA2x as an example, that is, two vertices are selected from the four vertices of the bounding box to calculate the depth range. Among them, P5~P8 are the four vertices of the bounding box of the primitive in the test block, and the bounding box range has been adjusted according to the sampling coordinate accuracy. Similarly, according to the depth gradient growth direction (x / y depth gradient growth direction) of the test block in the horizontal and vertical directions, and according to the criteria for selecting vertices when calculating the depth range as shown in Table 1 above, P5 is selected to calculate the minimum value primitive_range.min of the depth range primitive_range, and P8 is selected to calculate the maximum value primitive_range.max of the depth range primitive_range.

[0076] Step S603: For each test block, obtain the corresponding background depth range, and determine whether to eliminate the test block according to the comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block.

[0077] In this step, after the P6 coarse-grained depth tester obtains the depth range corresponding to the test block and its corresponding background depth range, it is necessary to perform a depth range comparison to determine whether to eliminate the test block. In this step, the P6 coarse-grained depth tester needs to perform according to the specific depth test operator, as follows:

[0078] Less: If primitive_range.min >= background_range.max, eliminate.

[0079] Less-equal: If primitive_range.min > background_range.max, eliminate.

[0080] Greater: If primitive_range.max <= background_range.min, eliminate.

[0081] Greater-equal: If primitive_range.max < background_range.min, eliminate.

[0082] Equal: If primitive_range.min > background_range.max || primitive_range.max < background_range.min, eliminate.

[0083] Not-equal: If primitive_range.min == primitive_range.max && background_range.min == background_range.max && primitive_range.min == background_range.min, eliminate.

[0084] Never: Eliminate all.

[0085] Always: Keep all.

[0086] Regarding the acquisition of the background depth range corresponding to the test block, in one embodiment, the acquisition of the background depth range corresponding to the test block specifically includes:

[0087] If the background depth range corresponding to the test block is stored in the internal cache, the background depth range stored in the internal cache is read; if the background depth range corresponding to the test block is not stored in the internal cache, the background depth data corresponding to the test block is read from the external storage module, and the background depth range corresponding to the test block is calculated based on the background depth data corresponding to the test block, and the background depth range is stored in the internal cache.

[0088] Specifically, the coarse-grained depth test of the P6 coarse-grained depth tester involves two depth ranges: the depth range of each test block into which the current primitive is cut [primitive_range.min, primitive_range.max], and the background depth range corresponding to this test block [background_range.min, background_range.max]. The depth test of the P6 coarse-grained depth tester compares primitive_range with background_range, and the test result is used to determine whether to remove the test block.

[0089] The calculation of the depth range primitive_range has been described in the aforementioned step S602 , and the calculation of the background depth range is described here, which can be completed in the internal cache of P2 .

[0090] In this embodiment, the P2 internal cache can be used to cache background depth range data and can be updated in real time to ensure the validity of the data. Among them, the P4 depth range calculator can send a "read background depth" instruction to the P2 internal cache. At this time, if the P2 internal cache stores the background depth range corresponding to the test block, that is, the P2 internal cache finds that the required background depth information is in the local cache, it will directly read it out and send it to the P6 coarse-grained depth tester; if the P2 internal cache does not store the background depth range corresponding to the test block, that is, the P2 internal cache finds that the required background depth information is not local, it will send a read instruction to the external storage module. After the P2 internal cache receives the background depth data returned by the external storage module, it calculates the depth range based on the returned background depth data and stores it locally, and outputs it to the P6 coarse-grained depth tester. In addition, the background depth range in the P2 internal cache can be updated in real time according to the test results of the P6 coarse-grained depth tester and the depth range corresponding to the test block to ensure the real-time reliability of the data.

[0091] Therefore, when calculating the background depth range corresponding to the test block, a feasible approach is to read back the depth values ​​of all pixels (sampling points) covered by the current test block from the external storage module, compare them to obtain the maximum and minimum values, and store these two values ​​in the P2 internal cache.

[0092] In order to reduce the reading of data from the external storage module, in one embodiment, after determining whether to remove the test block according to the comparison result of the depth range corresponding to the test block and the background depth range corresponding to the test block in step S603, the following steps may be further included:

[0093] For the test blocks that are not eliminated, the depth range corresponding to the test blocks that are not eliminated is used to update the corresponding background depth range in the internal cache.

[0094] Specifically, in this embodiment, if the test result of the P6 coarse-grained depth tester indicates that the test block has not been eliminated, the depth range corresponding to the non-eliminated test block can be used to update the corresponding background depth range in the P2 internal cache for use in the next elimination experiment at the same position.

[0095] Based on the above embodiments, for example, combined Figure 8 and Fig. 9 , assuming that the selected test block contains 16 sampling points, when the depth range test is performed for the first time, the corresponding depth range data must not be stored in the internal cache of P2, so it is necessary to read and calculate the background depth range of these 16 sampling points from the external storage module, and then store the background depth range in the internal cache of P2. Therefore, after each depth range test of the test block at the same position is completed, if the test block is not eliminated, the depth range of the test block that has not been eliminated is used to update the corresponding background depth range in the internal cache of P2, and the test block is sent to the downstream module and the next test block is selected to start the test.

[0096] Among them, for the test blocks that are not eliminated, their depth range needs to be used to update the background depth range in the P2 internal cache to ensure the real-time performance of the cached data. Specifically, the background depth range used to update the P2 internal cache also needs to be determined according to the specific depth test operator, as follows:

[0097] Less / less-equal: background.min = min{primitive_range.min, background.min};

[0098] Greater / greater-equal: background.max = max{primitive_range.max,backgroup.max};

[0099] Equal / never: no update;

[0100] Not-equal / always: background.min=min{primitive_range.min,background.min}, background.max=max{primitive_range.max,backgroup.max}.

[0101] In addition, before obtaining the background depth range corresponding to each test block and determining whether to remove the test block based on the comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block, the method may further include the following steps:

[0102] For each trial block, the trial blocks outside the viewing frustum are eliminated.

[0103] This step can be performed by the P5 coarse-grained depth clipper. Fig.10 As shown, the P5 coarse-grained depth clipper performs depth clipping on each test block and removes the test blocks outside the viewing frustum in advance, that is, the parts outside the viewing frustum will be clipped in this step to save processing resources.

[0104] Step S604: sending the test blocks that have not been eliminated to the subsequent graphics drawing pipeline.

[0105] This step mainly sends the unculled test blocks to the subsequent graphics drawing pipeline, and performs fine culling at the pixel / sampling point level in the subsequent "second / third part depth culling" part (module).

[0106] The coarse-grained depth culling method in the above-mentioned graphics drawing pipeline adaptively selects the appropriate culling granularity according to the depth gradient information corresponding to the primitive, divides the primitive into multiple test blocks according to its culling granularity, and then performs depth culling on each test block in turn, which can effectively improve the efficiency of depth culling. Therefore, the primitives with large depth changes will not be fully culled due to the fixed selection of too large culling granularity, nor will the calculation amount increase and reduce the culling efficiency due to the fixed selection of too small culling granularity. When calculating the depth range of each test block, the appropriate calculation method will be adaptively selected according to its depth gradient information to ensure the accuracy of the calculated depth range, which can further improve the culling efficiency. This solution can find the best balance between the amount of calculation and the calculation accuracy by adaptively adjusting the culling granularity according to the depth gradient information corresponding to the primitive and flexibly selecting the depth range calculation method of the test block, so as to replace the first part of the current culling method, and give full play to the optimal effect of the coarse-grained depth culling part, thereby improving the overall work efficiency of the graphics drawing pipeline.

[0107] like Fig.11 The overall flow chart of the coarse-grained depth culling method provided by the present application is shown. First, the P3 culling granularity selector adaptively selects the culling granularity of the primitive and performs test block segmentation. Then, the P4 adaptive depth range calculator adaptively calculates the corresponding depth range for each test block. Then, the P1 register pool can determine whether depth clipping is required. If so, the coarse-grained depth clipper performs depth clipping to cull the test blocks outside the viewing cone in advance. The parts that fail to pass the depth clipping and have been culled in advance do not need to be sent to the subsequent modules. For the test blocks that have not been culled in advance or do not need depth clipping, the depth test can continue. At this time, the P1 register pool can determine whether a depth test is needed. If so, the P6 coarse-grained depth tester and the P2 internal cache will perform a depth test on each test block. Then, the test blocks that fail the depth test will be eliminated without being sent to subsequent modules. For test blocks that pass the depth test, that is, are not eliminated, or do not need a depth test, the corresponding background depth range in the P2 internal cache can be updated according to the depth range of the test block and sent to the subsequent graphics drawing pipeline. In the subsequent "second / third part depth elimination" part (module), fine elimination at the pixel / sampling point level will be performed.

[0108] On the whole, compared with the depth culling module in the current technology, the present application uses an adaptive coarse-grained depth culling strategy to replace the depth culling module in the current technology, and adaptively selects a suitable culling granularity according to the depth-related information of each primitive, and divides each primitive into multiple test blocks according to its culling granularity, and then performs depth culling on each test block in turn, which can effectively improve the depth culling efficiency; and when calculating the depth range of each test block, it will also select a suitable calculation method based on its depth information to ensure the accuracy of the calculated depth range, which can further improve the culling efficiency.

[0109] Therefore, the advantages of this application include: 1. The culling granularity can be adaptively adjusted according to the depth information of the primitives, so as to ensure the culling efficiency of coarse-grained culling. The primitives with large depth changes will not be fully culled due to the culling granularity being too large, nor will the calculation amount increase and the culling efficiency decrease due to the culling granularity being too small. 2. The depth range calculation method of each test block can be automatically adjusted to further ensure the culling efficiency. 3. The culling granularity is adaptively adjusted through the depth information of the primitives, and the depth range calculation method of the test blocks is flexibly selected to find the best balance between the calculation amount and the calculation accuracy, so as to give full play to the coarse-grained depth culling module and improve the overall work efficiency of the pipeline.

[0110] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0111] Based on the same inventive concept, the embodiment of the present application also provides a coarse-grained depth culling device in a graphics rendering pipeline for implementing the coarse-grained depth culling method in the graphics rendering pipeline involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more embodiments of the coarse-grained depth culling device in the graphics rendering pipeline provided below can be referred to the limitations of the coarse-grained depth culling method in the graphics rendering pipeline above, and will not be repeated here.

[0112] In one embodiment, Fig.12As shown, a coarse-grained depth culling device in a graphics rendering pipeline is provided, and the device 1200 includes:

[0113] A test block segmentation module 1201 is used to select a corresponding culling granularity to segment the primitive into a plurality of test blocks according to the depth gradient information corresponding to the primitive;

[0114] A depth range calculation module 1202 is used to select a corresponding depth range calculation method for each test block according to the depth gradient information corresponding to the test block to calculate the depth range corresponding to the test block;

[0115] The rejection judgment module 1203 is used to obtain the background depth range corresponding to each test block, and judge whether to reject the test block according to the comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block;

[0116] The post-processing module 1204 is used to send the test blocks that have not been eliminated to the subsequent graphics drawing pipeline.

[0117] In one embodiment, the depth gradient information includes a transverse depth gradient value and a longitudinal depth gradient value of the primitive; a test block segmentation module 1201 is used to obtain a preset depth gradient threshold range; based on the comparison results of the transverse depth gradient value and the longitudinal depth gradient value with the depth gradient threshold range, the transverse culling granularity and the longitudinal culling granularity corresponding to the primitive are selected respectively; based on the transverse culling granularity and the longitudinal culling granularity, the corresponding culling granularity is obtained; and the primitive is segmented into multiple test blocks according to the corresponding culling granularity.

[0118] In one embodiment, the test block segmentation module 1201 is used for selecting a large rejection granularity as the horizontal rejection granularity from the optional rejection granularities if the horizontal depth gradient value is less than the minimum threshold of the depth gradient threshold range; selecting a medium rejection granularity as the horizontal rejection granularity from the optional rejection granularities if the horizontal depth gradient value is within the depth gradient threshold range; selecting a small rejection granularity as the horizontal rejection granularity from the optional rejection granularities if the horizontal depth gradient value is greater than the maximum threshold of the depth gradient threshold range; and selecting a large rejection granularity as the vertical rejection granularity from the optional rejection granularities if the vertical depth gradient value is less than the minimum threshold of the depth gradient threshold range; selecting a medium rejection granularity as the vertical rejection granularity from the optional rejection granularities if the vertical depth gradient value is within the depth gradient threshold range; and selecting a small rejection granularity as the vertical rejection granularity from the optional rejection granularities if the vertical depth gradient value is greater than the maximum threshold of the depth gradient threshold range.

[0119] In one embodiment, the depth range calculation module 1202 is used to determine whether the depth gradient value corresponding to the test block is greater than a preset threshold value; if so, a bounding box method is selected from the optional depth range calculation methods to calculate the depth range corresponding to the test block; if not, a test block method is selected from the optional depth range calculation methods to calculate the depth range corresponding to the test block.

[0120] In one embodiment, the depth range calculation module 1202 is used to select two vertices from the four vertices of the bounding box where the primitive is located in the test block according to the depth gradient growth direction of the test block in the horizontal and vertical directions, and calculate the depth range corresponding to the test block based on the two vertices.

[0121] In one embodiment, the depth range calculation module 1202 is used to select two vertices from the four vertices of the test block according to the depth gradient growth direction of the test block in the horizontal and vertical directions, and calculate the depth range corresponding to the test block based on the two vertices.

[0122] In one embodiment, the elimination judgment module 1203 is used to read the background depth range stored in the internal cache if the background depth range corresponding to the test block is stored in the internal cache; if the background depth range corresponding to the test block is not stored in the internal cache, read the background depth data corresponding to the test block from the external storage module, and calculate the background depth range corresponding to the test block based on the background depth data corresponding to the test block, and store the background depth range in the internal cache.

[0123] In one embodiment, the post-processing module 1204 is further configured to update the corresponding background depth range in the internal cache with the depth range corresponding to the non-eliminated test block.

[0124] In one embodiment, the apparatus 1200 further includes: an early elimination module, configured to eliminate, for each trial block, trial blocks that are outside the viewing frustum.

[0125] Each module in the coarse-grained depth culling device in the above-mentioned graphics drawing pipeline can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0126] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0127] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0128] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A coarse-grained depth culling method in a graphics rendering pipeline, characterized in that: The method comprises: According to the depth gradient information corresponding to the primitive, a corresponding culling granularity is selected to divide the primitive into a plurality of test blocks; For each test block, according to the depth gradient information corresponding to the test block, a corresponding depth range calculation method is selected to calculate the depth range corresponding to the test block; For each test block, obtain the background depth range corresponding to the test block, and determine whether to remove the test block according to the comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block; The unrejected test blocks are sent to the subsequent graphics drawing pipeline; The depth gradient information includes a horizontal depth gradient value and a vertical depth gradient value of the primitive; the selecting a corresponding culling granularity to divide the primitive into a plurality of test blocks according to the depth gradient information corresponding to the primitive includes: obtaining a preset depth gradient threshold range; selecting a horizontal culling granularity and a vertical culling granularity corresponding to the primitive according to a comparison result of the horizontal depth gradient value and the vertical depth gradient value with the depth gradient threshold range; obtaining the corresponding culling granularity according to the horizontal culling granularity and the vertical culling granularity; dividing the primitive into a plurality of test blocks according to the corresponding culling granularity; The selecting the horizontal culling granularity and the vertical culling granularity corresponding to the primitive according to the comparison results of the horizontal depth gradient value and the vertical depth gradient value with the depth gradient threshold range respectively includes: for the horizontal direction, if the horizontal depth gradient value is less than the minimum threshold of the depth gradient threshold range, selecting a large culling granularity from the optional culling granularities as the horizontal culling granularity; if the horizontal depth gradient value is within the depth gradient threshold range, selecting a medium culling granularity from the optional culling granularities as the horizontal culling granularity; if the horizontal depth gradient value is greater than the depth gradient threshold range, selecting a large culling granularity from the optional culling granularities as the horizontal culling granularity. For the longitudinal direction, if the longitudinal depth gradient value is less than the minimum threshold of the depth gradient threshold range, a large rejection granularity is selected from the optional rejection granularities as the longitudinal rejection granularity; if the longitudinal depth gradient value is within the depth gradient threshold range, a medium rejection granularity is selected from the optional rejection granularities as the longitudinal rejection granularity; if the longitudinal depth gradient value is greater than the maximum threshold of the depth gradient threshold range, a small rejection granularity is selected from the optional rejection granularities as the longitudinal rejection granularity.

2. The method according to claim 1, characterized in that: The step of selecting a corresponding depth range calculation method according to the depth gradient information corresponding to the test block to calculate the depth range corresponding to the test block includes: Determine whether the depth gradient value corresponding to the test block is greater than a preset threshold value; If yes, select a bounding box method from the optional depth range calculation methods to calculate the depth range corresponding to the test block; If not, a test block method is selected from the optional depth range calculation methods to calculate the depth range corresponding to the test block.

3. The method according to claim 2, characterized in that The step of selecting a bounding box method from the optional depth range calculation methods to calculate the depth range corresponding to the test block includes: According to the depth gradient growth direction of the test block in the horizontal and vertical directions, two vertices are selected from the four vertices of the bounding box where the primitive is located in the test block, and the depth range corresponding to the test block is calculated based on the two vertices.

4. The method according to claim 2, characterized in that: The step of selecting a test block method from the optional depth range calculation methods to calculate the depth range corresponding to the test block includes: According to the depth gradient growth direction of the test block in the horizontal and vertical directions, two vertices are selected from the four vertices of the test block, and the depth range corresponding to the test block is calculated based on the two vertices.

5. The method according to claim 1, characterized in that The obtaining of the background depth range corresponding to the test block includes: If the background depth range corresponding to the test block is stored in the internal cache, reading the background depth range stored in the internal cache; If the background depth range corresponding to the test block is not stored in the internal cache, the background depth data corresponding to the test block is read from the external storage module, and the background depth range corresponding to the test block is calculated based on the background depth data corresponding to the test block, and the background depth range is stored in the internal cache.

6. The method according to claim 5, characterized in that After determining whether to remove the test block based on the comparison result of the depth range corresponding to the test block and the background depth range corresponding to the test block, the method further includes: For the test blocks that are not eliminated, the depth range corresponding to the test blocks that are not eliminated is used to update the corresponding background depth range in the internal buffer.

7. The method according to any one of claims 1 to 6, characterized in that: Before obtaining the background depth range corresponding to each test block and determining whether to remove the test block based on a comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block, the method further includes: For each trial block, the trial blocks outside the viewing frustum are eliminated.

8. A coarse-grained depth culling device in a graphics rendering pipeline, characterized in that: The device comprises: A test block segmentation module is used to select a corresponding culling granularity to segment the primitive into a plurality of test blocks according to the depth gradient information corresponding to the primitive; A depth range calculation module is used to select a corresponding depth range calculation method for each test block according to the depth gradient information corresponding to the test block to calculate the depth range corresponding to the test block; A rejection judgment module is used to obtain, for each test block, a background depth range corresponding to the test block, and judge whether to reject the test block according to a comparison result between the depth range corresponding to the test block and the background depth range corresponding to the test block; The post-processing module is used to send the unrejected test blocks to the subsequent graphics drawing pipeline; The depth gradient information includes a horizontal depth gradient value and a vertical depth gradient value of the primitive; a test block segmentation module is used to obtain a preset depth gradient threshold range; according to the comparison results of the horizontal depth gradient value and the vertical depth gradient value with the depth gradient threshold range, respectively select the horizontal culling granularity and the vertical culling granularity corresponding to the primitive; according to the horizontal culling granularity and the vertical culling granularity, obtain the corresponding culling granularity; according to the corresponding culling granularity, divide the primitive into a plurality of test blocks; A test block segmentation module is used for, for the horizontal direction, if the horizontal depth gradient value is less than the minimum threshold of the depth gradient threshold range, selecting a large rejection granularity from the optional rejection granularities as the horizontal rejection granularity; if the horizontal depth gradient value is within the depth gradient threshold range, selecting a medium rejection granularity from the optional rejection granularities as the horizontal rejection granularity; if the horizontal depth gradient value is greater than the maximum threshold of the depth gradient threshold range, selecting a small rejection granularity from the optional rejection granularity as the horizontal rejection granularity; for the vertical direction, if the vertical depth gradient value is less than the minimum threshold of the depth gradient threshold range, selecting a large rejection granularity from the optional rejection granularity as the vertical rejection granularity; if the vertical depth gradient value is within the depth gradient threshold range, selecting a medium rejection granularity from the optional rejection granularity as the vertical rejection granularity; if the vertical depth gradient value is greater than the maximum threshold of the depth gradient threshold range, selecting a small rejection granularity from the optional rejection granularity as the vertical rejection granularity.

9. The device according to claim 8, characterized in that A depth range calculation module is used to determine whether the depth gradient value corresponding to the test block is greater than a preset threshold value; if so, a bounding box method is selected from the optional depth range calculation methods to calculate the depth range corresponding to the test block; if not, a test block method is selected from the optional depth range calculation methods to calculate the depth range corresponding to the test block.

10. The device according to claim 9, characterized in that A depth range calculation module is used to select two vertices from the four vertices of the bounding box where the primitive is located in the test block according to the depth gradient growth direction of the test block in the horizontal and vertical directions, and calculate the depth range corresponding to the test block based on the two vertices.