summaryrefslogtreecommitdiff
path: root/libs/graphicsenv/GraphicsEnv.cpp
diff options
context:
space:
mode:
author Peiyong Lin <lpy@google.com> 2020-06-17 18:47:12 -0700
committer Peiyong Lin <lpy@google.com> 2020-06-18 17:22:11 -0700
commit0acbfdc7d8c06917e3c22fb30de7486ba49df067 (patch)
tree29cd7fd9b3595f406522d8d4ab21cb8a3e15a387 /libs/graphicsenv/GraphicsEnv.cpp
parent7553059284a38f9aa4b1f91c8dbe723a9130a2cf (diff)
Allow native process to load updatable driver.
Previously an application process can be specified to load the updatable driver and the driver path will be set up correctly via GraphicsEnvironment.java. For a native process that is not an application process, there's no way for it to be specificed to load the updatable driver and hence the driver path is not set up. This patch provides a way for a native process that runs in an environment, for example shell, where environment variables can be set, to opt into using udpatable driver by setting UPDATABLE_GFX_DRIVER to 1. Bug: b/157832445, b/159240322 Test: ./gapit validate_gpu_profiling --os android Change-Id: I597535caa5ae0a033c2b8d581bb39b14875ac8fc
Diffstat (limited to 'libs/graphicsenv/GraphicsEnv.cpp')
-rw-r--r--libs/graphicsenv/GraphicsEnv.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index cfc7e98da3..119b3e0b7d 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -39,6 +39,13 @@
#include <string>
#include <thread>
+// TODO(b/159240322): Extend this to x86 ABI.
+#if defined(__LP64__)
+#define UPDATABLE_DRIVER_ABI "arm64-v8a"
+#else
+#define UPDATABLE_DRIVER_ABI "armeabi-v7a"
+#endif // defined(__LP64__)
+
// TODO(ianelliott@): Get the following from an ANGLE header:
#define CURRENT_ANGLE_API_VERSION 2 // Current API verion we are targetting
// Version-2 API:
@@ -582,7 +589,28 @@ android_namespace_t* GraphicsEnv::getDriverNamespace() {
}
if (mDriverPath.empty()) {
- return nullptr;
+ // For an application process, driver path is empty means this application is not opted in
+ // to use updatable driver. Application process doesn't have the ability to set up
+ // environment variables and hence before `getenv` call will return.
+ // For a process that is not an application process, if it's run from an environment,
+ // for example shell, where environment variables can be set, then it can opt into using
+ // udpatable driver by setting UPDATABLE_GFX_DRIVER to 1. By setting to 1 the developer
+ // driver will be used currently.
+ // TODO(b/159240322) Support the production updatable driver.
+ const char* id = getenv("UPDATABLE_GFX_DRIVER");
+ if (id == nullptr || std::strcmp(id, "1")) {
+ return nullptr;
+ }
+ const sp<IGpuService> gpuService = getGpuService();
+ if (!gpuService) {
+ return nullptr;
+ }
+ mDriverPath = gpuService->getUpdatableDriverPath();
+ if (mDriverPath.empty()) {
+ return nullptr;
+ }
+ mDriverPath.append(UPDATABLE_DRIVER_ABI);
+ ALOGI("Driver path is setup via UPDATABLE_GFX_DRIVER: %s", mDriverPath.c_str());
}
auto vndkNamespace = android_get_exported_namespace("vndk");