release-request-777c0f47-a42e-446a-b45c-0bb1aaa9612e-for-git_oc-release-4066915 snap-temp-L92300000070444114

Change-Id: I43cfe70848f39de298e8ae197533bfb5b70035a9
diff --git a/cpp/rsDispatch.h b/cpp/rsDispatch.h
index ab57936..1bcd954 100644
--- a/cpp/rsDispatch.h
+++ b/cpp/rsDispatch.h
@@ -29,6 +29,7 @@
 typedef void (*DeviceDestroyFnPtr) (RsDevice dev);
 typedef void (*DeviceSetConfigFnPtr) (RsDevice dev, RsDeviceParam p, int32_t value);
 typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags);
+typedef RsContext (*ContextCreateVendorFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags, const char* vendorDriverName);
 typedef void (*GetNameFnPtr)(RsContext, void * obj, const char **name);
 typedef RsClosure (*ClosureCreateFnPtr)(RsContext, RsScriptKernelID, RsAllocation, RsScriptFieldID*, size_t, int64_t*, size_t, int*, size_t, RsClosure*, size_t, RsScriptFieldID*, size_t);
 typedef RsClosure (*InvokeClosureCreateFnPtr)(RsContext, RsScriptInvokeID, const void*, const size_t, const RsScriptFieldID*, const size_t, const int64_t*, const size_t, const int*, const size_t);
@@ -177,6 +178,7 @@
     ClosureSetArgFnPtr ClosureSetArg;
     ClosureSetGlobalFnPtr ClosureSetGlobal;
     ContextCreateFnPtr ContextCreate;
+    ContextCreateVendorFnPtr ContextCreateVendor;
     ContextDeinitToClientFnPtr ContextDeinitToClient;
     ContextDestroyFnPtr ContextDestroy;
     ContextDumpFnPtr ContextDump;
diff --git a/rsApiContext.cpp b/rsApiContext.cpp
index 1160985..53d9e4a 100644
--- a/rsApiContext.cpp
+++ b/rsApiContext.cpp
@@ -25,16 +25,22 @@
 using android::renderscript::Device;
 using android::renderscript::ObjectBase;
 
-extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
-                                      RsContextType ct, uint32_t flags) {
+extern "C" RsContext rsContextCreateVendor(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
+                                           RsContextType ct, uint32_t flags,
+                                           const char* vendorDriverName) {
     Device * dev = static_cast<Device *>(vdev);
-    Context *rsc = Context::createContext(dev, nullptr, ct, flags);
+    Context *rsc = Context::createContext(dev, nullptr, ct, flags, vendorDriverName);
     if (rsc) {
         rsc->setTargetSdkVersion(sdkVersion);
     }
     return rsc;
 }
 
+extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
+                                      RsContextType ct, uint32_t flags) {
+    return rsContextCreateVendor(vdev, version, sdkVersion, ct, flags, nullptr);
+}
+
 extern "C" void rsaContextSetNativeLibDir(RsContext con, char *libDir, size_t length) {
 #ifdef RS_COMPATIBILITY_LIB
     Context *rsc = static_cast<Context *>(con);
diff --git a/rsContext.cpp b/rsContext.cpp
index f6686a9..f69f5ee 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -460,7 +460,8 @@
 }
 
 Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc,
-                                 RsContextType ct, uint32_t flags) {
+                                 RsContextType ct, uint32_t flags,
+                                 const char* vendorDriverName) {
     Context * rsc = new Context();
 
     if (flags & RS_CONTEXT_LOW_LATENCY) {
@@ -471,6 +472,7 @@
     }
     rsc->mContextType = ct;
     rsc->mHal.flags = flags;
+    rsc->mVendorDriverName = vendorDriverName;
 
     if (!rsc->initContext(dev, sc)) {
         delete rsc;
diff --git a/rsContext.h b/rsContext.h
index 10574de..17a890b 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -81,7 +81,8 @@
 
     static Context * createContext(Device *, const RsSurfaceConfig *sc,
             RsContextType ct = RS_CONTEXT_TYPE_NORMAL,
-            uint32_t flags = 0);
+            uint32_t flags = 0,
+            const char* vendorDriverName = nullptr);
     static Context * createContextLite();
     ~Context();
 
@@ -352,6 +353,7 @@
     // Since this is always just a static string, we don't have to
     // allocate, copy, or free any memory here.
     const char* mDriverName;
+    const char* mVendorDriverName;
 
     std::vector<ObjectBase *> mNames;
 
diff --git a/rsDriverLoader.cpp b/rsDriverLoader.cpp
index 48ff990..e432a4f 100644
--- a/rsDriverLoader.cpp
+++ b/rsDriverLoader.cpp
@@ -240,21 +240,14 @@
         ALOGE("Failed to load the RSoV driver!");
     }
 
-#ifdef OVERRIDE_RS_DRIVER
-#define XSTR(S) #S
-#define STR(S) XSTR(S)
-#define OVERRIDE_RS_DRIVER_STRING STR(OVERRIDE_RS_DRIVER)
-    if (!forceDefault) {
-        if (loadRuntime(OVERRIDE_RS_DRIVER_STRING)) {
-            ALOGV("Successfully loaded runtime: %s", OVERRIDE_RS_DRIVER_STRING);
+    if (!forceDefault && mVendorDriverName != nullptr) {
+        if (loadRuntime(mVendorDriverName)) {
+            ALOGV("Successfully loaded runtime: %s", mVendorDriverName);
             loadDefault = false;
         } else {
-            ALOGE("Failed to load runtime %s, loading default", OVERRIDE_RS_DRIVER_STRING);
+            ALOGE("Failed to load runtime %s, loading default", mVendorDriverName);
         }
     }
-#undef XSTR
-#undef STR
-#endif  // OVERRIDE_RS_DRIVER
 
     if (loadDefault) {
         if (!loadRuntime("libRSDriver.so")) {