Skip to content

Commit

Permalink
Implement accurate shader multiply option
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBRDeveloper committed Oct 24, 2024
1 parent 8cf0fbe commit 28c5b56
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/jni_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern "C" {
AlberFunction(void, functionName) (JNIEnv* env, jobject obj, type value) { emulator->getConfig().settingName = value; }

MAKE_SETTING(setShaderJitEnabled, jboolean, shaderJitEnabled)
MAKE_SETTING(setAccurateShaderMulEnable, jboolean, accurateShaderMul)

#undef MAKE_SETTING

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class AlberDriver {
public static native byte[] GetSmdh();

public static native void setShaderJitEnabled(boolean enable);
public static native void setAccurateShaderMulEnable(boolean enable);

public static int openDocument(String path, String mode) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void changeOverlayVisibility(boolean visible) {
@Override
protected void onResume() {
super.onResume();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
InputHandler.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S

setItemClick("performanceMonitor", pref -> GlobalConfig.set(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("shaderJit", pref -> GlobalConfig.set(GlobalConfig.KEY_SHADER_JIT, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("accurateShaderMul", pref -> GlobalConfig.set(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("loggerService", pref -> {
boolean checked = ((SwitchPreferenceCompat) pref).isChecked();
Context ctx = PandroidApplication.getAppContext();
Expand All @@ -46,5 +47,6 @@ private void refresh() {
((SwitchPreferenceCompat) findPreference("performanceMonitor")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY));
((SwitchPreferenceCompat) findPreference("loggerService")).setChecked(GlobalConfig.get(GlobalConfig.KEY_LOGGER_SERVICE));
((SwitchPreferenceCompat) findPreference("shaderJit")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
((SwitchPreferenceCompat) findPreference("accurateShaderMul")).setChecked(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ScreenEditorPreference extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
layout = new LinearLayout(container.getContext());
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_FULLSCREEN|View.SYSTEM_UI_FLAG_IMMERSIVE);
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN|View.SYSTEM_UI_FLAG_IMMERSIVE);
return layout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class GlobalConfig {
public static DataModel data;

public static final Key<Boolean> KEY_SHADER_JIT = new Key<>("emu.shader_jit", true);
public static final Key<Boolean> KEY_ACCURATE_SHADER_MULTIPLY = new Key<>("emu.accurate_shader_mul", false);
public static final Key<Boolean> KEY_PICTURE_IN_PICTURE = new Key<>("app.behavior.pictureInPicture", false);
public static final Key<Boolean> KEY_SHOW_PERFORMANCE_OVERLAY = new Key<>("dev.performanceOverlay", false);
public static final Key<Boolean> KEY_LOGGER_SERVICE = new Key<>("dev.loggerService", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) {

AlberDriver.Initialize();
AlberDriver.setShaderJitEnabled(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
AlberDriver.setAccurateShaderMulEnable(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY));

// If loading the ROM failed, display an error message and early exit
if (!AlberDriver.LoadRom(romPath)) {
Expand Down
2 changes: 2 additions & 0 deletions src/pandroid/app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,6 @@
<string name="behavior">Comportamento</string>
<string name="invalid_game">Jogo invalido</string>
<string name="tools">Ferramentas</string>
<string name="pref_accurate_shader_title">Multiplicação precisa de shader</string>
<string name="pref_accurate_shader_summary">Usar calculos mais precisos para shaders</string>
</resources>
2 changes: 2 additions & 0 deletions src/pandroid/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@
<string name="region_taiwan">Taiwan</string>
<string name="behavior">Behavior</string>
<string name="invalid_game">Invalid game</string>
<string name="pref_accurate_shader_title">Accurate shader multiplication</string>
<string name="pref_accurate_shader_summary">Use better precision on shaders</string>
</resources>
6 changes: 6 additions & 0 deletions src/pandroid/app/src/main/res/xml/advanced_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
app:summary="@string/pref_shader_jit_summary"
app:iconSpaceReserved="false"/>

<SwitchPreferenceCompat
app:key="accurateShaderMul"
app:title="@string/pref_accurate_shader_title"
app:summary="@string/pref_accurate_shader_summary"
app:iconSpaceReserved="false"/>

</PreferenceCategory>
</PreferenceScreen>

0 comments on commit 28c5b56

Please sign in to comment.