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

Commit 481a50fb authored by Cairn Overturf's avatar Cairn Overturf Committed by Android (Google) Code Review
Browse files

Merge "Track full HWC strategy when doing prediction" into main

parents f423c74b 0a56063b
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -1147,6 +1147,15 @@ void Output::prepareFrame() {

    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    bool success = chooseCompositionStrategy(&changes);

    if (success && changes.has_value()) {
        for (const compositionengine::OutputLayer* layer : getOutputLayersOrderedByZ()) {
            HWC2::Layer* hwcLayer = layer->getHwcLayer();
            if (!hwcLayer || changes->changedTypes.contains(hwcLayer)) continue;
            changes->changedTypes[hwcLayer] = layer->getState().hwc->hwcCompositionType;
        }
    }

    resetCompositionStrategy();
    outputState.strategyPrediction = CompositionStrategyPredictionState::DISABLED;
    outputState.previousDeviceRequestedChanges = changes;
@@ -1178,6 +1187,14 @@ GpuCompositionResult Output::prepareFrameAsync() {
    const auto& previousChanges = state.previousDeviceRequestedChanges;
    std::optional<android::HWComposer::DeviceRequestedChanges> changes;
    resetCompositionStrategy();
    // Store all layer composition types before appplying composition strategy
    android::HWComposer::DeviceRequestedChanges::ChangedTypes backups;
    for (const compositionengine::OutputLayer* layer : getOutputLayersOrderedByZ()) {
        HWC2::Layer* hwcLayer = layer->getHwcLayer();
        if (!hwcLayer) continue;
        backups[hwcLayer] = layer->getState().hwc->hwcCompositionType;
    }

    auto hwcResult = chooseCompositionStrategyAsync(&changes);
    if (state.previousDeviceRequestedSuccess) {
        applyCompositionStrategy(previousChanges);
@@ -1198,6 +1215,14 @@ GpuCompositionResult Output::prepareFrameAsync() {
    }

    auto chooseCompositionSuccess = hwcResult.get();
    if (chooseCompositionSuccess && changes.has_value()) {
        // Keep track of all layer composition types, not just changes
        for (const compositionengine::OutputLayer* layer : getOutputLayersOrderedByZ()) {
            HWC2::Layer* hwcLayer = layer->getHwcLayer();
            if (!hwcLayer || changes->changedTypes.contains(hwcLayer)) continue;
            changes->changedTypes[hwcLayer] = backups[hwcLayer];
        }
    }
    const bool predictionSucceeded = dequeueSucceeded && changes == previousChanges;
    state.strategyPrediction = predictionSucceeded ? CompositionStrategyPredictionState::SUCCESS
                                                   : CompositionStrategyPredictionState::FAIL;
+5 −0
Original line number Diff line number Diff line
@@ -970,6 +970,11 @@ void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType)
    LOG_FATAL_IF(!state.hwc);
    auto& hwcState = *state.hwc;

    if (hwcState.hwcCompositionType == compositionType) {
        // no changes
        return;
    }

    // Only detected disallowed changes if this was not a skip layer, because the
    // validated composition type may be arbitrary (usually DEVICE, to reflect that there were
    // fewer GPU layers)