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