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 // This limits the worst case number of extensions to be tracked. 62 static const uint32_t MAX_NUM_EXTENSIONS = 100; 63 64 GpuStatsAppInfo() = default; 65 GpuStatsAppInfo(const GpuStatsAppInfo&) = default; 66 virtual ~GpuStatsAppInfo() = default; 67 virtual status_t writeToParcel(Parcel* parcel) const; 68 virtual status_t readFromParcel(const Parcel* parcel); 69 std::string toString() const; 70 71 std::string appPackageName = ""; 72 uint64_t driverVersionCode = 0; 73 std::vector<int64_t> glDriverLoadingTime = {}; 74 std::vector<int64_t> vkDriverLoadingTime = {}; 75 std::vector<int64_t> angleDriverLoadingTime = {}; 76 bool cpuVulkanInUse = false; 77 bool falsePrerotation = false; 78 bool gles1InUse = false; 79 bool angleInUse = false; 80 bool createdGlesContext = false; 81 bool createdVulkanDevice = false; 82 bool createdVulkanSwapchain = false; 83 uint32_t vulkanApiVersion = 0; 84 uint64_t vulkanDeviceFeaturesEnabled = 0; 85 std::vector<int32_t> vulkanInstanceExtensions = {}; 86 std::vector<int32_t> vulkanDeviceExtensions = {}; 87 88 std::chrono::time_point<std::chrono::system_clock> lastAccessTime; 89 }; 90 91 /* 92 * class for holding the gpu stats in GraphicsEnv before sending to GpuService. 93 */ 94 class GpuStatsInfo { 95 public: 96 enum Api { 97 API_GL = 0, 98 API_VK = 1, 99 }; 100 101 enum Driver { 102 NONE = 0, 103 GL = 1, 104 GL_UPDATED = 2, 105 VULKAN = 3, 106 VULKAN_UPDATED = 4, 107 ANGLE = 5, 108 }; 109 110 enum Stats { 111 CPU_VULKAN_IN_USE = 0, 112 FALSE_PREROTATION = 1, 113 GLES_1_IN_USE = 2, 114 CREATED_GLES_CONTEXT = 3, 115 CREATED_VULKAN_API_VERSION = 4, 116 CREATED_VULKAN_DEVICE = 5, 117 CREATED_VULKAN_SWAPCHAIN = 6, 118 VULKAN_DEVICE_FEATURES_ENABLED = 7, 119 VULKAN_INSTANCE_EXTENSION = 8, 120 VULKAN_DEVICE_EXTENSION = 9, 121 }; 122 123 GpuStatsInfo() = default; 124 GpuStatsInfo(const GpuStatsInfo&) = default; 125 virtual ~GpuStatsInfo() = default; 126 127 std::string driverPackageName = ""; 128 std::string driverVersionName = ""; 129 uint64_t driverVersionCode = 0; 130 int64_t driverBuildTime = 0; 131 std::string appPackageName = ""; 132 int32_t vulkanVersion = 0; 133 Driver glDriverToLoad = Driver::NONE; 134 Driver glDriverFallback = Driver::NONE; 135 Driver vkDriverToLoad = Driver::NONE; 136 Driver vkDriverFallback = Driver::NONE; 137 bool glDriverToSend = false; 138 bool vkDriverToSend = false; 139 int64_t glDriverLoadingTime = 0; 140 int64_t vkDriverLoadingTime = 0; 141 }; 142 143 } // namespace android 144