mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
Feat[surface]: allow force vsync for alternate surface rendering
This commit is contained in:
parent
64d271a8af
commit
1ecbb6bd25
@ -60,6 +60,7 @@ public class LauncherPreferences {
|
||||
public static boolean PREF_GYRO_INVERT_X = false;
|
||||
|
||||
public static boolean PREF_GYRO_INVERT_Y = false;
|
||||
public static boolean PREF_FORCE_VSYNC = false;
|
||||
|
||||
|
||||
public static void loadPreferences(Context ctx) {
|
||||
@ -99,6 +100,7 @@ public class LauncherPreferences {
|
||||
PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16);
|
||||
PREF_GYRO_INVERT_X = DEFAULT_PREF.getBoolean("gyroInvertX", false);
|
||||
PREF_GYRO_INVERT_Y = DEFAULT_PREF.getBoolean("gyroInvertY", false);
|
||||
PREF_FORCE_VSYNC = DEFAULT_PREF.getBoolean("force_vsync", false);
|
||||
|
||||
/*
|
||||
if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) {
|
||||
|
@ -2,14 +2,17 @@ package net.kdt.pojavlaunch.prefs.screens;
|
||||
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.kdt.pojavlaunch.R;
|
||||
import net.kdt.pojavlaunch.prefs.CustomSeekBarPreference;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||
|
||||
/**
|
||||
* Fragment for any settings video related
|
||||
@ -34,5 +37,17 @@ public class LauncherPreferenceVideoFragment extends LauncherPreferenceFragment
|
||||
// Sustained performance is only available since Nougat
|
||||
SwitchPreference sustainedPerfSwitch = findPreference("sustainedPerformance");
|
||||
sustainedPerfSwitch.setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N);
|
||||
computeVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences p, String s) {
|
||||
super.onSharedPreferenceChanged(p, s);
|
||||
computeVisibility();
|
||||
}
|
||||
|
||||
private void computeVisibility(){
|
||||
SwitchPreferenceCompat preference = findPreference("force_vsync");
|
||||
preference.setVisible(LauncherPreferences.PREF_USE_ALTERNATE_SURFACE);
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +203,8 @@ public class JREUtils {
|
||||
// The OPEN GL version is changed according
|
||||
envMap.put("LIBGL_ES", (String) ExtraCore.getValue(ExtraConstants.OPEN_GL_VERSION));
|
||||
|
||||
envMap.put("FORCE_VSYNC", String.valueOf(LauncherPreferences.PREF_FORCE_VSYNC));
|
||||
|
||||
envMap.put("MESA_GLSL_CACHE_DIR", activity.getCacheDir().getAbsolutePath());
|
||||
if (LOCAL_RENDERER != null) {
|
||||
envMap.put("MESA_GL_VERSION_OVERRIDE", LOCAL_RENDERER.equals("opengles3_virgl")?"4.3":"4.6");
|
||||
|
@ -165,5 +165,7 @@ void gl_setup_window() {
|
||||
}
|
||||
|
||||
void gl_swap_interval(int swapInterval) {
|
||||
if(pojav_environ->force_vsync) swapInterval = 1;
|
||||
|
||||
eglSwapInterval_p(g_EglDisplay, swapInterval);
|
||||
}
|
||||
|
@ -732,6 +732,11 @@ int pojavInit() {
|
||||
savedHeight = ANativeWindow_getHeight(pojav_environ->pojavWindow);
|
||||
ANativeWindow_setBuffersGeometry(pojav_environ->pojavWindow,savedWidth,savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM);
|
||||
|
||||
// Only affects GL4ES as of now
|
||||
const char *forceVsync = getenv("FORCE_VSYNC");
|
||||
if (strcmp(forceVsync, "true") == 0)
|
||||
pojav_environ->force_vsync = true;
|
||||
|
||||
// NOTE: Override for now.
|
||||
const char *renderer = getenv("POJAV_RENDERER");
|
||||
if (strncmp("opengles3_virgl", renderer, 15) == 0) {
|
||||
|
@ -11,6 +11,7 @@ struct pojav_environ_s {
|
||||
struct ANativeWindow* pojavWindow;
|
||||
render_window_t* mainWindowBundle;
|
||||
int config_renderer;
|
||||
bool force_vsync;
|
||||
};
|
||||
extern struct pojav_environ_s *pojav_environ;
|
||||
|
||||
|
@ -284,6 +284,8 @@
|
||||
<string name="preference_experimental_description">Use things there with consideration, no support.</string>
|
||||
<string name="preference_sustained_performance_title">Enable sustained performance mode</string>
|
||||
<string name="preference_sustained_performance_description">Limit thermal throttling by limiting peak performance</string>
|
||||
<string name="preference_force_vsync_title">Force enable vsync</string>
|
||||
<string name="preference_force_vsync_description">Limit thermal throttling by limiting peak performance</string>
|
||||
<string name="preference_force_english_title">Force language to english</string>
|
||||
<string name="preference_force_english_description">Allows you to see original strings, as intended by developers. Requires a restart</string>
|
||||
<string name="preference_edit_controls_title">Edit custom controls</string>
|
||||
|
@ -45,5 +45,12 @@
|
||||
android:summary="@string/mcl_setting_subtitle_use_surface_view"
|
||||
android:title="@string/mcl_setting_title_use_surface_view"
|
||||
/>
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="force_vsync"
|
||||
android:summary="@string/preference_force_vsync_description"
|
||||
android:title="@string/preference_force_vsync_title"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user