diff options
| author | 2019-07-09 00:22:16 +0000 | |
|---|---|---|
| committer | 2019-07-09 00:22:16 +0000 | |
| commit | c11137b5e9c2068340bfa0035b7e82ef63b00a87 (patch) | |
| tree | d877d7403441d144f19953c484745b31a9955eb2 | |
| parent | 5ae36f50d4794abd41ff9bedd4eef6d95bfb6da8 (diff) | |
| parent | 69395cd3ff5ef500c2b33991c2ab7284bc010ce9 (diff) | |
Merge "GpuStats: track Vulkan apps not doing pre-rotation correctly"
| -rw-r--r-- | libs/graphicsenv/GpuStatsInfo.cpp | 3 | ||||
| -rw-r--r-- | libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h | 2 | ||||
| -rw-r--r-- | services/gpuservice/gpustats/GpuStats.cpp | 3 | ||||
| -rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 16 |
4 files changed, 24 insertions, 0 deletions
diff --git a/libs/graphicsenv/GpuStatsInfo.cpp b/libs/graphicsenv/GpuStatsInfo.cpp index 4a801bec38..85137f5ca9 100644 --- a/libs/graphicsenv/GpuStatsInfo.cpp +++ b/libs/graphicsenv/GpuStatsInfo.cpp @@ -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); diff --git a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h index 711e8691ab..7959652189 100644 --- a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h +++ b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h @@ -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; diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp index 423c89f797..67babd496f 100644 --- a/services/gpuservice/gpustats/GpuStats.cpp +++ b/services/gpuservice/gpustats/GpuStats.cpp @@ -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; } diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index 761d128d79..e5ac2de705 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -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; |