有没有办法优化skia ::冲洗时间成本?

时间:2018-03-05 09:49:44

标签: cobalt

我们有两个不同的平台,并且CPU频率设置相同,并且发现光栅化器线程上 canvas->flush() 的时间成本在YT开始时间有很大差异,只有快速的一个在大多数时间有1.632ms,而慢速在大多数时间有7.292ms,所以有没有办法找到差异的根本原因并优化它?

钴版本:带有ARM-Linux和Opengl的Cobalt 11.132145

1。 enter image description here 2.Cark的编码 - > flush()

    void HardwareRasterizer::Impl::Submit(
    const scoped_refptr<render_tree::Node>& render_tree,
    const scoped_refptr<backend::RenderTarget>& render_target,
    const Options& options) {
  DCHECK(thread_checker_.CalledOnValidThread());
  scoped_refptr<backend::RenderTargetEGL> render_target_egl(
      base::polymorphic_downcast<backend::RenderTargetEGL*>(
          render_target.get()));
  // Skip rendering if we lost the surface. This can happen just before suspend
  // on Android, so now we're just waiting for the suspend to clean up.
  if (render_target_egl->is_surface_bad()) {
    return;
  }
  backend::GraphicsContextEGL::ScopedMakeCurrent scoped_make_current(
      graphics_context_, render_target_egl);
  // Make sure the render target's framebuffer is bound before continuing.
  // Skia will usually do this, but it is possible for some render trees to
  // have non-skia draw calls only, in which case this needs to be done.
  GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER,
                            render_target_egl->GetPlatformHandle()));
  // First reset the graphics context state for the pending render tree
  // draw calls, in case we have modified state in between.
  gr_context_->resetContext();
  AdvanceFrame();
  // Get a SkCanvas that outputs to our hardware render target.
  SkCanvas* canvas = GetCanvasFromRenderTarget(render_target);
  canvas->save();
  if (options.flags & Rasterizer::kSubmitFlags_Clear) {
    canvas->clear(SkColorSetARGB(0, 0, 0, 0));
  } else if (options.dirty) {
    // Only a portion of the display is dirty. Reuse the previous frame
    // if possible.
    if (render_target_egl->ContentWasPreservedAfterSwap()) {
      canvas->clipRect(CobaltRectFToSkiaRect(*options.dirty));
    }
  }
  // Rasterize the passed in render tree to our hardware render target.
  RasterizeRenderTreeToCanvas(render_tree, canvas, kBottomLeft_GrSurfaceOrigin);
  {
    TRACE_EVENT0("cobalt::renderer", "Skia Flush");
    canvas->flush();
  }
  graphics_context_->SwapBuffers(render_target_egl);
  canvas->restore();
}

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:2)

Skia flush()调用是调用所有OpenGL函数的函数(在调用该函数之前,所有绘图函数都只是序列化并以内部Skia格式排队)。

因此,在这种情况下,我会研究你的GL驱动程序实现。可能是您的CPU正在等待GPU消耗GLES发送给它的一些绘图命令。