GpuStatsInfo.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #include <inttypes.h>
  17. #include <android-base/stringprintf.h>
  18. #include <binder/Parcel.h>
  19. #include <graphicsenv/GpuStatsInfo.h>
  20. namespace android {
  21. using base::StringAppendF;
  22. status_t GpuStatsGlobalInfo::writeToParcel(Parcel* parcel) const {
  23. status_t status;
  24. if ((status = parcel->writeUtf8AsUtf16(driverPackageName)) != OK) return status;
  25. if ((status = parcel->writeUtf8AsUtf16(driverVersionName)) != OK) return status;
  26. if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status;
  27. if ((status = parcel->writeInt64(driverBuildTime)) != OK) return status;
  28. if ((status = parcel->writeInt32(glLoadingCount)) != OK) return status;
  29. if ((status = parcel->writeInt32(glLoadingFailureCount)) != OK) return status;
  30. if ((status = parcel->writeInt32(vkLoadingCount)) != OK) return status;
  31. if ((status = parcel->writeInt32(vkLoadingFailureCount)) != OK) return status;
  32. if ((status = parcel->writeInt32(vulkanVersion)) != OK) return status;
  33. if ((status = parcel->writeInt32(cpuVulkanVersion)) != OK) return status;
  34. if ((status = parcel->writeInt32(glesVersion)) != OK) return status;
  35. if ((status = parcel->writeInt32(angleLoadingCount)) != OK) return status;
  36. if ((status = parcel->writeInt32(angleLoadingFailureCount)) != OK) return status;
  37. return OK;
  38. }
  39. status_t GpuStatsGlobalInfo::readFromParcel(const Parcel* parcel) {
  40. status_t status;
  41. if ((status = parcel->readUtf8FromUtf16(&driverPackageName)) != OK) return status;
  42. if ((status = parcel->readUtf8FromUtf16(&driverVersionName)) != OK) return status;
  43. if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status;
  44. if ((status = parcel->readInt64(&driverBuildTime)) != OK) return status;
  45. if ((status = parcel->readInt32(&glLoadingCount)) != OK) return status;
  46. if ((status = parcel->readInt32(&glLoadingFailureCount)) != OK) return status;
  47. if ((status = parcel->readInt32(&vkLoadingCount)) != OK) return status;
  48. if ((status = parcel->readInt32(&vkLoadingFailureCount)) != OK) return status;
  49. if ((status = parcel->readInt32(&vulkanVersion)) != OK) return status;
  50. if ((status = parcel->readInt32(&cpuVulkanVersion)) != OK) return status;
  51. if ((status = parcel->readInt32(&glesVersion)) != OK) return status;
  52. if ((status = parcel->readInt32(&angleLoadingCount)) != OK) return status;
  53. if ((status = parcel->readInt32(&angleLoadingFailureCount)) != OK) return status;
  54. return OK;
  55. }
  56. std::string GpuStatsGlobalInfo::toString() const {
  57. std::string result;
  58. StringAppendF(&result, "driverPackageName = %s\n", driverPackageName.c_str());
  59. StringAppendF(&result, "driverVersionName = %s\n", driverVersionName.c_str());
  60. StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
  61. StringAppendF(&result, "driverBuildTime = %" PRId64 "\n", driverBuildTime);
  62. StringAppendF(&result, "glLoadingCount = %d\n", glLoadingCount);
  63. StringAppendF(&result, "glLoadingFailureCount = %d\n", glLoadingFailureCount);
  64. StringAppendF(&result, "angleLoadingCount = %d\n", angleLoadingCount);
  65. StringAppendF(&result, "angleLoadingFailureCount = %d\n", angleLoadingFailureCount);
  66. StringAppendF(&result, "vkLoadingCount = %d\n", vkLoadingCount);
  67. StringAppendF(&result, "vkLoadingFailureCount = %d\n", vkLoadingFailureCount);
  68. StringAppendF(&result, "vulkanVersion = %d\n", vulkanVersion);
  69. StringAppendF(&result, "cpuVulkanVersion = %d\n", cpuVulkanVersion);
  70. StringAppendF(&result, "glesVersion = %d\n", glesVersion);
  71. return result;
  72. }
  73. status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const {
  74. status_t status;
  75. if ((status = parcel->writeUtf8AsUtf16(appPackageName)) != OK) return status;
  76. if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status;
  77. if ((status = parcel->writeInt64Vector(glDriverLoadingTime)) != OK) return status;
  78. if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status;
  79. if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status;
  80. if ((status = parcel->writeBool(cpuVulkanInUse)) != OK) return status;
  81. return OK;
  82. }
  83. status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) {
  84. status_t status;
  85. if ((status = parcel->readUtf8FromUtf16(&appPackageName)) != OK) return status;
  86. if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status;
  87. if ((status = parcel->readInt64Vector(&glDriverLoadingTime)) != OK) return status;
  88. if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status;
  89. if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status;
  90. if ((status = parcel->readBool(&cpuVulkanInUse)) != OK) return status;
  91. return OK;
  92. }
  93. std::string GpuStatsAppInfo::toString() const {
  94. std::string result;
  95. StringAppendF(&result, "appPackageName = %s\n", appPackageName.c_str());
  96. StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode);
  97. StringAppendF(&result, "cpuVulkanInUse = %d\n", cpuVulkanInUse);
  98. result.append("glDriverLoadingTime:");
  99. for (int32_t loadingTime : glDriverLoadingTime) {
  100. StringAppendF(&result, " %d", loadingTime);
  101. }
  102. result.append("\n");
  103. result.append("angleDriverLoadingTime:");
  104. for (int32_t loadingTime : angleDriverLoadingTime) {
  105. StringAppendF(&result, " %d", loadingTime);
  106. }
  107. result.append("\n");
  108. result.append("vkDriverLoadingTime:");
  109. for (int32_t loadingTime : vkDriverLoadingTime) {
  110. StringAppendF(&result, " %d", loadingTime);
  111. }
  112. result.append("\n");
  113. return result;
  114. }
  115. } // namespace android