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

Commit d1f089aa authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Automerger Merge Worker
Browse files

Merge "Reduce size of buffer used to prime the RenderEngine shader cache."...

Merge "Reduce size of buffer used to prime the RenderEngine shader cache." into sc-dev am: ca8596e1 am: e66802bb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14455156

Change-Id: I70a5e6b6b6f20ed5b74fa5782906adaa686ba89a
parents 62755009 e66802bb
Loading
Loading
Loading
Loading
+55 −48
Original line number Diff line number Diff line
@@ -238,9 +238,14 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
    if (previousCount) {
        ALOGD("%d Shaders already compiled before Cache::primeShaderCache ran\n", previousCount);
    }

    // The loop is beneficial for debugging and should otherwise be optimized out by the compiler.
    // Adding additional bounds to the loop is useful for verifying that the size of the dst buffer
    // does not impact the shader compilation counts by triggering different behaviors in RE/Skia.
    for (SkSize bounds : {SkSize::Make(128, 128), /*SkSize::Make(1080, 2340)*/}) {
        const nsecs_t timeBefore = systemTime();
        // The dimensions should not matter, so long as we draw inside them.
    const Rect displayRect(0, 0, 1080, 2340);
        const Rect displayRect(0, 0, bounds.fWidth, bounds.fHeight);
        DisplaySettings display{
                .physicalDisplay = displayRect,
                .clip = displayRect,
@@ -251,18 +256,19 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
        const int64_t usage = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;

        sp<GraphicBuffer> dstBuffer =
            new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888, 1,
                              usage, "primeShaderCache_dst");
                new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888,
                                  1, usage, "primeShaderCache_dst");

    const auto dstTexture = std::make_shared<ExternalTexture>(dstBuffer, *renderengine,
        const auto dstTexture =
                std::make_shared<ExternalTexture>(dstBuffer, *renderengine,
                                                  ExternalTexture::Usage::WRITEABLE);
        // This buffer will be the source for the call to drawImageLayers. Draw
        // something to it as a placeholder for what an app draws. We should draw
        // something, but the details are not important. Make use of the shadow layer drawing step
        // to populate it.
        sp<GraphicBuffer> srcBuffer =
            new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888, 1,
                              usage, "drawImageLayer_src");
                new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888,
                                  1, usage, "drawImageLayer_src");

        const auto srcTexture =
                std::make_shared<ExternalTexture>(srcBuffer, *renderengine,
@@ -279,8 +285,8 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
        const int64_t usageExternal = GRALLOC_USAGE_HW_TEXTURE;

        sp<GraphicBuffer> externalBuffer =
            new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888, 1,
                              usageExternal, "primeShaderCache_external");
                new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888,
                                  1, usageExternal, "primeShaderCache_external");
        const auto externalTexture =
                std::make_shared<ExternalTexture>(externalBuffer, *renderengine,
                                                  ExternalTexture::Usage::READABLE);
@@ -296,5 +302,6 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
        const int shadersCompiled = renderengine->reportShadersCompiled();
        ALOGD("Shader cache generated %d shaders in %f ms\n", shadersCompiled, compileTimeMs);
    }
}

} // namespace android::renderengine::skia