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

Commit dbd96159 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

swapchain: add query for MaxBufferCount

The current vkCreateSwapchainKHR use the hard coded maxImageCount from
GetPhysicalDeviceSurfaceCapabilitiesKHR, which results in possible
conflicts with the maxBufferCount set by BufferQueueConsumer. Thus add
a query to grab the consumer set maxBufferCount into maxImageCount of
surface capability.

Test: adb shell setprop debug.hwui.renderer skiavk
Test: open Play store search and click on apps
Bug: b/71894146
Change-Id: Iba75d977b13a849b62e6c4f259f7ca519ac26db8
parent a8cbd474
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1121,6 +1121,9 @@ int BufferQueueProducer::query(int what, int *outValue) {
        case NATIVE_WINDOW_CONSUMER_IS_PROTECTED:
        case NATIVE_WINDOW_CONSUMER_IS_PROTECTED:
            value = static_cast<int32_t>(mCore->mConsumerIsProtected);
            value = static_cast<int32_t>(mCore->mConsumerIsProtected);
            break;
            break;
        case NATIVE_WINDOW_MAX_BUFFER_COUNT:
            value = static_cast<int32_t>(mCore->mMaxBufferCount);
            break;
        default:
        default:
            return BAD_VALUE;
            return BAD_VALUE;
    }
    }
+5 −0
Original line number Original line Diff line number Diff line
@@ -184,6 +184,11 @@ enum {
     * Returns data space for the buffers.
     * Returns data space for the buffers.
     */
     */
    NATIVE_WINDOW_DATASPACE = 20,
    NATIVE_WINDOW_DATASPACE = 20,

    /*
     * Returns maxBufferCount set by BufferQueueConsumer
     */
    NATIVE_WINDOW_MAX_BUFFER_COUNT = 21,
};
};


/* Valid operations for the (*perform)() hook.
/* Valid operations for the (*perform)() hook.
+8 −1
Original line number Original line Diff line number Diff line
@@ -573,8 +573,15 @@ VkResult GetPhysicalDeviceSurfaceCapabilitiesKHR(
    }
    }


    // TODO(jessehall): Figure out what the min/max values should be.
    // TODO(jessehall): Figure out what the min/max values should be.
    int max_buffer_count;
    err = window->query(window, NATIVE_WINDOW_MAX_BUFFER_COUNT, &max_buffer_count);
    if (err != 0) {
        ALOGE("NATIVE_WINDOW_MAX_BUFFER_COUNT query failed: %s (%d)",
              strerror(-err), err);
        return VK_ERROR_SURFACE_LOST_KHR;
    }
    capabilities->minImageCount = 2;
    capabilities->minImageCount = 2;
    capabilities->maxImageCount = 3;
    capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count);


    capabilities->currentExtent =
    capabilities->currentExtent =
        VkExtent2D{static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
        VkExtent2D{static_cast<uint32_t>(width), static_cast<uint32_t>(height)};