Region-based depth test method and apparatus, device, storage medium and computer program product
By performing area segmentation and the use of depth range caching before tile rasterization, the depth test results of the area to be tested are determined in advance, which solves the problem of low depth test efficiency in the existing technology and achieves a more efficient rendering process.
Patent Information
- Application Number
- PCT/CN2024/079698
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-24
- Filing Date
- 2024-03-01
- Publication Date
- 2024-10-31
AI Technical Summary
In the existing technology, the early depth test is performed after the rasterization process, which reduces the efficiency of removing occluded objects and increases the load on the graphics processor.
Before the rasterization process of the tile, by dividing the tile into multiple areas to be tested, the depth range of each area is generated, and the second depth range is obtained from the depth range cache, and the depth test result is determined to decide whether to perform pixel-level Deep testing.
Eliminate occluded objects that do not need to be rendered in advance, saving rasterization computing resources and improving overall rendering efficiency.
Smart Images

Figure CN2024079698_31102024_PF_FP_ABST
Abstract
Description
Area-based depth testing method, device, equipment, storage medium, and computer program product
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] The embodiments of this application are based on the Chinese patent application with application number 202310444667.X, application date April 24, 2023, and application name “Region-based depth testing method, device, equipment and storage medium”, and claim the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field
[0003] The present application relates to, but is not limited to, the field of image processing technology, and in particular to a region-based depth testing method, apparatus, device, storage medium, and computer program product. Background Art
[0004] In the current standard rendering pipeline, after rasterization, valid pixels are directly sent to the pixel shader for shading. To improve graphics processing unit (GPU) performance, GPU manufacturers have implemented numerous architectural optimizations, including Early-Z test. Early-Z test performs a depth test before executing the pixel shader, preemptively culling pixels obscured by depth, thereby reducing the pixel shader's load.
[0005] Currently, in order to implement pixel-level early depth testing, the early depth test must be placed after the rasterization process, that is, the early depth test needs to be based on factors such as pixel rasterization and depth interpolation, and the culling efficiency is greatly affected.
[0006] Summary of the Invention
[0007] In view of this, embodiments of the present application at least provide a region-based depth testing method, apparatus, device, storage medium, and computer program product.
[0008] The technical solution of the embodiment of the present application can be implemented as follows:
[0009] The present invention provides a method for depth testing based on a region, including:
[0010] Before executing the rasterization process of the image block, the image block is segmented to obtain a plurality of to-be-tested regions and region data corresponding to each of the to-be-tested regions; the region data includes region information of the to-be-tested regions and primitive information corresponding to the to-be-tested regions;
[0011] For each of the areas to be tested, generating a first depth range of the area to be tested based on the area information of the area to be tested and the primitive information corresponding to the area to be tested;
[0012] Obtain a second depth range of the area to be tested from a depth range cache; determine a depth test result of the area to be tested based on the first depth range and the second depth range; the depth test result is used to indicate whether the area to be tested requires pixel-level depth testing.
[0013] The present invention provides a region-based depth testing device, comprising:
[0014] The image block segmentation part is configured to segment the image block before performing the rasterization process of the image block to obtain multiple areas to be tested and area data corresponding to each area to be tested; the area data includes area information of the area to be tested and primitive information corresponding to the area to be tested;
[0015] The area depth testing part is configured to generate, for each area to be tested, a first depth range of the area to be tested based on the area information of the area to be tested and the primitive information corresponding to the area to be tested;
[0016] The area depth testing part is further configured to obtain a second depth range of the area to be tested from a depth range cache;
[0017] The area depth testing part is further configured to determine a depth test result of the area to be tested based on the first depth range and the second depth range; the depth test result is used to indicate whether the area to be tested needs to be subjected to pixel-level depth testing.
[0018] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0019] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements some or all of the steps in the above method when executed by a processor.
[0020] An embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements some or all of the steps in the above method.
[0021] In an embodiment of the present application, since a region-based depth test process is set before executing the rasterization process of the tile, compared with the early depth test process in the related art, the present application can eliminate occluded objects that do not need to be rendered earlier, and there is no need to enter the rasterization stage, thereby saving computing resources of the rasterization part; at the same time, by setting a depth range cache and storing the second depth range of each area in the tile through the depth range cache, the second depth range of the area to be tested can be directly obtained from the depth range cache, thereby improving the overall rendering efficiency.
[0022] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and do not limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, are used to illustrate the technical solutions of the present application.
[0024] FIG1 is a schematic diagram of a typical TBR pipeline flow chart provided in an embodiment of the present application;
[0025] FIG2 is a schematic diagram of a first implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0026] FIG3 is a second schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0027] FIG4 is a third schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0028] FIG5 is a fourth schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0029] FIG6 is a fifth schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0030] FIG7 is a sixth schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0031] FIG8 is a seventh schematic diagram of an implementation flow of a region-based depth testing method provided in an embodiment of the present application;
[0032] FIG9 is a schematic diagram of the overall architecture of a region-based depth testing method provided in an embodiment of the present application;
[0033] FIG10 is a schematic diagram of a region segmentation process provided in an embodiment of the present application;
[0034] FIG11 is a schematic structural diagram of a regional depth test portion provided in an embodiment of the present application;
[0035] FIG12A is a schematic diagram of a depth range comparison provided in an embodiment of the present application;
[0036] FIG12B is a schematic diagram of another depth range comparison provided by an embodiment of the present application;
[0037] FIG12C is a schematic diagram of another depth range comparison provided in an embodiment of the present application;
[0038] FIG12D is a schematic diagram of another depth range comparison provided in an embodiment of the present application;
[0039] FIG13 is a schematic diagram of the structure of a region-based depth testing device provided in an embodiment of the present application;
[0040] FIG14 is a schematic diagram of a hardware entity of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions of this application are further elaborated in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0042] In the following description, references to "some embodiments" describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" are used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that the specific order or sequence of "first / second / third" may be interchanged where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing this application only and are not intended to limit this application.
[0044] Tile-Based Rendering (TBR) is a process of subdividing a computer graphics image into a regular grid in optical space and rendering each part of the grid (grid) or tile (tile) separately. The advantage of this design is that it reduces memory and bandwidth consumption compared to immediate mode rendering systems that draw the entire frame at once. This makes tile rendering systems common in low-power hardware devices. Tile rendering is sometimes also called a sort middle architecture because it performs geometry sorting in the middle of the graphics pipeline rather than near the end. TBR is the most commonly used architecture for mobile GPUs and has significant advantages in reducing power consumption.
[0045] A typical TBR pipeline process is shown in Figure 1. The TBR pipeline process is divided into a front-end part 110 and a back-end part 120, wherein the front-end part 110 includes a vertex processing part 111, a graphics processing part 112 and a tiling part 113; the back-end part 120 includes a rasterization part 121, a hidden surface removal (HSR) part 122, a pixel shading part 123 and an output merging part 124.
[0046] The front-end 110 performs vertex and primitive transformations (vertex processing), graphics processing (including clipping / culling, etc.), and then completes screen segmentation in the tiling phase, records the graphics data covering the tiles, and writes the generated information to the system memory 130. In this way, the system memory 130 can store tile information (primitive list) and vertex information (vertex data). The primitive list is a fixed-length array with a length of tiles. Each element in the array is a linked list that stores pointers to all triangles that intersect the current tile, and the pointers point to the vertex data. The vertex data stores vertex and vertex attribute data.
[0047] The backend 120 performs operations such as rasterization, depth testing, and pixel shading, and finally outputs the data to the render target. For each tile, since the amount of data is not large, the required depth data, texture data, or color data can be loaded into the GPU's on-chip storage SRAM, that is, the on-chip memory 140 in the figure; for example, the hidden surface removal part 122 can store the depth data in the depth data buffer in the on-chip memory 140, the pixel shading part 123 can store the texture data in the texture data buffer in the on-chip memory 140, and the output merging part 124 can store the color data in the color data buffer in the on-chip memory 140.
[0048] During the rendering process, the rendering object (screen) will be divided into multiple tiles. In this way, the on-chip memory 140 can accommodate all the data of this tile. After at least one drawing instruction arrives at the GPU, the front-end part 110 processes each drawing instruction in turn and stores the corresponding tile information and vertex information in the system memory 130 until the data stored in the system memory 130 reaches a preset threshold or at least one drawing instruction has been processed. The back-end part 120 will read the corresponding vertex information from the system memory 130 in units of tiles and perform subsequent processing. In this way, since the back-end part 120's access to the system memory 130 is changed to the back-end part 120's access to the on-chip memory 140, the rendering efficiency can be improved.
[0049] The present invention provides a region-based depth testing method that can be executed by a processor of a computer device. The computer device may include a server, laptop, tablet, desktop computer, smart TV, set-top box, mobile device (e.g., mobile phone, portable video player, personal digital assistant, dedicated messaging device, portable gaming device), or other device with data processing capabilities.
[0050] FIG2 is a schematic diagram of a first implementation flow of a region-based depth testing method provided in an embodiment of the present application. The method can be executed by a processor of a computer device and will be described in conjunction with the steps shown in FIG2 .
[0051] Step S201 : before executing the rasterization process of a block, segment the block to obtain multiple test areas and area data corresponding to each test area; the area data includes area information of the test area and primitive information corresponding to the test area.
[0052] In some embodiments, in the TBR architecture, the back-end part performs subsequent rendering processes in units of tiles. Compared with the depth testing method in the related art, in order to perform depth testing earlier, the present application performs the region-based depth testing process of the present application before executing the rasterization process of the tile.
[0053] In some embodiments, the image block can be divided into multiple areas of the same size according to a preset segmentation rule, and the obtained multiple areas do not have any intersection. In this case, the area covered by the existing primitive is used as the above-mentioned test area, and the multiple test areas can be obtained. The area information of the test area may include information such as the area range and area coordinates of the test area, and the primitive information corresponding to the test area is the primitive shape information, primitive depth information, etc. of the primitive covering the test area.
[0054] Step S202 : For each of the to-be-tested areas, based on the area information of the to-be-tested area and the primitive information corresponding to the to-be-tested area, generate a first depth range of the to-be-tested area.
[0055] In some embodiments, the first depth range is the range of depth values of each pixel in the test area when the current primitive is rendered in the test area. Thus, based on the area range of the test area and the primitive depth information and primitive shape information of the current primitive corresponding to the test area, the range of depth values in the test area when the test area is rendered, i.e., the first depth range, can be determined.
[0056] Step S203: Acquire a second depth range of the area to be tested from the depth range cache.
[0057] In some embodiments, the depth range cache is used to cache the depth value range of each area in the tile in real time, that is, the depth range cache caches the second depth range corresponding to each area to be tested. The second depth range represents the historical range of the depth value of the area to be tested, which can be understood as that, for the area to be tested, before executing the area depth test process of the current primitive, the area depth test process of other primitives has been completed. At this time, the second depth range of the area to be tested stored in the depth range cache is the range of depth values of each pixel in the area to be tested when the other primitives are rendered.
[0058] In some embodiments, in an initial state, that is, when the depth range cache is just assigned the current tile, the second depth range of the area to be tested in the depth range cache is determined based on the depth value of each pixel in the area to be tested in the depth information cache.
[0059] Step S204: Determine a depth test result of the area to be tested based on the first depth range and the second depth range; the depth test result is used to indicate whether the area to be tested needs to be subjected to a pixel-level depth test.
[0060] In some embodiments, based on the numerical size relationship between the first depth range and the second depth range, it can be determined whether the area to be tested needs to render the current primitive in the subsequent rendering process, and then a depth test result is generated to indicate whether the area to be tested needs to perform pixel-level depth testing.
[0061] In an embodiment of the present application, since a region-based depth test process is set before executing the rasterization process of the tile, compared with the early depth test process in the related art, the present application can eliminate occluded objects that do not need to be rendered earlier, and there is no need to enter the rasterization stage, thereby saving computing resources of the rasterization part; at the same time, by setting a depth range cache and storing the second depth range of each area in the tile through the depth range cache, the second depth range of the area to be tested can be directly obtained from the depth range cache, thereby improving the overall rendering efficiency.
[0062] FIG3 is a second schematic diagram of a process flow for implementing a region-based depth testing method according to an embodiment of the present application, which can be executed by a processor of a computer device. The primitive information includes the primitive's depth plane equation; based on FIG2 , step S202 in FIG2 can be updated to steps S301 to S302, which will be described in conjunction with the steps shown in FIG3 .
[0063] Step S301 : determining a minimum interpolation depth value and a maximum interpolation depth value in the area to be tested based on the depth plane equation of the primitive and the area information of the area to be tested.
[0064] In some embodiments, the area information of the area to be tested may include the position coordinates of each pixel in the area to be tested. Combined with the depth plane equation corresponding to the primitive, the depth value of each pixel in the area to be tested can be determined, the depth value of each pixel can be sorted, and the maximum depth value is used as the maximum interpolation depth value, and the minimum depth value is used as the minimum interpolation depth value.
[0065] In some embodiments, the above-mentioned depth plane equation based on the primitive and the area information of the area to be tested can be implemented through steps S3011 to S3013 to determine the minimum interpolation depth value and the maximum interpolation depth value in the area to be tested.
[0066] Step S3011: Determine a first slope and a second slope based on the depth plane equation of the primitive.
[0067] The first slope represents the slope of the depth plane of the graphic element in a first direction, the second slope represents the slope of the depth plane of the graphic element in a second direction, and the first direction, the second direction and the depth direction are perpendicular to each other.
[0068] Step S3012: Determine coordinate information of a minimum interpolation depth value and coordinate information of a maximum interpolation depth value based on the first slope, the second slope, and the region information.
[0069] The area to be tested is determined by the first area vertex, the second area vertex, the third area vertex, and the fourth area vertex, and the area information includes the vertex coordinates of the first area vertex, the second area vertex, the third area vertex, and the fourth area vertex. The above-mentioned determination of the coordinate information of the minimum interpolation depth value and the coordinate information of the maximum interpolation depth value based on the first slope, the second slope, and the area information can be achieved by:
[0070] In some embodiments, when the first slope is greater than or equal to 0 and the second slope is greater than or equal to 0, the vertex coordinates of the vertices of the first area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices of the third area are used as the coordinate information of the maximum interpolation depth value.
[0071] In some embodiments, when the first slope is less than 0 and the second slope is less than 0, the vertex coordinates of the vertices of the third area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices of the first area are used as the coordinate information of the maximum interpolation depth value.
[0072] In some embodiments, when the first slope is greater than or equal to 0 and the second slope is less than 0, the vertex coordinates of the vertices of the second area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices of the fourth area are used as the coordinate information of the maximum interpolation depth value.
[0073] In some embodiments, when the first slope is less than 0 and the second slope is greater than or equal to 0, the vertex coordinates of the vertices of the fourth area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices of the second area are used as the coordinate information of the maximum interpolation depth value.
[0074] Step S3013: Determine a minimum interpolation depth value and a maximum interpolation depth value based on the coordinate information of the minimum interpolation depth value, the coordinate information of the maximum interpolation depth value, and the depth plane equation.
[0075] Substituting the coordinate information of the minimum interpolation depth value into the depth plane equation can obtain the minimum interpolation depth value, and substituting the coordinate information of the maximum interpolation depth value into the depth plane equation can obtain the maximum interpolation depth value.
[0076] Step S302: Generate a first depth range of the area to be tested based on the minimum interpolation depth value and the maximum interpolation depth value.
[0077] In an embodiment of the present application, the first depth range of the area to be tested is determined by the depth surface equation of the primitives in the area to be tested, and subsequent low-precision depth testing can be implemented, which can eliminate occluded objects early, reduce the workload of the subsequent rendering part, and improve the performance of the rendering pipeline.
[0078] FIG4 is a third schematic diagram of the implementation flow of the region-based depth testing method provided in an embodiment of the present application, which can be executed by a processor of a computer device. Based on FIG2 , step S203 in FIG2 can be updated to steps S401 to S403, which will be explained in conjunction with the steps shown in FIG4 .
[0079] Step S401: Obtain the area position information of the area to be tested in the image block.
[0080] In some embodiments, the region position information is used to represent the relative position of the region to be tested in the tile. For example, when the tile size is 32×32 and the preset region size is 16×16, the tile can be divided into four initial regions, and the region position information of these four initial regions is (0, 0), (1, 0), (0, 1), and (1, 1).
[0081] Step S402: Generate index information of the area to be tested based on the area location information of the area to be tested.
[0082] In some embodiments, the depth range cache stores the second depth range of each initial region in the tile, and the storage address of the second depth range of each initial region in the depth range cache is related to the region position information of each initial region. Based on this, an index conversion algorithm can be preset to convert the region position information of the to-be-tested region into the index information of the to-be-tested region, and then determine the storage address of the to-be-tested region based on the index information, and then find the second depth range of the to-be-tested region from the depth range cache.
[0083] Step S403: Acquire a second depth range of the area to be tested from the depth range cache based on the index information of the area to be tested.
[0084] In some embodiments, the above-mentioned acquisition of the second depth range of the area to be tested in the depth range cache based on the index information of the area to be tested may be achieved through steps S4031 to S4033.
[0085] Step S4031: Perform a hit test in the depth range buffer based on the index information of the area to be tested.
[0086] Among them, the hit test is used to determine whether there is index information corresponding to the area to be tested in the depth range cache. If the index information exists, the storage address can be found directly based on the index information, and then the corresponding second depth range can be obtained; if the index information does not exist, it means that the second depth range of the area to be tested does not exist in the current depth range cache.
[0087] Step S4032: When the hit test result of the hit test indicates that the second depth range of the area to be tested exists in the depth range cache, obtain the second depth range of the area to be tested.
[0088] At this time, the storage address is directly found based on the index information, and then the corresponding second depth range is obtained.
[0089] Step S4033: When the hit test result of the hit test indicates that the second depth range of the area to be tested does not exist in the depth range cache, determine the second depth range of the area to be tested from the depth information cache and write it into the depth range cache.
[0090] At this time, the second depth range of the area to be tested does not exist in the current depth range cache. At this time, it is necessary to obtain the depth value of each pixel in the area to be tested from the depth information cache, sort the depth value of each pixel in the area to be tested, and determine the maximum depth value and minimum depth value corresponding to the area to be tested to obtain the second depth range and write it into the depth range cache.
[0091] In an embodiment of the present application, the second depth range of each area in the tile is stored through a depth range cache. In this way, in the process of obtaining the second depth range of the area to be tested, there is no need to obtain it from the depth information cache, and it can be obtained directly from the depth range cache. In this way, the data query efficiency can be improved, and then the depth test efficiency can be improved, thereby improving the rendering speed as a whole.
[0092] FIG5 is a fourth flow chart illustrating an implementation flow of a region-based depth testing method according to an embodiment of the present application, which can be executed by a processor of a computer device. Based on any of the above embodiments, taking FIG2 as an example, step S201 in FIG2 can be updated to steps S501 to S503, which will be explained in conjunction with the steps shown in FIG5.
[0093] Step S501: Segment the image block based on a preset region size to obtain a plurality of initial regions and region information corresponding to each of the initial regions.
[0094] In some embodiments, the preset area size may be, but is not limited to, any one of the following: 16×16, 8×8, and 4×4.
[0095] In some embodiments, the region information may include region position information of the initial region in the tile and vertex information of the initial region.
[0096] Among them, the region position information represents the relative position of the initial region in the tile. For example, when the tile size is 32×32 and the preset region size is 16×16, the tile can be divided into 4 initial regions, and the region position information of these 4 initial regions are (0, 0), (1, 0), (0, 1), and (1, 1), respectively.
[0097] The vertex information of the initial region is the coordinate information of the four region vertices of the initial region.
[0098] Step S502: Obtain the primitive information of the primitive corresponding to the block; the primitive information includes the bounding box information of the primitive.
[0099] In some embodiments, the primitive corresponding to the tile is the primitive that falls within the tile. The bounding box information of the primitive is the bounding box information of the rectangular box in which the primitive is located. Exemplarily, the bounding box information can be determined by BBoxMinX, BBoxMaxX, BBoxMinY, and BBoxMaxY. That is, the bounding box information of the primitive is used to represent the coordinate range of the primitive in the X direction and the coordinate range in the Y direction.
[0100] In some embodiments, the primitive information may further include at least one of the following: equations of edges of the primitive, equations of faces of the primitive.
[0101] Step S503 : Based on the bounding box information of the primitive, the multiple initial regions are screened to obtain multiple to-be-tested regions corresponding to the image block and region data of each to-be-tested region.
[0102] In some embodiments, based on the bounding box information of the primitive and the area information of each initial area, an initial area that intersects with the rectangular box where the primitive is located can be determined among the multiple initial areas, and the initial area that intersects with the rectangular box can be used as the area to be tested.
[0103] In some embodiments, for each area to be tested, the area information of the area to be tested is the area information of the initial area corresponding to the area to be tested, and the graphic element information of the area to be tested is the graphic element information of the graphic element corresponding to the above-mentioned block.
[0104] In the embodiment of the present application, by dividing the tiles into regions, low-precision depth testing with region granularity is achieved, which can reduce the workload of the subsequent rendering part and improve the performance of the rendering pipeline.
[0105] FIG6 is a fifth flow chart of an implementation process of a region-based depth testing method provided in an embodiment of the present application, which can be executed by a processor of a computer device. Based on any of the above embodiments, taking FIG2 as an example, step S204 in FIG2 can be updated to steps S601 to S603, which will be explained in conjunction with the steps shown in FIG6.
[0106] Step S601: When the maximum value of the first depth range is less than the minimum value of the second depth range, generate a first test result; the first test result is used to characterize that the area to be tested does not require pixel-level depth testing, and update the depth value of each pixel in the area to be tested in the depth information cache.
[0107] In some embodiments, the first depth range is determined by a maximum interpolated depth value and a minimum interpolated depth value, and the second depth range is determined by a maximum cached depth value and a minimum cached depth value.
[0108] In some embodiments, when the maximum interpolation depth value is less than the minimum cache depth value, at this time, the first depth range and the second depth range do not have an intersection, and at the same time, the first depth range as a whole is located before the second depth range. Therefore, a depth value for each pixel in the area to be tested in the depth information cache can be generated to characterize that the area to be tested does not need to be subjected to pixel-level depth testing, and the depth information cache can be updated.
[0109] Among them, since there is no intersection between the first depth range and the second depth range, and the first depth range is located as a whole before the second depth range, the depth value of the pixel at the corresponding position in the depth information cache can be directly updated based on the depth value of each pixel of the current primitive in the tested area.
[0110] Step S602: When the first depth range and the second depth range have an intersection, generate a second test result; the second test result is used to indicate that the area to be tested needs to be subjected to a pixel-level depth test.
[0111] In some embodiments, when the minimum interpolation depth value is less than or equal to the minimum cache depth value, and the minimum cache depth value is less than or equal to the maximum interpolation depth value, the first depth range and the second depth range have an intersection.
[0112] In some other embodiments, when the minimum interpolation depth value is less than or equal to the maximum cache depth value, and the maximum cache depth value is less than or equal to the maximum interpolation depth value, the first depth range and the second depth range have an intersection.
[0113] In either of the above two situations, a second test result may be generated, indicating that the area to be tested needs to be subjected to a pixel-level depth test.
[0114] After obtaining the second test result and performing a pixel-level depth test on the area to be tested, the depth value of the pixel at the corresponding position in the depth information cache is updated based on the test result of the pixel-level depth test. That is, for any pixel, if the depth value corresponding to the pixel in the current primitive is less than the depth value of the pixel in the depth information cache, the depth value of the pixel in the depth information cache is updated based on the depth value corresponding to the pixel in the current primitive; if the depth value corresponding to the pixel in the current primitive is greater than or equal to the depth value of the pixel in the depth information cache, the depth value of the pixel in the depth information cache remains unchanged.
[0115] Step S603: When the minimum value of the first depth range is greater than the maximum value of the second depth range, generate a third test result; the third test result is used to indicate that the area to be tested needs to be eliminated and does not require pixel-level depth testing.
[0116] In some embodiments, when the minimum interpolation depth value is greater than the maximum cache depth value, at this time, there is no intersection between the first depth range and the second depth range, and a third test result is generated to characterize that the area to be tested needs to be eliminated and no pixel-level depth test is required.
[0117] After obtaining the third test result, pixel-level depth testing is not required because the depth value of the current primitive in the area to be tested is eliminated. Therefore, compared to the first and second test results, in this case, the depth value of each pixel in the area to be tested in the depth information cache remains unchanged.
[0118] In some embodiments, the method may further include step S604.
[0119] Step S604: In response to the depth test result of the area to be tested being the first test result or the second test result, using the minimum interpolated depth value in the first depth range, update the minimum cached depth value in the second depth range of the area to be tested in the depth range cache.
[0120] In some embodiments, when the depth test result of the area to be tested is the first test result or the second test result, it indicates that the minimum interpolated depth value of the area to be tested currently undergoing the depth test is already less than the minimum cached depth value in the second depth range of the area to be tested in the depth range cache. In this case, it is necessary to update the minimum cached depth value using the minimum interpolated depth value, that is, to reduce the minimum cached depth value in the second depth range of the area to be tested in the depth range cache to the minimum interpolated depth value.
[0121] In this embodiment of the present application, for each area to be tested, by comparing the first depth range of the area to be tested obtained through interpolation with the second depth range of the area to be tested in the depth range cache, occluded objects can be quickly and early eliminated without entering the rasterization stage. This can reduce workload and improve rendering pipeline performance.
[0122] FIG7 is a sixth schematic diagram of a flow chart of an implementation of a region-based depth testing method provided in an embodiment of the present application, which can be executed by a processor of a computer device. Based on any of the above embodiments, taking FIG2 as an example, the method can further include steps S701 to S703, which will be described in conjunction with the steps shown in FIG7.
[0123] Step S701: In response to a depth information buffer being allocated to the tile and completing initialization, obtaining a depth value of each pixel in each initial area from the depth information buffer.
[0124] In this embodiment, the initialization process includes loading the depth values of all pixels in the tile from memory and writing them to the depth buffer. At this point, the depth values cached in the depth buffer are not infinite, but rather between 0 and 1. Accordingly, the depth range buffer is also initialized based on the depth values of each pixel cached in the depth buffer, completing the initialization process.
[0125] Among them, since the region-based depth testing method provided in the embodiment of the present application is applied to an image processor based on a TBR architecture, the back-end part of the TBR architecture processes rendering tasks in units of tiles.
[0126] In some embodiments, when the back-end starts processing a rendering task corresponding to a tile, a depth information cache needs to be allocated to the tile and initialized; thereafter, the depth value of each pixel in each of the initial areas is obtained from the depth information cache.
[0127] Step S702: Determine a second depth range corresponding to each of the initial regions based on the depth value of each pixel in each of the initial regions.
[0128] In some embodiments, for each initial region, the depth values of each pixel within the initial region are sorted to determine the maximum depth value and the minimum depth value corresponding to the initial region. The second depth range is determined by the maximum cached depth value and the minimum cached depth value. The maximum depth value can then be used as the maximum cached depth value for the initial region, and the minimum depth value can be used as the minimum cached depth value for the initial region.
[0129] Step S703: Update the second depth range corresponding to each of the initial areas to the depth range cache.
[0130] In some embodiments, in the depth range cache, the obtained maximum cache depth value and minimum cache depth value corresponding to each initial region are used as the second depth range corresponding to each initial region.
[0131] In the embodiment of the present application, when the depth information cache is assigned to the current tile, the second depth range of each initial area stored in the depth range cache is updated based on the depth value of each pixel of the tile in the depth information cache. In this way, the depth range cache can be made closer to the depth information cache more accurately, achieving real-time updating of the depth range cache.
[0132] FIG8 is a seventh flow chart of an implementation process of a region-based depth testing method provided in an embodiment of the present application, which can be executed by a processor of a computer device. Based on any of the above embodiments, taking FIG2 as an example, the method can further include steps S801 to S802, which will be described in conjunction with the steps shown in FIG8.
[0133] Step S801 : In response to all depth values of primitives being written into the depth information cache during the early depth test and / or the late depth test, the depth value of each pixel corresponding to the tile is read from the depth information cache.
[0134] The early depth test is called the Early-Z test in related technologies, also known as the Early Depth Test. This early depth test allows the depth test to occur before the pixel shading phase, eliminating the need for pixel shader calculations for pixels that fail the test, thereby improving performance. The late depth test is the depth test that occurs after the pixel shader in related technologies.
[0135] In some embodiments, since the TBR architecture renders in parts in tiles, during the early depth test and / or the late depth test, in response to the depth values of the primitives being all written to the depth information cache, that is, when the last depth value of the primitive is written to the depth information cache, the depth value of each pixel corresponding to the tile is read from the depth information cache.
[0136] Step S802: Based on the depth value of each pixel corresponding to the tile, update the second depth range corresponding to each of the initial areas in the depth range cache.
[0137] In some embodiments, after obtaining the depth value of each pixel in the tile, the depth value of each pixel within the area range can be sorted according to the area range of each initial area in the tile to obtain the maximum depth value and the minimum depth value corresponding to each initial area. The maximum depth value can then be used as the maximum cache depth value of the initial area, and the minimum depth value can be used as the minimum cache depth value of the initial area. Thereafter, in the depth range cache, the obtained maximum cache depth value and minimum cache depth value corresponding to each initial area are used as the second depth range corresponding to each initial area.
[0138] In some embodiments, since the early depth test and / or late depth test process performs depth testing on the depth value of each pixel in the tile and updates it to a smaller depth value, the above-mentioned update of the second depth range is to update the maximum cached depth value in the second depth range. In this way, the hit range of the third test result can be increased, thereby improving the area culling rate.
[0139] In an embodiment of the present application, since a pixel-level depth test is performed during the early depth test and / or the late depth test, the depth value of each pixel in the tile is updated in the depth information cache after the test is completed. At this time, the depth value of each pixel in the depth information cache is used to update the second depth range in the depth range cache. In this way, by continuously updating the second depth range, the efficiency of culling the area can be improved.
[0140] The following describes the application of the region-based depth testing method provided in an embodiment of the present application in a practical scenario.
[0141] This application improves the TBR depth test (Ztest) in the related art and proposes a TBR-based regional depth test (Block Z) algorithm. This algorithm is designed to improve the execution efficiency of the early depth test (Early-Ztest) on the TBR architecture and make up for the defects of the traditional Ztest algorithm in the following aspects: (1) In order to eliminate the occluded objects as quickly as possible and improve the efficiency of the existing Early-Ztest, a regional depth test part is added before the pixel-level Early-Ztest. (2) By performing the early depth test (Early-Ztest) in units of regions, the occlusion test can be completed before rasterization, thereby reducing the load of the rasterization part and the pixel shading part. (3) The advantage of the depth information cache (Depth Buffer) under the TBR architecture to cache the depth information (Depth value) of the current block is fully utilized, and the secondary depth range information reading mechanism is used to simplify the reading and writing complexity of the depth range information required for the regional depth test.
[0142] In some embodiments, this application is based on the TBR architecture and adds a block z test before the rasterization stage (rasterization part). This uses the existing depth buffer (Depth Buffer) to quickly perform block z tests, thereby improving the overall performance of the depth test (Ztest) and implementing it on GPU hardware. The overall design concept is as follows:
[0143] Construct equations for the triangle's sides and properties through the Triangle setup section;
[0144] The tile splitter divides the tiles into blocks. Based on performance verification results, the block sizes can be configured as 16×16, 8×8, and 4×4. The tile splitter extracts block information, including coordinates, size, and corresponding triangle data (including edge equations and depth plane equations), and packages it into the block z test.
[0145] The regional depth test part is based on the input regional information. On the one hand, it determines the position (min_z_x, min_z_y) of the minimum interpolation depth value (bmin_z) of the region and the position (max_z_x, max_z_y) of the maximum interpolation depth value (bmax_z) of the region according to the equation parameters of Z (surface). Then, the minimum interpolation depth value and the maximum interpolation depth value of the region are interpolated through the internal network arithmetic logic unit (ALU); on the other hand, the depth sorting (Zsorter) part is requested to obtain the minimum cache depth value (rmin_z) and the maximum cache depth value (rmax_z) corresponding to the region in the depth information buffer (Depth Buffer). Afterwards, the comparison portion of the area depth test takes the "minimum interpolated depth value, maximum interpolated depth value" and the "minimum cache depth value, maximum cache depth value" as input and performs Block Ztest according to the current draw Ztest comparison mode. The comparison mode can include any of the following: LESS mode or GREATER mode. The test results of the area depth test process are output to the rasterization part and the HSR part. The HSR part includes pixel-level early depth test (Early-Ztest) and late depth test (Late Ztest). The HSR part performs pixel-level Ztest and updates the depth information cache based on the test results of the depth test process.
[0146] In some embodiments, the present application stores the depth range information Zrange (including the minimum cache depth value and the maximum cache depth value) of all areas of the tile through a depth range buffer (Zrange Buffer). The number of area information stored in the depth range buffer is the same as the number of area information stored in the depth information buffer. That is, the depth range information of the same area is bound to a depth range buffer and a depth information buffer. The depth range buffer will be written with data by the regional depth test part and the depth sorting part. The depth sorting part writes the initial depth range information to the depth range buffer, and the regional depth test part continuously updates the depth range information in the depth range buffer during the image rendering (draw) process.
[0147] In some embodiments, the depth sorting part can write an initial value for the depth range cache. The depth sorting part will first load the depth value (Depth value) for all pixels (samples) in the area into the depth information cache, and then compare these depth values to obtain the minimum and maximum values, i.e. (minimum cache depth value, maximum cache depth value), and write them to the corresponding position in the depth range cache. In other embodiments, after the early depth test part or the late depth test part completes the ztest processing on the pixels of the primitive and writes them into the depth information cache, the depth sorting part will actively update the Zrange based on the latest depth information in the depth information cache to improve the real-time performance of the Zrange value. Block Z will initiate a Zrange request to the Zsorter for the new Block.
[0148] Please refer to FIG9 , which shows a schematic diagram of the overall architecture of a region-based depth testing method.
[0149] In some embodiments, for each tile, the triangle initialization portion 901 may calculate primitive information for each primitive in the tile. For example, if the primitive is a triangle, the primitive information may be triangle data, which includes the equations of the triangle's edges, the depth plane equation, and the range information of the triangle identification box.
[0150] For example, the equations of the sides of the triangle can be expressed as formulas (1) to (3). EDGE0: A0*x+B0*y+C0=0 Formula (1); EDGE1: A1*x+B1*y+C1=0 Formula (2); EDGE2: A2*x+B2*y+C2=0 Formula (3);
[0151] The above formulas (1) to (3) can be used in the rasterization process.
[0152] For example, the depth plane equation of Z can be expressed as formula (4). ZFace: ZA*x+ZB*y+ZC=0 Formula (4);
[0153] Among them, ZA can be considered as the slope of the triangle depth plane in the x direction, ZB can be considered as the slope of the triangle depth plane in the y direction, and ZC is the parameter of the depth plane equation.
[0154] For example, the range information of the triangular identification box can be represented by BBoxMinX, BBoxMaxX, BBoxMinY, and BBoxMaxY, that is, the range of the triangular identification box in the X direction and the range in the Y direction.
[0155] In some embodiments, for each tile, the tile segmentation part 902 can split the tile with the region as the granularity. Please refer to Figure 10, which shows a schematic diagram of the region segmentation process. In Figure 10, the size of the tile 1010 is 32*32. When the size of the region 1020 is 8×8, the tile 1010 can be divided into 16 8×8 regions from B0 to B15. Combined with the range information 1030 of the above-mentioned triangular identification box, the tile segmentation part 902 can finally obtain 12 8×8 blocks, such as B1, B2, B3, B5, B6, B7, B9, B10, B11, B13, B14, and B15 in the figure.
[0156] In some embodiments, the tile segmentation section 902 packages the region information and corresponding primitive information of a preset number of regions and sends them to the region depth testing section 903. The preset number is related to the number of ALUs in the region depth testing section 903. For example, if the region depth testing section 903 includes four ALUs, the tile segmentation section 902 will package the region information and corresponding primitive information of the four regions and send them to the region depth testing section 903 in sequence.
[0157] Please refer to FIG. 11 , which shows a schematic structural diagram of the regional depth testing portion 903 .
[0158] After receiving information about the four regions, the Zrange prefetcher 1101 determines the block index of each region in the Zrange Buffer based on its relative position in the tile (including Offset_x and Offset_y). This index information can be used to retrieve the depth range information of each region from the Zrange Buffer. In some embodiments, the depth range buffer performs a hit-miss test on the depth range buffer based on the index information to detect whether the depth range information corresponding to the region already exists in the depth range buffer. If the depth range information corresponding to the region already exists in the depth range buffer, the information is directly retrieved and returned to the corresponding comparison (Tester) 1103. If the depth range information corresponding to the region does not exist in the depth range buffer, the depth range prefetcher 1101 needs to notify the depth sorting component to retrieve the depth range information corresponding to the region from the depth information buffer (Depth) and then write it into the depth range buffer.
[0159] As shown in FIG11 , the region depth test portion 903 internally includes four independent network arithmetic logic portions 1102 and a comparison portion 1103 .
[0160] The network arithmetic logic part is configured to calculate the coordinate information of the minimum interpolation depth value and the coordinate information of the maximum interpolation depth value, and determine the minimum interpolation depth value (bmin_z) and the maximum interpolation depth value (bmax_z) by interpolation. The comparison part is configured to perform the depth test Ztest and update the depth range buffer.
[0161] Among them, for a region, its depth value should be a range. Since the Z plane changes linearly, the minimum depth value and the maximum depth value of the region must be at the four points of the region boundary. Therefore, the relationship between the minimum depth value and the maximum depth value of the region and the parameters ZA and ZB of the Z plane is shown in Table 1:
[0162] Table 1
[0163] Combining the above table with the coordinate information of the four vertices of the region, the coordinate information of the minimum interpolation depth value and the coordinate information of the maximum interpolation depth value can be determined. After obtaining the coordinate information of the minimum interpolation depth value and the coordinate information of the maximum interpolation depth value, the minimum interpolation depth value and the maximum interpolation depth value of the region can be determined by the equations of the Z plane, such as Formula (5) and Formula (6): bmin_z=ZA*bmin_z.Offset_x+ZB*bmin_z.Offset_y+ZC Formula (5); bmax_z=ZA*bmax_z.Offset_x+ZB*bmax_z.Offset_y+ZC Formula (6);
[0164] Among them, bmin_z is the minimum interpolation depth value, bmax_z is the maximum interpolation depth value, bmin_z.Offset_x and bmin_z.Offset_y are the coordinate information of the minimum interpolation depth value, and bmax_z.Offset_x and bmax_z.Offset_y are the coordinate information of the maximum interpolation depth value.
[0165] The comparison unit is configured to compare the interpolated minimum and maximum interpolated depth values with the minimum and maximum cached depth values retrieved from the depth range buffer to complete the depth test process for the area. The depth test process has three possible outcomes, each of which is described below.
[0166] In some embodiments, when the maximum interpolated depth value is less than or equal to the minimum buffer depth value (bmax_z <= rmin_z), the depth test process obtains a first test result (which can be set to PASS). The area with the first test result will enter the pixel-level early depth test (Early-Ztest), but the Ztest can be reduced to only update the Depth Buffer. This is shown in Figure 12A as a schematic diagram of the depth range comparison.
[0167] In some embodiments, when the minimum interpolation depth value is less than or equal to the minimum cache depth value (bmin_z <= rmin_z), and the minimum cache depth value is less than or equal to the maximum interpolation depth value (rmin_z <= bmax_z), or when the minimum interpolation depth value is less than or equal to the maximum cache depth value (bmin_z <= rmin_z), and the maximum cache depth value is less than or equal to the maximum interpolation depth value (rmin_z <= bmax_z), the depth test process obtains a second test result (which can be set to UNDONE). The area of the second test result performs a pixel-level early depth test (Early-Ztest). As shown in Figures 12B and 12C, a depth range comparison diagram.
[0168] In some embodiments, if the maximum cached depth value is less than or equal to the minimum interpolated depth value (rmax_z <= bmin_z), the depth test process obtains a third test result (which can be set to FAIL). The area with the third test result is immediately eliminated and does not enter the pixel-level early depth test (Early-Z test). Figure 12D shows a schematic diagram of the depth range comparison.
[0169] In some embodiments, the test results of the regional depth test process are output to the rasterization part 905 , the early depth test part 906 and the late depth test part 907 .
[0170] In some embodiments, the depth range buffer may be updated by the comparison part and the depth sorting part. For example, in the following embodiments, the depth range buffer may be updated in the following situations.
[0171] The first case is that the comparison part updates the minimum cache depth value (rmin_z) of the depth range information according to the test results obtained during the depth test process. That is, for the area where the test results are the first test results and the second test results, the minimum interpolation depth value of the area is directly updated to the minimum cache depth value. In this way, the interpolation depth value of the area where the first test result is obtained can be continuously reduced, thereby improving the accuracy of the first test result.
[0172] In the second case, after the depth information cache is assigned to the current tile and initialized, the depth sorting part reads the depth values of all pixels in the area from the depth information cache, then sorts all the depth values to obtain the minimum cache depth value and the maximum cache depth value, and then updates them to the depth range cache.
[0173] The third approach is to further enhance depth testing efficiency by adding a method to the depth sorting component to proactively update the depth range cache. This approach involves writing the final depth value of a primitive to the depth information cache during either the early-Ztest or later-Ztest depth tests. The depth sorting component is then notified to read the depth values of all pixels in that tile from the depth information cache, sort them, and update the depth range cache. This step effectively continuously updates the maximum cached depth value, thereby improving region culling efficiency.
[0174] Based on the above embodiments, the present application takes the early depth test (Early-Ztest) as the theme, and by adding the regional depth test part 903 before the rasterization part 904, on the one hand, the depth test process is fully realized, the efficiency of the early depth test (Early-Ztest) is improved, and the load of the rasterization part 904 and the pixel shading part is reduced. On the other hand, through the update mechanism of the two depth range caches, the depth range cache is made to be more accurately close to the depth information cache, basically realizing the instant update of the depth range cache, improving the efficiency of the depth test, and thus enhancing the rendering performance of the GPU as a whole.
[0175] The embodiment of the present application, through an implementation scheme based on the early depth test under the block rendering architecture, can fully utilize the on-chip depth information cache resources of the TBR architecture to implement regional depth test logic, which can quickly and early eliminate occluded objects without entering the rasterization stage, saving computing resources; at the same time, through a more efficient depth range cache update method, it not only improves the probability of accurate low-precision (coarse) depth testing, but also improves the real-time performance of the depth range cache to a certain extent, thereby improving the efficiency of regional culling; at the same time, the region-based depth test method proposed in the present application is suitable for the TBR architecture, effectively reducing the workload of the pixel shading part, and improving the performance of the existing rasterization pipeline.
[0176] Based on the aforementioned embodiments, an embodiment of the present application provides a region-based depth testing device, which includes various parts and can be implemented by a processor in a computer device; of course, it can also be implemented by a detailed logic circuit.
[0177] FIG13 is a schematic diagram of the structure of a region-based depth testing device provided in an embodiment of the present application. As shown in FIG13 , the region-based depth testing device 1300 includes: a tile segmentation module 1310 and a region depth testing module 1320 , wherein:
[0178] The block segmentation section 1310 is configured to segment the block before performing the rasterization process of the block to obtain a plurality of to-be-tested regions and region data corresponding to each of the to-be-tested regions; the region data includes region information of the to-be-tested regions and primitive information corresponding to the to-be-tested regions;
[0179] The region depth testing part 1320 is configured to generate, for each of the regions to be tested, a first depth range of the region to be tested based on the region information of the region to be tested and the primitive information corresponding to the region to be tested;
[0180] The area depth testing part 1320 is further configured to obtain a second depth range of the area to be tested from a depth range cache;
[0181] The regional depth testing part 1320 is further configured to determine a depth test result of the area to be tested based on the first depth range and the second depth range; the depth test result is used to indicate whether the area to be tested needs to be subjected to pixel-level depth testing.
[0182] In some embodiments, the primitive information includes the depth plane equation of the primitive; the area depth testing part 1320 is further configured to: determine the minimum interpolation depth value and the maximum interpolation depth value in the area to be tested based on the depth plane equation of the primitive and the area information of the area to be tested; and generate a first depth range of the area to be tested based on the minimum interpolation depth value and the maximum interpolation depth value.
[0183] In this embodiment and other embodiments, "part" can be part of a circuit, part of a processor, part of a program or software, etc., and of course it can also be a unit, a module, or a non-modular one.
[0184] In some embodiments, the area depth testing portion 1320 is further configured to: determine a first slope and a second slope based on the depth plane equation of the primitive; the first slope represents the slope of the depth plane of the primitive in a first direction, and the second slope is the slope of the depth plane of the primitive in a second direction, and the first direction, the second direction and the depth direction are perpendicular to each other; determine the coordinate information of the minimum interpolation depth value and the coordinate information of the maximum interpolation depth value based on the first slope, the second slope and the area information; determine the minimum interpolation depth value and the maximum interpolation depth value based on the coordinate information of the minimum interpolation depth value, the coordinate information of the maximum interpolation depth value and the depth plane equation.
[0185] In some embodiments, the area to be tested is determined by a first area vertex, a second area vertex, a third area vertex, and a fourth area vertex, and the area information includes the vertex coordinates of the first area vertex, the vertex coordinates of the second area vertex, the vertex coordinates of the third area vertex, and the vertex coordinates of the fourth area vertex; the area depth testing part 1320 is further configured to: when the first slope is greater than or equal to 0 and the second slope is greater than or equal to 0, use the vertex coordinates of the first area vertex as the coordinate information of the minimum interpolation depth value, and use the vertex coordinates of the third area vertex as the coordinate information of the maximum interpolation depth value; when the first slope is less than 0 and the second slope is less than 0, In this case, the vertex coordinates of the vertices in the third area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices in the first area are used as the coordinate information of the maximum interpolation depth value; in the case that the first slope is greater than or equal to 0 and the second slope is less than 0, the vertex coordinates of the vertices in the second area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices in the fourth area are used as the coordinate information of the maximum interpolation depth value; in the case that the first slope is less than 0 and the second slope is greater than or equal to 0, the vertex coordinates of the vertices in the fourth area are used as the coordinate information of the minimum interpolation depth value, and the vertex coordinates of the vertices in the second area are used as the coordinate information of the maximum interpolation depth value.
[0186] In some embodiments, the area depth testing part 1320 is further configured to: obtain the area position information of the area to be tested in the tile; generate index information of the area to be tested based on the area position information of the area to be tested; and obtain the second depth range of the area to be tested in the depth range cache based on the index information of the area to be tested.
[0187] In some embodiments, the area depth test part 1320 is further configured to: perform a hit test in the depth range cache based on the index information of the area to be tested; obtain the second depth range of the area to be tested when the hit test result of the hit test indicates that the second depth range of the area to be tested exists in the depth range cache; determine the second depth range of the area to be tested from the depth information cache and write it into the depth range cache when the hit test result of the hit test indicates that the second depth range of the area to be tested does not exist in the depth range cache.
[0188] In some embodiments, the tile segmentation part 1310 is further configured to: segment the tile based on a preset area size to obtain multiple initial areas and area information corresponding to each of the initial areas; obtain the graphic element information of the graphic element corresponding to the tile; the graphic element information includes the bounding box information of the graphic element; based on the bounding box information of the graphic element, filter the multiple initial areas to obtain multiple areas to be tested corresponding to the tile and area data of each area to be tested.
[0189] In some embodiments, the area depth test part 1320 is further configured to: generate a first test result when the maximum value of the first depth range is less than the minimum value of the second depth range; the first test result is used to characterize that the area to be tested does not require pixel-level depth testing, and update the depth value of each pixel in the area to be tested in the depth information cache; generate a second test result when there is an intersection between the first depth range and the second depth range; the second test result is used to characterize that the area to be tested requires pixel-level depth testing; generate a third test result when the minimum value of the first depth range is greater than the maximum value of the second depth range; the third test result is used to characterize that the area to be tested needs to be eliminated and does not require pixel-level depth testing.
[0190] In some embodiments, the area depth test part 1320 is further configured to: in response to the depth test result of the area to be tested being the first test result or the second test result, use the minimum interpolation depth value in the first depth range to update the minimum cache depth value in the second depth range of the area to be tested in the depth range cache.
[0191] In some embodiments, the region-based depth testing device also includes a depth sorting part, which is configured to: in response to the depth information cache being assigned to the tile and completing initialization, obtain the depth value of each pixel in each of the initial regions from the depth information cache; based on the depth value of each pixel in each of the initial regions, determine the second depth range corresponding to each of the initial regions; and update the second depth range corresponding to each of the initial regions to the depth range cache.
[0192] In some embodiments, the depth sorting part is further configured to: in response to all the depth values of the primitives being written into the depth information cache during the early depth test and / or the late depth test, read the depth value of each pixel corresponding to the tile from the depth information cache; and update the second depth range corresponding to each of the initial areas in the depth range cache based on the depth value of each pixel corresponding to the tile.
[0193] The description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. In some embodiments, the functions or parts included in the device provided in the embodiments of the present application can be configured to perform the methods described in the above method embodiments. For technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0194] It should be noted that, in the embodiment of the present application, if the above-mentioned area-based depth testing method is implemented in the form of a software function part and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software and firmware.
[0195] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0196] The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the above method. The computer-readable storage medium may be transient or non-transient.
[0197] An embodiment of the present application provides a computer program, including computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.
[0198] An embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, implements some or all of the steps in the above method. The computer program product can be implemented by hardware, software, or a combination thereof. In some embodiments, the computer program product is embodied as a computer storage medium. In other embodiments, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0199] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between the various embodiments, and their similarities or similarities can be referenced to each other. The descriptions of the above device, storage medium, computer program, and computer program product embodiments are similar to the descriptions of the above method embodiments and have similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this application, please refer to the description of the method embodiments of this application for understanding.
[0200] Figure 14 is a schematic diagram of the hardware entity of a computer device provided in an embodiment of the present application. As shown in Figure 14, the hardware entity of the computer device 1400 includes: a processor 1401 and a memory 1402, wherein the memory 1402 stores a computer program that can be run on the processor 1401, and when the processor 1401 executes the program, the steps in the method of any of the above embodiments are implemented.
[0201] The memory 1402 stores computer programs that can be run on the processor. The memory 1402 is configured to store instructions and applications executable by the processor 1401. It can also cache data to be processed or processed by the processor 1401 and various parts of the computer device 1400 (for example, image data, audio data, voice communication data and video communication data). It can be implemented through flash memory (FLASH) or random access memory (RAM).
[0202] When the processor 1401 executes the program, the processor 1401 implements the steps of any of the above-mentioned area-based depth testing methods. The processor 1401 generally controls the overall operation of the computer device 1400.
[0203] An embodiment of the present application provides a computer storage medium storing one or more programs, which can be executed by one or more processors to implement the steps of the region-based depth testing method of any of the above embodiments.
[0204] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0205] The processor may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic device that implements the functions of the processor may also be other electronic devices, which are not specifically limited in the embodiments of the present application.
[0206] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0207] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned steps / processes does not mean the order of execution. The execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The serial numbers of the embodiments of the present application mentioned above are for description and do not represent the advantages and disadvantages of the embodiments.
[0208] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0209] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are schematic. For example, the division of the units is a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0210] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0211] In addition, the functional units in the embodiments of the present application can all be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units. It can be understood by those skilled in the art that all or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions, and the above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiments; and the above-mentioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), magnetic disks or optical disks.
[0212] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0213] The above is merely an embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims. Industrial Applicability
[0214] In this embodiment, since a region-based depth test process is set before executing the rasterization process of the tile, compared with the early depth test process in the related art, the present application can eliminate occluded objects that do not need to be rendered earlier, and there is no need to enter the rasterization stage, thereby saving computing resources of the rasterization part; at the same time, by setting a depth range cache and storing the second depth range of each area in the tile through the depth range cache, the second depth range of the area to be tested can be directly obtained from the depth range cache, thereby improving the overall rendering efficiency.
Claims
1. A region-based depth testing method, the method comprising: Before executing the rasterization process of the image block, the image block is segmented to obtain a plurality of to-be-tested regions and region data corresponding to each of the to-be-tested regions; The area data includes area information of the area to be tested and primitive information corresponding to the area to be tested; For each of the to-be-tested areas, generating a first depth range of the to-be-tested area based on area information of the to-be-tested area and primitive information corresponding to the to-be-tested area; Acquire a second depth range of the area to be tested from a depth range cache; Determining a depth test result of the area to be tested based on the first depth range and the second depth range; The depth test result is used to indicate whether the area to be tested needs to be subjected to a pixel-level depth test.
2. The method according to claim 1, wherein: The primitive information includes a depth plane equation of the primitive; The step of generating a first depth range of the area to be tested based on the area information of the area to be tested and the primitive information corresponding to the area to be tested includes: Determining a minimum interpolation depth value and a maximum interpolation depth value in the area to be tested based on the depth plane equation of the primitive and the area information of the area to be tested; Based on the minimum interpolation depth value and the maximum interpolation depth value, a first depth range of the area to be tested is generated.
3. The method according to claim 2, wherein: The determining, based on the depth plane equation of the primitive and the area information of the area to be tested, the minimum interpolation depth value and the maximum interpolation depth value in the area to be tested comprises: Based on the depth plane equation of the primitive, determine a first slope and a second slope; the first slope represents the slope of the depth plane of the primitive in a first direction, the second slope represents the slope of the depth plane of the primitive in a second direction, and the first direction, the second direction and the depth direction are perpendicular to each other; Determine coordinate information of a minimum interpolation depth value and coordinate information of a maximum interpolation depth value based on the first slope, the second slope, and the area information; Based on the coordinate information of the minimum interpolation depth value, the coordinate information of the maximum interpolation depth value, and the depth plane equation, a minimum interpolation depth value and a maximum interpolation depth value are determined.
4. The method according to claim 1, wherein: The acquiring the second depth range of the area to be tested from the depth range cache comprises: Obtaining the area position information of the area to be tested in the image block; generating index information of the area to be tested based on the area location information of the area to be tested; A second depth range of the area to be tested is obtained in the depth range cache based on the index information of the area to be tested.
5. The method according to claim 4, wherein: The acquiring, in the depth range cache, a second depth range of the area to be tested based on the index information of the area to be tested comprises: Based on the index information of the area to be tested, performing a hit test in the depth range buffer; In a case where a hit test result of the hit test indicates that a second depth range of the area to be tested exists in the depth range cache, acquiring the second depth range of the area to be tested; When the hit test result of the hit test indicates that the second depth range of the area to be tested does not exist in the depth range cache, the second depth range of the area to be tested is determined from the depth information cache and written into the depth range cache.
6. The method according to claim 1, wherein: The step of segmenting the image block to obtain a plurality of to-be-tested areas and area data corresponding to each of the to-be-tested areas includes: Segmenting the image block based on a preset region size to obtain a plurality of initial regions and region information corresponding to each of the initial regions; Acquire the primitive information of the primitive corresponding to the block; the primitive information includes the bounding box information of the primitive; Based on the bounding box information of the primitive, the multiple initial regions are screened to obtain multiple to-be-tested regions corresponding to the image block and region data of each of the to-be-tested regions.
7. The method according to claim 1, wherein: The step of determining a depth test result of the area to be tested based on the first depth range and the second depth range includes: When the maximum value of the first depth range is less than the minimum value of the second depth range, a first test result is generated; the first test result is used to indicate that the area to be tested does not need to be subjected to a pixel-level depth test, and the depth value of each pixel in the area to be tested in the depth information cache is updated; In the case where the first depth range and the second depth range have an intersection, a second test result is generated; the second test result is used to indicate that the area to be tested needs to be subjected to a pixel-level depth test; When the minimum value of the first depth range is greater than the maximum value of the second depth range, a third test result is generated; the third test result is used to indicate that the area to be tested needs to be eliminated and no pixel-level depth test is required.
8. The method according to claim 7, wherein: The method further comprises: In response to the depth test result of the area to be tested being the first test result or the second test result, a minimum cached depth value in a second depth range of the area to be tested is updated in the depth range cache using a minimum interpolated depth value in the first depth range.
9. The method according to any one of claims 1 to 8, wherein: The method further comprises: In response to the depth information buffer being allocated to the tile and completing initialization, obtaining a depth value of each pixel in each initial area from the depth information buffer; Determine a second depth range corresponding to each of the initial regions based on a depth value of each pixel in each of the initial regions; The second depth range corresponding to each of the initial areas is updated to the depth range buffer.
10. The method according to any one of claims 1 to 8, wherein: The method further comprises: In the early depth test and / or the late depth test process, in response to all the depth values of the primitives being written into the depth information cache, the depth value of each pixel corresponding to the tile is read from the depth information cache; Based on the depth value of each pixel corresponding to the tile, a second depth range corresponding to each initial area in the depth range buffer is updated.
11. A region-based depth testing device, the device comprising: The image block segmentation part is configured to segment the image block before executing the rasterization process of the image block to obtain a plurality of to-be-tested areas and area data corresponding to each of the to-be-tested areas; the area data includes area information of the to-be-tested area and image element information corresponding to the to-be-tested area; A regional depth testing part is configured to generate, for each of the regions to be tested, a first depth range of the region to be tested based on the region information of the region to be tested and the primitive information corresponding to the region to be tested; The area depth testing part is further configured to obtain a second depth range of the area to be tested from a depth range cache; The area depth testing section is further configured to determine a depth test result of the area to be tested based on the first depth range and the second depth range; The depth test result is used to indicate whether the area to be tested needs to be subjected to a pixel-level depth test.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 10 when executing the program.
13. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 10.
14. A computer program product, comprising a computer program or instructions, wherein when the computer program or instructions are executed by a processor, the steps in the method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Tessellating Patches Of Surface Data In Tile Based Computer Graphics Rendering
CN103886633A
Pre-testing circuit for depth value of graphics processor
CN107993184A
Merging unit, method for selecting coverage area merging scheme and depth test system
CN112116518A
Coarse depth test in graphics processing systems
CN112116519A
Region-based depth testing method and device, equipment and storage medium
CN116188552A
