5

在尝试调试为什么某些 CoreImage 渲染显着增加了我们的 CPU 使用率时,我可以在示例跟踪中看到,当我以某些方式裁剪和合成图像时,CoreImage 正在执行 memcpys。当我取出裁剪过滤器时,它就消失了。我将它用于实时 2D 视频管道,所以这不好。

我所有的图像都在 GPU 上,所以我很难理解它在 CPU 上复制了什么。

任何人都知道这可能会做什么?

+                       ! 457 -[CIContext render:toCVPixelBuffer:bounds:colorSpace:]  (in CoreImage) + 1296  [0x7fff8db01111]
+                       !   457 -[CIContext render:toIOSurface:bounds:colorSpace:]  (in CoreImage) + 1907  [0x7fff8db030e5]
+                       !     455 CI::image_render_to_surface(CI::Context*, CI::Image*, CGRect, CGColorSpace*, __IOSurface*, CGPoint, CI::PixelFormat)  (in CoreImage) + 1862  [0x7fff8db1d8a9]
+                       !     : 451 CI::_image_render(char const*, CI::Context*, CI::Image*, CGRect, CGColorSpace*, CI::PixelFormat, unsigned long, CGPoint const&, CI::swizzle_info const&)  (in CoreImage) + 869  [0x7fff8db1cdda]
+                       !     : | 443 CI::tile_node_graph(CI::Context*, char const*, CI::Node*, CGRect const&, CI::PixelFormat, CI::swizzle_info const&, void (CI::Node*, CGRect) block_pointer)  (in CoreImage) + 834  [0x7fff8db1ffe1]
+                       !     : | + 416 ___ZN2CIL13_image_renderEPKcPNS_7ContextEPNS_5ImageE6CGRectP12CGColorSpaceNS_11PixelFormatEmRK7CGPointRKNS_12swizzle_infoE_block_invoke  (in CoreImage) + 22  [0x7fff8db22d54]
+                       !     : | + ! 416 CI::Context::render(CI::Node*, CGRect const&)  (in CoreImage) + 75  [0x7fff8db0efb1]
+                       !     : | + !   413 CI::Context::recursive_render(CI::Node*, CGRect const&, CI::Node*)  (in CoreImage) + 1285  [0x7fff8db0ee95]
+                       !     : | + !   : 277 CI::MetalContext::render_root_node(CI::ProgramNode*, CGRect const&, void () block_pointer)  (in CoreImage) + 105  [0x7fff8dc09549]
+                       !     : | + !   : | 273 CI::MetalContext::render_node(CI::ProgramNode*, CGRect const&, void const**, unsigned long, bool)  (in CoreImage) + 765  [0x7fff8dc08ddb]
+                       !     : | + !   : | + 269 CI::MetalContext::bind_arguments(CI::ProgramNode const*, CGRect const&, CGRect const&)  (in CoreImage) + 532  [0x7fff8dc0906a]
+                       !     : | + !   : | + ! 252 CI::Context::bind_sampler(CI::TextureSampler const*, CGRect const&, int, CI::KernelArgumentType)  (in CoreImage) + 992  [0x7fff8db0f3a6]
+                       !     : | + !   : | + ! : 232 CI::SurfaceNode::surfaceForROI(CI::Context const*, CGRect) const  (in CoreImage) + 718  [0x7fff8db71dc2]
+                       !     : | + !   : | + ! : | 142 SurfaceApplyPlaneReadOnlyBlock  (in CoreImage) + 170  [0x7fff8dbdcd39]
+                       !     : | + !   : | + ! : | + 142 ___ZNK2CI11SurfaceNode13surfaceForROIEPKNS_7ContextE6CGRect_block_invoke  (in CoreImage) + 123  [0x7fff8db71e5c]
+                       !     : | + !   : | + ! : | +   139 SurfaceApplyPlaneBlock  (in CoreImage) + 196  [0x7fff8dbdcbeb]
+                       !     : | + !   : | + ! : | +   ! 133 ___ZNK2CI11SurfaceNode13surfaceForROIEPKNS_7ContextE6CGRect_block_invoke_2  (in CoreImage) + 367  [0x7fff8db71fd1]
+                       !     : | + !   : | + ! : | +   ! : 133 _platform_memmove$VARIANT$Haswell  (in libsystem_platform.dylib) + 324,224,...  [0x7fffa2a63fe4,0x7fffa2a63f80,...]

更新:

这是包含裁剪的渲染管道。这个使用大量的 CPU 和上面的 memcpy。所有的来源都是 IOSurfaces。它正在拍摄两张图像并进行分屏:

<CIImage: 0x618000623e20 extent [infinite]>
  colorkernel _sourceOver(src,dst) extent=[infinite]
    crop [1280 0 1280 1440] extent=[1280 0 1280 1440]
      affine [3.13725 0 0 3.13725 825.098 0] extent=[825.098 0 2189.8 1440]
        affine [1 0 0 -1 0 459] extent=[0 0 698 459]
          IOSurface 0x610000010300 BGRA8 extent=[0 0 698 459]
    colorkernel _sourceOver(src,dst) extent=[infinite]
      crop [0 0 1281 1440] extent=[0 0 1281 1440] opaque
        affine [-2.00156 -0 0 2 1921.5 0] extent=[-640.5 0 2562 1440] opaque
          affine [1 0 0 -1 0 720] extent=[0 0 1280 720] opaque
            IOSurface 0x60000000b650 YCC420v 709 alpha_one extent=[0 0 1280 720] opaque
      fill [0 0 0 1 "Generic Gray Profile"] extent=[infinite][0 0 1 1] opaque

-

如果我取出作物,这是不使用 CPU 的管道,并且不会沿着 surfaceForROI 路径走:

<CIImage: 0x618000225040 extent [infinite]>
  colorkernel _sourceOver(src,dst) extent=[infinite]
    affine [3.13725 0 0 3.13725 825.098 0] extent=[825.098 0 2189.8 1440]
      affine [1 0 0 -1 0 459] extent=[0 0 698 459]
        IOSurface 0x6180000077c0 BGRA8 extent=[0 0 698 459]
    colorkernel _sourceOver(src,dst) extent=[infinite]
      affine [-2.00156 -0 0 2 1921.5 0] extent=[-640.5 0 2562 1440] opaque
        affine [1 0 0 -1 0 720] extent=[0 0 1280 720] opaque
          IOSurface 0x61000000c730 YCC420v 709 alpha_one extent=[0 0 1280 720] opaque
      fill [0 0 0 1 "Generic Gray Profile"] extent=[infinite][0 0 1 1] opaque
4

0 回答 0