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

Commit 189e8749 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Update pinImages to report when GPU resource limits are exceeded.

Bug: 32691999
Test: proposed CTS test (ag/1500396) and existing UiRendering tests
Change-Id: I190f888ae5499ac048569af8256fdd31d19d1285
parent c4fbada7
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -53,11 +53,15 @@ void SkiaDisplayList::updateChildren(std::function<void(RenderNode*)> updateFn)

bool SkiaDisplayList::prepareListAndChildren(TreeInfo& info, bool functorsNeedLayer,
        std::function<void(RenderNode*, TreeInfo&, bool)> childFn) {
    // If the prepare tree is triggered by the UI thread then we must force all
    // mutable images to be pinned in the GPU cache until the next UI thread
    // draw
    if (info.mode == TreeInfo::MODE_FULL) {
        info.prepareTextures = info.canvasContext.pinImages(mMutableImages);
    // If the prepare tree is triggered by the UI thread and no previous call to
    // pinImages has failed then we must pin all mutable images in the GPU cache
    // until the next UI thread draw.
    if (info.prepareTextures && !info.canvasContext.pinImages(mMutableImages)) {
        // In the event that pinning failed we prevent future pinImage calls for the
        // remainder of this tree traversal and also unpin any currently pinned images
        // to free up GPU resources.
        info.prepareTextures = false;
        info.canvasContext.unpinImages();
    }

    for (auto& child : mChildNodes) {
+5 −3
Original line number Diff line number Diff line
@@ -48,9 +48,11 @@ void SkiaPipeline::onDestroyHardwareResources() {

bool SkiaPipeline::pinImages(std::vector<SkImage*>& mutableImages) {
    for (SkImage* image : mutableImages) {
        if (SkImage_pinAsTexture(image, mRenderThread.getGrContext())) {
            mPinnedImages.emplace_back(sk_ref_sp(image));
        // TODO: return false if texture creation fails (see b/32691999)
        SkImage_pinAsTexture(image, mRenderThread.getGrContext());
        } else {
            return false;
        }
    }
    return true;
}
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public:
     * remain in the cache until it has been unpinned. We leverage this feature
     * to avoid making a CPU copy of the pixels.
     *
     * @return true if the images have been successfully pinned to the GPU cache
     * @return true if all images have been successfully pinned to the GPU cache
     *         and false otherwise (e.g. cache limits have been exceeded).
     */
    bool pinImages(std::vector<SkImage*>& mutableImages) {