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

Commit 12536a8f authored by silence_dogood's avatar silence_dogood
Browse files

Cache NATIVE_WINDOW_MAX_BUFFER_COUNT in Surface

To avoid the sync binder call to BufferQueue everytime
vkGetPhysicalDeviceSurfaceCapabilitiesKHR is called, we cache the
NATIVE_WINDOW_MAX_BUFFER_COUNT at the Surface each time the client
connects.

Bug: 133187007
Test: Vulkan cts tests
Change-Id: I1942ff75ceb539c4904dc98c2e488c4d4cade31d
parent 29d4e9ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1199,6 +1199,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
                    static_cast<uint32_t>(mCore->mQueue.size());
            output->nextFrameNumber = mCore->mFrameCounter + 1;
            output->bufferReplaced = false;
            output->maxBufferCount = mCore->mMaxBufferCount;

            if (listener != nullptr) {
                // Set up a death notification so that we can disconnect
+6 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controll
    mConnectedToCpu = false;
    mProducerControlledByApp = controlledByApp;
    mSwapIntervalZero = false;
    mMaxBufferCount = 0;
}

Surface::~Surface() {
@@ -961,6 +962,10 @@ int Surface::query(int what, int* value) const {
                *value = static_cast<int>(mDataSpace);
                return NO_ERROR;
            }
            case NATIVE_WINDOW_MAX_BUFFER_COUNT: {
                *value = mMaxBufferCount;
                return NO_ERROR;
            }
        }
    }
    return mGraphicBufferProducer->query(what, value);
@@ -1298,6 +1303,7 @@ int Surface::connect(
        mDefaultWidth = output.width;
        mDefaultHeight = output.height;
        mNextFrameNumber = output.nextFrameNumber;
        mMaxBufferCount = output.maxBufferCount;

        // Ignore transform hint if sticky transform is set or transform to display inverse flag is
        // set. Transform hint should be ignored if the client is expected to always submit buffers
+1 −0
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ public:
        uint64_t nextFrameNumber{0};
        FrameEventHistoryDelta frameTimestamps;
        bool bufferReplaced{false};
        int maxBufferCount{0};
    };

    virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
+1 −0
Original line number Diff line number Diff line
@@ -465,6 +465,7 @@ protected:

    bool mReportRemovedBuffers = false;
    std::vector<sp<GraphicBuffer>> mRemovedBuffers;
    int mMaxBufferCount;
};

} // namespace android