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

Commit 2f46157c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11778614 from d50d517f to 24Q3-release

Change-Id: I1646d48c2069c599437904e470c02ed165180292
parents 760265da d50d517f
Loading
Loading
Loading
Loading
+34 −9
Original line number Original line Diff line number Diff line
@@ -7,9 +7,10 @@
#include <cstdlib>
#include <cstdlib>
#include <cstdio>
#include <cstdio>


#include <fstream>
#include <iostream>
#include <iostream>
#include <vector>
#include <tuple>
#include <tuple>
#include <vector>


#include <unistd.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/wait.h>
@@ -63,6 +64,18 @@ struct ProcResults {
    uint64_t worst() {
    uint64_t worst() {
        return *max_element(data.begin(), data.end());
        return *max_element(data.begin(), data.end());
    }
    }
    void dump_to_file(string filename) {
        ofstream output;
        output.open(filename);
        if (!output.is_open()) {
            cerr << "Failed to open '" << filename << "'." << endl;
            exit(EXIT_FAILURE);
        }
        for (uint64_t value : data) {
            output << value << "\n";
        }
        output.close();
    }
    void dump() {
    void dump() {
        if (data.size() == 0) {
        if (data.size() == 0) {
            // This avoids index-out-of-bounds below.
            // This avoids index-out-of-bounds below.
@@ -293,12 +306,8 @@ void signal_all(vector<Pipe>& v)
    }
    }
}
}


void run_main(int iterations,
void run_main(int iterations, int workers, int payload_size, int cs_pair,
              int workers,
              bool training_round = false, bool dump_to_file = false, string dump_filename = "") {
              int payload_size,
              int cs_pair,
              bool training_round=false)
{
    vector<Pipe> pipes;
    vector<Pipe> pipes;
    // Create all the workers and wait for them to spawn.
    // Create all the workers and wait for them to spawn.
    for (int i = 0; i < workers; i++) {
    for (int i = 0; i < workers; i++) {
@@ -349,6 +358,9 @@ void run_main(int iterations,
        warn_latency = 2 * tot_results.worst();
        warn_latency = 2 * tot_results.worst();
        cout << "Max latency during training: " << tot_results.worst() / 1.0E6 << "ms" << endl;
        cout << "Max latency during training: " << tot_results.worst() / 1.0E6 << "ms" << endl;
    } else {
    } else {
        if (dump_to_file) {
            tot_results.dump_to_file(dump_filename);
        }
        tot_results.dump();
        tot_results.dump();
    }
    }
}
}
@@ -361,6 +373,8 @@ int main(int argc, char *argv[])
    bool cs_pair = false;
    bool cs_pair = false;
    bool training_round = false;
    bool training_round = false;
    int max_time_us;
    int max_time_us;
    bool dump_to_file = false;
    string dump_filename;


    // Parse arguments.
    // Parse arguments.
    for (int i = 1; i < argc; i++) {
    for (int i = 1; i < argc; i++) {
@@ -372,6 +386,7 @@ int main(int argc, char *argv[])
            cout << "\t-s N    : Specify payload size." << endl;
            cout << "\t-s N    : Specify payload size." << endl;
            cout << "\t-t      : Run training round." << endl;
            cout << "\t-t      : Run training round." << endl;
            cout << "\t-w N    : Specify total number of workers." << endl;
            cout << "\t-w N    : Specify total number of workers." << endl;
            cout << "\t-d FILE : Dump raw data to file." << endl;
            return 0;
            return 0;
        }
        }
        if (string(argv[i]) == "-w") {
        if (string(argv[i]) == "-w") {
@@ -430,14 +445,24 @@ int main(int argc, char *argv[])
            i++;
            i++;
            continue;
            continue;
        }
        }
        if (string(argv[i]) == "-d") {
            if (i + 1 == argc) {
                cout << "-d requires an argument\n" << endl;
                exit(EXIT_FAILURE);
            }
            dump_to_file = true;
            dump_filename = argv[i + 1];
            i++;
            continue;
        }
    }
    }


    if (training_round) {
    if (training_round) {
        cout << "Start training round" << endl;
        cout << "Start training round" << endl;
        run_main(iterations, workers, payload_size, cs_pair, training_round=true);
        run_main(iterations, workers, payload_size, cs_pair, true);
        cout << "Completed training round" << endl << endl;
        cout << "Completed training round" << endl << endl;
    }
    }


    run_main(iterations, workers, payload_size, cs_pair);
    run_main(iterations, workers, payload_size, cs_pair, false, dump_to_file, dump_filename);
    return 0;
    return 0;
}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -3218,6 +3218,10 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    mFlinger->mTimeStats->setPostTime(layerId, mDrawingState.frameNumber, getName().c_str(),
    mFlinger->mTimeStats->setPostTime(layerId, mDrawingState.frameNumber, getName().c_str(),
                                      mOwnerUid, postTime, getGameMode());
                                      mOwnerUid, postTime, getGameMode());


    if (mFlinger->mLegacyFrontEndEnabled) {
        recordLayerHistoryBufferUpdate(getLayerProps(), systemTime());
    }

    setFrameTimelineVsyncForBufferTransaction(info, postTime);
    setFrameTimelineVsyncForBufferTransaction(info, postTime);


    if (dequeueTime && *dequeueTime != 0) {
    if (dequeueTime && *dequeueTime != 0) {
+114 −76
Original line number Original line Diff line number Diff line
@@ -531,6 +531,8 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI


    mLayerLifecycleManagerEnabled =
    mLayerLifecycleManagerEnabled =
            base::GetBoolProperty("persist.debug.sf.enable_layer_lifecycle_manager"s, true);
            base::GetBoolProperty("persist.debug.sf.enable_layer_lifecycle_manager"s, true);
    mLegacyFrontEndEnabled = !mLayerLifecycleManagerEnabled ||
            base::GetBoolProperty("persist.debug.sf.enable_legacy_frontend"s, false);


    // These are set by the HWC implementation to indicate that they will use the workarounds.
    // These are set by the HWC implementation to indicate that they will use the workarounds.
    mIsHotplugErrViaNegVsync =
    mIsHotplugErrViaNegVsync =
@@ -2438,6 +2440,7 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
    mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;
    mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;


    bool newDataLatched = false;
    bool newDataLatched = false;
    if (!mLegacyFrontEndEnabled) {
        ATRACE_NAME("DisplayCallbackAndStatsUpdates");
        ATRACE_NAME("DisplayCallbackAndStatsUpdates");
        mustComposite |= applyTransactionsLocked(update.transactions, vsyncId);
        mustComposite |= applyTransactionsLocked(update.transactions, vsyncId);
        traverseLegacyLayers([&](Layer* layer) { layer->commitTransaction(); });
        traverseLegacyLayers([&](Layer* layer) { layer->commitTransaction(); });
@@ -2492,7 +2495,8 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,


        updateLayerHistory(latchTime);
        updateLayerHistory(latchTime);
        mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        if (mLayersIdsWithQueuedFrames.find(snapshot.path.id) == mLayersIdsWithQueuedFrames.end())
            if (mLayersIdsWithQueuedFrames.find(snapshot.path.id) ==
                mLayersIdsWithQueuedFrames.end())
                return;
                return;
            Region visibleReg;
            Region visibleReg;
            visibleReg.set(snapshot.transformedBoundsWithoutTransparentRegion);
            visibleReg.set(snapshot.transformedBoundsWithoutTransparentRegion);
@@ -2513,9 +2517,9 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
            ALOGI("Enter boot animation");
            ALOGI("Enter boot animation");
            mBootStage = BootStage::BOOTANIMATION;
            mBootStage = BootStage::BOOTANIMATION;
        }
        }

    }
    mustComposite |= (getTransactionFlags() & ~eTransactionFlushNeeded) || newDataLatched;
    mustComposite |= (getTransactionFlags() & ~eTransactionFlushNeeded) || newDataLatched;
    if (mustComposite) {
    if (mustComposite && !mLegacyFrontEndEnabled) {
        commitTransactions();
        commitTransactions();
    }
    }


