From bccd0f873bf1cf6c3695a6c9e1865ba320792ad7 Mon Sep 17 00:00:00 2001 From: artdeell Date: Mon, 20 Jan 2025 21:06:29 +0300 Subject: [PATCH] Freat[misc_settings]: check for Turnip compatibility to hide the driver option --- .../src/main/java/net/kdt/pojavlaunch/Tools.java | 15 +++------------ .../LauncherPreferenceMiscellaneousFragment.java | 8 +++++--- .../net/kdt/pojavlaunch/utils/GLInfoUtils.java | 15 ++++++++++++++- .../java/net/kdt/pojavlaunch/utils/JREUtils.java | 11 +++-------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java index dc2fb2340e..a66c61ed1b 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -22,11 +22,6 @@ import android.hardware.Sensor; import android.hardware.SensorManager; import android.net.Uri; -import android.opengl.EGL14; -import android.opengl.EGLConfig; -import android.opengl.EGLContext; -import android.opengl.EGLDisplay; -import android.opengl.GLES30; import android.os.Build; import android.os.Bundle; import android.os.Environment; @@ -48,10 +43,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationManagerCompat; -import androidx.core.view.ViewCompat; -import androidx.core.view.WindowCompat; -import androidx.core.view.WindowInsetsCompat; -import androidx.core.view.WindowInsetsControllerCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -242,8 +233,8 @@ private static boolean hasSodium(File gameDir) { * @return whether the GPU is affected by the Large Thin Wrapper render distance issue on vanilla */ private static boolean affectedByRenderDistanceIssue() { - GLInfoUtils.GLInfo info = GLInfoUtils.getInfo(); - return info.renderer.contains("Adreno") && info.vendor.equals("Qualcomm") && info.glesMajorVersion >= 3; + GLInfoUtils.GLInfo info = GLInfoUtils.getGlInfo(); + return info.isAdreno() && info.glesMajorVersion >= 3; } private static boolean checkRenderDistance(File gamedir) { @@ -1035,7 +1026,7 @@ public static void printLauncherInfo(String gameVersion, String javaArguments) { Logger.appendToLog("Info: API version: " + SDK_INT); Logger.appendToLog("Info: Selected Minecraft version: " + gameVersion); Logger.appendToLog("Info: Custom Java arguments: \"" + javaArguments + "\""); - GLInfoUtils.GLInfo info = GLInfoUtils.getInfo(); + GLInfoUtils.GLInfo info = GLInfoUtils.getGlInfo(); Logger.appendToLog("Info: Graphics device: "+info.vendor+ " "+info.renderer+" (OpenGL ES "+info.glesMajorVersion+")"); } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceMiscellaneousFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceMiscellaneousFragment.java index 9cdbf9dc9f..5d100a7653 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceMiscellaneousFragment.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceMiscellaneousFragment.java @@ -1,19 +1,21 @@ package net.kdt.pojavlaunch.prefs.screens; +import android.content.pm.PackageManager; import android.os.Bundle; import androidx.preference.Preference; import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.Tools; +import net.kdt.pojavlaunch.utils.GLInfoUtils; public class LauncherPreferenceMiscellaneousFragment extends LauncherPreferenceFragment { @Override public void onCreatePreferences(Bundle b, String str) { addPreferencesFromResource(R.xml.pref_misc); Preference driverPreference = requirePreference("zinkPreferSystemDriver"); - if(!Tools.checkVulkanSupport(driverPreference.getContext().getPackageManager())) { - driverPreference.setVisible(false); - } + PackageManager packageManager = driverPreference.getContext().getPackageManager(); + boolean supportsTurnip = Tools.checkVulkanSupport(packageManager) && GLInfoUtils.getGlInfo().isAdreno(); + driverPreference.setVisible(supportsTurnip); } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/GLInfoUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/GLInfoUtils.java index 32a350b31d..98a8bd7421 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/GLInfoUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/GLInfoUtils.java @@ -99,7 +99,12 @@ private static boolean initAndQueryInfo() { return true; } - public static GLInfo getInfo() { + /** + * Get the information about the current OpenGL ES device, which consists of the vendor, + * the renderer and the major GLES version + * @return the info + */ + public static GLInfo getGlInfo() { if(info != null) return info; Log.i("GLInfoUtils", "Querying graphics device info..."); boolean infoQueryResult = false; @@ -121,5 +126,13 @@ protected GLInfo(String vendor, String renderer, int glesMajorVersion) { this.renderer = renderer; this.glesMajorVersion = glesMajorVersion; } + + /** + * Check if this GLInfo belongs to a Qualcomm Adreno graphics adapter + * @return + */ + public boolean isAdreno() { + return renderer.contains("Adreno") && vendor.equals("Qualcomm"); + } } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java index 016d8483c5..627c611a90 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java @@ -32,11 +32,6 @@ import net.kdt.pojavlaunch.prefs.*; import org.lwjgl.glfw.*; -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; - public class JREUtils { private JREUtils() {} @@ -239,7 +234,7 @@ public static void setJavaEnvironment(Activity activity, String jreHome) throws reader.close(); } - GLInfoUtils.GLInfo info = GLInfoUtils.getInfo(); + GLInfoUtils.GLInfo info = GLInfoUtils.getGlInfo(); if(!envMap.containsKey("LIBGL_ES") && LOCAL_RENDERER != null) { int glesMajor = info.glesMajorVersion; Log.i("glesDetect","GLES version detected: "+glesMajor); @@ -256,7 +251,7 @@ public static void setJavaEnvironment(Activity activity, String jreHome) throws } } - if(info.vendor.equals("Qualcomm") && info.renderer.contains("Adreno") && !PREF_ZINK_PREFER_SYSTEM_DRIVER) { + if(info.isAdreno() && !PREF_ZINK_PREFER_SYSTEM_DRIVER) { envMap.put("POJAV_LOAD_TURNIP", "1"); } @@ -517,7 +512,7 @@ private static boolean hasExtension(String extensions, String name) { } public static int getDetectedVersion() { - return GLInfoUtils.getInfo().glesMajorVersion; + return GLInfoUtils.getGlInfo().glesMajorVersion; } public static native int chdir(String path); public static native boolean dlopen(String libPath);