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

Commit ca8596e1 authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Android (Google) Code Review
Browse files

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

parents 2a4e4e58 e9a51086
Loading
Loading
Loading
Loading
+55 −48
Original line number Original line Diff line number Diff line
@@ -238,9 +238,14 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
    if (previousCount) {
    if (previousCount) {
        ALOGD("%d Shaders already compiled before Cache::primeShaderCache ran\n", 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();
        const nsecs_t timeBefore = systemTime();
        // The dimensions should not matter, so long as we draw inside them.
        // 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{
        DisplaySettings display{
                .physicalDisplay = displayRect,
                .physicalDisplay = displayRect,
                .clip = displayRect,
                .clip = displayRect,
@@ -251,18 +256,19 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
        const int64_t usage = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
        const int64_t usage = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;


        sp<GraphicBuffer> dstBuffer =
        sp<GraphicBuffer> dstBuffer =
            new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888, 1,
                new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888,
                              usage, "primeShaderCache_dst");
                                  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);
                                                  ExternalTexture::Usage::WRITEABLE);
        // This buffer will be the source for the call to drawImageLayers. Draw
        // 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 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
        // something, but the details are not important. Make use of the shadow layer drawing step
        // to populate it.
        // to populate it.
        sp<GraphicBuffer> srcBuffer =
        sp<GraphicBuffer> srcBuffer =
            new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888, 1,
                new GraphicBuffer(displayRect.width(), displayRect.height(), PIXEL_FORMAT_RGBA_8888,
                              usage, "drawImageLayer_src");
                                  1, usage, "drawImageLayer_src");


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


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


} // namespace android::renderengine::skia
} // namespace android::renderengine::skia