1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <chrono> 20 #include <string> 21 #include <vector> 22 23 #include <binder/Parcelable.h> 24 25 namespace android { 26 27 /* 28 * class for transporting gpu global stats from GpuService to authorized 29 * recipents. This class is intended to be a data container. 30 */ 31 class GpuStatsGlobalInfo : public Parcelable { 32 public: 33 GpuStatsGlobalInfo() = default; 34 GpuStatsGlobalInfo(const GpuStatsGlobalInfo&) = default; 35 virtual ~GpuStatsGlobalInfo() = default; 36 virtual status_t writeToParcel(Parcel* parcel) const; 37 virtual status_t readFromParcel(const Parcel* parcel); 38 std::string toString() const; 39 40 std::string driverPackageName = ""; 41 std::string driverVersionName = ""; 42 uint64_t driverVersionCode = 0; 43 int64_t driverBuildTime = 0; 44 int32_t glLoadingCount = 0; 45 int32_t glLoadingFailureCount = 0; 46 int32_t vkLoadingCount = 0; 47 int32_t vkLoadingFailureCount = 0; 48 int32_t vulkanVersion = 0; 49 int32_t cpuVulkanVersion = 0; 50 int32_t glesVersion = 0; 51 int32_t angleLoadingCount = 0; 52 int32_t angleLoadingFailureCount = 0; 53 }; 54 55 /* 56 * class for transporting gpu app stats from GpuService to authorized recipients. 57 * This class is intended to be a data container. 58 */ 59 class GpuStatsAppInfo : public Parcelable { 60 public: 61 GpuStatsAppInfo() = default; 62 GpuStatsAppInfo(const GpuStatsAppInfo&) = default; 63 virtual ~GpuStatsAppInfo() = default; 64 virtual status_t writeToParcel(Parcel* parcel) const; 65 virtual status_t readFromParcel(const Parcel* parcel); 66 std::string toString() const; 67 68 std::string appPackageName = ""; 69 uint64_t driverVersionCode = 0; 70 std::vector<int64_t> glDriverLoadingTime = {}; 71 std::vector<int64_t> vkDriverLoadingTime = {}; 72 std::vector<int64_t> angleDriverLoadingTime = {}; 73 bool cpuVulkanInUse = false; 74 bool falsePrerotation = false; 75 bool gles1InUse = false; 76 bool angleInUse = false; 77 78 std::chrono::time_point<std::chrono::system_clock> lastAccessTime; 79 }; 80 81 /* 82 * class for holding the gpu stats in GraphicsEnv before sending to GpuService. 83 */ 84 class GpuStatsInfo { 85 public: 86 enum Api { 87 API_GL = 0, 88 API_VK = 1, 89 }; 90 91 enum Driver { 92 NONE = 0, 93 GL = 1, 94 GL_UPDATED = 2, 95 VULKAN = 3, 96 VULKAN_UPDATED = 4, 97 ANGLE = 5, 98 }; 99 100 enum Stats { 101 CPU_VULKAN_IN_USE = 0, 102 FALSE_PREROTATION = 1, 103 GLES_1_IN_USE = 2, 104 }; 105 106 GpuStatsInfo() = default; 107 GpuStatsInfo(const GpuStatsInfo&) = default; 108 virtual ~GpuStatsInfo() = default; 109 110 std::string driverPackageName = ""; 111 std::string driverVersionName = ""; 112 uint64_t driverVersionCode = 0; 113 int64_t driverBuildTime = 0; 114 std::string appPackageName = ""; 115 int32_t vulkanVersion = 0; 116 Driver glDriverToLoad = Driver::NONE; 117 Driver glDriverFallback = Driver::NONE; 118 Driver vkDriverToLoad = Driver::NONE; 119 Driver vkDriverFallback = Driver::NONE; 120 bool glDriverToSend = false; 121 bool vkDriverToSend = false; 122 int64_t glDriverLoadingTime = 0; 123 int64_t vkDriverLoadingTime = 0; 124 }; 125 126 } // namespace android 127