• 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 #include <inttypes.h>
18 
19 #include <android-base/stringprintf.h>
20 #include <binder/Parcel.h>
21 #include <graphicsenv/GpuStatsInfo.h>
22 
23 namespace android {
24 
25 using base::StringAppendF;
26 
writeToParcel(Parcel * parcel) const27 status_t GpuStatsGlobalInfo::writeToParcel(Parcel* parcel) const {
28     status_t status;
29     if ((status = parcel->writeUtf8AsUtf16(driverPackageName)) != OK) return status;
30     if ((status = parcel->writeUtf8AsUtf16(driverVersionName)) != OK) return status;
31     if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status;
32     if ((status = parcel->writeInt64(driverBuildTime)) != OK) return status;
33     if ((status = parcel->writeInt32(glLoadingCount)) != OK) return status;
34     if ((status = parcel->writeInt32(glLoadingFailureCount)) != OK) return status;
35     if ((status = parcel->writeInt32(vkLoadingCount)) != OK) return status;
36     if ((status = parcel->writeInt32(vkLoadingFailureCount)) != OK) return status;
37     if ((status = parcel->writeInt32(vulkanVersion)) != OK) return status;
38     if ((status = parcel->writeInt32(cpuVulkanVersion)) != OK) return status;
39     if ((status = parcel->writeInt32(glesVersion)) != OK) return status;
40     if ((status = parcel->writeInt32(angleLoadingCount)) != OK) return status;
41     if ((status = parcel->writeInt32(angleLoadingFailureCount)) != OK) return status;
42     return OK;
43 }
44 
readFromParcel(const Parcel * parcel)45 status_t GpuStatsGlobalInfo::readFromParcel(const Parcel* parcel) {
46     status_t status;
47     if ((status = parcel->readUtf8FromUtf16(&driverPackageName)) != OK) return status;
48     if ((status = parcel->readUtf8FromUtf16(&driverVersionName)) != OK) return status;
49     if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status;
50     if ((status = parcel->readInt64(&driverBuildTime)) != OK) return status;
51     if ((status = parcel->readInt32(&glLoadingCount)) != OK) return status;
52     if ((status = parcel->readInt32(&glLoadingFailureCount)) != OK) return status;
53     if ((status = parcel->readInt32(&vkLoadingCount)) != OK) return status;
54     if ((status = parcel->readInt32(&vkLoadingFailureCount)) != OK) return status;
55     if ((status = parcel->readInt32(&vulkanVersion)) != OK) return status;
56     if ((status = parcel->readInt32(&cpuVulkanVersion)) != OK) return status;
57     if ((status = parcel->readInt32(&glesVersion)) != OK) return status;
58     if ((status = parcel->readInt32(&angleLoadingCount)) != OK) return status;
59     if ((status = parcel->readInt32(&angleLoadingFailureCount)) != OK) return status;
60     return OK;
61 }
62 
toString() const63 std::string GpuStatsGlobalInfo::toString() const {
64     std::string result;
65     StringAppendF(&result, "driverPackageName = %s\n", driverPackageName.c_str());
66     StringAppendF(&result, "driverVersionName = %s\n", driverVersionName.c_str());
67     StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
68     StringAppendF(&result, "driverBuildTime = %" PRId64 "\n", driverBuildTime);
69     StringAppendF(&result, "glLoadingCount = %d\n", glLoadingCount);
70     StringAppendF(&result, "glLoadingFailureCount = %d\n", glLoadingFailureCount);
71     StringAppendF(&result, "angleLoadingCount = %d\n", angleLoadingCount);
72     StringAppendF(&result, "angleLoadingFailureCount = %d\n", angleLoadingFailureCount);
73     StringAppendF(&result, "vkLoadingCount = %d\n", vkLoadingCount);
74     StringAppendF(&result, "vkLoadingFailureCount = %d\n", vkLoadingFailureCount);
75     StringAppendF(&result, "vulkanVersion = %d\n", vulkanVersion);
76     StringAppendF(&result, "cpuVulkanVersion = %d\n", cpuVulkanVersion);
77     StringAppendF(&result, "glesVersion = %d\n", glesVersion);
78     return result;
79 }
80 
writeToParcel(Parcel * parcel) const81 status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const {
82     status_t status;
83     if ((status = parcel->writeUtf8AsUtf16(appPackageName)) != OK) return status;
84     if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status;
85     if ((status = parcel->writeInt64Vector(glDriverLoadingTime)) != OK) return status;
86     if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status;
87     if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status;
88     if ((status = parcel->writeBool(cpuVulkanInUse)) != OK) return status;
89     if ((status = parcel->writeBool(falsePrerotation)) != OK) return status;
90     if ((status = parcel->writeBool(gles1InUse)) != OK) return status;
91     if ((status = parcel->writeBool(angleInUse)) != OK) return status;
92     if ((status = parcel->writeBool(createdGlesContext)) != OK) return status;
93     if ((status = parcel->writeBool(createdVulkanDevice)) != OK) return status;
94     if ((status = parcel->writeBool(createdVulkanSwapchain)) != OK) return status;
95     if ((status = parcel->writeUint32(vulkanApiVersion)) != OK) return status;
96     if ((status = parcel->writeUint64(vulkanDeviceFeaturesEnabled)) != OK) return status;
97     if ((status = parcel->writeInt32Vector(vulkanInstanceExtensions)) != OK) return status;
98     if ((status = parcel->writeInt32Vector(vulkanDeviceExtensions)) != OK) return status;
99     if ((status = parcel->writeUtf8VectorAsUtf16Vector(vulkanEngineNames)) != OK) return status;
100 
101     return OK;
102 }
103 
readFromParcel(const Parcel * parcel)104 status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) {
105     status_t status;
106     if ((status = parcel->readUtf8FromUtf16(&appPackageName)) != OK) return status;
107     if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status;
108     if ((status = parcel->readInt64Vector(&glDriverLoadingTime)) != OK) return status;
109     if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status;
110     if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status;
111     if ((status = parcel->readBool(&cpuVulkanInUse)) != OK) return status;
112     if ((status = parcel->readBool(&falsePrerotation)) != OK) return status;
113     if ((status = parcel->readBool(&gles1InUse)) != OK) return status;
114     if ((status = parcel->readBool(&angleInUse)) != OK) return status;
115     if ((status = parcel->readBool(&createdGlesContext)) != OK) return status;
116     if ((status = parcel->readBool(&createdVulkanDevice)) != OK) return status;
117     if ((status = parcel->readBool(&createdVulkanSwapchain)) != OK) return status;
118     if ((status = parcel->readUint32(&vulkanApiVersion)) != OK) return status;
119     if ((status = parcel->readUint64(&vulkanDeviceFeaturesEnabled)) != OK) return status;
120     if ((status = parcel->readInt32Vector(&vulkanInstanceExtensions)) != OK) return status;
121     if ((status = parcel->readInt32Vector(&vulkanDeviceExtensions)) != OK) return status;
122     if ((status = parcel->readUtf8VectorFromUtf16Vector(&vulkanEngineNames)) != OK) return status;
123 
124     return OK;
125 }
126 
toString() const127 std::string GpuStatsAppInfo::toString() const {
128     std::string result;
129     StringAppendF(&result, "appPackageName = %s\n", appPackageName.c_str());
130     StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
131     StringAppendF(&result, "cpuVulkanInUse = %d\n", cpuVulkanInUse);
132     StringAppendF(&result, "falsePrerotation = %d\n", falsePrerotation);
133     StringAppendF(&result, "gles1InUse = %d\n", gles1InUse);
134     StringAppendF(&result, "angleInUse = %d\n", angleInUse);
135     StringAppendF(&result, "createdGlesContext = %d\n", createdGlesContext);
136     StringAppendF(&result, "createdVulkanDevice = %d\n", createdVulkanDevice);
137     StringAppendF(&result, "createdVulkanSwapchain = %d\n", createdVulkanSwapchain);
138     StringAppendF(&result, "vulkanApiVersion = 0x%" PRIx32 "\n", vulkanApiVersion);
139     StringAppendF(&result, "vulkanDeviceFeaturesEnabled = 0x%" PRIx64 "\n",
140                   vulkanDeviceFeaturesEnabled);
141     result.append("glDriverLoadingTime:");
142     for (int32_t loadingTime : glDriverLoadingTime) {
143         StringAppendF(&result, " %d", loadingTime);
144     }
145     result.append("\n");
146     result.append("angleDriverLoadingTime:");
147     for (int32_t loadingTime : angleDriverLoadingTime) {
148         StringAppendF(&result, " %d", loadingTime);
149     }
150     result.append("\n");
151     result.append("vkDriverLoadingTime:");
152     for (int32_t loadingTime : vkDriverLoadingTime) {
153         StringAppendF(&result, " %d", loadingTime);
154     }
155     result.append("\n");
156     result.append("vulkanInstanceExtensions:");
157     for (int32_t extension : vulkanInstanceExtensions) {
158         StringAppendF(&result, " 0x%x", extension);
159     }
160     result.append("\n");
161     result.append("vulkanDeviceExtensions:");
162     for (int32_t extension : vulkanDeviceExtensions) {
163         StringAppendF(&result, " 0x%x", extension);
164     }
165     result.append("\n");
166     result.append("vulkanEngineNames:");
167     for (const std::string& engineName : vulkanEngineNames) {
168         StringAppendF(&result, " %s,", engineName.c_str());
169     }
170     result.append("\n");
171     return result;
172 }
173 
174 } // namespace android
175