gpt4 book ai didi

cobalt - 有没有办法优化skia::flush时间成本?

转载 作者:行者123 更新时间:2023-12-03 16:41:04 24 4
gpt4 key购买 nike

我们有两个不同的平台,CPU 频率相同的设置,发现时间成本canvas->flush() rasterizer线程在YT启动时间有很大的差异,快的最多只有1.632ms,慢的最多有7.292ms,那么有没有办法找到差异的根本原因并对其进行优化?

钴版本:Cobalt 11.132145 with ARM-Linux and Opengl

1.
enter image description here
2.canvas代码->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

最佳答案

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

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

关于cobalt - 有没有办法优化skia::flush时间成本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49107505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com