Compare commits

..
7 changed files with 40 additions and 31 deletions

No files matched your search

@@ -22,11 +22,6 @@ import android.database.Cursor;
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.annotation.Nullable;
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 @@ public final class Tools {
* @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 final class Tools {
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+")");
}
@@ -23,6 +23,8 @@ public class CustomSeekBarPreference extends SeekBarPreference {
private int mMin;
/** The textview associated by default to the preference */
private TextView mTextView;
/** Seekbar increment in case the max gets set */
private final int mIncrement;
@SuppressLint("PrivateResource")
@@ -31,6 +33,7 @@ public class CustomSeekBarPreference extends SeekBarPreference {
try (TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SeekBarPreference, defStyleAttr, defStyleRes)) {
mMin = a.getInt(R.styleable.SeekBarPreference_min, 0);
mIncrement = a.getInt(R.styleable.SeekBarPreference_seekBarIncrement, 0);
}
}
@@ -111,7 +114,12 @@ public class CustomSeekBarPreference extends SeekBarPreference {
*/
public void setRange(int min, int max){
setMin(min);
setMax(max);
setMaxKeepIncrement(max);
}
public void setMaxKeepIncrement(int max) {
super.setMax(max);
setSeekBarIncrement(mIncrement);
}
@@ -141,14 +141,14 @@ public class LauncherPreferences {
*/
private static int findBestRAMAllocation(Context ctx){
int deviceRam = Tools.getTotalDeviceMemory(ctx);
if (deviceRam < 1024) return 300;
if (deviceRam < 1536) return 450;
if (deviceRam < 2048) return 600;
if (deviceRam < 1024) return 296;
if (deviceRam < 1536) return 448;
if (deviceRam < 2048) return 656;
// Limit the max for 32 bits devices more harshly
if (is32BitsDevice()) return 700;
if (is32BitsDevice()) return 696;
if (deviceRam < 3064) return 936;
if (deviceRam < 4096) return 1148;
if (deviceRam < 4096) return 1144;
if (deviceRam < 6144) return 1536;
return 2048; //Default RAM allocation for 64 bits
}
@@ -38,7 +38,7 @@ public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment {
if(is32BitsDevice() || deviceRam < 2048) maxRAM = Math.min(1024, deviceRam);
else maxRAM = deviceRam - (deviceRam < 3064 ? 800 : 1024); //To have a minimum for the device to breathe
memorySeekbar.setMax(maxRAM);
memorySeekbar.setMaxKeepIncrement(maxRAM);
memorySeekbar.setValue(ramAllocation);
memorySeekbar.setSuffix(" MB");
@@ -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);
}
}
@@ -99,7 +99,12 @@ public class GLInfoUtils {
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 @@ public class GLInfoUtils {
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");
}
}
}
@@ -32,11 +32,6 @@ import net.kdt.pojavlaunch.plugins.FFmpegPlugin;
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() {}
@@ -240,7 +235,7 @@ public class JREUtils {
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);
@@ -257,7 +252,7 @@ public class JREUtils {
}
}
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");
}
@@ -518,7 +513,7 @@ public class JREUtils {
}
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);