CN117203661A - Image processing apparatus and method - Google Patents
Image processing apparatus and method Download PDFInfo
- Publication number
- CN117203661A CN117203661A CN202180096777.0A CN202180096777A CN117203661A CN 117203661 A CN117203661 A CN 117203661A CN 202180096777 A CN202180096777 A CN 202180096777A CN 117203661 A CN117203661 A CN 117203661A
- Authority
- CN
- China
- Prior art keywords
- depth
- rendered
- pixel block
- depth value
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/20—Processor architectures; Processor configuration, e.g. pipelining
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Generation (AREA)
Abstract
Description
本申请涉及计算机技术领域,尤其涉及图像处理装置和方法。The present application relates to the field of computer technology, and in particular to image processing devices and methods.
渲染是将三维场景中的模型,按照设定好的环境、灯光、材质及渲染参数进行二维投影得到数字图像的过程。但在渲染过程中图形处理器(graphics processing unit,GPU)会消耗大量计算资源。为此,GPU可以在渲染阶段剔除不影响渲染结果的待渲染数据,以降低计算资源消耗量。Rendering is the process of two-dimensional projection of a model in a three-dimensional scene according to the set environment, lighting, materials and rendering parameters to obtain a digital image. However, during the rendering process, the graphics processing unit (GPU) consumes a large amount of computing resources. To this end, the GPU can eliminate data to be rendered that does not affect the rendering results during the rendering phase to reduce computing resource consumption.
然而在相关技术中,GPU仅能在渲染阶段剔除少量不影响渲染结果的待渲染数据,无法达到很高的剔除率。However, in related technologies, the GPU can only eliminate a small amount of data to be rendered that does not affect the rendering result during the rendering stage, and cannot achieve a high elimination rate.
发明内容Contents of the invention
本申请提供图像处理装置和方法,能够提升对待渲染数据的剔除率,从而降低计算资源消耗量并提升渲染速度。This application provides an image processing device and method that can improve the rejection rate of data to be rendered, thereby reducing computing resource consumption and increasing rendering speed.
第一方面,本申请提供了一种图像处理装置,该装置包括渲染管线,所述渲染管线中设置有第一光栅化器和第一深度测试模块。第一光栅化器,用于将输入所述渲染管线的图元转换为待渲染片段。第一深度测试模块,用于根据全局深度信息对所述待渲染片段进行第一深度测试,若所述待渲染片段未通过所述第一深度测试,则剔除所述待渲染片段,所述全局深度信息包括根据全部待渲染图元更新得到的多个像素块的深度信息。In a first aspect, this application provides an image processing device, which includes a rendering pipeline in which a first rasterizer and a first depth testing module are disposed. The first rasterizer is used to convert primitives input into the rendering pipeline into fragments to be rendered. A first depth test module, configured to perform a first depth test on the fragment to be rendered based on global depth information. If the fragment to be rendered fails the first depth test, the fragment to be rendered is eliminated. The global The depth information includes depth information of multiple pixel blocks updated based on all primitives to be rendered.
可以看出,本申请提供的图像处理装置可以通过全局深度信息对待渲染片段进行剔除,由于全局深度信息是根据全部待渲染图元确定,而待渲染片段是由待渲染图元转换得到的,所以全局深度信息相当于是根据所有待渲染片段生成的。本申请实施例利用全部待渲染片段的深度信息进行片段剔除,相较于相关技术仅通过部分待渲染片段的深度信息进行片段剔除,本申请提供的方法能够提升对待渲染数据的剔除率,从而降低计算资源消耗量,以提升GPU的渲染速度。It can be seen that the image processing device provided by this application can eliminate the fragments to be rendered through the global depth information. Since the global depth information is determined based on all the primitives to be rendered, and the fragments to be rendered are converted from the primitives to be rendered, so Global depth information is equivalent to being generated based on all fragments to be rendered. The embodiment of the present application uses the depth information of all the fragments to be rendered to perform fragment elimination. Compared with the related technology, which only uses the depth information of some of the fragments to be rendered to perform fragment elimination, the method provided by the application can improve the elimination rate of the data to be rendered, thereby reducing the Calculate resource consumption to increase GPU rendering speed.
在一种可能的实现方式中,第一深度测试模块具体用于:根据所述全局信息中目标像素块的深度信息和所述待渲染片段的深度信息对所述待渲染片段进行所述第一深度测试,所述目标像素块为所述多个像素块中与所述待渲染片段存在重叠的像素块。In a possible implementation, the first depth testing module is specifically configured to perform the first step on the fragment to be rendered according to the depth information of the target pixel block in the global information and the depth information of the fragment to be rendered. For depth testing, the target pixel block is a pixel block among the plurality of pixel blocks that overlaps with the segment to be rendered.
在一种可能的实现方式中,第一深度测试模块具体用于:在所述待渲染片段的深度值大于所述目标像素块的深度值的情况下,确定所述待渲染片段未通过第一深度测试。In a possible implementation, the first depth testing module is specifically configured to: when the depth value of the fragment to be rendered is greater than the depth value of the target pixel block, determine that the fragment to be rendered has not passed the first depth test module. Deep testing.
由于目标像素块和待渲染片段存在重叠,所以待渲染片段会在目标像素块上渲染。通过全局信息中目标像素块的深度信息和所述待渲染片段的深度信息,可以在待渲染片段的深度值大于目标像素块的深度值的情况下判断待渲染片段会被目标像素块上的可见片段所遮挡。Since the target pixel block and the fragment to be rendered overlap, the fragment to be rendered will be rendered on the target pixel block. Through the depth information of the target pixel block in the global information and the depth information of the fragment to be rendered, it can be determined that the fragment to be rendered will be visible on the target pixel block when the depth value of the fragment to be rendered is greater than the depth value of the target pixel block. blocked by the fragment.
可选地,像素块(如目标像素块)可以包括目标区域。像素块的深度信息可以包括像素块的目标区域的最大深度值、像素块的非目标区域的最大深度值和像素块的目标区域的范围。Alternatively, a block of pixels (such as a target block of pixels) may include a target area. The depth information of the pixel block may include the maximum depth value of the target area of the pixel block, the maximum depth value of the non-target area of the pixel block, and the range of the target area of the pixel block.
可选地,片段(如待渲染片段)的深度信息可以包括片段的深度值。其中,片段的深度值可以是通过插值得到的。Optionally, the depth information of a fragment (eg, a fragment to be rendered) may include a depth value of the fragment. Among them, the depth value of the fragment can be obtained through interpolation.
在一种可能的实现方式中,所述目标像素块包括目标区域,所述目标像素块的深度值包括第一深度值和第二深度值,所述第一深度测试模块具体用于:In a possible implementation, the target pixel block includes a target area, the depth value of the target pixel block includes a first depth value and a second depth value, and the first depth testing module is specifically used to:
在待渲染片段位于目标像素块的目标区域且待渲染片段的深度值小于或等于第一深度值的情况下,确定待渲染片段通过第一深度测试。When the segment to be rendered is located in the target area of the target pixel block and the depth value of the segment to be rendered is less than or equal to the first depth value, it is determined that the segment to be rendered passes the first depth test.
在待渲染片段位于目标像素块的目标区域且待渲染片段的深度值大于第一深度值的情况下,确定待渲染片段未通过第一深度测试。When the fragment to be rendered is located in the target area of the target pixel block and the depth value of the fragment to be rendered is greater than the first depth value, it is determined that the fragment to be rendered fails the first depth test.
在待渲染片段位于目标像素块的非目标区域且待渲染片段的深度值小于或等于第二深度值的情况下,确定待渲染片段通过第一深度测试。When the fragment to be rendered is located in a non-target area of the target pixel block and the depth value of the fragment to be rendered is less than or equal to the second depth value, it is determined that the fragment to be rendered passes the first depth test.
在待渲染片段位于目标像素块的非目标区域且待渲染片段的深度值大于第二深度值的情况下,确定待渲染片段未通过第一深度测试。When the fragment to be rendered is located in a non-target area of the target pixel block and the depth value of the fragment to be rendered is greater than the second depth value, it is determined that the fragment to be rendered fails the first depth test.
需要说明的是,待渲染片段位于目标像素块的目标区域且待渲染片段的深度值大于第一深度值,说明该待渲染片段会被目标像素块的目标区域内的可见片段所遮挡,所以可以将该待渲染片段剔除,以降低计算资源消耗量,提升GPU的渲染速度。It should be noted that the fragment to be rendered is located in the target area of the target pixel block and the depth value of the fragment to be rendered is greater than the first depth value, indicating that the fragment to be rendered will be occluded by the visible fragments in the target area of the target pixel block, so it can Eliminate the fragment to be rendered to reduce the consumption of computing resources and increase the rendering speed of the GPU.
待渲染片段位于非目标像素块的目标区域且待渲染片段的深度值大于第二深度值,说明该待渲染片段会被目标像素块的非目标区域内的可见片段所遮挡,所以可以将该待渲染片段剔除,以降低计算资源消耗量,提升GPU的渲染速度。The fragment to be rendered is located in the target area of the non-target pixel block and the depth value of the fragment to be rendered is greater than the second depth value, indicating that the fragment to be rendered will be obscured by the visible fragments in the non-target area of the target pixel block, so the fragment to be rendered can be Eliminate rendering fragments to reduce computing resource consumption and increase GPU rendering speed.
可以理解的是,相较于仅通过目标像素块的深度值对待渲染片段进行深度测试,将目标像素块分为目标区域和非目标区域并分别通过这两个区域上的最大深度值对待渲染片段进行深度测试,可以增加深度测试的准确性,降低错误剔除的概率。It can be understood that, instead of only performing a depth test on the fragment to be rendered by the depth value of the target pixel block, the target pixel block is divided into a target area and a non-target area and the maximum depth value in these two areas is used to test the fragment to be rendered. Conducting depth testing can increase the accuracy of depth testing and reduce the probability of false rejections.
在一种可能的实现方式中,该装置还可以包括第一缓存模块,所述第一缓存模块用于缓存所述全局深度信息。In a possible implementation, the device may further include a first cache module configured to cache the global depth information.
在一种可能的实现方式中,该装置还可以包括分区管线,所述分区管线中设置有第二光栅化器和第二深度测试模块。第二光栅化器,用于将输入所述分区管道的待渲染图元投射至多个像素块生成多个投射区域。第二深度模块,用于根据所述多个投射区域对所述待渲染图元进行第二深度测试,若所述待渲染图元未通过所述第二深度测试,则剔除所述待渲染图元。其中,所述多个投射区域与所述多个像素块一一对应。In a possible implementation, the device may further include a partition pipeline, in which a second rasterizer and a second depth test module are disposed. The second rasterizer is used to project the primitives to be rendered input into the partition pipeline to multiple pixel blocks to generate multiple projection areas. A second depth module, configured to perform a second depth test on the primitive to be rendered according to the plurality of projection areas, and if the primitive to be rendered fails the second depth test, eliminate the graphic to be rendered. Yuan. Wherein, the plurality of projection areas correspond to the plurality of pixel blocks on a one-to-one basis.
可以看出,本申请提供的装置不仅可以剔除无需渲染的待渲染片段,还可以剔除无需渲染的待渲染图元,相较于仅对无需渲染的待渲染片段进行剔除,本申请还对无需渲染的待渲染图元进行剔除,从而进一步提升对待渲染数据的剔除率,进一步降低计算资源消耗量,以进一步提升GPU的渲染速度。It can be seen that the device provided by this application can not only eliminate the fragments to be rendered that do not need to be rendered, but also eliminate the elements to be rendered that do not need to be rendered. Compared with only eliminating the fragments to be rendered that do not need to be rendered, this application can also eliminate the fragments that do not need to be rendered. The primitives to be rendered are eliminated, thereby further improving the elimination rate of the data to be rendered, further reducing the consumption of computing resources, and further improving the rendering speed of the GPU.
在一种可能的实现方式中,第二深度模块具体用于:根据第一像素块的深度信息和第一投射区域的深度信息确定所述待渲染图元在所述第一像素块中是否通过深度测试,所述第一像素块为所述多个像素块中的任一像素块,所述第一投射区域为所述第一像素块对应的投射区域。若所述待渲染图元在所述第一像素块中通过深度测试,则确定所述待渲染图 元通过所述第二深度测试;若所述待渲染图元在所述多个像素块中均未通过深度测试,则确定所述待渲染图元未通过所述第二深度测试。In a possible implementation, the second depth module is specifically configured to: determine whether the primitive to be rendered passes in the first pixel block according to the depth information of the first pixel block and the depth information of the first projection area. For depth testing, the first pixel block is any pixel block among the plurality of pixel blocks, and the first projection area is the projection area corresponding to the first pixel block. If the primitive to be rendered passes the depth test in the first pixel block, it is determined that the primitive to be rendered passes the second depth test; if the primitive to be rendered is in the plurality of pixel blocks If both of them fail the depth test, it is determined that the primitive to be rendered fails the second depth test.
在一种可能的实现方式中,第二深度模块具体用于:在所述第一投射区域的最小深度值小于所述第一像素块的深度值的情况下,确定所述待渲染图元在所述第一像素块中通过所述深度测试。In a possible implementation, the second depth module is specifically configured to: when the minimum depth value of the first projection area is less than the depth value of the first pixel block, determine where the primitive to be rendered is located. The first pixel block passes the depth test.
可选地,投射区域(如第一投射区域)的深度信息可以包括投射区域的最大深度值、投射区域的最小深度值和投射区域的范围。Optionally, the depth information of the projection area (such as the first projection area) may include a maximum depth value of the projection area, a minimum depth value of the projection area, and a range of the projection area.
在一种可能的实现方式中,所述第一像素块包括目标区域,所述第一像素块的深度值包括所述第一像素块的目标区域的最大深度值和所述第一像素块的非目标区域的最大深度值,第二深度模块具体用于:In a possible implementation, the first pixel block includes a target area, and the depth value of the first pixel block includes a maximum depth value of the target area of the first pixel block and a depth value of the first pixel block. The maximum depth value of the non-target area. The second depth module is specifically used for:
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值小于第一深度值或第二深度值,则确定待渲染图元在第一像素块中通过测试。When both the target area and the non-target area of the first projection area overlap with the first pixel block and the minimum depth value of the first projection area is less than the first depth value or the second depth value, it is determined that the primitive to be rendered is in the first pixel The block passes the test.
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值大于第一深度值和第二深度值的情况下,确定待渲染图元在第一像素块中未通过测试In the case where the first projection area overlaps with both the target area and the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value and the second depth value, it is determined that the primitive to be rendered is in the first Failed test in one pixel block
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值小于第一深度值的情况下,确定待渲染图元在第一像素块中通过测试。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, it is determined that the primitive to be rendered passes the test in the first pixel block.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,确定待渲染图元在第一像素块中未通过测试。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, it is determined that the primitive to be rendered fails the test in the first pixel block.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,确定待渲染图元在第一像素块中通过测试。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, it is determined that the primitive to be rendered passes the test in the first pixel block.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值的情况下,确定待渲染图元在第一像素块中未通过测试。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, it is determined that the primitive to be rendered fails the test in the first pixel block.
在一种可能的实现方式中,所述第二深度模块还用于根据所述多个投射区域更新所述全局深度信息。In a possible implementation, the second depth module is also configured to update the global depth information according to the multiple projection areas.
在一种可能的实现方式中,所述第二深度模块还具体用于:根据第一像素块的深度信息和第一投射区域的深度信息更新所述全局深度信息中所述第一像素块的深度信息,所述第一像素块为所述多个像素块中的任一像素块,所述第一投射区域为所述第一像素块对应的投射区域。In a possible implementation, the second depth module is further specifically configured to: update the depth information of the first pixel block in the global depth information according to the depth information of the first pixel block and the depth information of the first projection area. Depth information, the first pixel block is any pixel block among the plurality of pixel blocks, and the first projection area is the projection area corresponding to the first pixel block.
在一种可能的实现方式中,所述第一像素块包括目标区域,所述第二深度模块还具体用于:根据所述第一投射区域的最大深度值、所述第一像素块的目标区域的最大深度值、所述第一像素块的非目标区域的最大深度值,更新所述第一像素块的深度信息。In a possible implementation, the first pixel block includes a target area, and the second depth module is further specifically configured to: based on the maximum depth value of the first projection area, the target of the first pixel block The maximum depth value of the area, the maximum depth value of the non-target area of the first pixel block, and the depth information of the first pixel block are updated.
在一种可能的实现方式中,所述第二深度模块还具体用于:In a possible implementation, the second depth module is also specifically used to:
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值小于第一深度值或第二深度值的情况下,更新第一像素块的深度信息。When the first projection area overlaps with both the target area and the non-target area of the first pixel block and the maximum depth value of the first projection area is less than the first depth value or the second depth value, update the depth of the first pixel block. information.
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值大于第一深度值和第二深度值的情况下,不更新第一像素块的深度信息。In the case where the first projection area overlaps with both the target area and the non-target area of the first pixel block and the maximum depth value of the first projection area is greater than the first depth value and the second depth value, the first pixel block is not updated. depth information.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值 小于第一深度值的情况下,更新第一像素块的深度信息。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, the depth information of the first pixel block is updated.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,不更新第一像素块的深度信息。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, the depth information of the first pixel block is not updated.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,更新第一像素块的深度信息。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, the depth information of the first pixel block is updated.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值的情况下,不更新第一像素块的深度信息。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, the depth information of the first pixel block is not updated.
在一种可能的实现方式中,所述第二深度模块还具体用于:In a possible implementation, the second depth module is also specifically used to:
在第一投射区域与第一像素块的目标区域完全重合且第三深度值(即投射区域的最大深度值)小于第一深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更新为第三深度值。When the first projection area completely coincides with the target area of the first pixel block and the third depth value (ie, the maximum depth value of the projection area) is less than the first depth value, the target area of the first pixel block is updated to the target projection. area and update the first depth value of the first pixel block to the third depth value.
在第一投射区域与第一像素块的非目标区域完全重合且第三深度值小于第二深度值的情况下,将第一像素块的目标区域更新为非目标投射区域且将第一像素块的第二深度值更新为第三深度值。When the first projection area completely coincides with the non-target area of the first pixel block and the third depth value is less than the second depth value, the target area of the first pixel block is updated to the non-target projection area and the first pixel block is The second depth value is updated to the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第二条件的情况下,将第一像素块的目标区域更新为第一区域且将第一像素块的第一深度值更新为第一数值。其中,上述第一条件为第三深度值小于第一深度值但大于第二深度值或第三深度值小于第二深度值但大于第一深度值。上述第二条件为第一绝对值小于第二绝对值,上述第一绝对值为上述第一深度值与上述第三深度值之差的绝对值,上述第二绝对值为上述第二深度值与上述第三深度值之差的绝对值。上述第一区域为目标区域与目标投射区域的并集区域,第一数值为第一深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the second condition are met, the target area of the first pixel block is updated to the first area and the third The first depth value of a pixel block is updated to a first numerical value. Wherein, the above-mentioned first condition is that the third depth value is smaller than the first depth value but larger than the second depth value or the third depth value is smaller than the second depth value but larger than the first depth value. The second condition is that the first absolute value is less than the second absolute value. The first absolute value is the absolute value of the difference between the first depth value and the third depth value. The second absolute value is the difference between the second depth value and the third depth value. The absolute value of the difference between the above third depth values. The above-mentioned first area is the union area of the target area and the target projection area, and the first value is the larger value between the first depth value and the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第三条件的情况下,将第一像素块的目标区域更新为第二区域且将第一像素块的第二深度值更新为第二数值。其中,上述第三条件为第一绝对值大于第二绝对值。上述第二区域为目标区域与非目标投射区域的交集区域。上述第二数值为第二深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the third condition are met, the target area of the first pixel block is updated to the second area and the third The second depth value of a pixel block is updated to a second value. Wherein, the above third condition is that the first absolute value is greater than the second absolute value. The above-mentioned second area is the intersection area of the target area and the non-target projection area. The above-mentioned second value is the larger value between the second depth value and the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且第三深度值小于第一深度值和第二深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更为第三深度值,将第一像素块的第二深度值更新为第三数值。其中,第三数值为第一深度值与第二深度值之间的较大值。In the case that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the third depth value is smaller than the first depth value and the second depth value, the target area of the first pixel block is updated as The target projection area is to change the first depth value of the first pixel block to a third depth value, and update the second depth value of the first pixel block to a third value. The third value is the larger value between the first depth value and the second depth value.
可选地,目标投射区域(CurMask)包括第一目标投射区域(即CurMask0)和第二目标投射区域(即CurMask0)Optionally, the target projection area (CurMask) includes a first target projection area (ie CurMask0) and a second target projection area (ie CurMask0)
在投射区域的第三深度值小于像素块的第二深度值的情况下,第一目标投射区域(即CurMask0)可以表示投射区域与像素块的非目标区域的重叠区域。In the case where the third depth value of the projection area is smaller than the second depth value of the pixel block, the first target projection area (ie CurMask0) may represent an overlapping area of the projection area and the non-target area of the pixel block.
在投射区域的第三深度值小于像素块的第一深度值的情况下,第二目标投射区域(即CurMask0)可以表示投射区域与像素块的目标区域的重叠区域。In the case where the third depth value of the projection area is smaller than the first depth value of the pixel block, the second target projection area (ie, CurMask0) may represent an overlapping area of the projection area and the target area of the pixel block.
目标投射区域(CurMask)可以为第一目标投射区域(CurMask0)和第二目标投射区域(CurMask0)的并集。The target projection area (CurMask) may be the union of the first target projection area (CurMask0) and the second target projection area (CurMask0).
在一种可能的实现方式中,图像处理装置的渲染管线还可以设置有前深度测试模块、 像素着色器、后深度测试模块或深度缓存模块中的至少一项。前深度测试模块,用于根据所述深度缓存模块中的深度值对第一目标片段进行前深度测试。像素着色器用于对第二目标片段进行着色渲染。后深度测试模块,用于根据所述深度缓存模块中的深度值对第三目标片段进行后深度测试。深度缓存模块,用于缓存深度值。所述第一目标片段为通过第一深度测试的片段,所述第二目标片段为通过前深度测试的片段,所述第三目标片段为经过像素着色器着色渲染后的片段。In a possible implementation, the rendering pipeline of the image processing device may also be provided with at least one of a front depth testing module, a pixel shader, a post depth testing module, or a depth cache module. A front depth test module, configured to perform a front depth test on the first target fragment according to the depth value in the depth cache module. The pixel shader is used to shade the second target fragment. A post-depth test module, configured to perform a post-depth test on the third target fragment according to the depth value in the depth cache module. Depth cache module, used to cache depth values. The first target fragment is a fragment that passes the first depth test, the second target fragment is a fragment that passes a previous depth test, and the third target fragment is a fragment that is rendered by a pixel shader.
第二方面,本申请还提供了另一种图像处理装置,该装置包括渲染管线,所述渲染管线中设置有光栅化器、渲染粗粒度深度测试模块、前深度测试模块、像素着色器、深度缓存模块和后深度测试模块。所述光栅化器,用于将输入所述渲染管线的图元转换为待渲染片段;所述渲染粗粒度深度测试模块,用于对所述待渲染片段进行第一深度测试;所述前深度测试模块,用于根据所述深度缓存模块中的深度值对第一目标片段进行前深度测试;所述像素着色器用于对所述第二目标片段进行着色渲染;所述后深度测试模块,用于根据所述深度缓存模块中的深度值对所述第三目标片段进行后深度测试;所述深度缓存模块,用于缓存深度值。所述第一目标片段为通过第一深度测试的片段,所述第二目标片段为通过前深度测试的片段,所述第三目标片段为经过像素着色器着色渲染后的片段。In a second aspect, this application also provides another image processing device, which includes a rendering pipeline, which is provided with a rasterizer, a rendering coarse-grained depth test module, a front-depth test module, a pixel shader, a depth test module, and a depth test module. Cache module and post-depth test module. The rasterizer is used to convert graphics elements input into the rendering pipeline into fragments to be rendered; the rendering coarse-grained depth test module is used to perform a first depth test on the fragments to be rendered; the front depth The test module is used to perform a front depth test on the first target fragment according to the depth value in the depth cache module; the pixel shader is used to perform color rendering on the second target fragment; the back depth test module is used Perform a post-depth test on the third target fragment according to the depth value in the depth cache module; the depth cache module is used to cache the depth value. The first target fragment is a fragment that passes the first depth test, the second target fragment is a fragment that passes a previous depth test, and the third target fragment is a fragment that is rendered by a pixel shader.
相较于相关技术仅在渲染管线中设置前深度测试模块和后深度测试模块对片段进行剔除。本申请提供的图像处理装置的渲染管线中不仅设置前深度测试模块和后深度测试模块,还设置有渲染粗粒度深度测试模块。通过渲染粗粒度深度测试模块、前深度测试模块和后深度测试模共同对片段进行深度测试,可以能够提升对待渲染数据的剔除率,从而降低计算资源消耗量,以提升GPU的渲染速度。Compared with related technologies, only a pre-depth test module and a post-depth test module are set up in the rendering pipeline to eliminate fragments. The rendering pipeline of the image processing device provided by this application is not only provided with a front depth test module and a post depth test module, but is also provided with a rendering coarse-grained depth test module. By rendering the coarse-grained depth test module, the front depth test module and the post-depth test module together to perform depth tests on the fragments, the rejection rate of the data to be rendered can be improved, thereby reducing the consumption of computing resources and improving the rendering speed of the GPU.
在一种可能的实现方式中,所述渲染粗粒度深度测试模块具体用于:根据全局信息中目标像素块的深度信息和所述待渲染片段的深度信息对所述待渲染片段进行所述第一深度测试,所述目标像素块为所述多个像素块中与所述待渲染片段存在重叠的像素块,所述全局深度信息包括根据全部待渲染图元更新得到的多个像素块的深度信息。In a possible implementation, the rendering coarse-grained depth testing module is specifically configured to perform the first step on the segment to be rendered based on the depth information of the target pixel block in the global information and the depth information of the segment to be rendered. A depth test, the target pixel block is a pixel block among the plurality of pixel blocks that overlaps with the segment to be rendered, and the global depth information includes the depth of the plurality of pixel blocks updated based on all primitives to be rendered. information.
在一种可能的实现方式中,所述装置还包括粗粒度深度缓存模块,所述粗粒度深度缓存模块用于缓存所述全局深度信息。In a possible implementation, the device further includes a coarse-grained depth cache module configured to cache the global depth information.
在一种可能的实现方式中,所述装置还包括分区管线,所述分区管线设置有粗粒度光栅化器和分区粗粒度深度测试模块;所述粗粒度光栅化器,用于将输入所述分区管道的待渲染图元投射至多个像素块生成多个投射区域,所述多个投射区域与所述多个像素块一一对应;所述分区粗粒度深度测试模块,用于根据所述多个投射区域对所述待渲染图元进行第二深度测试。In a possible implementation, the device further includes a partition pipeline, which is provided with a coarse-grained rasterizer and a partitioned coarse-grained depth testing module; the coarse-grained rasterizer is used to convert the input into the The primitives to be rendered in the partition pipeline are projected to multiple pixel blocks to generate multiple projection areas, and the multiple projection areas correspond to the multiple pixel blocks one-to-one; the partition coarse-grained depth test module is used to generate multiple projection areas according to the multiple pixel blocks. A projection area is used to perform a second depth test on the primitive to be rendered.
在一种可能的实现方式中,所述分区粗粒度深度测试模块还用于:根据所述多个投射区域更新全局深度信息,所述全局深度信息包括根据全部待渲染图元更新得到的多个像素块的深度信息。In a possible implementation, the partitioned coarse-grained depth testing module is also configured to update global depth information based on the multiple projection areas, where the global depth information includes multiple depth information updated based on all primitives to be rendered. Depth information for pixel blocks.
用户可以在片段按深度值由小到大的顺序输入渲染管线的场景,关闭渲染管线中的渲染粗粒度深度测试模块,以减少渲染过程的数据处理量。Users can input the scene of the rendering pipeline in order of depth value from small to large in the fragment, and turn off the rendering coarse-grained depth test module in the rendering pipeline to reduce the amount of data processing in the rendering process.
用户可以在不涉及深度的场景(如平面场景、二维场景等)关闭渲染管线中的全部深度测试模块(即渲染粗粒度深度测试模块、前深度测试模块和后深度测试模块)使待渲染数据直接进入像素着色器进行着色渲染,以减少渲染过程的数据处理量。Users can turn off all depth testing modules in the rendering pipeline (i.e. rendering coarse-grained depth testing module, pre-depth testing module and post-depth testing module) in scenes that do not involve depth (such as plane scenes, 2D scenes, etc.) to make the data to be rendered Directly enter the pixel shader for shading rendering to reduce the amount of data processing during the rendering process.
用户可以在片段的深度值不受像素着色器影响(即片段的深度值在像素着色器着色渲染前后不会发生变化)的场景,关闭后深度测试模块,以减少渲染过程的数据处理量。Users can turn off the post-depth test module in scenes where the depth value of the fragment is not affected by the pixel shader (that is, the depth value of the fragment does not change before and after pixel shader rendering) to reduce the amount of data processing in the rendering process.
用户可以在片段的深度值受像素着色器影响(即片段的深度值在像素着色器着色渲染前后会发生变化)且片段的深度值变化方向不固定的场景(例如,部分片段的深度值在作色渲染后增大,另一部分片段的深度值在着色渲染后减少),关闭前深度测试模块,以减少渲染过程的数据处理量。Users can use this method in a scene where the depth value of a fragment is affected by the pixel shader (that is, the depth value of the fragment will change before and after the pixel shader is rendered) and the direction of change of the depth value of the fragment is not fixed (for example, the depth value of some fragments is changing during operation). The depth value of another part of the fragment increases after color rendering, and the depth value of another part of the fragment decreases after color rendering). Turn off the front depth test module to reduce the amount of data processing in the rendering process.
第三方面,本申请还提供了一种图像处理方法,该方法包括:首先将输入渲染管线的图元转换为待渲染片段。然后根据全局深度信息对所述待渲染片段进行第一深度测试,之后若所述待渲染片段未通过所述第一深度测试,则剔除所述待渲染片段。其中,所述全局深度信息包括根据全部待渲染图元更新得到的多个像素块的深度信息。In a third aspect, this application also provides an image processing method, which method includes: first converting primitives input into the rendering pipeline into fragments to be rendered. Then, a first depth test is performed on the segment to be rendered according to the global depth information, and then if the segment to be rendered fails the first depth test, the segment to be rendered is eliminated. Wherein, the global depth information includes depth information of multiple pixel blocks updated based on all primitives to be rendered.
在一种可能的实现方式中,所述全局深度信息包括多个像素块的深度信息,所述根据全局深度信息对所述待渲染片段进行第一深度测试,包括:根据目标像素块的深度信息和所述待渲染片段的深度信息对所述待渲染片段进行所述第一深度测试,所述目标像素块为所述多个像素块中与所述待渲染片段存在重叠的像素块。In a possible implementation, the global depth information includes depth information of multiple pixel blocks, and performing a first depth test on the fragment to be rendered based on the global depth information includes: based on the depth information of the target pixel block The first depth test is performed on the segment to be rendered using the depth information of the segment to be rendered, and the target pixel block is a pixel block among the plurality of pixel blocks that overlaps with the segment to be rendered.
在一种可能的实现方式中,所述根据目标像素块的深度信息和所述待渲染片段的深度信息对所述待渲染片段进行所述第一深度测试,包括:在所述待渲染片段的深度值大于所述目标像素块的深度值的情况下,确定所述待渲染片段未通过第一深度测试。In a possible implementation, performing the first depth test on the fragment to be rendered based on the depth information of the target pixel block and the depth information of the fragment to be rendered includes: If the depth value is greater than the depth value of the target pixel block, it is determined that the fragment to be rendered fails the first depth test.
在一种可能的实现方式中,所述目标像素块包括目标区域,所述目标像素块的深度值包括第一深度值和第二深度值,所述第一深度值为所述目标区域的最大深度值,所述第二深度值为所述目标像素块中非目标区域的最大深度值。In a possible implementation, the target pixel block includes a target area, the depth value of the target pixel block includes a first depth value and a second depth value, and the first depth value is the maximum depth value of the target area. Depth value, the second depth value is the maximum depth value of the non-target area in the target pixel block.
可选地,像素块(如目标像素块)可以包括目标区域。像素块的深度信息可以包括像素块的目标区域的最大深度值、像素块的非目标区域的最大深度值和像素块的目标区域的范围。Alternatively, a block of pixels (such as a target block of pixels) may include a target area. The depth information of the pixel block may include the maximum depth value of the target area of the pixel block, the maximum depth value of the non-target area of the pixel block, and the range of the target area of the pixel block.
可选地,片段(如待渲染片段)的深度信息可以包括片段的深度值。其中,片段的深度值可以是通过插值得到的。Optionally, the depth information of a fragment (eg, a fragment to be rendered) may include a depth value of the fragment. Among them, the depth value of the fragment can be obtained through interpolation.
在一种可能的实现方式中,所述方法还包括:将输入分区管道的待渲染图元投射至多个像素块生成多个投射区域,所述多个投射区域与所述多个像素块一一对应;根据所述多个投射区域对所述待渲染图元进行第二深度测试;若所述待渲染图元未通过所述第二深度测试,则剔除所述待渲染图元。In a possible implementation, the method further includes: projecting the primitives to be rendered in the input partition pipeline to multiple pixel blocks to generate multiple projection areas, and the multiple projection areas are one by one with the multiple pixel blocks. Correspondingly: perform a second depth test on the primitive to be rendered according to the plurality of projection areas; if the primitive to be rendered fails the second depth test, remove the primitive to be rendered.
在一种可能的实现方式中,所述根据所述多个投射区域对所述待渲染图元进行第二深度测试,包括:根据第一像素块的深度信息和第一投射区域的深度信息确定所述待渲染图元在所述第一像素块中是否通过深度测试,所述第一像素块为所述多个像素块中的任一像素块,所述第一投射区域为所述第一像素块对应的投射区域;若所述待渲染图元在所述第一像素块中通过深度测试,则确定所述待渲染图元通过所述第二深度测试;若所述待渲染图元在所述多个像素块中均未通过深度测试,则确定所述待渲染图元未通过所述第二深度测试。In a possible implementation, performing a second depth test on the primitive to be rendered based on the multiple projection areas includes: determining based on the depth information of the first pixel block and the depth information of the first projection area. Whether the primitive to be rendered passes the depth test in the first pixel block, the first pixel block is any pixel block among the plurality of pixel blocks, and the first projection area is the first The projection area corresponding to the pixel block; if the primitive to be rendered passes the depth test in the first pixel block, it is determined that the primitive to be rendered passes the second depth test; if the primitive to be rendered is in If none of the plurality of pixel blocks passes the depth test, it is determined that the primitive to be rendered fails the second depth test.
可选地,投射区域(如第一投射区域)的深度信息可以包括投射区域的最大深度值、投射区域的最小深度值和投射区域的范围。Optionally, the depth information of the projection area (such as the first projection area) may include a maximum depth value of the projection area, a minimum depth value of the projection area, and a range of the projection area.
在一种可能的实现方式中,所述根据第一像素块的深度信息和第一投射区域的深度信 息确定所述待渲染图元在所述第一像素块中是否通过深度测试,包括:在所述第一投射区域的最小深度值小于所述第一像素块的深度值的情况下,确定所述待渲染图元在所述第一像素块中通过所述深度测试。In a possible implementation, determining whether the primitive to be rendered passes the depth test in the first pixel block based on the depth information of the first pixel block and the depth information of the first projection area includes: If the minimum depth value of the first projection area is less than the depth value of the first pixel block, it is determined that the primitive to be rendered passes the depth test in the first pixel block.
在一种可能的实现方式中,所述第一像素块包括目标区域,所述第一像素块的深度值包括所述第一像素块的目标区域的最大深度值和所述第一像素块的非目标区域的最大深度值。In a possible implementation, the first pixel block includes a target area, and the depth value of the first pixel block includes a maximum depth value of the target area of the first pixel block and a depth value of the first pixel block. Maximum depth value for non-target areas.
在一种可能的实现方式中,所述方法还包括:根据所述多个投射区域更新所述全局深度信息。In a possible implementation, the method further includes: updating the global depth information according to the multiple projection areas.
在一种可能的实现方式中,所述根据所述多个投射区域更新所述全局深度信息,包括:根据第一像素块的深度信息和第一投射区域的深度信息更新所述全局深度信息中所述第一像素块的深度信息,所述第一像素块为所述多个像素块中的任一像素块,所述第一投射区域为所述第一像素块对应的投射区域。In a possible implementation, updating the global depth information according to the multiple projection areas includes: updating the global depth information according to the depth information of the first pixel block and the depth information of the first projection area. Depth information of the first pixel block, the first pixel block is any pixel block among the plurality of pixel blocks, and the first projection area is the projection area corresponding to the first pixel block.
在一种可能的实现方式中,所述根据第一像素块的深度信息和第一投射区域的深度信息更新所述全局深度信息中所述第一像素块的深度信息,包括:根据所述第一投射区域的最大深度值、所述第一像素块的目标区域的最大深度值、所述第一像素块的非目标区域的最大深度值,更新所述第一像素块的深度信息。In a possible implementation, updating the depth information of the first pixel block in the global depth information according to the depth information of the first pixel block and the depth information of the first projection area includes: The maximum depth value of a projection area, the maximum depth value of the target area of the first pixel block, the maximum depth value of the non-target area of the first pixel block are used to update the depth information of the first pixel block.
在一种可能的实现方式中,所述方法还包括:对通过第一深度测试的片段进行前深度测试。In a possible implementation, the method further includes: performing a pre-depth test on the fragments that pass the first depth test.
在另一种可能的实现方式中,所述方法还包括:对通过第一深度测试的片段进行后深度测试。In another possible implementation, the method further includes: performing a post-depth test on the fragments that pass the first depth test.
在又一种可能的实现方式中,所述方法还包括:对通过第一深度测试的片段进行前深度测试和后深度测试。In yet another possible implementation, the method further includes: performing a pre-depth test and a post-depth test on the fragments that pass the first depth test.
第四方面,本申请还提供了一种图形处理器,该图形处理器包括述各方面或其任意可能的实现方式中所述的电子设备,该图形处理器用于实现上述各方面或其任意可能的实现方式中所述的方法。In a fourth aspect, this application also provides a graphics processor, which includes the electronic device described in the above aspects or any possible implementation thereof, and is used to implement the above aspects or any possible implementation thereof. The method described in the implementation.
第五方面,本申请还提供一种电子设备,该电子设备包括:存储器、至少一个处理器、收发器及存储在该存储器上并可在该处理器上运行的指令。进一步,该存储器、该处理器以及该通信接口之间通过内部连接通路互相通信。该至少一个处理器执行该指令使得该图像处理装置实现上述各方面或其任意可能的实现方式中所述的方法。In a fifth aspect, the present application also provides an electronic device, which includes a memory, at least one processor, a transceiver, and instructions stored on the memory and executable on the processor. Further, the memory, the processor and the communication interface communicate with each other through internal connection paths. The at least one processor executes the instruction so that the image processing apparatus implements the method described in the above aspects or any possible implementation manner thereof.
示例性地,该电子设备为手机。For example, the electronic device is a mobile phone.
第六方面,本申请还提供一种计算机可读存储介质,用于存储计算机程序,该计算机程序包括用于实现上述各方面或其任意可能的实现方式中所述的方法。In a sixth aspect, the present application also provides a computer-readable storage medium for storing a computer program. The computer program includes methods for implementing the above aspects or any possible implementation manner thereof.
第七方面,本申请还提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机实现上述各个方面或其任意可能的实现方式中所述的方法。In a seventh aspect, the present application also provides a computer program product containing instructions that, when run on a computer, causes the computer to implement the methods described in each of the above aspects or any possible implementation thereof.
本实施例提供的图像处理方法、图像处理装置、图形处理器、电子设备、计算机存储介质和计算机程序产品均用于执行上文所提供的图像处理方法,因此,其所能达到的有益效果可参考上文所提供的图像处理方法中的有益效果,此处不再赘述。The image processing method, image processing device, graphics processor, electronic equipment, computer storage medium and computer program product provided by this embodiment are all used to execute the image processing method provided above. Therefore, the beneficial effects they can achieve can be Refer to the beneficial effects of the image processing method provided above, which will not be described again here.
图1为本申请实施例提供的一种深度示意图;Figure 1 is a depth schematic diagram provided by an embodiment of the present application;
图2为一种渲染管线的结构示意图;Figure 2 is a schematic structural diagram of a rendering pipeline;
图3为本申请实施例提供的一种图像处理装置的结构示意图;Figure 3 is a schematic structural diagram of an image processing device provided by an embodiment of the present application;
图4为本申请实施例提供的一种图像处理方法的流程示意图;Figure 4 is a schematic flowchart of an image processing method provided by an embodiment of the present application;
图5为本申请实施例提供的另一种图像处理方法的流程示意图;Figure 5 is a schematic flow chart of another image processing method provided by an embodiment of the present application;
图6为本申请实施例提供的一种投射过程的示意图;Figure 6 is a schematic diagram of a projection process provided by an embodiment of the present application;
图7为本申请实施例提供的一种像素块的示意图;Figure 7 is a schematic diagram of a pixel block provided by an embodiment of the present application;
图8为本申请实施例提供的另一种像素块的示意图;Figure 8 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图9为本申请实施例提供的一种深度值的示意图;Figure 9 is a schematic diagram of a depth value provided by an embodiment of the present application;
图10为本申请实施例提供的又一种像素块的示意图;Figure 10 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图11为本申请实施例提供的另一种深度值的示意图;Figure 11 is a schematic diagram of another depth value provided by an embodiment of the present application;
图12为本申请实施例提供的又一种像素块的示意图;Figure 12 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图13为本申请实施例提供的又一种像素块的示意图;Figure 13 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图14为本申请实施例提供的又一种深度值的示意图;Figure 14 is a schematic diagram of another depth value provided by an embodiment of the present application;
图15为本申请实施例提供的又一种像素块的示意图;Figure 15 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图16为本申请实施例提供的又一种深度值的示意图;Figure 16 is a schematic diagram of another depth value provided by an embodiment of the present application;
图17为本申请实施例提供的又一种像素块的示意图;Figure 17 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图18为本申请实施例提供的又一种深度值的示意图;Figure 18 is a schematic diagram of another depth value provided by an embodiment of the present application;
图19为本申请实施例提供的又一种像素块的示意图;Figure 19 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图20为本申请实施例提供的一种包含像素块的画面的示意图;Figure 20 is a schematic diagram of a picture including pixel blocks provided by an embodiment of the present application;
图21为本申请实施例提供的又一种像素块的示意图;Figure 21 is a schematic diagram of another pixel block provided by an embodiment of the present application;
图22为本申请实施例提供的另一种图像处理装置的结构示意图。Figure 22 is a schematic structural diagram of another image processing device provided by an embodiment of the present application.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.
本申请中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。The term "and/or" in this application is just an association relationship describing related objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, A and B exist simultaneously, alone There are three situations B.
本申请的说明书以及附图中的术语“第一”和“第二”等是用于区别不同的对象,或者用于区别对同一对象的不同处理,而不是用于描述对象的特定顺序。The terms “first” and “second” in the description of this application and the drawings are used to distinguish different objects, or to distinguish different processes on the same object, rather than to describe a specific order of objects.
此外,本申请的描述中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其他步骤或单元。Furthermore, references to the terms "including" and "having" and any variations thereof in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes other unlisted steps or units, or optionally also Includes other steps or units inherent to those processes, methods, products or devices.
需要说明的是,本申请实施例的描述中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性地”或者“例如”的任何实施例或 设计方案不应被解释为比其他实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that in the description of the embodiments of this application, words such as "exemplarily" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "such as" in the embodiments of the present application shall not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.
在本申请的描述中,除非另有说明,“多个”的含义是指两个或两个以上。In the description of this application, unless otherwise stated, the meaning of "plurality" means two or more.
首先,对本申请中的部分用语进行解释说明,以便于本领域技术人员理解。First, some terms used in this application are explained to facilitate understanding by those skilled in the art.
深度:用于表征物体与摄像机之间远近程度。如图1所示,远近程度用于表示根据摄像机朝向做线段得到的投影距离。Depth: used to characterize the distance between an object and the camera. As shown in Figure 1, the distance is used to represent the projection distance obtained by making a line segment based on the camera orientation.
深度测试:判断待渲染数据的深度值是否大于深度阈值的过程。Depth test: The process of determining whether the depth value of the data to be rendered is greater than the depth threshold.
前深度测试:在数据(如片段)未经像素着色器着色渲染之前对数据进行的深度测试。Pre-depth testing: A depth test performed on the data (such as a fragment) before it has been rendered by a pixel shader.
后深度测试:在数据经像素着色器着色渲染之后对数据进行的深度测试。Post depth test: A depth test performed on the data after it has been rendered by a pixel shader.
图元(primitive):图形渲染管线中几何表示的基本单位,几何顶点的组合称为图元(如点、线段或多边形等)。Primitive: The basic unit of geometric representation in the graphics rendering pipeline. The combination of geometric vertices is called a primitive (such as a point, line segment, or polygon, etc.).
光栅化:光栅化可以将图元转化为片段,片段拥有关于像素的信息。光栅化过程确定了所有像素需要绘制的位置,光栅化过程会进行插值,以便确定两个顶点间的所有像素的位置。光栅化不仅可以对像素插值,任何顶点着色器的输出变量和片段着色器的输入变量都可以基于对应的像素插值。通过光栅化可以实现平滑的颜色渐变和真实光照等效果。Rasterization: Rasterization converts primitives into fragments, which hold information about pixels. The rasterization process determines where all pixels need to be drawn, and the rasterization process interpolates to determine the location of all pixels between two vertices. Not only does rasterization interpolate pixels, any vertex shader output variable and fragment shader input variable can be interpolated based on the corresponding pixel. Effects such as smooth color gradients and realistic lighting can be achieved through rasterization.
分区阶段(binning pass):将屏幕分为若干区域(bin),将所有需要进行渲染的图元进行视角变换之后得到该图元的屏幕位置,根据图元的屏幕位置将图元筛选到对应屏幕区域,最终每个区域(bin)独立进行渲染,只渲染分区过程中落到本区域的图元集合。这个筛选过程就是分区阶段。Partitioning stage (binning pass): Divide the screen into several areas (bins), change the perspective of all primitives that need to be rendered, and obtain the screen position of the primitive. Filter the primitives to the corresponding screen based on the screen position of the primitive. area, and finally each area (bin) is rendered independently, and only the set of primitives that fall into this area during the partitioning process are rendered. This screening process is the partitioning stage.
渲染过程中GPU会消耗大量计算资源。为此,GPU可以在渲染阶段剔除不影响渲染结果的待渲染数据,以降低计算资源消耗量。The GPU consumes a lot of computing resources during the rendering process. To this end, the GPU can eliminate data to be rendered that does not affect the rendering results during the rendering phase to reduce computing resource consumption.
在相关技术中,可以采用深度测试剔除不影响渲染结果的待渲染数据。例如,在如图2所示的图像处理器的渲染管线中,渲染管线中的前深度测试模块可以根据深度缓存中的深度值对输入前深度测试模块的片段进行前深度测试(earlylate-detph-test)。当该片段的深度值小于深度缓存中的深度值时,确定该片段通过前深度测试之后将该片段输入像素着色器进行着色渲染并将深度缓存中的深度值更新为该片段的深度值;当该片段的深度值大于深度缓存中的深度值时,确定该片段未通过前深度测试并剔除该片段。在一部分场景中,比片段的深度值会受到像素着色器影响,深度测试需要在像素着色器,这时就需要后深度测试模式进行后深度测试(late-detph-test)。In related technologies, depth testing can be used to eliminate data to be rendered that does not affect the rendering results. For example, in the rendering pipeline of the image processor as shown in Figure 2, the early depth test module in the rendering pipeline can perform early depth testing (earlylate-detph- test). When the depth value of the fragment is less than the depth value in the depth cache, after determining that the fragment passes the pre-depth test, the fragment is input into the pixel shader for rendering and the depth value in the depth cache is updated to the depth value of the fragment; when When the depth value of the fragment is greater than the depth value in the depth buffer, it is determined that the fragment has failed the pre-depth test and the fragment is eliminated. In some scenes, the depth value of the fragment will be affected by the pixel shader. The depth test needs to be in the pixel shader. In this case, the post-depth test mode is required to perform a post-depth test (late-detph-test).
可以看出相关技术中,深度缓存中的深度值是根据已通过测试的部分待渲染片段确定的,即相关技术在深度测试时仅能利用部分片段的深度信息对待渲染片段进行剔除,所以无法达到很高的剔除率。例如,待渲染片段包括待渲染片段1、待渲染片段2、待渲染片段3、待渲染片段4和待渲染片段5,深度值分别为50、40、30、20、10。如果同时利用这5个待渲染片段的深度值进行深度测试,则只有深度值最小的待渲染片段5会通过深度测试,其余4个待渲染片段则会被剔除。It can be seen that in the related technology, the depth value in the depth cache is determined based on some of the fragments to be rendered that have passed the test. That is, the related technology can only use the depth information of some fragments to eliminate the fragments to be rendered during the depth test, so it cannot achieve Very high rejection rate. For example, the fragments to be rendered include fragments to be rendered 1, fragments to be rendered 2, fragments to be rendered 3, fragments to be rendered 4, and fragments to be rendered 5, and the depth values are 50, 40, 30, 20, and 10 respectively. If the depth values of these five to-be-rendered fragments are used for depth testing at the same time, only the to-be-rendered fragment 5 with the smallest depth value will pass the depth test, and the remaining four to-be-rendered fragments will be eliminated.
如表1所示,通过现有技术对待渲染片段1进行深度测试时,深度缓存中未缓存有深度值,则待渲染片段1通过深度测试进入着色器中进行着色渲染,深度缓存中的深度值更新为50。通过现有技术对待渲染片段2进行深度测试时,待渲染片段2的深度值40小于深度缓存中的深度值50,则待渲染片段2通过深度测试进入着色器中进行着色渲染,深 度缓存中的深度值更新为40。As shown in Table 1, when performing a depth test on the fragment to be rendered 1 through the existing technology, there is no depth value cached in the depth cache. Then the fragment 1 to be rendered passes the depth test and enters the shader for rendering. The depth value in the depth cache Updated to 50. When performing a depth test on the fragment to be rendered 2 using the existing technology, if the depth value 40 of the fragment 2 to be rendered is less than the depth value 50 in the depth cache, then the fragment 2 to be rendered passes the depth test and enters the shader for rendering. The depth value is updated to 40.
通过现有技术对待渲染片段3进行深度测试时,待渲染片段3的深度值30小于深度缓存中的深度值50,则待渲染片段3通过深度测试进入着色器中进行着色渲染,深度缓存中的深度值更新为30。When performing a depth test on the fragment to be rendered 3 using the existing technology, if the depth value 30 of the fragment 3 to be rendered is less than the depth value 50 in the depth cache, then the fragment 3 to be rendered passes the depth test and enters the shader for rendering. The depth value is updated to 30.
通过现有技术对待渲染片段4进行深度测试时,待渲染片段4的深度值20小于深度缓存中的深度值50,则待渲染片段3通过深度测试进入着色器中进行着色渲染,深度缓存中的深度值更新为20。When performing a depth test on the fragment to be rendered 4 through the existing technology, the depth value 20 of the fragment 4 to be rendered is less than the depth value 50 in the depth cache, then the fragment 3 to be rendered passes the depth test and enters the shader for rendering. The depth value is updated to 20.
通过现有技术对待渲染片段5进行深度测试时,待渲染片段5的深度值10小于深度缓存中的深度值50,则待渲染片段3通过深度测试进入着色器中进行着色渲染,深度缓存中的深度值更新为10。When using the existing technology to perform a depth test on the fragment to be rendered 5, the depth value 10 of the fragment 5 to be rendered is less than the depth value 50 in the depth cache, then the fragment 3 to be rendered passes the depth test and enters the shader for rendering. The depth value is updated to 10.
通过表1可以看出,待渲染片段1、待渲染片段2、待渲染片段3、待渲染片段4和待渲染片段5均能通过深度测试,相关技术仅利用通过深度测试的部分片段的深度信息对待渲染片段进行剔除无法达到较高的剔除率。It can be seen from Table 1 that the fragment to be rendered 1, the fragment to be rendered 2, the fragment to be rendered 3, the fragment to be rendered 4 and the fragment to be rendered 5 can all pass the depth test. The related technology only uses the depth information of some fragments that pass the depth test. Culling the fragments to be rendered cannot achieve a high culling rate.
表1Table 1
为此,本申请实施例提供了一种图像处理方法,能够提升对待渲染数据的剔除率。To this end, embodiments of the present application provide an image processing method that can improve the rejection rate of data to be rendered.
本申请实施例提供的图像处理方法适用于图像处理装置。该图像处理装置可以设置在图形处理器中。The image processing method provided by the embodiment of the present application is suitable for image processing devices. The image processing device may be provided in a graphics processor.
具体地,该图像处理装置可以设置于电子设备的图形处理器中。本申请实施例对电子设备的具体类型不作任何限制。例如,电子设备可以为手机、平板电脑、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等。Specifically, the image processing device may be provided in a graphics processor of an electronic device. The embodiments of this application do not place any restrictions on the specific types of electronic devices. For example, the electronic device may be a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc.
示例性地,图像处理装置可以设置在手机的图形处理器中。For example, the image processing device may be provided in a graphics processor of a mobile phone.
图3示出了该图像处理装置的一种示意性框图,该图像处理装置包括分区管线、全局深度信息缓存模块和渲染管线。Figure 3 shows a schematic block diagram of the image processing device. The image processing device includes a partition pipeline, a global depth information cache module and a rendering pipeline.
在分区管线中,屏幕空间会被分为多个像素块(pixel block),每个CPU调用图形编程接口(draw-call)中的每一个图元(primitive)经过光栅化(rasterization)之后会被投射到上述多个像素块上。例如,屏幕空间可以分为N个像素块。In the partition pipeline, the screen space will be divided into multiple pixel blocks (pixel blocks), and each primitive (primitive) in each CPU's graphics programming interface (draw-call) will be rasterized (rasterization). Project onto the multiple pixel blocks mentioned above. For example, the screen space can be divided into N blocks of pixels.
分区管线中设置有粗粒度光栅化器和分区粗粒度深度测试模块。The partition pipeline is equipped with a coarse-grained rasterizer and a partitioned coarse-grained depth test module.
粗粒度光栅化器(也可称为第二光栅化器),用于将输入分区管线中的图元(即待渲染图元)投射至多个像素块生成多个投射区域。例如,第二光栅化器可以将输入分区管线中的图元投射至N个像素块中生成N个投射区域。其中,多个像素块和多个投射区域一一对应。A coarse-grained rasterizer (also called a second rasterizer) is used to project primitives in the input partition pipeline (i.e. primitives to be rendered) to multiple pixel blocks to generate multiple projection areas. For example, the second rasterizer can project the primitives in the input partition pipeline into N pixel blocks to generate N projection areas. Among them, multiple pixel blocks and multiple projection areas correspond one to one.
分区粗粒度深度测试模块(也可称为第二深度测试模块),用于根据多个投射区域对待渲染图元进行分区粗粒度深度测试(也可称为第二深度测试)。若待渲染图元未通过第二深度测试,则剔除待渲染图元。若待渲染图元未通过第二深度测试,则待渲染图元通过第二深度测试,则将待渲染图元输入渲染管线。The partitioned coarse-grained depth test module (which can also be called the second depth test module) is used to perform a partitioned coarse-grained depth test (which can also be called the second depth test) of the primitives to be rendered based on multiple projection areas. If the primitive to be rendered fails the second depth test, the primitive to be rendered is eliminated. If the primitive to be rendered fails the second depth test, then the primitive to be rendered passes the second depth test, and the primitive to be rendered is input into the rendering pipeline.
在一种可能的实现方式中,分区管线还可以设置有多边形列表生成(polygon list generation)模块,polygon list generation模块用于通过内存存储通过第二深度测试的待渲染图元,以及将通过第二深度测试的待渲染图元打包为多边形列表(PL),以多边形堆栈(PL-Heap)的形式输入渲染管线。In a possible implementation, the partition pipeline can also be equipped with a polygon list generation module. The polygon list generation module is used to store the primitives to be rendered that pass the second depth test through memory, and the primitives that pass the second depth test. The primitives to be rendered for the depth test are packaged as polygon lists (PL) and input into the rendering pipeline in the form of polygon stacks (PL-Heap).
在一种可能的实现方式中,第二深度测试模块可以在第二深度测试过程中更新每个像素块上所累积的深度信息,并将每个像素块的深度信息存储到全局深度信息缓存模块中。In a possible implementation, the second depth testing module can update the depth information accumulated on each pixel block during the second depth testing process, and store the depth information of each pixel block in the global depth information cache module. middle.
全局深度信息缓存模块(可简称为第一缓存模块),用于缓存上述多个像素块的深度信息(可简称为全局深度信息),像素块的深度信息包括待定区掩膜(pending mask,Pmask)、待定目标深度值(pending destination z value,PZ)和原始目标深度值(old Destination z value,OZ)。例如,第一缓存模块缓存有全局深度信息,该全局深度信息包括通过全部待渲染图元更新得到的多个(如N个)像素块的深度信息。The global depth information cache module (which may be referred to as the first cache module) is used to cache the depth information of the above-mentioned multiple pixel blocks (which may be referred to as the global depth information). The depth information of the pixel blocks includes a pending mask (Pmask). ), pending destination z value (PZ) and original destination z value (OZ). For example, the first cache module caches global depth information, which includes depth information of multiple (eg, N) pixel blocks updated by all primitives to be rendered.
全局深度信息缓存模块可以为图像处理装置内部的缓存,也可以是其他设备的缓存(如CPU的缓存)。The global depth information cache module can be a cache inside the image processing device or a cache of other devices (such as a cache of a CPU).
Pmask,用于指示像素块中的目标区域。Pmask可以标识像素块中目标区域的范围。Pmask, used to indicate the target area in the pixel block. Pmask can identify the range of the target area in the pixel block.
PZ,用于指示像素块中目标区域的最大深度值,即像素块的目标区域中所有可见片段的深度值都比PZ值小。PZ, used to indicate the maximum depth value of the target area in the pixel block, that is, the depth values of all visible fragments in the target area of the pixel block are smaller than the PZ value.
OZ,用于指示像素块中非目标区域的最大深度值,即像素块的非目标区域中所有可见片段的深度值都比OZ值小。OZ, used to indicate the maximum depth value of the non-target area in the pixel block, that is, the depth values of all visible fragments in the non-target area of the pixel block are smaller than the OZ value.
渲染管线设置有光栅化器、渲染粗粒度深度测试模块和像素着色器。The rendering pipeline is set up with a rasterizer, a rendering coarse-grained depth test module, and a pixel shader.
光栅化器(可称为第一光栅化器),用于将输入渲染管线的图元(即通过第二深度测试的图元)转换为片段(即待渲染片段)。A rasterizer (which may be called a first rasterizer) is used to convert primitives input into the rendering pipeline (i.e., primitives that pass the second depth test) into fragments (i.e., fragments to be rendered).
渲染粗粒度深度测试模块(可称为第一深度测试模块),用于根据上述全局深度信息对待渲染片段进行第一深度测试。若待渲染片段未通过第一深度测试,则剔除待渲染片段。若待渲染片段通过第一深度测试,则将待渲染片段输入像素着色器。Rendering a coarse-grained depth test module (which may be called a first depth test module) is used to perform a first depth test on the fragment to be rendered based on the above-mentioned global depth information. If the fragment to be rendered fails the first depth test, the fragment to be rendered is eliminated. If the fragment to be rendered passes the first depth test, the fragment to be rendered is input into the pixel shader.
在一种可能的实现方式中,渲染粗粒度深度测试模块也可以通过其他信息对待渲染片段进行第一深度测试。In a possible implementation, the rendering coarse-grained depth test module can also use other information to perform the first depth test on the fragment to be rendered.
像素着色器,用于对输入像素着色器的片段进行着色渲染。A pixel shader used to shade the fragments input to the pixel shader.
在一种可能的实现方式中,渲染管线中还可以设置有前深度测试模块、后深度测试模块和深度缓存模块。In a possible implementation, the rendering pipeline may also be provided with a front depth testing module, a post depth testing module and a depth cache module.
前深度测试模块,用于对待渲染片段进行前深度测试。前深度测试的具体方法可以采用本领域技术人员能够想到的任何一种方法进行处理,本申请实施例对此不做具体限定。The front depth testing module is used to perform front depth testing on the fragments to be rendered. The specific method of the front depth test can be processed by any method that can be thought of by those skilled in the art, and the embodiments of the present application do not specifically limit this.
后深度测试模块,用于对着色渲染后的片段进行后深度测试。后深度测试的具体方法可以采用本领域技术人员能够想到的任何一种方法进行处理,本申请实施例对此不做具体限定。Post-depth testing module, used to perform post-depth testing on fragments after shader rendering. The specific method of the post-depth test can be processed by any method that can be thought of by those skilled in the art, and the embodiments of the present application do not specifically limit this.
在一种可能的实现方式中,第二深度模块具体用于:根据第一像素块的深度信息和第 一投射区域的深度信息确定待渲染图元在第一像素块中是否通过深度测试,第一像素块为多个像素块中的任一像素块,第一投射区域为第一像素块对应的投射区域。若待渲染图元在第一像素块中通过深度测试,则确定待渲染图元通过第二深度测试;若待渲染图元在多个像素块中均未通过深度测试,则确定待渲染图元未通过第二深度测试。In a possible implementation, the second depth module is specifically configured to: determine whether the primitive to be rendered passes the depth test in the first pixel block according to the depth information of the first pixel block and the depth information of the first projection area. A pixel block is any pixel block among multiple pixel blocks, and the first projection area is the projection area corresponding to the first pixel block. If the primitive to be rendered passes the depth test in the first pixel block, it is determined that the primitive to be rendered passes the second depth test; if the primitive to be rendered fails the depth test in multiple pixel blocks, it is determined that the primitive to be rendered is Failed second depth test.
在一种可能的实现方式中,第二深度模块具体用于:在所述第一投射区域的最小深度值小于所述第一像素块的深度值的情况下,确定所述待渲染图元在所述第一像素块中通过所述深度测试。In a possible implementation, the second depth module is specifically configured to: when the minimum depth value of the first projection area is less than the depth value of the first pixel block, determine where the primitive to be rendered is located. The first pixel block passes the depth test.
可选地,投射区域(如第一投射区域)的深度信息可以包括投射区域的最大深度值、投射区域的最小深度值和投射区域的范围。Optionally, the depth information of the projection area (such as the first projection area) may include a maximum depth value of the projection area, a minimum depth value of the projection area, and a range of the projection area.
在一种可能的实现方式中,所述第一像素块包括目标区域,所述第一像素块的深度值包括所述第一像素块的目标区域的最大深度值和所述第一像素块的非目标区域的最大深度值,第二深度模块具体用于:In a possible implementation, the first pixel block includes a target area, and the depth value of the first pixel block includes a maximum depth value of the target area of the first pixel block and a depth value of the first pixel block. The maximum depth value of the non-target area. The second depth module is specifically used for:
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值小于第一深度值或第二深度值,则确定待渲染图元在第一像素块中通过测试。When both the target area and the non-target area of the first projection area overlap with the first pixel block and the minimum depth value of the first projection area is less than the first depth value or the second depth value, it is determined that the primitive to be rendered is in the first pixel The block passes the test.
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值大于第一深度值和第二深度值的情况下,确定待渲染图元在第一像素块中未通过测试In the case where the first projection area overlaps with both the target area and the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value and the second depth value, it is determined that the primitive to be rendered is in the first Failed test in one pixel block
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值小于第一深度值的情况下,确定待渲染图元在第一像素块中通过测试。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, it is determined that the primitive to be rendered passes the test in the first pixel block.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,确定待渲染图元在第一像素块中未通过测试。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, it is determined that the primitive to be rendered fails the test in the first pixel block.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,确定待渲染图元在第一像素块中通过测试。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, it is determined that the primitive to be rendered passes the test in the first pixel block.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值的情况下,确定待渲染图元在第一像素块中未通过测试。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, it is determined that the primitive to be rendered fails the test in the first pixel block.
在一种可能的实现方式中,第二深度模块还用于根据多个投射区域更新全局深度信息。In a possible implementation, the second depth module is also used to update global depth information according to multiple projection areas.
在一种可能的实现方式中,第二深度模块还具体用于:根据第一像素块的深度信息和第一投射区域的深度信息更新全局深度信息中第一像素块的深度信息,第一像素块为多个像素块中的任一像素块,第一投射区域为第一像素块对应的投射区域。In a possible implementation, the second depth module is further specifically configured to: update the depth information of the first pixel block in the global depth information according to the depth information of the first pixel block and the depth information of the first projection area, the first pixel The block is any pixel block among the plurality of pixel blocks, and the first projection area is the projection area corresponding to the first pixel block.
在一种可能的实现方式中,第一像素块包括目标区域,第二深度模块还具体用于:根据第一投射区域的最大深度值、第一像素块的目标区域的最大深度值、第一像素块的非目标区域的最大深度值,更新第一像素块的深度信息。In a possible implementation, the first pixel block includes a target area, and the second depth module is specifically configured to: based on the maximum depth value of the first projection area, the maximum depth value of the target area of the first pixel block, the first The maximum depth value of the non-target area of the pixel block updates the depth information of the first pixel block.
在一种可能的实现方式中,第二深度模块还具体用于:In a possible implementation, the second depth module is also specifically used to:
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值小于第一深度值或第二深度值的情况下,更新第一像素块的深度信息。When the first projection area overlaps with both the target area and the non-target area of the first pixel block and the maximum depth value of the first projection area is less than the first depth value or the second depth value, update the depth of the first pixel block. information.
在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值大于第一深度值和第二深度值的情况下,不更新第一像素块的深度信息。In the case where the first projection area overlaps with both the target area and the non-target area of the first pixel block and the maximum depth value of the first projection area is greater than the first depth value and the second depth value, the first pixel block is not updated. depth information.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值小于第一深度值的情况下,更新第一像素块的深度信息。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, the depth information of the first pixel block is updated.
在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,不更新第一像素块的深度信息。When the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, the depth information of the first pixel block is not updated.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,更新第一像素块的深度信息。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, the depth information of the first pixel block is updated.
在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值的情况下,不更新第一像素块的深度信息。When the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, the depth information of the first pixel block is not updated.
在一种可能的实现方式中,第二深度模块还具体用于:In a possible implementation, the second depth module is also specifically used to:
在第一投射区域与第一像素块的目标区域完全重合且第三深度值(即投射区域的最大深度值)小于第一深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更新为第三深度值。When the first projection area completely coincides with the target area of the first pixel block and the third depth value (ie, the maximum depth value of the projection area) is less than the first depth value, the target area of the first pixel block is updated to the target projection. area and update the first depth value of the first pixel block to the third depth value.
在第一投射区域与第一像素块的非目标区域完全重合且第三深度值小于第二深度值的情况下,将第一像素块的目标区域更新为非目标投射区域且将第一像素块的第二深度值更新为第三深度值。When the first projection area completely coincides with the non-target area of the first pixel block and the third depth value is less than the second depth value, the target area of the first pixel block is updated to the non-target projection area and the first pixel block is The second depth value is updated to the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第二条件的情况下,将第一像素块的目标区域更新为第一区域且将第一像素块的第一深度值更新为第一数值。其中,上述第一条件为第三深度值小于第一深度值但大于第二深度值或第三深度值小于第二深度值但大于第一深度值。上述第二条件为第一绝对值小于第二绝对值,上述第一绝对值为上述第一深度值与上述第三深度值之差的绝对值,上述第二绝对值为上述第二深度值与上述第三深度值之差的绝对值。上述第一区域为目标区域与目标投射区域的并集区域,第一数值为第一深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the second condition are met, the target area of the first pixel block is updated to the first area and the third The first depth value of a pixel block is updated to a first numerical value. Wherein, the above-mentioned first condition is that the third depth value is smaller than the first depth value but larger than the second depth value or the third depth value is smaller than the second depth value but larger than the first depth value. The second condition is that the first absolute value is less than the second absolute value. The first absolute value is the absolute value of the difference between the first depth value and the third depth value. The second absolute value is the difference between the second depth value and the third depth value. The absolute value of the difference between the above third depth values. The above-mentioned first area is the union area of the target area and the target projection area, and the first value is the larger value between the first depth value and the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第三条件的情况下,将第一像素块的目标区域更新为第二区域且将第一像素块的第二深度值更新为第二数值。其中,上述第三条件为第一绝对值大于第二绝对值。上述第二区域为目标区域与非目标投射区域的交集区域。上述第二数值为第二深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the third condition are met, the target area of the first pixel block is updated to the second area and the third The second depth value of a pixel block is updated to a second value. Wherein, the above third condition is that the first absolute value is greater than the second absolute value. The above-mentioned second area is the intersection area of the target area and the non-target projection area. The above-mentioned second value is the larger value between the second depth value and the third depth value.
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且第三深度值小于第一深度值和第二深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更为第三深度值,将第一像素块的第二深度值更新为第三数值。其中,第三数值为第一深度值与第二深度值之间的较大值。In the case that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the third depth value is smaller than the first depth value and the second depth value, the target area of the first pixel block is updated as The target projection area is to change the first depth value of the first pixel block to a third depth value, and update the second depth value of the first pixel block to a third value. The third value is the larger value between the first depth value and the second depth value.
可选地,目标投射区域(CurMask)包括第一目标投射区域(即CurMask0)和第二目标投射区域(即CurMask0)Optionally, the target projection area (CurMask) includes a first target projection area (ie CurMask0) and a second target projection area (ie CurMask0)
在投射区域的第三深度值小于像素块的第二深度值的情况下,第一目标投射区域(即CurMask0)可以表示投射区域与像素块的非目标区域的重叠区域。In the case where the third depth value of the projection area is smaller than the second depth value of the pixel block, the first target projection area (ie CurMask0) may represent an overlapping area of the projection area and the non-target area of the pixel block.
在投射区域的第三深度值小于像素块的第一深度值的情况下,第二目标投射区域(即CurMask0)可以表示投射区域与像素块的目标区域的重叠区域。In the case where the third depth value of the projection area is smaller than the first depth value of the pixel block, the second target projection area (ie, CurMask0) may represent an overlapping area of the projection area and the target area of the pixel block.
目标投射区域(CurMask)可以为第一目标投射区域(CurMask0)和第二目标投射区域(CurMask0)的并集。The target projection area (CurMask) may be the union of the first target projection area (CurMask0) and the second target projection area (CurMask0).
在一种可能的实现方式中,第一深度测试模块具体用于:根据全局信息中目标像素块的深度信息和待渲染片段的深度信息对待渲染片段进行第一深度测试,目标像素块为多个像素块中与待渲染片段存在重叠的像素块。In a possible implementation, the first depth test module is specifically configured to: perform a first depth test on the fragment to be rendered based on the depth information of the target pixel block in the global information and the depth information of the fragment to be rendered, and the target pixel block is multiple There are pixel blocks in the pixel block that overlap with the fragment to be rendered.
在一种可能的实现方式中,第一深度测试模块具体用于:在所述待渲染片段的深度值大于所述目标像素块的深度值的情况下,确定所述待渲染片段未通过第一深度测试。In a possible implementation, the first depth testing module is specifically configured to: when the depth value of the fragment to be rendered is greater than the depth value of the target pixel block, determine that the fragment to be rendered has not passed the first depth test module. Deep testing.
可选地,像素块(如目标像素块)可以包括目标区域。像素块的深度信息可以包括像素块的目标区域的最大深度值、像素块的非目标区域的最大深度值和像素块的目标区域的范围。Alternatively, a block of pixels (such as a target block of pixels) may include a target area. The depth information of the pixel block may include the maximum depth value of the target area of the pixel block, the maximum depth value of the non-target area of the pixel block, and the range of the target area of the pixel block.
可选地,片段(如待渲染片段)的深度信息可以包括片段的深度值。其中,片段的深度值可以是通过插值得到的。Optionally, the depth information of a fragment (eg, a fragment to be rendered) may include a depth value of the fragment. Among them, the depth value of the fragment can be obtained through interpolation.
在一种可能的实现方式中,目标像素块包括目标区域,所述目标像素块的深度值包括第一深度值和第二深度值,第一深度测试模块具体用于:In a possible implementation, the target pixel block includes a target area, the depth value of the target pixel block includes a first depth value and a second depth value, and the first depth testing module is specifically used to:
在待渲染片段位于目标像素块的目标区域且待渲染片段的深度值小于或等于第一深度值的情况下,确定待渲染片段通过第一深度测试。When the segment to be rendered is located in the target area of the target pixel block and the depth value of the segment to be rendered is less than or equal to the first depth value, it is determined that the segment to be rendered passes the first depth test.
在待渲染片段位于目标像素块的目标区域且待渲染片段的深度值大于第一深度值的情况下,确定待渲染片段未通过第一深度测试。When the fragment to be rendered is located in the target area of the target pixel block and the depth value of the fragment to be rendered is greater than the first depth value, it is determined that the fragment to be rendered fails the first depth test.
在待渲染片段位于目标像素块的非目标区域且待渲染片段的深度值小于或等于第二深度值的情况下,确定待渲染片段通过第一深度测试。When the fragment to be rendered is located in a non-target area of the target pixel block and the depth value of the fragment to be rendered is less than or equal to the second depth value, it is determined that the fragment to be rendered passes the first depth test.
在待渲染片段未位于目标像素块的非目标区域且待渲染片段的深度值大于第二深度值的情况下,确定待渲染片段未通过第一深度测试。When the fragment to be rendered is not located in the non-target area of the target pixel block and the depth value of the fragment to be rendered is greater than the second depth value, it is determined that the fragment to be rendered fails the first depth test.
如图3所示,用户可以在不涉及深度的场景(如平面场景、二维场景等)关闭图像处理装置中渲染管线中的全部深度测试模块(即渲染粗粒度深度测试模块、前深度测试模块和后深度测试模块)使待渲染数据直接进入像素着色器进行着色渲染,以减少渲染过程的数据处理量。As shown in Figure 3, users can turn off all depth test modules (i.e., rendering coarse-grained depth test module, pre-depth test module) in the rendering pipeline of the image processing device in scenes that do not involve depth (such as plane scenes, two-dimensional scenes, etc.) and post-depth testing module) so that the data to be rendered directly enters the pixel shader for shading rendering to reduce the amount of data processing in the rendering process.
用户可以在片段按深度值由小到大的顺序输入渲染管线的场景,关闭渲染管线中的渲染粗粒度深度测试模块,以减少渲染过程的数据处理量。Users can input the scene of the rendering pipeline in order of depth value from small to large in the fragment, and turn off the rendering coarse-grained depth test module in the rendering pipeline to reduce the amount of data processing in the rendering process.
用户可以在片段的深度值不受像素着色器影响(即片段的深度值在像素着色器着色渲染前后不会发生变化)的场景,关闭后深度测试模块,以减少渲染过程的数据处理量。Users can turn off the post-depth test module in scenes where the depth value of the fragment is not affected by the pixel shader (that is, the depth value of the fragment does not change before and after pixel shader rendering) to reduce the amount of data processing in the rendering process.
用户可以在片段的深度值受像素着色器影响(即片段的深度值在像素着色器着色渲染前后会发生变化)且片段的深度值变化方向不固定的场景(例如,部分片段的深度值在着色渲染后增大,另一部分片段的深度值在着色渲染后减少),关闭前深度测试模块,以减少渲染过程的数据处理量。Users can use this method in a scene where the depth value of a fragment is affected by the pixel shader (that is, the depth value of the fragment will change before and after the pixel shader renders) and the direction of the change of the depth value of the fragment is not fixed (for example, the depth value of some fragments is changed during shading). increases after rendering, and the depth value of another part of the fragment decreases after shading and rendering), turn off the front depth test module to reduce the amount of data processing during the rendering process.
图4示出了本申请实施例提供的图像处理方法的示意性流程图,该方法可以由图3所示的图像处理装置执行。如图4所示,该图像处理方法包括:FIG. 4 shows a schematic flowchart of the image processing method provided by the embodiment of the present application. The method can be executed by the image processing device shown in FIG. 3 . As shown in Figure 4, the image processing method includes:
S401、图像处理装置对输入分区管线的待渲染图元进行第二深度测试并剔除未通过第二深度测试的待渲染图元。S401. The image processing device performs a second depth test on the graphics elements to be rendered that are input into the partition pipeline and eliminates the graphics elements to be rendered that fail the second depth test.
示例性地,以M个待渲染图元输入分区管线为例,则图像处理装置先对第1个待渲染图元进行第二深度测试,接着对第2个进行第二深度测试,然后对第3个、第4个、……、第M个待渲染图元进行第二深度测试。若待渲染图元未通过第二深度测试,则剔除该待 渲染图元;若该待渲染图元通过第二测试,则将该待渲染图元输入渲染管线。For example, taking the input partition pipeline of M primitives to be rendered as an example, the image processing device first performs the second depth test on the first primitive to be rendered, then performs the second depth test on the second primitive, and then performs the second depth test on the second primitive to be rendered. The 3rd, 4th,..., Mth primitives to be rendered are subjected to the second depth test. If the primitive to be rendered fails the second depth test, the primitive to be rendered is eliminated; if the primitive to be rendered passes the second test, the primitive to be rendered is input into the rendering pipeline.
需要说明的是,待渲染图元未通过第二深度测试说明该待渲染图元深度较高会被其他待渲染图元所遮挡,所以可以不对该图元进行渲染,而是将该图元剔除以降低计算资源消耗量。It should be noted that if the primitive to be rendered fails the second depth test, it means that the primitive to be rendered has a higher depth and will be blocked by other primitives to be rendered. Therefore, the primitive may not be rendered, but the primitive may be eliminated. to reduce computing resource consumption.
在一种可能的实现方式中,图像处理装置对每个待渲染图元进行第二深度测试可以包括:先通过粗粒度光栅化器将该待渲染图元投射至由屏幕空间分成的多个像素块生成多个投射区域,然后根据多个投射区域对待渲染图元进行第二深度测试。其中,上述多个投射区域与上述多个像素块一一对应。In a possible implementation, the image processing device performing a second depth test on each primitive to be rendered may include: first projecting the primitive to be rendered to multiple pixels divided by the screen space through a coarse-grained rasterizer. The block generates multiple projection areas and then performs a second depth test on the primitive to be rendered based on the multiple projection areas. Wherein, the plurality of projection areas correspond to the plurality of pixel blocks in one-to-one correspondence.
示例性地,如图6所示,屏幕空间可以分成16个像素块(图中白色区域),图像处理装置可以将待渲染图元投射分别投射至这16个像素块中生成与16个像素块一一对应的16个投射区域(图中黑色区域),然后根据这16个投射区域对待渲染图元进行第二深度测试。For example, as shown in Figure 6, the screen space can be divided into 16 pixel blocks (the white area in the figure), and the image processing device can project the primitives to be rendered into these 16 pixel blocks to generate 16 pixel blocks. There are 16 projection areas in one-to-one correspondence (the black area in the picture), and then a second depth test is performed on the primitive to be rendered based on these 16 projection areas.
在一种可能的实现方式中,图像处理装置可以根据每个像素块的深度信息和每个像素块对应的投射区域的深度信息确定待渲染图元在每个像素块中是否通过深度测试。若该待渲染图元在任一像素块中通过深度测试,则确定该待渲染图元通过第二深度测试;若该待渲染图元在上述多个像素块中均未通过深度测试,则确定待渲染图元未通过第二深度测试。In a possible implementation, the image processing device may determine whether the primitive to be rendered passes the depth test in each pixel block based on the depth information of each pixel block and the depth information of the projection area corresponding to each pixel block. If the primitive to be rendered passes the depth test in any pixel block, it is determined that the primitive to be rendered passes the second depth test; if the primitive to be rendered fails the depth test in any of the plurality of pixel blocks, it is determined that the primitive to be rendered is The render primitive failed the second depth test.
示例性地,如图6所示,图像处理装置可以根据图6中16个像素块的深度信息和图6中16个投射区域的深度信息确定待渲染图元在图6中16个像素块中每个像素块中是否通过深度测试。若该待渲染图元在任一像素块中通过深度测试,则确定该待渲染图元通过第二深度测试。若该待渲染图元在上述16个像素块中均未深度通过测试,则确定待渲染图元未通过第二深度测试。For example, as shown in Figure 6, the image processing device can determine that the primitive to be rendered is in the 16 pixel blocks in Figure 6 based on the depth information of the 16 pixel blocks in Figure 6 and the depth information of the 16 projection areas in Figure 6 Whether the depth test passes in each pixel block. If the primitive to be rendered passes the depth test in any pixel block, it is determined that the primitive to be rendered passes the second depth test. If the primitive to be rendered fails the depth test in the above 16 pixel blocks, it is determined that the primitive to be rendered fails the second depth test.
可选地,像素块可以包括目标区域,像素块的深度信息可以包括像素块的目标区域的最大深度值(可简称为第一深度值)、像素块的非目标区域的最大深度值(可简称为第二深度值)和像素块的目标区域的范围。Optionally, the pixel block may include a target area, and the depth information of the pixel block may include a maximum depth value of the target area of the pixel block (which may be referred to as a first depth value), and a maximum depth value of a non-target area of the pixel block (which may be referred to as a first depth value for short). is the second depth value) and the range of the target area of the pixel block.
可选地,投射区域的深度信息可以包括投射区域的最大深度值和投射区域的最小深度值。Optionally, the depth information of the projection area may include a maximum depth value of the projection area and a minimum depth value of the projection area.
在一种可能的实现方式中,图像处理装置可以根据每个像素块的目标区域的最大深度值、每个像素块的非目标区域的最大深度值和每个像素块对应的投射区域的最小深度值确定待渲染图元在每个像素块中是否通过深度测试。In a possible implementation, the image processing device can determine the maximum depth value of the target area of each pixel block, the maximum depth value of the non-target area of each pixel block, and the minimum depth of the projection area corresponding to each pixel block. The value determines whether the primitive to be rendered passes the depth test in each pixel block.
图7示出了像素块和投射区域,图7中灰色区域为像素块的目标区域,白色区域为像素块的非目标区域,黑色区域为投射区域。通过图7可以看出像素块与投射区域一共存在三种位置关系。图7中(a)图示出了第一种位置关系即投射区域与像素块的目标区域和非目标区域均存在重叠;图7中(b)图示出了第二种位置关系即投射区域仅与像素块的目标区域存在重叠;图7中(c)图示出了第三种位置关系即投射区域仅与像素块的非目标区域存在重叠。Figure 7 shows the pixel block and the projection area. The gray area in Figure 7 is the target area of the pixel block, the white area is the non-target area of the pixel block, and the black area is the projection area. It can be seen from Figure 7 that there are three positional relationships between pixel blocks and projection areas. Figure 7 (a) shows that the first positional relationship, that is, the projection area overlaps with both the target area and the non-target area of the pixel block; Figure 7(b) shows the second positional relationship, that is, the projection area. There is only overlap with the target area of the pixel block; (c) in Figure 7 shows the third positional relationship, that is, the projection area only overlaps with the non-target area of the pixel block.
下面以结合图7,以第一像素块和第一投射区域为例,介绍图像处理装置根据每个像素块的目标区域的最大深度值、每个像素块的非目标区域的最大深度值和每个像素块对应的投射区域的最小深度值确定待渲染图元在每个像素块中是否通过深度测试的具体过程。 其中,第一像素块为多个像素块中的任一像素块,第一投射区域为第一像素块对应的投射区域。With reference to FIG. 7 , taking the first pixel block and the first projection area as an example, the following describes how the image processing device determines the maximum depth value of the target area of each pixel block, the maximum depth value of the non-target area of each pixel block, and the maximum depth value of each pixel block. The minimum depth value of the projection area corresponding to each pixel block determines whether the primitive to be rendered passes the depth test in each pixel block. Wherein, the first pixel block is any pixel block among the plurality of pixel blocks, and the first projection area is the projection area corresponding to the first pixel block.
如图7中(a)图所示,在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值小于第一深度值或第二深度值的情况下,确定待渲染图元在第一像素块中通过深度测试。As shown in (a) of Figure 7 , there is overlap between the target area and the non-target area of the first projection area and the first pixel block, and the minimum depth value of the first projection area is smaller than the first depth value or the second depth value. In the case of , it is determined that the primitive to be rendered passes the depth test in the first pixel block.
如图7中(a)图所示,在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最小深度值大于第一深度值和第二深度值的情况下,确定待渲染图元在第一像素块中未通过深度测试。As shown in (a) of Figure 7 , there is overlap between the target area and the non-target area of the first projection area and the first pixel block, and the minimum depth value of the first projection area is greater than the first depth value and the second depth value. In the case of , it is determined that the primitive to be rendered fails the depth test in the first pixel block.
如图7中(b)图所示,在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值小于第一深度值的情况下,确定待渲染图元在第一像素块中通过深度测试。As shown in (b) of Figure 7 , in the case where the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, the primitive to be rendered is determined Pass the depth test in the first block of pixels.
如图7中(b)图所示,在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,确定待渲染图元在第一像素块中未通过深度测试。As shown in (b) of Figure 7 , in the case where the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, the primitive to be rendered is determined Depth test failed in first block of pixels.
如图7中(c)图所示,在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,确定待渲染图元在第一像素块中通过深度测试。As shown in (c) of Figure 7 , in the case where the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, the image to be rendered is determined The element passes the depth test in the first block of pixels.
如图7中(c)图所示,在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值情况下,确定待渲染图元在第一像素块中未深度通过测试。As shown in (c) of Figure 7, in the case where the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, the primitive to be rendered is determined The depth fails the test in the first block of pixels.
在一种可能的实现方式中,图像处理装置还可以根据上述多个投射区域更新全局深度信息。其中,全局深度信息包括由屏幕空间分成的多个像素块的深度信息。例如,图像处理装置可以根据每个像素块的深度信息(当前的深度信息)和每个像素块对应的投射区域的深度信息更新全局深度信息中每个像素块的深度信息。In a possible implementation, the image processing device can also update the global depth information according to the multiple projection areas. Among them, the global depth information includes the depth information of multiple pixel blocks divided by the screen space. For example, the image processing device may update the depth information of each pixel block in the global depth information based on the depth information of each pixel block (current depth information) and the depth information of the projection area corresponding to each pixel block.
下面以结合图7,以第一投射区域和第一像素块为例,介绍图像处理装置根据第一投射区域的最大深度值、第一像素块的目标区域的最大深度值(即第一深度值)、第一像素块的非目标区域的最大深度值(即第二深度值),更新第一像素块的深度信息的具体过程。With reference to FIG. 7 , taking the first projection area and the first pixel block as an example, the following describes how the image processing device determines the maximum depth value of the first projection area and the maximum depth value of the target area of the first pixel block (i.e., the first depth value). ), the maximum depth value of the non-target area of the first pixel block (ie, the second depth value), and the specific process of updating the depth information of the first pixel block.
如图7中(a)图所示,在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值小于第一深度值或第二深度值的情况下,更新第一像素块的深度信息。As shown in (a) of Figure 7 , there is overlap between the target area and the non-target area of the first projection area and the first pixel block, and the maximum depth value of the first projection area is smaller than the first depth value or the second depth value. In the case of , update the depth information of the first pixel block.
如图7中(a)图所示,在第一投射区域与第一像素块的目标区域和非目标区域均存在重叠且第一投射区域的最大深度值大于第一深度值和第二深度值的情况下,不更新第一像素块的深度信息。As shown in (a) of Figure 7 , there is overlap between the target area and the non-target area of the first projection area and the first pixel block, and the maximum depth value of the first projection area is greater than the first depth value and the second depth value. In the case of , the depth information of the first pixel block is not updated.
如图7中(b)图所示,在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值小于第一深度值的情况下,更新第一像素块的深度信息。As shown in (b) of Figure 7 , when the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is less than the first depth value, the first pixel block is updated. depth information.
如图7中(b)图所示,在第一投射区域仅与第一像素块的目标区域存在重叠且第一投射区域的最小深度值大于第一深度值的情况下,不更新第一像素块的深度信息。As shown in (b) of Figure 7 , when the first projection area only overlaps with the target area of the first pixel block and the minimum depth value of the first projection area is greater than the first depth value, the first pixel is not updated. Block depth information.
如图7中(c)图所示,在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值小于第二深度值的情况下,更新第一像素块的深度信息。As shown in (c) of Figure 7 , when the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is less than the second depth value, the first pixel is updated. Block depth information.
如图7中(c)图所示,在第一投射区域仅与第一像素块的非目标区域存在重叠且第一投射区域的最小深度值大于第二深度值的情况下,不更新第一像素块的深度信息。As shown in (c) of Figure 7 , when the first projection area only overlaps with the non-target area of the first pixel block and the minimum depth value of the first projection area is greater than the second depth value, the first projection area is not updated. Depth information for pixel blocks.
在一种可能的实现方式中,图像处理装置可以根据目标区域更新第一像素块的深度信息。其中,目标投射区域(CurMask)包括第一目标投射区域(即CurMask0)和第二目标投射区域(即CurMask0)。In a possible implementation, the image processing device may update the depth information of the first pixel block according to the target area. The target projection area (CurMask) includes a first target projection area (ie, CurMask0) and a second target projection area (ie, CurMask0).
CurMask0:待渲染图元的投射区域与像素块的非目标区域(也可称为OZ区域)的重叠区域中,如果该投射区域的最大深度(可称为第三深度值,也可简称为Zmax)小于像素块的非目标区域的最大深度值(即第二深度值,可简称为OZ),那么上述重叠区域中像素块的所有可见片段的深度值一定比Zmax值小(否则会被该图元遮蔽),那么该像素块的OZ值就有条件被更新为该待渲染图元的投射区域的Zmax值。这种情况下可以用CurMask0掩码表示这部分区域的覆盖范围。即在投射区域的第三深度值小于像素块的第二深度值的情况下,CurMask0可以表示投射区域与像素块的非目标区域的重叠区域。CurMask0: In the overlapping area between the projection area of the primitive to be rendered and the non-target area of the pixel block (also called the OZ area), if the maximum depth of the projection area (can be called the third depth value, or simply Zmax ) is less than the maximum depth value of the non-target area of the pixel block (that is, the second depth value, which can be referred to as OZ), then the depth values of all visible fragments of the pixel block in the above overlapping area must be smaller than the Zmax value (otherwise the image will be element occlusion), then the OZ value of the pixel block is conditionally updated to the Zmax value of the projection area of the primitive to be rendered. In this case, the CurMask0 mask can be used to represent the coverage of this part of the area. That is, in the case where the third depth value of the projection area is smaller than the second depth value of the pixel block, CurMask0 may represent an overlapping area of the projection area and the non-target area of the pixel block.
CurMask1:待渲染图元的投射区域与像素块的目标区域(也可称为PZ区域)的重叠区域中,如果该投射区域的最大深度小于像素块的目标区域的最大深度值(即第一深度值,可简称为PZ),那么上述重叠区域中像素块的所有可见片段的深度值一定比Zmax值小(否则会被该图元遮蔽),那么该像素块的PZ值就有条件被更新为该待渲染图元的投射区域的Zmax值。这种情况下可以用CurMask1掩码表示这部分区域的覆盖范围。即在投射区域的第三深度值小于像素块的第一深度值的情况下,CurMask1可以表示投射区域与像素块的目标区域的重叠区域。CurMask1: In the overlapping area between the projection area of the primitive to be rendered and the target area of the pixel block (also called the PZ area), if the maximum depth of the projection area is less than the maximum depth value of the target area of the pixel block (i.e. the first depth value, which can be abbreviated as PZ), then the depth values of all visible fragments of the pixel block in the above overlapping area must be smaller than the Zmax value (otherwise they will be obscured by the primitive), then the PZ value of the pixel block is conditionally updated to The Zmax value of the projected area of the primitive to be rendered. In this case, the CurMask1 mask can be used to represent the coverage of this part of the area. That is, in the case where the third depth value of the projection area is smaller than the first depth value of the pixel block, CurMask1 may represent the overlapping area of the projection area and the target area of the pixel block.
CurMask:CurMask0和CurMask1的并集。CurMask: The union of CurMask0 and CurMask1.
layer0Mask:表示原始OZ区域(即更新前的OZ区域中)中非CurMask0指示的区域。layer0Mask: Represents the area in the original OZ area (that is, the OZ area before update) that is not indicated by CurMask0.
layer1Mask:表示原始PZ区域(即更新前的PZ区域中)中非CurMask1指示的区域。layer1Mask: represents the area in the original PZ area (that is, the PZ area before update) that is not indicated by CurMask1.
具体地,图像处理装置更新第一像素块的深度信息,可以包括:Specifically, the image processing device updates the depth information of the first pixel block, which may include:
在第一投射区域与第一像素块的目标区域完全重合且第三深度值(即投射区域的最大深度值)小于第一深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更新为第三深度值。When the first projection area completely coincides with the target area of the first pixel block and the third depth value (ie, the maximum depth value of the projection area) is less than the first depth value, the target area of the first pixel block is updated to the target projection. area and update the first depth value of the first pixel block to the third depth value.
示例性地,图8中(a)图示出了第一像素块更新前的目标区域(灰色区域)和非目标区域(白色区域),图8中(b)图示出了第一投射区域(黑色区域)和第一像素块。通过图8中(b)图可以看出第一投射区域与第一像素块的目标区域完全重合。图9中(a)图示出了第一深度值(PZ)、第二深度值(OZ)以及第一投射区域的深度范围,图9中横轴表示深度值,从左往右深度值递增。通过图9中(a)图可以看出第一投射区域的最大深度值(Zmax)小于第一深度值(PZ)和第二深度值(OZ),所以目标投射区域包括整个第一投射区域。相应地,如图8中(c)图所示,图像处理装置将第一像素块的目标区域更新为目标投射区域。如图9中(b)图所示,图像处理装置将第一像素块的第一深度值(PZ)更新为第三深度值(Zmax)。Exemplarily, (a) in Figure 8 shows the target area (gray area) and non-target area (white area) before the first pixel block is updated, and (b) in Figure 8 shows the first projection area (black area) and the first pixel block. It can be seen from Figure 8(b) that the first projection area completely overlaps with the target area of the first pixel block. (a) in Figure 9 shows the first depth value (PZ), the second depth value (OZ) and the depth range of the first projection area. The horizontal axis in Figure 9 represents the depth value, and the depth value increases from left to right. . It can be seen from Figure 9(a) that the maximum depth value (Zmax) of the first projection area is smaller than the first depth value (PZ) and the second depth value (OZ), so the target projection area includes the entire first projection area. Correspondingly, as shown in (c) of FIG. 8 , the image processing device updates the target area of the first pixel block to the target projection area. As shown in (b) of FIG. 9 , the image processing device updates the first depth value (PZ) of the first pixel block to the third depth value (Zmax).
在第一投射区域与第一像素块的非目标区域完全重合且第三深度值小于第二深度值的情况下,将第一像素块的目标区域更新为非目标投射区域且将第一像素块的第二深度值更新为第三深度值。When the first projection area completely coincides with the non-target area of the first pixel block and the third depth value is less than the second depth value, the target area of the first pixel block is updated to the non-target projection area and the first pixel block is The second depth value is updated to the third depth value.
示例性地,参照图10中(a)和(b)图可以看出,第一投射区域与第一像素块的非 目标区域完全重合。参照图11中(a)图可以看出,第三深度值小于第二深度值但大于第一深度值,则目标投射区域包括第一投射区域与第一像素块的非目标区域的重合区域(即整个非目标区域)。如图8中(c)图所示,由于非目标投射区域与第一像素块的目标区域相同,图像处理装置则不更新目标区域。如图11中(b)图所示,图像处理装置将第一像素块的第二深度值(OZ)更新为第三深度值(Zmax)。For example, with reference to Figures (a) and (b) in Figure 10, it can be seen that the first projection area completely coincides with the non-target area of the first pixel block. Referring to Figure 11 (a), it can be seen that the third depth value is smaller than the second depth value but larger than the first depth value, then the target projection area includes the overlapping area of the first projection area and the non-target area of the first pixel block ( i.e. the entire non-target area). As shown in (c) of FIG. 8 , since the non-target projection area is the same as the target area of the first pixel block, the image processing device does not update the target area. As shown in (b) of FIG. 11 , the image processing device updates the second depth value (OZ) of the first pixel block to the third depth value (Zmax).
又示例性地,参照图12中(a)和(b)图可以看出,第一投射区域与第一像素块的非目标区域完全重合。若第一投射区域的最大深度值(Zmax)小于第一深度值(PZ)和第二深度值(OZ),则目标投射区域包括整个第一投射区域。那么如图12中(c)图所示,图像处理装置将第一像素块的目标区域更新为非目标投射区域(即第一像素块中未与第一投影区域重叠的区域)并将第一像素块的第二深度值(OZ)更新为第三深度值(Zmax)。As another example, with reference to pictures (a) and (b) in FIG. 12 , it can be seen that the first projection area completely coincides with the non-target area of the first pixel block. If the maximum depth value (Zmax) of the first projection area is smaller than the first depth value (PZ) and the second depth value (OZ), then the target projection area includes the entire first projection area. Then, as shown in (c) of Figure 12, the image processing device updates the target area of the first pixel block to the non-target projection area (that is, the area in the first pixel block that does not overlap with the first projection area) and adds the first The second depth value (OZ) of the pixel block is updated to the third depth value (Zmax).
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第二条件的情况下,将第一像素块的目标区域更新为第一区域且将第一像素块的第一深度值更新为第一数值。其中,上述第一条件为第三深度值小于第一深度值但大于第二深度值或第三深度值小于第二深度值但大于第一深度值。上述第二条件为第一绝对值小于第二绝对值,上述第一绝对值为上述第一深度值与上述第三深度值之差的绝对值,上述第二绝对值为上述第二深度值与上述第三深度值之差的绝对值。上述第一区域为目标区域与目标投射区域的并集区域,第一数值为第一深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the second condition are met, the target area of the first pixel block is updated to the first area and the third The first depth value of a pixel block is updated to a first numerical value. Wherein, the above-mentioned first condition is that the third depth value is smaller than the first depth value but larger than the second depth value or the third depth value is smaller than the second depth value but larger than the first depth value. The second condition is that the first absolute value is less than the second absolute value. The first absolute value is the absolute value of the difference between the first depth value and the third depth value. The second absolute value is the difference between the second depth value and the third depth value. The absolute value of the difference between the above third depth values. The above-mentioned first area is the union area of the target area and the target projection area, and the first value is the larger value between the first depth value and the third depth value.
需要说明的是,满足第一条件和第二条件,表示第三深度值处于第一深度值和第二深度值之间,且第三深度值距离第一深度值较近。It should be noted that satisfying the first condition and the second condition means that the third depth value is between the first depth value and the second depth value, and the third depth value is closer to the first depth value.
又示例性地,参照图13中(a)和(b)图可以看出,第一投射区域与第一像素块的目标区域和非目标区域均不完全重合。参照图14中(a)图可以看出第三深度值(Zmax)处于第一深度值(PZ)和第二深度值(OZ)之间,且第三深度值距离第一深度值较近。由于第三深度值小于第二深度值但大于第一深度值,所以目标投射区域仅包括第一投射区域与非目标区域的重叠区域,第一区域则包括目标投射区域和当前目标区域。如图13中(c)图所示,图像处理装置将第一像素块的目标区域更新为第一区域。由于第三深度值大于第一深度值,则第一数值为第三深度值。如图14中(b)图所示,图像处理装置将第一像素块的第一深度值(PZ)更新为第三深度值(Zmax)。As another example, with reference to pictures (a) and (b) in FIG. 13 , it can be seen that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block. Referring to Figure 14(a), it can be seen that the third depth value (Zmax) is between the first depth value (PZ) and the second depth value (OZ), and the third depth value is closer to the first depth value. Since the third depth value is smaller than the second depth value but larger than the first depth value, the target projection area only includes the overlapping area of the first projection area and the non-target area, and the first area includes the target projection area and the current target area. As shown in (c) of FIG. 13 , the image processing device updates the target area of the first pixel block to the first area. Since the third depth value is greater than the first depth value, the first value is the third depth value. As shown in (b) of FIG. 14 , the image processing device updates the first depth value (PZ) of the first pixel block to the third depth value (Zmax).
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且满足第一条件和第三条件的情况下,将第一像素块的目标区域更新为第二区域且将第一像素块的第二深度值更新为第二数值。其中,上述第三条件为第一绝对值大于第二绝对值。上述第二区域为目标区域与非目标投射区域的交集区域。上述第二数值为第二深度值与第三深度值之间的较大值。When the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the first condition and the third condition are met, the target area of the first pixel block is updated to the second area and the third The second depth value of a pixel block is updated to a second value. Wherein, the above third condition is that the first absolute value is greater than the second absolute value. The above-mentioned second area is the intersection area of the target area and the non-target projection area. The above-mentioned second value is the larger value between the second depth value and the third depth value.
需要说明的是,满足第一条件和第三条件,表示第三深度值处于第一深度值和第二深度值之间,且第三深度值距离第二深度值较近。It should be noted that satisfying the first condition and the third condition means that the third depth value is between the first depth value and the second depth value, and the third depth value is closer to the second depth value.
又示例性地,参照图15中(a)和(b)图可以看出,第一投射区域与第一像素块的目标区域和非目标区域均不完全重合。参照图16中(a)图可以看出第三深度(Zmax)值处于第一深度值(PZ)和第二深度值(OZ)之间,且第三深度值距离第二深度值较近。由于第三深度值小于第二深度值但大于第一深度值,所以目标投射区域仅包括第一投射区域与非目标区域的重叠区域。第二区域则包括非目标投射区域和当前目标区域的交集区 域。如图15中(c)图所示,由于第二区域与当前目标区域相同,则图像处理装置则不更新目标区域。由于第二深度值大于第三深度值,则第二数值为第二深度值。如图16中(b)图所示,由于第二数值和当前第二深度值(OZ)相同,图像处理装置则不更新第二深度值(OZ)。As another example, with reference to pictures (a) and (b) in FIG. 15 , it can be seen that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block. Referring to (a) in FIG. 16 , it can be seen that the third depth (Zmax) value is between the first depth value (PZ) and the second depth value (OZ), and the third depth value is closer to the second depth value. Since the third depth value is smaller than the second depth value but larger than the first depth value, the target projection area only includes an overlapping area of the first projection area and the non-target area. The second area includes the intersection area of the non-target projection area and the current target area. As shown in (c) of Figure 15, since the second area is the same as the current target area, the image processing device does not update the target area. Since the second depth value is greater than the third depth value, the second value is the second depth value. As shown in (b) of FIG. 16 , since the second value is the same as the current second depth value (OZ), the image processing device does not update the second depth value (OZ).
在第一投射区域与第一像素块的目标区域和非目标区域均不完全重合且第三深度值小于第一深度值和第二深度值的情况下,将第一像素块的目标区域更新为目标投射区域且将第一像素块的第一深度值更为第三深度值,将第一像素块的第二深度值更新为第三数值。其中,第三数值为第一深度值与第二深度值之间的较大值。In the case that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block and the third depth value is smaller than the first depth value and the second depth value, the target area of the first pixel block is updated as The target projection area is to change the first depth value of the first pixel block to a third depth value, and update the second depth value of the first pixel block to a third value. The third value is the larger value between the first depth value and the second depth value.
又示例性地,参照图17中(a)和(b)图可以看出,第一投射区域与第一像素块的目标区域和非目标区域均不完全重合。参照图18中(a)图可以看出第三深度值(Zmax)小于第一深度值(PZ)和第二深度值(OZ)。由于第三深度值小于第一深度值和第二深度值,所以目标投射区域包括整个第一投射区域。如图17中(c)图所示,图像处理装置将第一像素块的目标区域更新目标投射区域即整个第一投射区域。由于第一深度值小于第二深度值,所以第三数值为第二深度值。如图18中(a)图所示,图像处理装置将第一像素块的第一深度值更新为第三深度值。另外,由于第一像素块的当前第二深度值与第三数值相同,图像处理装置则不更新第一像素块的第二深度值。As another example, with reference to pictures (a) and (b) in FIG. 17 , it can be seen that the first projection area does not completely coincide with the target area and the non-target area of the first pixel block. Referring to (a) in FIG. 18 , it can be seen that the third depth value (Zmax) is smaller than the first depth value (PZ) and the second depth value (OZ). Since the third depth value is smaller than the first depth value and the second depth value, the target projection area includes the entire first projection area. As shown in (c) of FIG. 17 , the image processing device updates the target area of the first pixel block to the target projection area, that is, the entire first projection area. Since the first depth value is smaller than the second depth value, the third value is the second depth value. As shown in (a) of FIG. 18 , the image processing device updates the first depth value of the first pixel block to the third depth value. In addition, since the current second depth value of the first pixel block is the same as the third value, the image processing device does not update the second depth value of the first pixel block.
可选地,图像处理装置可以将通过第二深度测试的待渲染图元存储在分区管线中的多边形列表生成(polygon list generation)。Alternatively, the image processing device may store the primitives to be rendered that pass the second depth test in polygon list generation (polygon list generation) in the partition pipeline.
S402、图像处理装置将通过第二深度测试的待渲染图元输入渲染管线。S402. The image processing device inputs the graphics elements to be rendered that have passed the second depth test into the rendering pipeline.
示例性地,以M个待渲染图元输入分区管线的待渲染图元中的K个待渲染图元通过第二深度测试为例,图像处理装置中的polygon list generation可以将通过第二深度测试的待渲染图元打包成多个多边形列表(PL),然后以多边形堆栈(PL-Heap)的形式输入渲染管线。For example, taking the K to-be-rendered primitives among the M to-be-rendered primitives input into the partition pipeline to pass the second depth test, the polygon list generation in the image processing device can pass the second depth test. The primitives to be rendered are packed into multiple polygon lists (PL), and then input into the rendering pipeline in the form of polygon stacks (PL-Heap).
S403、图像处理装置将输入渲染管线的图元转换为待渲染片段。S403. The image processing device converts the primitives input into the rendering pipeline into fragments to be rendered.
示例性地,图像处理装置可以通过渲染管线中的光栅化器将输入渲染管线的图元(即通过第二深度测试的图元)转换为待渲染片段。For example, the image processing device may convert primitives input to the rendering pipeline (ie, primitives that pass the second depth test) into fragments to be rendered through a rasterizer in the rendering pipeline.
上述将图元转换为片段的具体方法可以采用本领域技术人员能够想到的任何一种方法进行处理,本申请实施例对此不做具体限定。The above-mentioned specific method of converting graphics elements into fragments can be processed by any method that can be thought of by those skilled in the art, and this is not specifically limited in the embodiments of the present application.
S404、图像处理装置对待渲染片段进行第一深度测试并剔除未通过第一深度测试的待渲染片段。S404. The image processing device performs a first depth test on the segments to be rendered and eliminates the segments to be rendered that fail the first depth test.
在一种可能的实现方式中,图像处理装置中可以根据全局深度信息缓存模块中的全局深度信息对待渲染片段进行第一深度测试。In a possible implementation, the image processing device may perform a first depth test on the segment to be rendered based on the global depth information in the global depth information cache module.
具体地,图像处理装置中可以根据全局深度信息中目标像素块的深度信息和待渲染片段的深度信息对待渲染片段进行第一深度测试。其中,目标像素块为多个像素块中与待渲染片段存在重叠的像素块。Specifically, the image processing device may perform a first depth test on the segment to be rendered based on the depth information of the target pixel block in the global depth information and the depth information of the segment to be rendered. The target pixel block is a pixel block among multiple pixel blocks that overlaps with the segment to be rendered.
示例性地,图19示出了9个像素块和1个待渲染片段(图中黑色方块),可以看出左上角的像素块与待渲染片段存在重叠。图像处理装置则根据全局深度信息中左上角的像素块的深度信息和待渲染片段的深度信息对待渲染片段进行第一深度测试。For example, Figure 19 shows 9 pixel blocks and 1 fragment to be rendered (black square in the figure). It can be seen that the pixel block in the upper left corner overlaps with the fragment to be rendered. The image processing device performs a first depth test on the segment to be rendered based on the depth information of the pixel block in the upper left corner of the global depth information and the depth information of the segment to be rendered.
可选地,片段的深度信息可以包括片段的深度值。其中,片段的深度值可以是通过插 值得到的。Alternatively, the depth information of the fragment may include a depth value of the fragment. Among them, the depth value of the fragment can be obtained through interpolation.
在一种可能的实现方式中,图像处理装置根据待渲染片段的深度值、第一深度值或第二深度值对待渲染片段进行第一深度测试。In a possible implementation, the image processing device performs a first depth test on the fragment to be rendered based on the depth value, the first depth value or the second depth value of the fragment to be rendered.
在一种可能的实现方式中,图像处理装置可以根据待渲染片段的深度值、第一深度值或第二深度值对待渲染片段进行第一深度测试,可以包括:In a possible implementation, the image processing device may perform a first depth test on the fragment to be rendered based on the depth value, the first depth value, or the second depth value of the fragment to be rendered, which may include:
图像处理装置在待渲染片段位于目标像素块的目标区域内且该待渲染片段的深度值小于或等于第一深度值的情况下,确定该待渲染片段通过第一深度测试。The image processing device determines that the segment to be rendered passes the first depth test when the segment to be rendered is located within the target area of the target pixel block and the depth value of the segment to be rendered is less than or equal to the first depth value.
图像处理装置在待渲染片段位于目标像素块的目标区域内且该待渲染片段的深度值大于第一深度值的情况下,确定该待渲染片段未通过第一深度测试。The image processing device determines that the segment to be rendered fails the first depth test when the segment to be rendered is located within the target area of the target pixel block and the depth value of the segment to be rendered is greater than the first depth value.
图像处理装置在待渲染片段未位于目标像素块的目标区域且该待渲染片段的深度值小于或等于第二深度值的情况下,确定该待渲染片段通过第一深度测试。The image processing device determines that the segment to be rendered passes the first depth test when the segment to be rendered is not located in the target area of the target pixel block and the depth value of the segment to be rendered is less than or equal to the second depth value.
图像处理装置在待渲染片段未位于目标像素块的目标区域且该待渲染片段的深度值大于第二深度值的情况下,确定该待渲染片段未通过第一深度测试。The image processing device determines that the segment to be rendered fails the first depth test when the segment to be rendered is not located in the target area of the target pixel block and the depth value of the segment to be rendered is greater than the second depth value.
需要说明的是,待渲染片段位于目标像素块的目标区域且待渲染片段的深度值大于第一深度值,说明该待渲染片段会被目标像素块的目标区域内的可见片段所遮挡,所以可以将该待渲染片段剔除,以降低计算资源消耗量,提升GPU的渲染速度。It should be noted that the fragment to be rendered is located in the target area of the target pixel block and the depth value of the fragment to be rendered is greater than the first depth value, indicating that the fragment to be rendered will be occluded by the visible fragments in the target area of the target pixel block, so it can Eliminate the fragment to be rendered to reduce the consumption of computing resources and increase the rendering speed of the GPU.
待渲染片段位于非目标像素块的目标区域且待渲染片段的深度值大于第二深度值,说明该待渲染片段会被目标像素块的非目标区域内的可见片段所遮挡,所以可以将该待渲染片段剔除,以降低计算资源消耗量,提升GPU的渲染速度。The fragment to be rendered is located in the target area of the non-target pixel block and the depth value of the fragment to be rendered is greater than the second depth value, indicating that the fragment to be rendered will be obscured by the visible fragments in the non-target area of the target pixel block, so the fragment to be rendered can be Eliminate rendering fragments to reduce computing resource consumption and increase GPU rendering speed.
示例性地,以图20所示的画面中位于左侧框内的一个4x4大小的像素块为例,可以看出该像素块中渲染的物体包括天空,屋顶以及一个的三角形。图21中(a)图所示的灰色区域为该像素块的目标区域,黑色区域为该像素块的非目标区域。全局深度信息中该像素块的目标区域的最大深度值(PZ)为0.1,非目标区域的最大深度值(OZ)为1.0。在对三角形进行光栅化后,通过图21中(b)图可以看出该三角形的两个片段(即图中的白色方格)位于目标区域,通过图21中(c)图可以看出该三角形的两个片段(即图中的浅灰色方格)位于非目标区域。如图21中(d)图所示,由于位于目标区域的两个片段插值出来的深度值大于PZ,所以位于目标区域的两个片段会被剔除;而位于非目标区域的两个片段插值出来的深度值小于OZ,所以位于非目标区域的两个片段不会被剔除,而是会输入像素着色器中进行着色渲染。For example, taking a 4x4 pixel block located in the left frame in the picture shown in Figure 20 as an example, it can be seen that the objects rendered in this pixel block include the sky, the roof, and a triangle. The gray area shown in (a) of Figure 21 is the target area of the pixel block, and the black area is the non-target area of the pixel block. In the global depth information, the maximum depth value (PZ) of the target area of the pixel block is 0.1, and the maximum depth value (OZ) of the non-target area is 1.0. After rasterizing the triangle, it can be seen from the picture (b) in Figure 21 that the two fragments of the triangle (that is, the white squares in the picture) are located in the target area. It can be seen from the picture (c) in Figure 21 The two segments of the triangle (the light gray squares in the figure) are located in the non-target area. As shown in (d) of Figure 21, since the interpolated depth values of the two fragments located in the target area are greater than the PZ, the two fragments located in the target area will be eliminated; while the two fragments located in the non-target area are interpolated. The depth value is smaller than OZ, so the two fragments located in the non-target area will not be culled, but will be input to the pixel shader for rendering.
可以看出,本申请实施例提供的方法可以通过全局深度信息对待渲染片段进行剔除,由于全局深度信息是根据全部待渲染图元确定,而待渲染片段是由待渲染图元转换得到的,所以全局深度信息相当于是根据所有待渲染片段生成的。本申请实施例利用全部待渲染片段的深度信息进行片段剔除,相较于相关技术仅通过部分待渲染片段的深度信息进行片段剔除,能够提升对待渲染数据的剔除率,从而降低计算资源消耗量,以提升GPU的渲染速度。It can be seen that the method provided by the embodiment of the present application can eliminate the fragments to be rendered through the global depth information. Since the global depth information is determined based on all the primitives to be rendered, and the fragments to be rendered are converted from the primitives to be rendered, so Global depth information is equivalent to being generated based on all fragments to be rendered. The embodiment of the present application uses the depth information of all the fragments to be rendered to eliminate fragments. Compared with the related technology, which only uses the depth information of some fragments to be rendered to eliminate fragments, the elimination rate of the data to be rendered can be improved, thereby reducing the consumption of computing resources. To improve the rendering speed of GPU.
S405、图像处理装置将通过第一深度测试的待渲染片段输入像素着色器。S405. The image processing device inputs the fragment to be rendered that passes the first depth test into the pixel shader.
在一种可能的实现方式中,图像处理装置可以先通过前深度测试模块对通过第一深度测试的待渲染片段进行前深度测试,然后将通过前深度测试的待渲染片段输入像素着色器。In a possible implementation, the image processing device may first perform a front-depth test on the to-be-rendered fragments that pass the first depth test through a front-depth test module, and then input the to-be-rendered fragments that pass the front-depth test into the pixel shader.
S406、图像处理装置对输入像素着色器的片段进行着色渲染。S406. The image processing device performs coloring and rendering on the fragments input to the pixel shader.
上述着色渲染的具体方法可以采用本领域技术人员能够想到的任何一种方法进行处理,本申请实施例对此不做具体限定。The above-mentioned specific method of shading and rendering can be processed by any method that can be thought of by those skilled in the art, and the embodiments of the present application do not specifically limit this.
在一种可能的实现方式中,图像处理装置可以通过后深度测试模块对着色渲染后的片段进行后深度测试。In a possible implementation, the image processing device can perform a post-depth test on the rendered fragments through a post-depth test module.
图5示出了本申请实施例提供的另一种图像处理方法的示意性流程图,该方法可以由图3所示的图像处理装置执行。如图5所示,该图像处理方法包括:FIG. 5 shows a schematic flowchart of another image processing method provided by an embodiment of the present application. This method can be executed by the image processing device shown in FIG. 3 . As shown in Figure 5, the image processing method includes:
S501、图像处理装置将输入渲染管线的图元转换为待渲染片段。S501. The image processing device converts the primitives input into the rendering pipeline into fragments to be rendered.
S502、图像处理装置根据全局深度信息对待渲染片段进行第一深度测试S502. The image processing device performs the first depth test on the fragment to be rendered based on the global depth information.
其中,全局深度信息包括根据全部待渲染图元更新得到的多个像素块的深度信息。The global depth information includes depth information of multiple pixel blocks updated based on all primitives to be rendered.
需要说明的是,S502的具体实现方式可以参考上述S404的描述,在此就不再赘述。It should be noted that the specific implementation of S502 may refer to the description of S404 above, and will not be described again here.
S503、若待渲染片段未通过第一深度测试,图像处理装置则剔除所述待渲染片段。S503. If the segment to be rendered fails the first depth test, the image processing device eliminates the segment to be rendered.
本申请实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在图像处理装置上运行时,使得图像处理装置执行上述相关方法步骤实现上述实施例中的图像处理方法。Embodiments of the present application also provide a computer storage medium. Computer instructions are stored in the computer storage medium. When the computer instructions are run on an image processing device, the image processing device executes the above related method steps to realize the image in the above embodiment. Approach.
本申请实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的图像处理方法。An embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, it causes the computer to perform the above related steps to implement the image processing method in the above embodiment.
本申请实施例还提供一种图像处理装置,这个装置具体可以是芯片、集成电路、组件或模块。具体的,该装置可包括相连的处理器和用于存储指令的存储器,或者该装置包括至少一个处理器,用于从外部存储器获取指令。当装置运行时,处理器可执行指令,以使芯片执行上述各方法实施例中的图像处理方法。An embodiment of the present application also provides an image processing device, which may be a chip, an integrated circuit, a component or a module. Specifically, the device may include a connected processor and a memory for storing instructions, or the device may include at least one processor for retrieving instructions from an external memory. When the device is running, the processor can execute instructions to cause the chip to execute the image processing method in each of the above method embodiments.
请参阅图22,图22是本申请实施例提供的另一种图像处理装置的结构示意图。该图像处理装置2000包括:至少一个CPU,GPU,存储器,存储器的类型例如可以包括SRAM和ROM,微控制器(Micro controller Unit,MCU)、WLAN子系统、总线、传输接口等。虽然图22中未示出,该图像处理装置2000还可以包括应用处理器(Application Processor,AP),NPU等其他专用处理器,以及电源管理子系统、时钟管理子系统和功耗管理子系统等其他子系统。Please refer to FIG. 22 , which is a schematic structural diagram of another image processing device provided by an embodiment of the present application. The image processing device 2000 includes: at least one CPU, GPU, and memory. The types of memory may include, for example, SRAM and ROM, a microcontroller unit (Micro controller Unit, MCU), a WLAN subsystem, a bus, a transmission interface, and the like. Although not shown in Figure 22, the image processing device 2000 may also include an application processor (Application Processor, AP), NPU and other dedicated processors, as well as a power management subsystem, a clock management subsystem, a power consumption management subsystem, etc. other subsystems.
图像处理装置2000的上述各个部分通过连接器相耦合,示例性的,连接器包括各类接口、传输线或总线等,这些接口通常是电性通信接口,但是也可能是机械接口或其他形式的接口,本实施例对此不做限定。The above-mentioned parts of the image processing device 2000 are coupled through connectors. For example, connectors include various types of interfaces, transmission lines or buses, etc. These interfaces are usually electrical communication interfaces, but they may also be mechanical interfaces or other forms of interfaces. , this embodiment does not limit this.
可选地,CPU可以是一个单核(single-CPU)处理器或多核(multi-CPU)处理器;可选地,CPU可以是多个处理器构成的处理器组,多个处理器之间通过一个或多个总线彼此耦合。在一种可选地情况中,CPU通过调用片上述存储器或者片外存储器中存储的程序指令实现如上述方法实施例中的任一种图像处理方法。在一种可选地情况中,CPU和MCU共同实现如上述方法实施例中的任一种图像处理方法,例如CPU完成图像处理方法中的部分步骤,而MCU完成图像处理方法中的其他步骤。在一种可选地情况中,AP或者其他专用处理器通过调用片上述存储器或者片外存储器中存储的程序指令实现如上述方法实施例中的任一种图像处理方法。Optionally, the CPU can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor; optionally, the CPU can be a processor group composed of multiple processors. Coupled to each other via one or more buses. In an optional situation, the CPU implements any of the image processing methods in the above method embodiments by calling program instructions stored in the above-mentioned on-chip memory or off-chip memory. In an optional situation, the CPU and the MCU jointly implement any of the image processing methods in the above method embodiments. For example, the CPU completes some steps in the image processing method, and the MCU completes other steps in the image processing method. In an optional situation, the AP or other special-purpose processor implements any of the image processing methods in the above method embodiments by calling program instructions stored in the above-mentioned on-chip memory or off-chip memory.
该传输接口可以为处理器芯片的接收和发送数据的接口,该传输接口通常包括多种接 口,在一种可选地情况下,该传输接口可以包括内部整合电路(Inter-Integrated Circuit,I2C)接口、串行外设接口(Serial Peripheral Interface,SPI)、通用异步收发机(Universal asynchronous receiver-transmitter,UART)接口、通用输入输出(General-purpose input/output,GPIO)接口等。应当理解,这些接口可以是通过复用相同的物理接口来实现不同的功能。The transmission interface may be an interface for receiving and sending data of the processor chip. The transmission interface usually includes a variety of interfaces. In an optional case, the transmission interface may include an internal integrated circuit (Inter-Integrated Circuit, I2C). interface, Serial Peripheral Interface (SPI), Universal asynchronous receiver-transmitter (UART) interface, General-purpose input/output (GPIO) interface, etc. It should be understood that these interfaces can implement different functions by reusing the same physical interface.
在一种可选地情况中,传输接口还可以包括高清晰度多媒体接口(High Definition Multimedia Interface,HDMI)、V-By-One接口、嵌入式显示端口(Embedded Display Port,eDP)、移动产业处理器接口(Mobile Industry Processor Interface,MIPI)或Display Port(DP)等。In an optional case, the transmission interface may also include a High Definition Multimedia Interface (HDMI), a V-By-One interface, an embedded display port (Embedded Display Port, eDP), and a mobile industry processing interface. Mobile Industry Processor Interface (MIPI) or Display Port (DP), etc.
在一种可选地情况中,上述各部分集成在同一个芯片上;在另一种可选地情况中,存储器可以是独立存在的芯片。In an optional situation, the above-mentioned parts are integrated on the same chip; in another optional situation, the memory can be an independent chip.
WLAN子系统例如可以包括射频电路和基带。A WLAN subsystem may include radio frequency circuitry and baseband, for example.
在本申请实施例中涉及的芯片是以集成电路工艺制造在同一个半导体衬底上的系统,也叫半导体芯片,其可以是利用集成电路工艺制作在衬底(通常是例如硅一类的半导体材料)上形成的集成电路的集合,其外层通常被半导体封装材料封装。上述集成电路可以包括各类功能器件,每一类功能器件包括逻辑门电路、金属氧化物半导体(Metal-Oxide-Semiconductor,MOS)晶体管、双极晶体管或二极管等晶体管,也可包括电容、电阻或电感等其他部件。每个功能器件可以独立工作或者在必要的驱动软件的作用下工作,可以实现通信、运算或存储等各类功能。The chip involved in the embodiment of the present application is a system manufactured on the same semiconductor substrate using an integrated circuit process, also called a semiconductor chip. It can be manufactured using an integrated circuit process on a substrate (usually a semiconductor such as silicon). A collection of integrated circuits formed on a semiconductor packaging material, the outer layer of which is usually encapsulated by a semiconductor packaging material. The above-mentioned integrated circuits may include various types of functional devices. Each type of functional devices may include logic gate circuits, metal-oxide-semiconductor (MOS) transistors, bipolar transistors or diodes, and may also include capacitors, resistors or transistors. Inductors and other components. Each functional device can work independently or with the help of necessary driver software, and can realize various functions such as communication, computing or storage.
其中,本实施例提供的图像处理装置、计算机存储介质和计算机程序产品均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Among them, the image processing device, computer storage medium and computer program product provided by this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the corresponding method provided above. The beneficial effects will not be repeated here.
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that in the various embodiments of the present application, the size of the sequence numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its functions and internal logic, and should not be used in the embodiments of the present application. The implementation process constitutes any limitation.
本领域普通技术人员可以意识到,结合本申请中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考上述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can be referred to the corresponding processes in the above method embodiments, and will not be described again here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其他的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其他的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the above units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or may be Integrated into another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络 单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit.
上述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例上述方法的全部或部分步骤。而上述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the above methods in various embodiments of the present application. The above-mentioned storage media include: U disk, mobile hard disk, read only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应所述以权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application. should be covered by the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims (33)
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2021/140588 WO2023115408A1 (en) | 2021-12-22 | 2021-12-22 | Image processing apparatus and method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117203661A true CN117203661A (en) | 2023-12-08 |
Family
ID=86901074
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202180096777.0A Pending CN117203661A (en) | 2021-12-22 | 2021-12-22 | Image processing apparatus and method |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN117203661A (en) |
WO (1) | WO2023115408A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117710502A (en) * | 2023-12-12 | 2024-03-15 | 摩尔线程智能科技(北京)有限责任公司 | Rendering method, device and storage medium |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9558585B2 (en) * | 2013-05-31 | 2017-01-31 | Arm Limited | Hidden surface removal in graphics processing systems |
US20180082464A1 (en) * | 2016-09-16 | 2018-03-22 | Tomas G. Akenine-Moller | Apparatus and method for an efficient 3d graphics pipeline |
US11315225B2 (en) * | 2019-06-20 | 2022-04-26 | Samsung Electronics Co., Ltd. | Coarse depth culling during binning |
CN111127299A (en) * | 2020-03-26 | 2020-05-08 | 南京芯瞳半导体技术有限公司 | Method and device for accelerating rasterization traversal and computer storage medium |
US11250620B2 (en) * | 2020-06-09 | 2022-02-15 | Arm Limited | Graphics processing |
CN112933599B (en) * | 2021-04-08 | 2022-07-26 | 腾讯科技(深圳)有限公司 | Three-dimensional model rendering method, device, equipment and storage medium |
-
2021
- 2021-12-22 WO PCT/CN2021/140588 patent/WO2023115408A1/en active Application Filing
- 2021-12-22 CN CN202180096777.0A patent/CN117203661A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117710502A (en) * | 2023-12-12 | 2024-03-15 | 摩尔线程智能科技(北京)有限责任公司 | Rendering method, device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
WO2023115408A1 (en) | 2023-06-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10475228B2 (en) | Allocation of tiles to processing engines in a graphics processing system | |
CN110390644B (en) | Method and system for modifying one or more digital images | |
KR100959470B1 (en) | Scalable high performance 3D graphics | |
US12002190B2 (en) | Primitive testing for ray intersection at multiple precisions | |
JP2010507875A (en) | 3D clipping in graphics processing unit | |
CN115147579A (en) | Block rendering mode graphic processing method and system for expanding block boundary | |
US20190188907A1 (en) | Assembling Primitive Data into Multi-view Primitive Blocks in a Graphics Processing System | |
CN115330986B (en) | Method and system for processing graphics in block rendering mode | |
CN111667542A (en) | Decompression technique for processing compressed data suitable for artificial neural networks | |
US20240046550A1 (en) | Quantized Ray Intersection Testing with Definitive Hit Detection | |
US8941660B2 (en) | Image generating apparatus, image generating method, and image generating integrated circuit | |
US8068120B2 (en) | Guard band clipping systems and methods | |
CN119516036A (en) | Add greater realism to computer-generated images by smoothing jagged edges | |
US20080055326A1 (en) | Processing of Command Sub-Lists by Multiple Graphics Processing Units | |
US10255655B1 (en) | Serial pixel processing with storage for overlapping texel data | |
CN117203661A (en) | Image processing apparatus and method | |
US10621782B1 (en) | Sub-patch techniques for graphics tessellation | |
US11734871B2 (en) | Ray intersection testing with quantization and interval representations | |
CN116957899B (en) | Graphics processor, system, device, equipment and method | |
US20150042656A1 (en) | Apparatus and method for processing image | |
US8711156B1 (en) | Method and system for remapping processing elements in a pipeline of a graphics processing unit | |
US11210761B1 (en) | Circuitry to determine set of priority candidates | |
CN101261744A (en) | Guard band cutting system and guard band cutting method in drawing processor | |
CN116503532A (en) | Model rendering method and device, electronic equipment and storage medium | |
TWI478094B (en) | Guard band clipping systems and methods |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |