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

Commit c11137b5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "GpuStats: track Vulkan apps not doing pre-rotation correctly"

parents 5ae36f50 69395cd3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const {
    if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status;
    if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status;
    if ((status = parcel->writeBool(cpuVulkanInUse)) != OK) return status;
    if ((status = parcel->writeBool(falsePrerotation)) != OK) return status;
    return OK;
}

@@ -97,6 +98,7 @@ status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) {
    if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status;
    if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status;
    if ((status = parcel->readBool(&cpuVulkanInUse)) != OK) return status;
    if ((status = parcel->readBool(&falsePrerotation)) != OK) return status;
    return OK;
}

@@ -105,6 +107,7 @@ std::string GpuStatsAppInfo::toString() const {
    StringAppendF(&result, "appPackageName = %s\n", appPackageName.c_str());
    StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
    StringAppendF(&result, "cpuVulkanInUse = %d\n", cpuVulkanInUse);
    StringAppendF(&result, "falsePrerotation = %d\n", falsePrerotation);
    result.append("glDriverLoadingTime:");
    for (int32_t loadingTime : glDriverLoadingTime) {
        StringAppendF(&result, " %d", loadingTime);
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public:
    std::vector<int64_t> vkDriverLoadingTime = {};
    std::vector<int64_t> angleDriverLoadingTime = {};
    bool cpuVulkanInUse = false;
    bool falsePrerotation = false;
};

/*
@@ -93,6 +94,7 @@ public:

    enum Stats {
        CPU_VULKAN_IN_USE = 0,
        FALSE_PREROTATION = 1,
    };

    GpuStatsInfo() = default;
+3 −0
Original line number Diff line number Diff line
@@ -142,6 +142,9 @@ void GpuStats::insertTargetStats(const std::string& appPackageName,
        case GpuStatsInfo::Stats::CPU_VULKAN_IN_USE:
            mAppStats[appStatsKey].cpuVulkanInUse = true;
            break;
        case GpuStatsInfo::Stats::FALSE_PREROTATION:
            mAppStats[appStatsKey].falsePrerotation = true;
            break;
        default:
            break;
    }
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <android/hardware/graphics/common/1.0/types.h>
#include <grallocusage/GrallocUsageConversion.h>
#include <graphicsenv/GraphicsEnv.h>
#include <log/log.h>
#include <sync/sync.h>
#include <system/window.h>
@@ -1253,6 +1254,15 @@ VkResult CreateSwapchainKHR(VkDevice device,
        return VK_ERROR_SURFACE_LOST_KHR;
    }

    int transform_hint;
    err = surface.window->query(surface.window.get(),
                                NATIVE_WINDOW_TRANSFORM_HINT, &transform_hint);
    if (err != 0) {
        ALOGE("NATIVE_WINDOW_TRANSFORM_HINT query failed: %s (%d)",
              strerror(-err), err);
        return VK_ERROR_SURFACE_LOST_KHR;
    }

    // -- Allocate our Swapchain object --
    // After this point, we must deallocate the swapchain on error.

@@ -1356,6 +1366,12 @@ VkResult CreateSwapchainKHR(VkDevice device,
        return result;
    }

    if (transform_hint != swapchain->pre_transform) {
        // Log that the app is not doing pre-rotation.
        android::GraphicsEnv::getInstance().setTargetStats(
            android::GpuStatsInfo::Stats::FALSE_PREROTATION);
    }

    surface.swapchain_handle = HandleFromSwapchain(swapchain);
    *swapchain_handle = surface.swapchain_handle;
    return VK_SUCCESS;