From a47f01065349fbb8347138bf051409c84042d547 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Mon, 13 Feb 2023 17:50:49 +0000 Subject: [PATCH] Add an option to allow CPU writes when fast readback is used --- app/src/main/cpp/skyline/common/android_settings.h | 1 + app/src/main/cpp/skyline/common/settings.h | 1 + app/src/main/cpp/skyline/gpu/buffer.cpp | 2 +- app/src/main/java/emu/skyline/utils/NativeSettings.kt | 1 + app/src/main/java/emu/skyline/utils/PreferenceSettings.kt | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/preferences.xml | 7 +++++++ 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/common/android_settings.h b/app/src/main/cpp/skyline/common/android_settings.h index 470c4615..ec7318ec 100644 --- a/app/src/main/cpp/skyline/common/android_settings.h +++ b/app/src/main/cpp/skyline/common/android_settings.h @@ -46,6 +46,7 @@ namespace skyline { forceMaxGpuClocks = ktSettings.GetBool("forceMaxGpuClocks"); disableShaderCache = ktSettings.GetBool("disableShaderCache"); enableFastGpuReadbackHack = ktSettings.GetBool("enableFastGpuReadbackHack"); + enableFastReadbackWrites = ktSettings.GetBool("enableFastReadbackWrites"); disableSubgroupShuffle = ktSettings.GetBool("disableSubgroupShuffle"); isAudioOutputDisabled = ktSettings.GetBool("isAudioOutputDisabled"); validationLayer = ktSettings.GetBool("validationLayer"); diff --git a/app/src/main/cpp/skyline/common/settings.h b/app/src/main/cpp/skyline/common/settings.h index cbad8199..65273b26 100644 --- a/app/src/main/cpp/skyline/common/settings.h +++ b/app/src/main/cpp/skyline/common/settings.h @@ -80,6 +80,7 @@ namespace skyline { // Hacks Setting enableFastGpuReadbackHack; //!< If the CPU texture readback skipping hack should be used + Setting enableFastReadbackWrites; //!< If buffers should be treated as CPU dirty when written with the readback hack Setting disableSubgroupShuffle; //!< If shader subgroup suffle operations should be ignored // Audio diff --git a/app/src/main/cpp/skyline/gpu/buffer.cpp b/app/src/main/cpp/skyline/gpu/buffer.cpp index bcaa5c88..a392a55e 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer.cpp @@ -98,7 +98,7 @@ namespace skyline::gpu { // As opposed to skipping readback as we do for textures, with buffers we can still perform the readback but just without syncinc the GPU // While the read data may be invalid it's still better than nothing and works in most cases memcpy(buffer->mirror.data(), buffer->backing->data(), buffer->mirror.size()); - buffer->dirtyState = DirtyState::Clean; + buffer->dirtyState = *buffer->gpu.state.settings->enableFastReadbackWrites ? DirtyState::CpuDirty : DirtyState::Clean; return true; } diff --git a/app/src/main/java/emu/skyline/utils/NativeSettings.kt b/app/src/main/java/emu/skyline/utils/NativeSettings.kt index beaabc7d..9faa96e3 100644 --- a/app/src/main/java/emu/skyline/utils/NativeSettings.kt +++ b/app/src/main/java/emu/skyline/utils/NativeSettings.kt @@ -34,6 +34,7 @@ class NativeSettings(context : Context, pref : PreferenceSettings) { // Hacks var enableFastGpuReadbackHack : Boolean = pref.enableFastGpuReadbackHack + var enableFastReadbackWrites : Boolean = pref.enableFastReadbackWrites var disableSubgroupShuffle : Boolean = pref.disableSubgroupShuffle // Audio diff --git a/app/src/main/java/emu/skyline/utils/PreferenceSettings.kt b/app/src/main/java/emu/skyline/utils/PreferenceSettings.kt index 69ff74d8..46d53e79 100644 --- a/app/src/main/java/emu/skyline/utils/PreferenceSettings.kt +++ b/app/src/main/java/emu/skyline/utils/PreferenceSettings.kt @@ -49,6 +49,7 @@ class PreferenceSettings @Inject constructor(@ApplicationContext private val con // Hacks var enableFastGpuReadbackHack by sharedPreferences(context, false) + var enableFastReadbackWrites by sharedPreferences(context, false) var disableSubgroupShuffle by sharedPreferences(context, false) // Audio diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50f6f484..0c47b240 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -96,6 +96,9 @@ Enable fast GPU readback Fast GPU readback is enabled (Will break some games but others will have higher performance) Fast GPU readback is disabled (Ensures highest accuracy) + Enable fast readback writes + Fast readback writes are enabled + Fast readback writes are disabled Disable GPU subgroup shuffle Shader subgroup shuffle operations are disabled, may cause severe graphical issues Shader subgroup shuffle operations are enabled, ensures maximum accuracy diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index ed72de01..79f05eab 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -186,6 +186,13 @@ android:summaryOn="@string/enable_fast_gpu_readback_enabled" app:key="enable_fast_gpu_readback_hack" app:title="@string/enable_fast_gpu_readback" /> +