From 4769d716fccc6a17ac321f46a6002465ef3491d5 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 20 Feb 2023 14:55:33 -0800 Subject: [PATCH] android: frontend: settings: Add graphics debugging. --- .../ui/SettingsFragmentPresenter.java | 2 ++ .../features/settings/utils/SettingsFile.java | 1 + src/android/app/src/main/jni/native.cpp | 19 +++++++++++++------ .../app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java index f924a167d..49447e606 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java @@ -162,6 +162,7 @@ public final class SettingsFragmentPresenter { Setting rendererAspectRation = rendererSection.getSetting(SettingsFile.KEY_RENDERER_ASPECT_RATIO); Setting rendererForceMaxClocks = rendererSection.getSetting(SettingsFile.KEY_RENDERER_FORCE_MAX_CLOCK); Setting rendererAsynchronousShaders = rendererSection.getSetting(SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS); + Setting rendererDebug = rendererSection.getSetting(SettingsFile.KEY_RENDERER_DEBUG); sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_BACKEND, Settings.SECTION_RENDERER, R.string.renderer_api, 0, R.array.rendererApiNames, R.array.rendererApiValues, 1, rendererBackend)); sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_ACCURACY, Settings.SECTION_RENDERER, R.string.renderer_accuracy, 0, R.array.rendererAccuracyNames, R.array.rendererAccuracyValues, 1, rendererAccuracy)); @@ -169,6 +170,7 @@ public final class SettingsFragmentPresenter { sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_ASPECT_RATIO, Settings.SECTION_RENDERER, R.string.renderer_aspect_ratio, 0, R.array.rendererAspectRatioNames, R.array.rendererAspectRatioValues, 0, rendererAspectRation)); sl.add(new CheckBoxSetting(SettingsFile.KEY_RENDERER_FORCE_MAX_CLOCK, Settings.SECTION_RENDERER, R.string.renderer_force_max_clock, R.string.renderer_force_max_clock_description, true, rendererForceMaxClocks)); sl.add(new CheckBoxSetting(SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS, Settings.SECTION_RENDERER, R.string.renderer_asynchronous_shaders, R.string.renderer_asynchronous_shaders_description, false, rendererAsynchronousShaders)); + sl.add(new CheckBoxSetting(SettingsFile.KEY_RENDERER_DEBUG, Settings.SECTION_RENDERER, R.string.renderer_debug, R.string.renderer_debug_description, false, rendererDebug)); } private void addAudioSettings(ArrayList sl) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java index 12bc03ffa..2b3d257a3 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java @@ -49,6 +49,7 @@ public final class SettingsFile { public static final String KEY_RENDERER_ASYNCHRONOUS_SHADERS = "use_asynchronous_shaders"; public static final String KEY_RENDERER_FORCE_MAX_CLOCK = "force_max_clock"; public static final String KEY_RENDERER_USE_SPEED_LIMIT = "use_speed_limit"; + public static final String KEY_RENDERER_DEBUG = "debug"; public static final String KEY_RENDERER_SPEED_LIMIT = "speed_limit"; // Audio public static final String KEY_AUDIO_VOLUME = "volume"; diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 505ae1176..3cfbec87c 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -77,20 +77,27 @@ public: const std::string& custom_driver_name, const std::string& file_redirect_dir) { void* handle{}; + const char* file_redirect_dir_{}; + int featureFlags{}; + + // Enable driver file redirection when renderer debugging is enabled. + if (Settings::values.renderer_debug && file_redirect_dir.size()) { + featureFlags |= ADRENOTOOLS_DRIVER_FILE_REDIRECT; + file_redirect_dir_ = file_redirect_dir.c_str(); + } // Try to load a custom driver. if (custom_driver_name.size()) { handle = adrenotools_open_libvulkan( - RTLD_NOW, ADRENOTOOLS_DRIVER_CUSTOM | ADRENOTOOLS_DRIVER_FILE_REDIRECT, nullptr, - hook_lib_dir.c_str(), custom_driver_dir.c_str(), custom_driver_name.c_str(), - file_redirect_dir.c_str(), nullptr); + RTLD_NOW, featureFlags | ADRENOTOOLS_DRIVER_CUSTOM, nullptr, hook_lib_dir.c_str(), + custom_driver_dir.c_str(), custom_driver_name.c_str(), file_redirect_dir_, nullptr); } // Try to load the system driver. if (!handle) { - handle = adrenotools_open_libvulkan(RTLD_NOW, ADRENOTOOLS_DRIVER_FILE_REDIRECT, nullptr, - hook_lib_dir.c_str(), nullptr, nullptr, - file_redirect_dir.c_str(), nullptr); + handle = + adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(), + nullptr, nullptr, file_redirect_dir_, nullptr); } m_vulkan_library = std::make_shared(handle); diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index bdaaa7650..c5e6a4e27 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -33,6 +33,8 @@ Forces the GPU to run at the maximum possible clocks (thermal constraints will still be applied). Use asynchronous shaders Compiles shaders asynchronously, which will reduce stutter but may introduce glitches. + Enable graphics debugging + When checked, the graphics API enters a slower debugging mode. Volume