@@ -2617,7 +2621,12 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId,
                                    mScheduler->getPacesetterRefreshRate());
                                    mScheduler->getPacesetterRefreshRate());


        const bool flushTransactions = clearTransactionFlags(eTransactionFlushNeeded);
        const bool flushTransactions = clearTransactionFlags(eTransactionFlushNeeded);
        bool transactionsAreEmpty = false;
        bool transactionsAreEmpty;
        if (mLegacyFrontEndEnabled) {
            mustComposite |=
                    updateLayerSnapshotsLegacy(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
                                               flushTransactions, transactionsAreEmpty);
        }
        if (mLayerLifecycleManagerEnabled) {
        if (mLayerLifecycleManagerEnabled) {
            mustComposite |=
            mustComposite |=
                    updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
                    updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
@@ -5241,9 +5250,16 @@ bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelin
    nsecs_t now = systemTime();
    nsecs_t now = systemTime();
    uint32_t clientStateFlags = 0;
    uint32_t clientStateFlags = 0;
    for (auto& resolvedState : states) {
    for (auto& resolvedState : states) {
        if (mLegacyFrontEndEnabled) {
            clientStateFlags |=
            clientStateFlags |=
                updateLayerCallbacksAndStats(frameTimelineInfo, resolvedState, desiredPresentTime,
                    setClientStateLocked(frameTimelineInfo, resolvedState, desiredPresentTime,
                                         isAutoTimestamp, postTime, transactionId);
                                         isAutoTimestamp, postTime, transactionId);

        } else /*mLayerLifecycleManagerEnabled*/ {
            clientStateFlags |= updateLayerCallbacksAndStats(frameTimelineInfo, resolvedState,
                                                             desiredPresentTime, isAutoTimestamp,
                                                             postTime, transactionId);
        }
        if (!mLayerLifecycleManagerEnabled) {
        if (!mLayerLifecycleManagerEnabled) {
            if ((flags & eAnimation) && resolvedState.state.surface) {
            if ((flags & eAnimation) && resolvedState.state.surface) {
                if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) {
                if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) {
@@ -5315,7 +5331,7 @@ bool SurfaceFlinger::applyAndCommitDisplayTransactionStatesLocked(
    }
    }


    mFrontEndDisplayInfosChanged = mTransactionFlags & eDisplayTransactionNeeded;
    mFrontEndDisplayInfosChanged = mTransactionFlags & eDisplayTransactionNeeded;
    if (mFrontEndDisplayInfosChanged) {
    if (mFrontEndDisplayInfosChanged && !mLegacyFrontEndEnabled) {
        processDisplayChangesLocked();
        processDisplayChangesLocked();
        mFrontEndDisplayInfos.clear();
        mFrontEndDisplayInfos.clear();
        for (const auto& [_, display] : mDisplays) {
        for (const auto& [_, display] : mDisplays) {
@@ -5958,6 +5974,11 @@ status_t SurfaceFlinger::mirrorDisplay(DisplayId displayId, const LayerCreationA
        return result;
        return result;
    }
    }


    if (mLegacyFrontEndEnabled) {
        std::scoped_lock<std::mutex> lock(mMirrorDisplayLock);
        mMirrorDisplays.emplace_back(layerStack, outResult.handle, args.client);
    }

    setTransactionFlags(eTransactionFlushNeeded);
    setTransactionFlags(eTransactionFlushNeeded);
    return NO_ERROR;
    return NO_ERROR;
}
}
@@ -6072,7 +6093,9 @@ void SurfaceFlinger::initializeDisplays() {
    std::vector<TransactionState> transactions;
    std::vector<TransactionState> transactions;
    transactions.emplace_back(state);
    transactions.emplace_back(state);


    {
    if (mLegacyFrontEndEnabled) {
        applyTransactions(transactions, VsyncId{0});
    } else {
        Mutex::Autolock lock(mStateLock);
        Mutex::Autolock lock(mStateLock);
        applyAndCommitDisplayTransactionStatesLocked(transactions);
        applyAndCommitDisplayTransactionStatesLocked(transactions);
    }
    }
@@ -6624,6 +6647,17 @@ perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t tra
        }
        }
    }
    }


    if (mLegacyFrontEndEnabled) {
        perfetto::protos::LayersProto layersProto;
        for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) {
            if (stackIdsToSkip.find(layer->getLayerStack().id) != stackIdsToSkip.end()) {
                continue;
            }
            layer->writeToProto(layersProto, traceFlags);
        }
        return layersProto;
    }

    return LayerProtoFromSnapshotGenerator(mLayerSnapshotBuilder, mFrontEndDisplayInfos,
    return LayerProtoFromSnapshotGenerator(mLayerSnapshotBuilder, mFrontEndDisplayInfos,
                                           mLegacyLayers, traceFlags)
                                           mLegacyLayers, traceFlags)
            .generate(mLayerHierarchyBuilder.getHierarchy());
            .generate(mLayerHierarchyBuilder.getHierarchy());
@@ -6872,6 +6906,10 @@ void SurfaceFlinger::dumpAll(const DumpArgs& args, const std::string& compositio
    }
    }
    result.push_back('\n');
    result.push_back('\n');


    if (mLegacyFrontEndEnabled) {
        dumpHwcLayersMinidumpLockedLegacy(result);
    }

    {
    {
        DumpArgs plannerArgs;
        DumpArgs plannerArgs;
        plannerArgs.add(); // first argument is ignored
        plannerArgs.add(); // first argument is ignored
@@ -9197,7 +9235,7 @@ void SurfaceFlinger::moveSnapshotsFromCompositionArgs(
            snapshots[i] = std::move(layerFE->mSnapshot);
            snapshots[i] = std::move(layerFE->mSnapshot);
        }
        }
    }
    }
    if (!mLayerLifecycleManagerEnabled) {
    if (mLegacyFrontEndEnabled && !mLayerLifecycleManagerEnabled) {
        for (auto [layer, layerFE] : layers) {
        for (auto [layer, layerFE] : layers) {
            layer->updateLayerSnapshot(std::move(layerFE->mSnapshot));
            layer->updateLayerSnapshot(std::move(layerFE->mSnapshot));
        }
        }
@@ -9234,7 +9272,7 @@ std::vector<std::pair<Layer*, LayerFE*>> SurfaceFlinger::moveSnapshotsToComposit
                    layers.emplace_back(legacyLayer.get(), layerFE.get());
                    layers.emplace_back(legacyLayer.get(), layerFE.get());
                });
                });
    }
    }
    if (!mLayerLifecycleManagerEnabled) {
    if (mLegacyFrontEndEnabled && !mLayerLifecycleManagerEnabled) {
        auto moveSnapshots = [&layers, &refreshArgs, cursorOnly](Layer* layer) {
        auto moveSnapshots = [&layers, &refreshArgs, cursorOnly](Layer* layer) {
            if (const auto& layerFE = layer->getCompositionEngineLayerFE()) {
            if (const auto& layerFE = layer->getCompositionEngineLayerFE()) {
                if (cursorOnly &&
                if (cursorOnly &&
+1 −0
Original line number Original line Diff line number Diff line
@@ -1486,6 +1486,7 @@ private:
    bool mPowerHintSessionEnabled;
    bool mPowerHintSessionEnabled;


    bool mLayerLifecycleManagerEnabled = false;
    bool mLayerLifecycleManagerEnabled = false;
    bool mLegacyFrontEndEnabled = true;


    frontend::LayerLifecycleManager mLayerLifecycleManager GUARDED_BY(kMainThreadContext);
    frontend::LayerLifecycleManager mLayerLifecycleManager GUARDED_BY(kMainThreadContext);
    frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
    frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
+0 −2
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@ namespace android {
class ColorMatrixTest : public CommitAndCompositeTest {};
class ColorMatrixTest : public CommitAndCompositeTest {};


TEST_F(ColorMatrixTest, colorMatrixChanged) {
TEST_F(ColorMatrixTest, colorMatrixChanged) {
    mFlinger.enableLayerLifecycleManager();
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;


@@ -46,7 +45,6 @@ TEST_F(ColorMatrixTest, colorMatrixChanged) {
}
}


TEST_F(ColorMatrixTest, colorMatrixChangedAfterDisplayTransaction) {
TEST_F(ColorMatrixTest, colorMatrixChangedAfterDisplayTransaction) {
    mFlinger.enableLayerLifecycleManager();
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;


Loading