Merge "Revert "Load native GLES driver when specified."" into udc-qpr-dev

This commit is contained in:
Treehugger Robot
2023-07-12 18:46:12 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 45 deletions

View File

@@ -112,17 +112,9 @@ public class GraphicsEnvironment {
private static final int ANGLE_GL_DRIVER_ALL_ANGLE_OFF = 0; private static final int ANGLE_GL_DRIVER_ALL_ANGLE_OFF = 0;
// Values for ANGLE_GL_DRIVER_SELECTION_VALUES // Values for ANGLE_GL_DRIVER_SELECTION_VALUES
private enum AngleDriverChoice { private static final String ANGLE_GL_DRIVER_CHOICE_DEFAULT = "default";
DEFAULT("default"), private static final String ANGLE_GL_DRIVER_CHOICE_ANGLE = "angle";
ANGLE("angle"), private static final String ANGLE_GL_DRIVER_CHOICE_NATIVE = "native";
NATIVE("native");
public final String choice;
AngleDriverChoice(String choice) {
this.choice = choice;
}
}
private static final String PROPERTY_RO_ANGLE_SUPPORTED = "ro.gfx.angle.supported"; private static final String PROPERTY_RO_ANGLE_SUPPORTED = "ro.gfx.angle.supported";
@@ -203,16 +195,15 @@ public class GraphicsEnvironment {
} }
/** /**
* Query to determine the ANGLE driver choice. * Query to determine if ANGLE should be used
*/ */
private AngleDriverChoice queryAngleChoice(Context context, Bundle coreSettings, private boolean shouldUseAngle(Context context, Bundle coreSettings, String packageName) {
String packageName) {
if (TextUtils.isEmpty(packageName)) { if (TextUtils.isEmpty(packageName)) {
Log.v(TAG, "No package name specified; use the system driver"); Log.v(TAG, "No package name specified; use the system driver");
return AngleDriverChoice.DEFAULT; return false;
} }
return queryAngleChoiceInternal(context, coreSettings, packageName); return shouldUseAngleInternal(context, coreSettings, packageName);
} }
private int getVulkanVersion(PackageManager pm) { private int getVulkanVersion(PackageManager pm) {
@@ -433,11 +424,10 @@ public class GraphicsEnvironment {
* forces a choice; * forces a choice;
* 3) Use ANGLE if isAngleEnabledByGameMode() returns true; * 3) Use ANGLE if isAngleEnabledByGameMode() returns true;
*/ */
private AngleDriverChoice queryAngleChoiceInternal(Context context, Bundle bundle, private boolean shouldUseAngleInternal(Context context, Bundle bundle, String packageName) {
String packageName) {
// Make sure we have a good package name // Make sure we have a good package name
if (TextUtils.isEmpty(packageName)) { if (TextUtils.isEmpty(packageName)) {
return AngleDriverChoice.DEFAULT; return false;
} }
// Check the semi-global switch (i.e. once system has booted enough) for whether ANGLE // Check the semi-global switch (i.e. once system has booted enough) for whether ANGLE
@@ -452,7 +442,7 @@ public class GraphicsEnvironment {
} }
if (allUseAngle == ANGLE_GL_DRIVER_ALL_ANGLE_ON) { if (allUseAngle == ANGLE_GL_DRIVER_ALL_ANGLE_ON) {
Log.v(TAG, "Turn on ANGLE for all applications."); Log.v(TAG, "Turn on ANGLE for all applications.");
return AngleDriverChoice.ANGLE; return true;
} }
// Get the per-application settings lists // Get the per-application settings lists
@@ -475,7 +465,7 @@ public class GraphicsEnvironment {
+ optInPackages.size() + ", " + optInPackages.size() + ", "
+ "number of values: " + "number of values: "
+ optInValues.size()); + optInValues.size());
return mEnabledByGameMode ? AngleDriverChoice.ANGLE : AngleDriverChoice.DEFAULT; return mEnabledByGameMode;
} }
// See if this application is listed in the per-application settings list // See if this application is listed in the per-application settings list
@@ -483,7 +473,7 @@ public class GraphicsEnvironment {
if (pkgIndex < 0) { if (pkgIndex < 0) {
Log.v(TAG, packageName + " is not listed in per-application setting"); Log.v(TAG, packageName + " is not listed in per-application setting");
return mEnabledByGameMode ? AngleDriverChoice.ANGLE : AngleDriverChoice.DEFAULT; return mEnabledByGameMode;
} }
mAngleOptInIndex = pkgIndex; mAngleOptInIndex = pkgIndex;
@@ -493,14 +483,14 @@ public class GraphicsEnvironment {
Log.v(TAG, Log.v(TAG,
"ANGLE Developer option for '" + packageName + "' " "ANGLE Developer option for '" + packageName + "' "
+ "set to: '" + optInValue + "'"); + "set to: '" + optInValue + "'");
if (optInValue.equals(AngleDriverChoice.ANGLE.choice)) { if (optInValue.equals(ANGLE_GL_DRIVER_CHOICE_ANGLE)) {
return AngleDriverChoice.ANGLE; return true;
} else if (optInValue.equals(AngleDriverChoice.NATIVE.choice)) { } else if (optInValue.equals(ANGLE_GL_DRIVER_CHOICE_NATIVE)) {
return AngleDriverChoice.NATIVE; return false;
} else { } else {
// The user either chose default or an invalid value; go with the default driver or what // The user either chose default or an invalid value; go with the default driver or what
// the game mode indicates // the game mode indicates
return mEnabledByGameMode ? AngleDriverChoice.ANGLE : AngleDriverChoice.DEFAULT; return mEnabledByGameMode;
} }
} }
@@ -568,13 +558,7 @@ public class GraphicsEnvironment {
private boolean setupAngle(Context context, Bundle bundle, PackageManager packageManager, private boolean setupAngle(Context context, Bundle bundle, PackageManager packageManager,
String packageName) { String packageName) {
final AngleDriverChoice angleDriverChoice = queryAngleChoice(context, bundle, packageName); if (!shouldUseAngle(context, bundle, packageName)) {
if (angleDriverChoice == AngleDriverChoice.DEFAULT) {
return false;
}
if (queryAngleChoice(context, bundle, packageName) == AngleDriverChoice.NATIVE) {
nativeSetAngleInfo("", true, packageName, null);
return false; return false;
} }
@@ -643,10 +627,10 @@ public class GraphicsEnvironment {
Log.d(TAG, "ANGLE package libs: " + paths); Log.d(TAG, "ANGLE package libs: " + paths);
} }
// If we make it to here, ANGLE apk will be used. Call nativeSetAngleInfo() with the // If we make it to here, ANGLE will be used. Call setAngleInfo() with the package name,
// application package name and ANGLE features to use. // and features to use.
final String[] features = getAngleEglFeatures(context, bundle); final String[] features = getAngleEglFeatures(context, bundle);
nativeSetAngleInfo(paths, false, packageName, features); setAngleInfo(paths, false, packageName, features);
return true; return true;
} }
@@ -668,10 +652,10 @@ public class GraphicsEnvironment {
return false; return false;
} }
// If we make it to here, system ANGLE will be used. Call nativeSetAngleInfo() with // If we make it to here, ANGLE will be used. Call setAngleInfo() with the package name,
// the application package name and ANGLE features to use. // and features to use.
final String[] features = getAngleEglFeatures(context, bundle); final String[] features = getAngleEglFeatures(context, bundle);
nativeSetAngleInfo("system", false, packageName, features); setAngleInfo("", true, packageName, features);
return true; return true;
} }
@@ -952,8 +936,8 @@ public class GraphicsEnvironment {
private static native void setDriverPathAndSphalLibraries(String path, String sphalLibraries); private static native void setDriverPathAndSphalLibraries(String path, String sphalLibraries);
private static native void setGpuStats(String driverPackageName, String driverVersionName, private static native void setGpuStats(String driverPackageName, String driverVersionName,
long driverVersionCode, long driverBuildTime, String appPackageName, int vulkanVersion); long driverVersionCode, long driverBuildTime, String appPackageName, int vulkanVersion);
private static native void nativeSetAngleInfo(String path, boolean useNativeDriver, private static native void setAngleInfo(String path, boolean useSystemAngle, String packageName,
String packageName, String[] features); String[] features);
private static native boolean setInjectLayersPrSetDumpable(); private static native boolean setInjectLayersPrSetDumpable();
private static native void nativeToggleAngleAsSystemDriver(boolean enabled); private static native void nativeToggleAngleAsSystemDriver(boolean enabled);

View File

@@ -50,7 +50,7 @@ void setGpuStats_native(JNIEnv* env, jobject clazz, jstring driverPackageName,
appPackageNameChars.c_str(), vulkanVersion); appPackageNameChars.c_str(), vulkanVersion);
} }
void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jboolean useNativeDriver, void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jboolean useSystemAngle,
jstring packageName, jobjectArray featuresObj) { jstring packageName, jobjectArray featuresObj) {
ScopedUtfChars pathChars(env, path); ScopedUtfChars pathChars(env, path);
ScopedUtfChars packageNameChars(env, packageName); ScopedUtfChars packageNameChars(env, packageName);
@@ -73,7 +73,7 @@ void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jboolean useN
} }
} }
android::GraphicsEnv::getInstance().setAngleInfo(pathChars.c_str(), useNativeDriver, android::GraphicsEnv::getInstance().setAngleInfo(pathChars.c_str(), useSystemAngle,
packageNameChars.c_str(), features); packageNameChars.c_str(), features);
} }
@@ -118,7 +118,7 @@ const JNINativeMethod g_methods[] = {
reinterpret_cast<void*>(setGpuStats_native)}, reinterpret_cast<void*>(setGpuStats_native)},
{"setInjectLayersPrSetDumpable", "()Z", {"setInjectLayersPrSetDumpable", "()Z",
reinterpret_cast<void*>(setInjectLayersPrSetDumpable_native)}, reinterpret_cast<void*>(setInjectLayersPrSetDumpable_native)},
{"nativeSetAngleInfo", "(Ljava/lang/String;ZLjava/lang/String;[Ljava/lang/String;)V", {"setAngleInfo", "(Ljava/lang/String;ZLjava/lang/String;[Ljava/lang/String;)V",
reinterpret_cast<void*>(setAngleInfo_native)}, reinterpret_cast<void*>(setAngleInfo_native)},
{"setLayerPaths", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V", {"setLayerPaths", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V",
reinterpret_cast<void*>(setLayerPaths_native)}, reinterpret_cast<void*>(setLayerPaths_native)},