Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40d80014 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Migrate renderengine atrace calls to perfetto

Flag: android.os.perfetto_sdk_tracing
Bug: 349905670
Test: perfetto
Change-Id: Icd84634317471a249976fd59eca28a300fc38266
parent 687f9fea
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -14,11 +14,11 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <common/trace.h>
#include <log/log.h>
#include <log/log.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/impl/ExternalTexture.h>
#include <renderengine/impl/ExternalTexture.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <utils/Trace.h>


namespace android::renderengine::impl {
namespace android::renderengine::impl {


@@ -35,7 +35,7 @@ ExternalTexture::~ExternalTexture() {
}
}


void ExternalTexture::remapBuffer() {
void ExternalTexture::remapBuffer() {
    ATRACE_CALL();
    SFTRACE_CALL();
    {
    {
        auto buf = mBuffer;
        auto buf = mBuffer;
        mRenderEngine.unmapExternalTextureBuffer(std::move(buf));
        mRenderEngine.unmapExternalTextureBuffer(std::move(buf));
+1 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ cc_benchmark {
        "libui",
        "libui",
        "libutils",
        "libutils",
        "server_configurable_flags",
        "server_configurable_flags",
        "libtracing_perfetto",
    ],
    ],


    data: ["resources/*"],
    data: ["resources/*"],
+3 −3
Original line number Original line Diff line number Diff line
@@ -25,8 +25,8 @@


#include "compat/SkiaBackendTexture.h"
#include "compat/SkiaBackendTexture.h"


#include <common/trace.h>
#include <log/log_main.h>
#include <log/log_main.h>
#include <utils/Trace.h>


namespace android {
namespace android {
namespace renderengine {
namespace renderengine {
@@ -63,7 +63,7 @@ void AutoBackendTexture::releaseImageProc(SkImages::ReleaseContext releaseContex
}
}


sk_sp<SkImage> AutoBackendTexture::makeImage(ui::Dataspace dataspace, SkAlphaType alphaType) {
sk_sp<SkImage> AutoBackendTexture::makeImage(ui::Dataspace dataspace, SkAlphaType alphaType) {
    ATRACE_CALL();
    SFTRACE_CALL();


    sk_sp<SkImage> image = mBackendTexture->makeImage(alphaType, dataspace, releaseImageProc, this);
    sk_sp<SkImage> image = mBackendTexture->makeImage(alphaType, dataspace, releaseImageProc, this);
    // The following ref will be counteracted by releaseProc, when SkImage is discarded.
    // The following ref will be counteracted by releaseProc, when SkImage is discarded.
@@ -75,7 +75,7 @@ sk_sp<SkImage> AutoBackendTexture::makeImage(ui::Dataspace dataspace, SkAlphaTyp
}
}


sk_sp<SkSurface> AutoBackendTexture::getOrCreateSurface(ui::Dataspace dataspace) {
sk_sp<SkSurface> AutoBackendTexture::getOrCreateSurface(ui::Dataspace dataspace) {
    ATRACE_CALL();
    SFTRACE_CALL();
    LOG_ALWAYS_FATAL_IF(!mBackendTexture->isOutputBuffer(),
    LOG_ALWAYS_FATAL_IF(!mBackendTexture->isOutputBuffer(),
                        "You can't generate an SkSurface for a read-only texture");
                        "You can't generate an SkSurface for a read-only texture");
    if (!mSurface.get() || mDataspace != dataspace) {
    if (!mSurface.get() || mDataspace != dataspace) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@


#include <include/gpu/ganesh/vk/GrVkBackendSemaphore.h>
#include <include/gpu/ganesh/vk/GrVkBackendSemaphore.h>


#include <common/trace.h>
#include <log/log_main.h>
#include <log/log_main.h>
#include <sync/sync.h>
#include <sync/sync.h>
#include <utils/Trace.h>


namespace android::renderengine::skia {
namespace android::renderengine::skia {


@@ -78,7 +78,7 @@ base::unique_fd GaneshVkRenderEngine::flushAndSubmit(SkiaGpuContext* context,
                                                     sk_sp<SkSurface> dstSurface) {
                                                     sk_sp<SkSurface> dstSurface) {
    sk_sp<GrDirectContext> grContext = context->grDirectContext();
    sk_sp<GrDirectContext> grContext = context->grDirectContext();
    {
    {
        ATRACE_NAME("flush surface");
        SFTRACE_NAME("flush surface");
        // TODO: Investigate feasibility of combining this "surface flush" into the "context flush"
        // TODO: Investigate feasibility of combining this "surface flush" into the "context flush"
        // below.
        // below.
        context->grDirectContext()->flush(dstSurface.get());
        context->grDirectContext()->flush(dstSurface.get());
+7 −8
Original line number Original line Diff line number Diff line
@@ -28,12 +28,11 @@
#include <GrContextOptions.h>
#include <GrContextOptions.h>
#include <GrTypes.h>
#include <GrTypes.h>
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <common/trace.h>
#include <gl/GrGLInterface.h>
#include <gl/GrGLInterface.h>
#include <include/gpu/ganesh/gl/GrGLDirectContext.h>
#include <include/gpu/ganesh/gl/GrGLDirectContext.h>
#include <gui/TraceUtils.h>
#include <sync/sync.h>
#include <sync/sync.h>
#include <ui/DebugUtils.h>
#include <ui/DebugUtils.h>
#include <utils/Trace.h>


#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstdint>
@@ -332,7 +331,7 @@ bool SkiaGLRenderEngine::useProtectedContextImpl(GrProtected isProtected) {


void SkiaGLRenderEngine::waitFence(SkiaGpuContext*, base::borrowed_fd fenceFd) {
void SkiaGLRenderEngine::waitFence(SkiaGpuContext*, base::borrowed_fd fenceFd) {
    if (fenceFd.get() >= 0 && !waitGpuFence(fenceFd)) {
    if (fenceFd.get() >= 0 && !waitGpuFence(fenceFd)) {
        ATRACE_NAME("SkiaGLRenderEngine::waitFence");
        SFTRACE_NAME("SkiaGLRenderEngine::waitFence");
        sync_wait(fenceFd.get(), -1);
        sync_wait(fenceFd.get(), -1);
    }
    }
}
}
@@ -341,19 +340,19 @@ base::unique_fd SkiaGLRenderEngine::flushAndSubmit(SkiaGpuContext* context,
                                                   sk_sp<SkSurface> dstSurface) {
                                                   sk_sp<SkSurface> dstSurface) {
    sk_sp<GrDirectContext> grContext = context->grDirectContext();
    sk_sp<GrDirectContext> grContext = context->grDirectContext();
    {
    {
        ATRACE_NAME("flush surface");
        SFTRACE_NAME("flush surface");
        grContext->flush(dstSurface.get());
        grContext->flush(dstSurface.get());
    }
    }
    base::unique_fd drawFence = flushGL();
    base::unique_fd drawFence = flushGL();


    bool requireSync = drawFence.get() < 0;
    bool requireSync = drawFence.get() < 0;
    if (requireSync) {
    if (requireSync) {
        ATRACE_BEGIN("Submit(sync=true)");
        SFTRACE_BEGIN("Submit(sync=true)");
    } else {
    } else {
        ATRACE_BEGIN("Submit(sync=false)");
        SFTRACE_BEGIN("Submit(sync=false)");
    }
    }
    bool success = grContext->submit(requireSync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
    bool success = grContext->submit(requireSync ? GrSyncCpu::kYes : GrSyncCpu::kNo);
    ATRACE_END();
    SFTRACE_END();
    if (!success) {
    if (!success) {
        ALOGE("Failed to flush RenderEngine commands");
        ALOGE("Failed to flush RenderEngine commands");
        // Chances are, something illegal happened (Skia's internal GPU object
        // Chances are, something illegal happened (Skia's internal GPU object
@@ -400,7 +399,7 @@ bool SkiaGLRenderEngine::waitGpuFence(base::borrowed_fd fenceFd) {
}
}


base::unique_fd SkiaGLRenderEngine::flushGL() {
base::unique_fd SkiaGLRenderEngine::flushGL() {
    ATRACE_CALL();
    SFTRACE_CALL();
    if (!GLExtensions::getInstance().hasNativeFenceSync()) {
    if (!GLExtensions::getInstance().hasNativeFenceSync()) {
        return base::unique_fd();
        return base::unique_fd();
    }
    }
Loading