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

Commit e66802bb 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

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

Change-Id: I1b1335cf93c07f674ad450c3f55251b2588413f6
parents a1534c95 ca8596e1
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