diff options
author | 2025-01-13 15:24:25 -0700 | |
---|---|---|
committer | 2025-02-19 10:04:15 -0700 | |
commit | 4b98bde791e67cdebb1a652ef8d0a3eb9aed715e (patch) | |
tree | 39467ae602e4cdcad75dcb210e6f58aed40223ce | |
parent | 8bba22be40afdb7f7fcfd5a663be6fc0856c899e (diff) |
FeatureConfig: Add GPU vendor ID support
Add GPU vendor ID support to FeatureConfig, to allow making
feature override decisions based on the GPU architecture of the device.
For example, restricting a particular feature override to Intel GPU
devices.
Bug: 372694741
Test: CQ, Manual verification
Flag: com.android.graphics.graphicsenv.flags.feature_overrides
Change-Id: I647c81f6f20c0443e3feaf67698af4fb66de0ed0
-rw-r--r-- | libs/graphicsenv/FeatureOverrides.cpp | 44 | ||||
-rw-r--r-- | libs/graphicsenv/include/graphicsenv/FeatureOverrides.h | 1 |
2 files changed, 43 insertions, 2 deletions
diff --git a/libs/graphicsenv/FeatureOverrides.cpp b/libs/graphicsenv/FeatureOverrides.cpp index 51afe285fb..9e7a4cf4a1 100644 --- a/libs/graphicsenv/FeatureOverrides.cpp +++ b/libs/graphicsenv/FeatureOverrides.cpp @@ -35,6 +35,18 @@ status_t FeatureConfig::writeToParcel(Parcel* parcel) const { if (status != OK) { return status; } + // Number of GPU vendor IDs. + status = parcel->writeVectorSize(mGpuVendorIDs); + if (status != OK) { + return status; + } + // GPU vendor IDs. + for (const auto& vendorID : mGpuVendorIDs) { + status = parcel->writeUint32(vendorID); + if (status != OK) { + return status; + } + } return OK; } @@ -50,6 +62,21 @@ status_t FeatureConfig::readFromParcel(const Parcel* parcel) { if (status != OK) { return status; } + // Number of GPU vendor IDs. + int numGpuVendorIDs; + status = parcel->readInt32(&numGpuVendorIDs); + if (status != OK) { + return status; + } + // GPU vendor IDs. + for (int i = 0; i < numGpuVendorIDs; i++) { + uint32_t gpuVendorIdUint; + status = parcel->readUint32(&gpuVendorIdUint); + if (status != OK) { + return status; + } + mGpuVendorIDs.emplace_back(gpuVendorIdUint); + } return OK; } @@ -58,6 +85,10 @@ std::string FeatureConfig::toString() const { std::string result; StringAppendF(&result, "Feature: %s\n", mFeatureName.c_str()); StringAppendF(&result, " Status: %s\n", mEnabled ? "enabled" : "disabled"); + for (const auto& vendorID : mGpuVendorIDs) { + // vkjson outputs decimal, so print both formats. + StringAppendF(&result, " GPU Vendor ID: 0x%04X (%d)\n", vendorID, vendorID); + } return result; } @@ -121,7 +152,12 @@ status_t FeatureOverrides::readFromParcel(const Parcel* parcel) { } // Number of package feature overrides. - int numPkgOverrides = parcel->readInt32(); + int numPkgOverrides; + status = parcel->readInt32(&numPkgOverrides); + if (status != OK) { + return status; + } + // Package feature overrides. for (int i = 0; i < numPkgOverrides; i++) { // Package name. std::string name; @@ -131,7 +167,11 @@ status_t FeatureOverrides::readFromParcel(const Parcel* parcel) { } std::vector<FeatureConfig> cfgs; // Number of package feature configs. - int numCfgs = parcel->readInt32(); + int numCfgs; + status = parcel->readInt32(&numCfgs); + if (status != OK) { + return status; + } // Package feature configs. for (int j = 0; j < numCfgs; j++) { FeatureConfig cfg; diff --git a/libs/graphicsenv/include/graphicsenv/FeatureOverrides.h b/libs/graphicsenv/include/graphicsenv/FeatureOverrides.h index 450eed2151..5dc613b901 100644 --- a/libs/graphicsenv/include/graphicsenv/FeatureOverrides.h +++ b/libs/graphicsenv/include/graphicsenv/FeatureOverrides.h @@ -35,6 +35,7 @@ public: std::string mFeatureName; bool mEnabled; + std::vector<uint32_t> mGpuVendorIDs; }; /* |