Skip to content

Commit

Permalink
Freat[misc_settings]: check for Turnip compatibility to hide the driv…
Browse files Browse the repository at this point in the history
…er option
  • Loading branch information
artdeell committed Jan 20, 2025
1 parent 2f853cf commit bccd0f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
15 changes: 3 additions & 12 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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+")");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down Expand Up @@ -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);
Expand All @@ -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");
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bccd0f8

Please sign in to comment.