From 63311bdeaf8202a8e87fc3d6860ef86e50a26e2a Mon Sep 17 00:00:00 2001 From: The412Banner Date: Sun, 29 Nov 2026 22:27:38 -0500 Subject: [PATCH] feat(upscale): in-game upscaler settings, launch wiring, live controls and HUD row Per-game choice (FSR/XeSS, DLSS or native FSR 4 mode, engine, sharpness, NPU sync, DLSS signature fix) in the game environment; droiddeck-game-env turns it into the bridge DLL overrides and folder, the layer switch, the control and status files, the NVIDIA or AMD identity for DLSS / native mode and the NGX registry entries (DLSS mode only). Bionic: paths converted in proton, names kept in launch.sh, the APK layer's manifest on VK_ADD_IMPLICIT_LAYER_PATH. UpscaleComponent fetches AMD's FSR 4 data, Intel's XeSS runtime and Qualcomm's QNN files from Winlator-NeuralScale at a pinned commit (SHA-256 checked), stages the upscale add-on pack and writes the live control file. --- .../com/droiddeck/launcher/core/AddonPack.kt | 3 + .../droiddeck/launcher/core/GameUpscaler.kt | 132 +++++++ .../launcher/hud/DroidDeckHudConfig.kt | 2 +- .../launcher/hud/DroidDeckHudHost.kt | 3 + .../launcher/hud/DroidDeckHudModels.kt | 3 +- .../launcher/hud/DroidDeckHudView.kt | 5 + .../launcher/session/GameEnvironmentStore.kt | 7 + .../launcher/session/SessionFiles.kt | 7 +- .../launcher/session/SessionService.kt | 2 + .../launcher/session/UpscaleComponent.kt | 352 ++++++++++++++++++ .../launcher/ui/DroidDeckHudSettings.kt | 1 + .../droiddeck/launcher/ui/FrontEndSetup.kt | 93 +++++ .../droiddeck/launcher/ui/SessionOverlay.kt | 46 +++ app/src/main/res/values/strings.xml | 22 ++ .../launcher/core/GameUpscalerTest.kt | 59 +++ tools/bionic-runtime/tool/launch.sh | 6 +- tools/bionic-runtime/tool/proton | 15 + .../overlay/usr/local/bin/droiddeck-game-env | 150 ++++++++ tools/tests/test_game_environment.py | 61 +++ 19 files changed, 965 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt create mode 100644 app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt create mode 100644 app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt index d0e2f2b575..2008a88526 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt @@ -175,6 +175,9 @@ internal class AddonPack( val ROCKSTAR = AddonPack("rockstar", BuildConfig.PACK_ROCKSTAR_SHA256, BuildConfig.PACK_ROCKSTAR_SIZE, listOf("Launcher32.exe", "Launcher64.exe")) val DIRT = AddonPack("dirt", BuildConfig.PACK_DIRT_SHA256, BuildConfig.PACK_DIRT_SIZE, listOf("ws2_32.dll")) + /** The in-game upscaler's bridge DLLs (tools/upscale/bridges), staged by UpscaleComponent. */ + val UPSCALE = AddonPack("upscale", BuildConfig.PACK_UPSCALE_SHA256, BuildConfig.PACK_UPSCALE_SIZE, + listOf("bridges/x86_64-windows/libxess.dll", "bridges/x86_64-windows/nvngx.dll")) val EPIC = AddonPack("epic", BuildConfig.PACK_EPIC_SHA256, BuildConfig.PACK_EPIC_SIZE, listOf("EpicGamesLauncher.exe")) } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt b/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt new file mode 100644 index 0000000000..df310a77bc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt @@ -0,0 +1,132 @@ +package com.droiddeck.launcher.core + +/** + * The in-game upscaler (tools/upscale): bridge DLLs stand in for a game's own DLSS / FidelityFX / FSR 2/3 / + * XeSS DLLs and hand each frame to the VK_LAYER_DROIDDECK_upscale layer, which runs FSR 4 (GPU or Hexagon NPU), + * XeSS 3 DP4a or a basic temporal upscaler in its place. Ported from Winlator-NeuralScale + * (michaelisomer-cyber, GPL-3.0, a fork of StevenMXZ/Winlator-Ludashi). + * + * Per game it is a few entries of the game environment; droiddeck-game-env turns them into the DLL overrides, + * the bridge folder, the layer switch and the files the layer reads. + */ +object GameUpscaler { + const val MODE = "DROIDDECK_UPSCALE_MODE" + const val ENGINE = "DROIDDECK_UPSCALE_ENGINE" + const val SHARPNESS = "DROIDDECK_UPSCALE_SHARPNESS" + const val NPU_SYNC = "DROIDDECK_UPSCALE_NPU_SYNC" + const val SIGFIX = "DROIDDECK_UPSCALE_SIGFIX" + + val keys = listOf(MODE, ENGINE, SHARPNESS, NPU_SYNC, SIGFIX) + + /** Which of the game's upscalers are replaced, and what GPU the game is shown. */ + enum class Mode(val id: String) { + /** FidelityFX (FSR 4 API), FSR 2/3 and XeSS games; the real GPU is reported. */ + FSR_XESS("fsr"), + /** DLSS games: also nvngx + nvapi64, and the game sees an RTX 2060. */ + DLSS("dlss"), + /** Games whose FSR 4 path wants an RDNA 4 card: the game sees a Radeon RX 9070 XT, shader model 6.8. */ + NATIVE_FSR4("native"); + + companion object { + fun byId(id: String?): Mode? = entries.firstOrNull { it.id == id?.trim()?.lowercase() } + } + } + + /** What runs in the game's upscaler's place. Ids are the layer's backend names (fsr4_layer.c parse_backend_str). */ + enum class Engine(val id: String, val npu: Boolean) { + FSR4_LITE_GPU("fsr4_1_lite_gpu", false), + FSR4_FULL_GPU("fsr4_1_full_gpu", false), + XESS("xess3_gpu", false), + BASIC("fsr3_gpu", false), + FSR4_NPU("fsr4_0_npu", true), + FSR4_LITE_NPU("fsr4_1_lite_npu", true); + + companion object { + fun byId(id: String?): Engine? = entries.firstOrNull { it.id == id?.trim()?.lowercase() } + } + } + + val DEFAULT_ENGINE = Engine.FSR4_LITE_GPU + const val DEFAULT_SHARPNESS = 55 + val sharpnessSteps = listOf(0, 25, 40, 55, 70, 85, 100) + + data class Choice( + val mode: Mode, + val engine: Engine = DEFAULT_ENGINE, + val sharpness: Int = DEFAULT_SHARPNESS, + val npuSync: Boolean = false, + val signatureFix: Boolean = false, + ) + + fun choice(config: GameEnvironment.Config, scope: String): Choice? { + if (scope.isEmpty()) return null + val entries = config.games[scope].orEmpty() + val mode = Mode.byId(entries[MODE]) ?: return null + return Choice( + mode = mode, + engine = Engine.byId(entries[ENGINE]) ?: DEFAULT_ENGINE, + sharpness = entries[SHARPNESS]?.toIntOrNull()?.coerceIn(0, 100) ?: DEFAULT_SHARPNESS, + npuSync = entries[NPU_SYNC] == "1", + signatureFix = entries[SIGFIX] == "1", + ) + } + + fun entries(choice: Choice?): Map = if (choice == null) emptyMap() else buildMap { + put(MODE, choice.mode.id) + put(ENGINE, choice.engine.id) + put(SHARPNESS, choice.sharpness.coerceIn(0, 100).toString()) + if (choice.npuSync) put(NPU_SYNC, "1") + if (choice.signatureFix && choice.mode == Mode.DLSS) put(SIGFIX, "1") + } + + fun withChoice(config: GameEnvironment.Config, scope: String, choice: Choice?): GameEnvironment.Config { + require(scope.isNotEmpty() && GameEnvironment.validScope(scope)) + val kept = config.entries(scope).filterKeys { it !in keys } + return config.withEntries(scope, kept + entries(choice)) + } + + /** NPU engines on a device without a usable Hexagon NPU run the matching GPU engine instead. */ + fun effectiveEngine(engine: Engine, npuAvailable: Boolean): Engine = when { + !engine.npu || npuAvailable -> engine + engine == Engine.FSR4_NPU -> Engine.FSR4_FULL_GPU + else -> Engine.FSR4_LITE_GPU + } + + /** The control file the layer polls (fsr4_layer.c read_live_ctrl): backend, sharpness 0..1, NPU sync, on/off. */ + fun controlText(engine: Engine, sharpness: Int, npuSync: Boolean, enabled: Boolean): String = + "enabled=${if (enabled) 1 else 0}\nbackend=${engine.id}\nsharpness=" + + String.format(java.util.Locale.ROOT, "%.2f", sharpness.coerceIn(0, 100) / 100f) + + "\nnpu_sync=${if (npuSync) 1 else 0}\n" + + /** One status file the layer writes (fsr4_layer.c write_live_status): key=value lines. */ + data class Status( + val active: Boolean, + val npu: Boolean, + val backendTag: String, + val render: String, + val output: String, + val gpuMs: Float, + val npuMs: Float, + val reason: String, + val timestampMs: Long, + ) + + fun parseStatus(text: String): Status? { + val values = text.lineSequence().mapNotNull { line -> + val eq = line.indexOf('=') + if (eq <= 0) null else line.substring(0, eq).trim() to line.substring(eq + 1).trim() + }.toMap() + if (values["layer"] != "1") return null + return Status( + active = values["active"] == "1", + npu = values["npu"] == "1", + backendTag = values["backend_tag"].orEmpty().ifEmpty { values["backend"].orEmpty() }, + render = values["render"].orEmpty(), + output = values["output"].orEmpty(), + gpuMs = (values["gpu_us"]?.toLongOrNull() ?: 0L) / 1000f, + npuMs = (values["htp_us"]?.toLongOrNull() ?: 0L) / 1000f, + reason = values["reason"].orEmpty(), + timestampMs = values["ts_ms"]?.toLongOrNull() ?: 0L, + ) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt index fbd14aea93..3427acc31d 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt @@ -14,7 +14,7 @@ internal object DroidDeckHudConfig { "showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "1", "showLow001" to "1", "showEngine" to "1", "showRenderer" to "1", "showDisplay" to "1", "showHdr" to "1", "showNet" to "1", "showResolution" to "1", - "showProton" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "", + "showProton" to "1", "showUpscale" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "", "tempUnit" to "c", "tempBands" to "1", "tempAuto" to "1", "tempRedCpu" to "90", "tempRedGpu" to "90", "tempRedBat" to "48", ) diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt index 7a96f0b6ac..2cb4fe7291 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt @@ -287,6 +287,9 @@ class DroidDeckHudHost(context: Context) { proton = protonName(pid) ?: proton } hud.setWineVersion(proton) + hud.setUpscale(com.droiddeck.launcher.session.UpscaleComponent.status(context)?.takeIf { it.active }?.let { + it.backendTag + " " + String.format(java.util.Locale.ROOT, "%.1fms", if (it.npu) it.npuMs else it.gpuMs) + }) hud.setPresentedFps(presentedFps()) } diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt index 94bcb2920f..f3867ec69b 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt @@ -74,12 +74,13 @@ enum class DroidDeckHudSize(val token: String, val label: String) { FULL to listOf( "showFPS", "showFPSGraph", "showGpuModel", "showDisplay", "showHdr", "showGPULoad", "showGpuTemp", "showCPUUsage", "showTemp", "showVram", "showRAM", "showBattery", "showBatteryTemp", "showBatteryTime", - "showPower", "showLatency", "showAvg", "showLow1", "showLow01", "showLow001", + "showPower", "showLatency", "showAvg", "showLow1", "showLow01", "showLow001", "showUpscale", ), TILES to listOf( "showFPS", "showFPSGraph", "showLatency", "showGPULoad", "showGpuTemp", "showCPUUsage", "showTemp", "showVram", "showRAM", "showEngine", "showDisplay", "showHdr", "showAvg", "showLow1", "showLow01", "showLow001", "showGpuModel", "showBattery", "showBatteryTemp", "showBatteryTime", "showPower", + "showUpscale", ), PILL to listOf( "showFPS", "showFPSGraph", "showGpuModel", "showGPULoad", "showGpuTemp", "showCPUUsage", "showTemp", diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt index f58320bc8e..c5f39c65ae 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt @@ -114,6 +114,7 @@ class DroidDeckHudView(context: Context) : View(context) { private var gpuModel = "" private var gpuSpoofName = "" private var wineVersion = "" + private var upscaleText = "" private var graphicsWrapper = "" private var dxvkVersion = "" private var vkd3dVersion = "" @@ -277,6 +278,8 @@ class DroidDeckHudView(context: Context) : View(context) { fun setEngineLabel(s: String?) { if ((s ?: "") != engineLabel) { engineLabel = s ?: ""; post { rebuildAndInvalidate() } } } fun setGpuModel(s: String?) { if ((s ?: "") != gpuModel) { gpuModel = s ?: ""; post { rebuildAndInvalidate() } } } fun setWineVersion(s: String?) { if ((s ?: "") != wineVersion) { wineVersion = s ?: ""; post { rebuildAndInvalidate() } } } + /** The in-game upscaler's backend and its time per frame (empty: not running). */ + fun setUpscale(s: String?) { if ((s ?: "") != upscaleText) { upscaleText = s ?: ""; post { rebuildAndInvalidate() } } } fun setResolution(s: String?) { resolution = s ?: "" } @@ -772,6 +775,7 @@ class DroidDeckHudView(context: Context) : View(context) { "showHdr" -> "HDR" to colHdr "showResolution" -> "RES" to colDim "showProton" -> "PROTON" to colVram + "showUpscale" -> "UPSCALE" to colFps "showSession" -> "TIME" to colDim else -> key.removePrefix("show") to colDim } @@ -809,6 +813,7 @@ class DroidDeckHudView(context: Context) : View(context) { "showHdr" -> if (showHdrLine()) hdrValue(valuePx) else listOf(Span("off", colDim, valuePx)) "showResolution" -> listOf(Span(resolutionString(), colValue, valuePx)) "showProton" -> listOf(Span(wineVersion.ifBlank { "—" }, colVram, valuePx)) + "showUpscale" -> listOf(Span(upscaleText.ifBlank { "—" }, colValue, valuePx)) "showSession" -> listOf(Span(elapsedString(), colValue, valuePx)) else -> listOf(Span("—", colDim, valuePx)) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt index 708c1bcada..fa1cc45d7f 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt @@ -98,6 +98,13 @@ object GameEnvironmentStore { return config } + @Synchronized + fun setGameUpscaler(context: Context, scope: String, choice: com.droiddeck.launcher.core.GameUpscaler.Choice?): GameEnvironment.Config { + val config = com.droiddeck.launcher.core.GameUpscaler.withChoice(read(context), scope, choice) + save(context, config) + return config + } + @Synchronized fun setDefault(context: Context, scope: String, name: String, value: String): Boolean { val config = read(context) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index aa240b6ed0..ef43a53767 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -250,6 +250,11 @@ object SessionFiles { "usr/local/lib/droiddeck-gpuload/libVkLayer_droiddeck_gpuload.so" to "usr/local/lib/droiddeck-gpuload/libVkLayer_droiddeck_gpuload.so", "usr/local/lib/droiddeck-gpuload/VK_LAYER_DROIDDECK_gpu_load.json" to "usr/share/vulkan/implicit_layer.d/droiddeck_gpu_load.json", ) + // The in-game upscaler's layer for PRoot games (UpscaleComponent; off unless DROIDDECK_UPSCALE=1). + val upscaleLayer = listOf( + "usr/local/lib/droiddeck-upscale-layer/libVkLayer_droiddeck_upscale.so" to "usr/local/lib/droiddeck-upscale-layer/libVkLayer_droiddeck_upscale.so", + "usr/local/lib/droiddeck-upscale-layer/VK_LAYER_DROIDDECK_upscale.json" to "usr/share/vulkan/implicit_layer.d/droiddeck_upscale.json", + ) val fexPreloads = listOf("x86_64", "i386").flatMap { arch -> listOf("libddsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" } } + listOf("libvulkan-thunk.so", "libwebkitinput.so").map { "x86_64/$it" to "usr/local/lib/droiddeck-fex/x86_64/$it" } @@ -272,7 +277,7 @@ object SessionFiles { "usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst", "usr/local/share/licenses/dwarfs/LICENSE" to "usr/local/share/licenses/dwarfs/LICENSE", "usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE", - ) + mangoapp + xclipse.map { it to it } + maliCompat + msitools.map { it to it } + vr + gpuLoad + fexPreloads).filter { (asset, _) -> + ) + mangoapp + xclipse.map { it to it } + maliCompat + msitools.map { it to it } + vr + gpuLoad + upscaleLayer + fexPreloads).filter { (asset, _) -> val dir = asset.substringBeforeLast('/') runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 56c4f27f57..c88db261af 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -1084,6 +1084,8 @@ class SessionService : Service() { if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1") guest.add("MESA_DISK_CACHE_DATABASE=1") guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this))) + guest.addAll(UpscaleComponent.guestEnv(this)) + UpscaleComponent.prepare(this) guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216") if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0")) SessionPaths.current()?.let { SessionArtifacts.markRpcs3Log(it, LinuxRuntime.rootDir(this)) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt new file mode 100644 index 0000000000..184977ccea --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt @@ -0,0 +1,352 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import android.os.Environment +import android.util.Log +import com.droiddeck.launcher.core.AddonPack +import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.GameEnvironment +import com.droiddeck.launcher.core.GameUpscaler +import com.droiddeck.launcher.gpu.SocNames +import com.droiddeck.launcher.runtime.LinuxRuntime +import java.io.File +import java.security.MessageDigest +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow + +/** + * The in-game upscaler's files on the device (see [GameUpscaler]): + * - the bridge DLLs, built from tools/upscale/bridges, come in the "upscale" add-on pack; + * - the Vulkan layer is in the APK (bionic games) and in the Linux runtime (PRoot games); + * - the parts with no source to build from (AMD's FSR 4 SPIR-V and weights, Intel's XeSS 3 runtime, Qualcomm's + * QNN libraries for the Hexagon NPU) are fetched from Winlator-NeuralScale at a pinned commit and checked against + * the SHA-256 listed here, or copied from a folder of the same files under Download. + * Everything lands under [GUEST_ROOT] in the rootfs, where both PRoot and bionic games read it. + */ +object UpscaleComponent { + private const val TAG = "UpscaleComponent" + const val UPSTREAM = "michaelisomer-cyber/Winlator-NeuralScale" + const val UPSTREAM_COMMIT = "a0ab6b0f770e1a6786b4e68def46b4edb8baafd0" + const val GUEST_ROOT = "/usr/local/lib/droiddeck-upscale" + const val GUEST_RUN = "/run/droiddeck-hud/upscale" + private const val LOCAL_COPY = "droiddeck-upscale" + private const val LAYER_LIBRARY = "libVkLayer_droiddeck_upscale.so" + private const val BRIDGES_STAMP = ".pack" + + enum class Group { CORE, XESS, NPU } + + data class DataFile(val group: Group, val relative: String, val upstreamPath: String, val sha256: String, val size: Long) { + val url get() = "https://raw.githubusercontent.com/$UPSTREAM/$UPSTREAM_COMMIT/$upstreamPath" + } + + val FILES = listOf( + DataFile(Group.CORE, "fsr4/fsr3_accumulate.spv", "app/src/main/assets/fsr4/fsr3_accumulate.spv", "06334f81fee9afff829085612bbedee4fae06a1d7cca62c0ce62fc4c49e11c85", 12168L), + DataFile(Group.CORE, "fsr4/fsr3_prepare.spv", "app/src/main/assets/fsr4/fsr3_prepare.spv", "a9bf26007c37daf775036558cf00af70e69d12c0b2e0d0c12b0372b085149c78", 8308L), + DataFile(Group.CORE, "fsr4/fsr3_rcas.spv", "app/src/main/assets/fsr4/fsr3_rcas.spv", "80d54b9a3b29626fee7c57ff24f5e5e0bb288c40375462bcd4f3a1e26f30aac3", 6312L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/initializers.bin", "app/src/main/assets/fsr4/fsr411_full/performance/initializers.bin", "a54e552ff69a3f7199861417f7ae461d1f67f636ab532c6ec9d8ea5d2963735a", 131072L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-00.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-00.spv", "d6a01100a56327713d2f7c1a768e41f8a31f2cadce5f37b7dac81630722ff5a2", 33116L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-01.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-01.spv", "759396dc2eccd731bebac13e8818568c8cc410150d24ed4cc01aa8b5ea873fbb", 58172L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-02.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-02.spv", "bdabc7c28f18c31ac8574856a386a268ae4d866f68a65e72b59bf3bad2235132", 3208L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-03.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-03.spv", "bcb4d1d01e33114c68bb13059577c280bb05b5a3af7218fdbc38e99883e0632d", 108840L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-04.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-04.spv", "d85b605d066d89178994ba835b6c3b267ed771de530117a5b9e6103d49e866e7", 3244L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-05.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-05.spv", "e44f0ccd272e4a85ad38894a38db7adae019d18660b166e6c28e82b328d7cc84", 109048L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-06.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-06.spv", "df469b6481234bf7b964a7c0ecf8a5829d84d1bc34fdb7c72e87014f82e31326", 3208L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-07.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-07.spv", "a873b766b2b8923aeb7d325a61cbea251cbac6450e708a23a7714c553ce577ff", 132572L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-08.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-08.spv", "c4aba5b9cd11100308aa2e3d8a4d39e66713c46c35edbe6496552764459a2228", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-09.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-09.spv", "d757fd28efbd09259f82918de5d3765784933d5b26eea56babe45fd6fefc5cfa", 190032L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-10.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-10.spv", "295873b3ecbd9db40cc4c50ecf15a72964d5846b96642d2e4743a9333382b557", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-11.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-11.spv", "73e05c6727408d5b1f472112c5d68060e9db9aaf918e892055e6619d5f0e4edc", 190032L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-12.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-12.spv", "007315c42072370919ac393b63a04a0ac025a802f927b490a6749bd6034c15fd", 3596L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-13.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-13.spv", "020929f63d8a70f90bd628a92c50b4049db89155d5e062bf03eb1e8cb8ee7c60", 497604L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-14.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-14.spv", "f26dc72bbe9ccc70e2cc2dc1f4b2a868baf3c2e470b4e76994f98c50674ec3d8", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-15.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-15.spv", "9487c52cec7e259f4cb212335e84db43c52902b4e3243afcd34305b95ad1b83b", 79128L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-16.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-16.spv", "55c48a8b7627343d996f7818ee6055e143d3b956b8f65911d6b6c337bd8f72ca", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-17.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-17.spv", "810636645f52d5b8c019206deb046e954af730fc13edaa6a00ebf66e686c3ac0", 79128L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-18.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-18.spv", "a3d130ad8fc6438766f3cdeb7e062d03291a25f6a5e439f71b905795cfc856ec", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-19.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-19.spv", "e1b576f7e8cedc46615a90f5d2026a43a525a2e43cfc66b62def8e700f55688a", 84476L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-20.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-20.spv", "70c2b7b4e55d665591b2dca3efddb6e99e6d393020722cec635fb8df3bd81bf1", 3596L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-21.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-21.spv", "bb1798794d6c8b0ad3760059bf36e2c396594226c0835202040a4a515a8beb01", 189952L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-22.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-22.spv", "b0545fc4c1886fa0a6252029eb6e3a2f999974bc0bc89539c8d6005c184d8a6f", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-23.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-23.spv", "e9aee05cec78f0659fa570bfc0f495a51d00d2bc80c4e99cde4106a3df51c35e", 61308L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-24.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-24.spv", "1e93b681a9264afc07f0ab41086474b3afaa2ff8d37b5b75c9ceae005e21e558", 3260L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-25.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-25.spv", "6292dd68a4da9370c7dabb3b192fe6958b1a12daffd92b7fa80ed6fe231e1e5d", 109064L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-26.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-26.spv", "abc2426ff739d25cba4d271cad08ec9f25056ae197a9727b7b7e72467ba49d28", 3224L), + DataFile(Group.CORE, "fsr4/fsr411_full/performance/pass-27.spv", "app/src/main/assets/fsr4/fsr411_full/performance/pass-27.spv", "fa5fc1de4625915c25a637b091f26f32c398f4985a14392a48505cfac111aaea", 125196L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/initializers.bin", "app/src/main/assets/fsr4/fsr411_full/quality/initializers.bin", "a54e552ff69a3f7199861417f7ae461d1f67f636ab532c6ec9d8ea5d2963735a", 131072L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-00.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-00.spv", "d6a01100a56327713d2f7c1a768e41f8a31f2cadce5f37b7dac81630722ff5a2", 33116L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-01.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-01.spv", "759396dc2eccd731bebac13e8818568c8cc410150d24ed4cc01aa8b5ea873fbb", 58172L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-02.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-02.spv", "bdabc7c28f18c31ac8574856a386a268ae4d866f68a65e72b59bf3bad2235132", 3208L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-03.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-03.spv", "bcb4d1d01e33114c68bb13059577c280bb05b5a3af7218fdbc38e99883e0632d", 108840L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-04.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-04.spv", "d85b605d066d89178994ba835b6c3b267ed771de530117a5b9e6103d49e866e7", 3244L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-05.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-05.spv", "e44f0ccd272e4a85ad38894a38db7adae019d18660b166e6c28e82b328d7cc84", 109048L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-06.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-06.spv", "df469b6481234bf7b964a7c0ecf8a5829d84d1bc34fdb7c72e87014f82e31326", 3208L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-07.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-07.spv", "a873b766b2b8923aeb7d325a61cbea251cbac6450e708a23a7714c553ce577ff", 132572L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-08.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-08.spv", "c4aba5b9cd11100308aa2e3d8a4d39e66713c46c35edbe6496552764459a2228", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-09.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-09.spv", "d757fd28efbd09259f82918de5d3765784933d5b26eea56babe45fd6fefc5cfa", 190032L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-10.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-10.spv", "295873b3ecbd9db40cc4c50ecf15a72964d5846b96642d2e4743a9333382b557", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-11.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-11.spv", "73e05c6727408d5b1f472112c5d68060e9db9aaf918e892055e6619d5f0e4edc", 190032L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-12.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-12.spv", "007315c42072370919ac393b63a04a0ac025a802f927b490a6749bd6034c15fd", 3596L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-13.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-13.spv", "020929f63d8a70f90bd628a92c50b4049db89155d5e062bf03eb1e8cb8ee7c60", 497604L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-14.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-14.spv", "f26dc72bbe9ccc70e2cc2dc1f4b2a868baf3c2e470b4e76994f98c50674ec3d8", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-15.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-15.spv", "9487c52cec7e259f4cb212335e84db43c52902b4e3243afcd34305b95ad1b83b", 79128L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-16.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-16.spv", "55c48a8b7627343d996f7818ee6055e143d3b956b8f65911d6b6c337bd8f72ca", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-17.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-17.spv", "810636645f52d5b8c019206deb046e954af730fc13edaa6a00ebf66e686c3ac0", 79128L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-18.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-18.spv", "a3d130ad8fc6438766f3cdeb7e062d03291a25f6a5e439f71b905795cfc856ec", 4268L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-19.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-19.spv", "e1b576f7e8cedc46615a90f5d2026a43a525a2e43cfc66b62def8e700f55688a", 84476L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-20.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-20.spv", "70c2b7b4e55d665591b2dca3efddb6e99e6d393020722cec635fb8df3bd81bf1", 3596L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-21.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-21.spv", "bb1798794d6c8b0ad3760059bf36e2c396594226c0835202040a4a515a8beb01", 189952L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-22.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-22.spv", "b0545fc4c1886fa0a6252029eb6e3a2f999974bc0bc89539c8d6005c184d8a6f", 3580L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-23.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-23.spv", "e9aee05cec78f0659fa570bfc0f495a51d00d2bc80c4e99cde4106a3df51c35e", 61308L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-24.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-24.spv", "1e93b681a9264afc07f0ab41086474b3afaa2ff8d37b5b75c9ceae005e21e558", 3260L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-25.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-25.spv", "6292dd68a4da9370c7dabb3b192fe6958b1a12daffd92b7fa80ed6fe231e1e5d", 109064L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-26.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-26.spv", "abc2426ff739d25cba4d271cad08ec9f25056ae197a9727b7b7e72467ba49d28", 3224L), + DataFile(Group.CORE, "fsr4/fsr411_full/quality/pass-27.spv", "app/src/main/assets/fsr4/fsr411_full/quality/pass-27.spv", "fa5fc1de4625915c25a637b091f26f32c398f4985a14392a48505cfac111aaea", 125196L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0000.spv", "app/src/main/assets/fsr4/fsr412_lite/0000.spv", "2ec08c00ba47d5812078073c68622101158762b2e885ae965afee39596243840", 97808L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0001.spv", "app/src/main/assets/fsr4/fsr412_lite/0001.spv", "71c2571ccc5ad447a0d41da49472aaf1c5a2b19dcfe3f871dca53b8c42cc53ed", 3456L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0002.spv", "app/src/main/assets/fsr4/fsr412_lite/0002.spv", "5b07b9b4ea0597811e069d684929ce0f74a0ab111665c83f5fdda97ef68b1a34", 120964L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0003.spv", "app/src/main/assets/fsr4/fsr412_lite/0003.spv", "6dd4ceef841a8aedf2e3222e23ef1b7a83788ff5eed3a4baf02cce2d9bd334c3", 3492L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0004.spv", "app/src/main/assets/fsr4/fsr412_lite/0004.spv", "61c63223e337584361af1ab8f28cc1bd3a9b1713608985dcb41d9255c734d1b1", 3928L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0005.spv", "app/src/main/assets/fsr4/fsr412_lite/0005.spv", "2cb371b67efc07da60d6c30a9fc4239d4d194306dbf4fb7bd90f82039968a8b7", 201880L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0006.spv", "app/src/main/assets/fsr4/fsr412_lite/0006.spv", "96aab40505a5fa1992cd02d9cd32b6ee799858e896b6a357a2cce09fd58f7c23", 3892L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0007.spv", "app/src/main/assets/fsr4/fsr412_lite/0007.spv", "20ec164ffc3f6269bc4f50e53825503188e157715989ae1841a8f485999d0a30", 279304L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0008.spv", "app/src/main/assets/fsr4/fsr412_lite/0008.spv", "a2c57206f1f8b79366b42497de16533a3e679d43bed97eee4fbaf695ce104b7f", 3508L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0009.spv", "app/src/main/assets/fsr4/fsr412_lite/0009.spv", "35453061b2637f1e4837d2dd1026b1b262ceabbda6911411829d716169220c60", 104052L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0010.spv", "app/src/main/assets/fsr4/fsr412_lite/0010.spv", "a60c0492e22ae608ba9b7e9d479db03ad198a8d9523edb7b65cc0eaef5829a29", 28988L), + DataFile(Group.CORE, "fsr4/fsr412_lite/0013.spv", "app/src/main/assets/fsr4/fsr412_lite/0013.spv", "f34905ea5d71368dd3e85be79424a94f68dfdf866e38d33bc9954701ebd0e64d", 57232L), + DataFile(Group.CORE, "fsr4/fsr412_lite/fsr412_lite_i8.wpack", "app/src/main/assets/fsr4/fsr412_lite/fsr412_lite_i8.wpack", "7de72e7bdcade967a4a64d81e4d625384ee8e0575c355dca432dc72db23d7adc", 27104L), + DataFile(Group.CORE, "fsr4/fsr412_lite/lite_npu_pack.spv", "app/src/main/assets/fsr4/fsr412_lite/lite_npu_pack.spv", "1b369e959ded731f4cfff895c9e7e5d045469742fb3a6db6a6fd3f039a076404", 1412L), + DataFile(Group.CORE, "fsr4/fsr412_lite/lite_npu_unpack.spv", "app/src/main/assets/fsr4/fsr412_lite/lite_npu_unpack.spv", "e2de130c7024667b57b0cbf12c3a62f6860b5954c0e03add6d44c5794034982a", 1712L), + DataFile(Group.CORE, "fsr4/fsr412_lite/weights.bin", "app/src/main/assets/fsr4/fsr412_lite/weights.bin", "4b9898da719dc2dca5dc45fd71dec5f80bdb9886a580fe3038af59efe637d55e", 27392L), + DataFile(Group.CORE, "fsr4/fsr4_builtin_post_a.spv", "app/src/main/assets/fsr4/fsr4_builtin_post_a.spv", "aca1e6ae4e9a303b8ce8c6b066266ea6ef64857bd5f6a97ac9ab818809fb5e24", 7764L), + DataFile(Group.CORE, "fsr4/fsr4_builtin_post_b.spv", "app/src/main/assets/fsr4/fsr4_builtin_post_b.spv", "898cc07bc0b175778264ec2dc1ef8df5b3a1ed463befaaf08e5f5686235d5963", 9076L), + DataFile(Group.CORE, "fsr4/fsr4_builtin_pre.spv", "app/src/main/assets/fsr4/fsr4_builtin_pre.spv", "314273b20839952b0829b8aa51bb3d5a23a5c11d620c239f99dd2f9c41b30458", 45340L), + DataFile(Group.CORE, "fsr4/fsr4_v07_i8.wpack", "app/src/main/assets/fsr4/fsr4_v07_i8.wpack", "a34d8b9fb5bb7dc8ff0fabf143f8cdc989ee412b3c80561107844ec768d90a58", 169624L), + DataFile(Group.NPU, "fsr4/adsp/libQnnHtpV79Skel.so", "app/src/main/assets/fsr4/adsp/libQnnHtpV79Skel.so", "974583f0cdc3d42de7a0633c9b987b160ad033a4cd53be30f9b5480b7e5a3213", 11702104L), + DataFile(Group.NPU, "fsr4/adsp/libQnnHtpV81Skel.so", "app/src/main/assets/fsr4/adsp/libQnnHtpV81Skel.so", "a0b9750d900a0afbba240e3506ba63ba91ec0e7f1b3a44de9afbb6818a665a32", 12606648L), + DataFile(Group.NPU, "jni/libQnnHtp.so", "app/src/main/jniLibs/arm64-v8a/libQnnHtp.so", "6e6da5284060ca4369bb6fd3c6f2b661a9cebabb2cf4cf695cd77f558082265f", 3760136L), + DataFile(Group.NPU, "jni/libQnnHtpNetRunExtensions.so", "app/src/main/jniLibs/arm64-v8a/libQnnHtpNetRunExtensions.so", "9776e906cff859504e9e5fd5f9cbb0ec592d9ae6be312ef0650cb95eb8e3aef6", 1383928L), + DataFile(Group.NPU, "jni/libQnnHtpPrepare.so", "app/src/main/jniLibs/arm64-v8a/libQnnHtpPrepare.so", "cd31f94ae79ad402312e75262297d1e1073f85927d95f7905357a10b1d32a263", 87913152L), + DataFile(Group.NPU, "jni/libQnnHtpV79Stub.so", "app/src/main/jniLibs/arm64-v8a/libQnnHtpV79Stub.so", "b3b4cca02e1f2cb5778ef9f18850814358d62a0b90123b25bb2806731a6af8b3", 754480L), + DataFile(Group.NPU, "jni/libQnnHtpV81Stub.so", "app/src/main/jniLibs/arm64-v8a/libQnnHtpV81Stub.so", "16188365d86ef09a9067e8e04b7fa1c604729d1870219b1bbf04ee904e6c3ffa", 777848L), + DataFile(Group.NPU, "jni/libQnnSystem.so", "app/src/main/jniLibs/arm64-v8a/libQnnSystem.so", "4cd077547a939b131c4733391545d64bdc4f9d0c86de78793335ddd18348789e", 4052904L), + DataFile(Group.XESS, "xess/wl_xess_official.dll", "app/src/main/assets/fsr4_bridge/wl_xess_official.dll", "251659dd84a3e84de67c886a4186e01f3eca49b00641906fe38bb6b807e5d5b7", 77795704L), + ) + + sealed interface State { + data object Missing : State + data class Downloading(val progress: Float) : State + data object Ready : State + data class Failed(val message: String) : State + } + + private val mutableState = MutableStateFlow(State.Missing) + val state: StateFlow = mutableState.asStateFlow() + private val lock = Any() + @Volatile private var busy = false + + fun root(context: Context) = File(LinuxRuntime.rootDir(context), GUEST_ROOT.removePrefix("/")) + fun dataDir(context: Context) = File(root(context), "data") + fun bridgesDir(context: Context) = File(root(context), "bridges") + fun runDir(context: Context) = File(LinuxRuntime.rootDir(context), GUEST_RUN.removePrefix("/")) + + /** The Hexagon NPU generation the bundled QNN files serve, or null: v79 on the Snapdragon 8 Elite, v81 on the 8 Elite Gen 5. */ + fun npuArch(model: String = SocNames.model()): String? { + val soc = SocNames.normalizedModel(model) + val arch = when { + soc.startsWith("SM8750") -> "v79" + soc.startsWith("SM8850") || soc.startsWith("SM8845") -> "v81" + else -> null + } ?: return null + val fastrpc = listOf("/dev/fastrpc-cdsp", "/dev/fastrpc-cdsp-secure", "/dev/adsprpc-smd").any { File(it).exists() } + return arch.takeIf { fastrpc } + } + + fun groups(engine: GameUpscaler.Engine, npu: Boolean = npuArch() != null): Set = buildSet { + add(Group.CORE) + if (engine == GameUpscaler.Engine.XESS) add(Group.XESS) + if (engine.npu && npu) add(Group.NPU) + } + + fun ready(context: Context, groups: Set): Boolean = + FILES.filter { it.group in groups }.all { f -> File(dataDir(context), f.relative).let { it.isFile && it.length() == f.size } } + + fun bridgesReady(context: Context): Boolean = File(bridgesDir(context), "x86_64-windows/libxess.dll").isFile + + /** Fetches what [groups] still lack (and the bridge pack) in the background. */ + fun ensure(context: Context, groups: Set, onDone: (Boolean) -> Unit = {}) { + val app = context.applicationContext + ensureBridges(app) + if (ready(app, groups)) { + mutableState.value = State.Ready + onDone(true) + return + } + synchronized(lock) { + if (busy) return + busy = true + } + Thread({ + val ok = try { + download(app, groups) + } catch (e: Exception) { + Log.w(TAG, "upscaler files not fetched", e) + mutableState.value = State.Failed(e.message ?: e.javaClass.simpleName) + false + } finally { + synchronized(lock) { busy = false } + } + onDone(ok) + }, "upscale-files").start() + } + + private fun download(context: Context, groups: Set): Boolean { + val wanted = FILES.filter { it.group in groups } + val missing = wanted.filter { f -> File(dataDir(context), f.relative).let { !it.isFile || it.length() != f.size } } + val total = missing.sumOf { it.size }.coerceAtLeast(1L) + var done = 0L + mutableState.value = State.Downloading(0f) + for (f in missing) { + val target = File(dataDir(context), f.relative) + target.parentFile?.mkdirs() + val part = File(target.path + ".part") + val ok = copyLocal(f, part) || Downloader.downloadFile(f.url, part, true, f.sha256) { p -> + mutableState.value = State.Downloading(((done + p * f.size) / total).coerceIn(0f, 1f)) + } + if (!ok || !part.renameTo(target)) { + part.delete() + val reason = Downloader.lastFailure() ?: "could not fetch ${f.relative}" + mutableState.value = State.Failed(reason) + Log.w(TAG, "upscaler file ${f.relative} not fetched: $reason") + return false + } + if (f.group == Group.NPU) { + target.setReadable(true, false) + target.setExecutable(true, false) + } + done += f.size + mutableState.value = State.Downloading((done.toFloat() / total).coerceIn(0f, 1f)) + } + mutableState.value = State.Ready + Log.i(TAG, "upscaler files ready (${wanted.size} files, groups $groups)") + return true + } + + /** A copy of the same file under Download/droiddeck-upscale (same relative path), used when its SHA-256 matches. */ + private fun copyLocal(f: DataFile, part: File): Boolean = runCatching { + @Suppress("DEPRECATION") + val local = File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY/${f.relative}") + if (!local.isFile || local.length() != f.size || sha256(local) != f.sha256) return false + local.inputStream().use { input -> part.outputStream().use { output -> input.copyTo(output, 1 shl 20) } } + sha256(part) == f.sha256 + }.getOrDefault(false) + + private fun sha256(file: File): String { + val digest = MessageDigest.getInstance("SHA-256") + file.inputStream().use { input -> + val buffer = ByteArray(1 shl 20) + while (true) { + val n = input.read(buffer) + if (n < 0) break + digest.update(buffer, 0, n) + } + } + return digest.digest().joinToString("") { "%02x".format(it) } + } + + fun ensureBridges(context: Context) { + val app = context.applicationContext + if (!AddonPack.UPSCALE.available) return + AddonPack.UPSCALE.ensure(app) { stageBridges(it) } + } + + /** Copies the add-on pack's bridges/ tree into the rootfs (once per pack version). */ + @Synchronized + fun stageBridges(context: Context): Boolean { + val pack = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context) ?: return bridgesReady(context) + val source = File(pack, "bridges") + if (!source.isDirectory) return false + val target = bridgesDir(context) + val stamp = File(target, BRIDGES_STAMP) + if (bridgesReady(context) && runCatching { stamp.readText() }.getOrNull() == pack.name) return true + var ok = true + source.walkTopDown().filter { it.isFile }.forEach { file -> + val out = File(target, file.relativeTo(source).path) + out.parentFile?.mkdirs() + val staged = File(out.path + ".staged") + ok = runCatching { + file.inputStream().use { input -> staged.outputStream().use { output -> input.copyTo(output) } } + staged.renameTo(out) + }.getOrDefault(false) && ok + staged.delete() + } + if (ok) runCatching { stamp.writeText(pack.name) } + Log.i(TAG, "upscaler bridges staged from pack ${pack.name}: $ok") + return ok + } + + /** The bionic layer's manifest (the layer itself is the APK's native library). */ + fun bionicLayerDir(context: Context): File { + val dir = File(context.filesDir, "upscale/layer") + val library = File(context.applicationInfo.nativeLibraryDir, LAYER_LIBRARY) + val manifest = """{ + "file_format_version": "1.0.0", + "layer": { + "name": "VK_LAYER_DROIDDECK_upscale", + "type": "GLOBAL", + "library_path": "${library.absolutePath}", + "api_version": "1.3.275", + "implementation_version": "1", + "description": "DroidDeck in-game upscaler (FSR 4, XeSS 3, Hexagon NPU)", + "enable_environment": { "DROIDDECK_UPSCALE": "1" }, + "disable_environment": { "DROIDDECK_UPSCALE_DISABLE": "1" } + } +} +""" + runCatching { + dir.mkdirs() + val file = File(dir, "VK_LAYER_DROIDDECK_upscale.json") + if (!file.isFile || file.readText() != manifest) file.writeText(manifest) + }.onFailure { Log.w(TAG, "could not write the upscaler layer manifest", it) } + return dir + } + + /** Session-wide guest variables: whether NPU engines can run here, and the bionic layer's manifest folder. */ + fun guestEnv(context: Context): List { + runCatching { runDir(context).mkdirs() } + return listOf( + "DROIDDECK_UPSCALE_NPU=" + (if (npuArch() != null) "1" else "0"), + "DROIDDECK_UPSCALE_LAYER=" + bionicLayerDir(context).absolutePath, + ) + } + + /** Fetches what the games set to use the upscaler need, at session start. */ + fun prepare(context: Context) { + val config = runCatching { GameEnvironmentStore.read(context) }.getOrNull() ?: return + val choices = config.games.keys.mapNotNull { GameUpscaler.choice(config, it) } + if (choices.isEmpty()) return + val npu = npuArch() != null + ensure(context, choices.flatMap { groups(it.engine, npu) }.toSet()) + } + + /** Live switch while a game runs: the layer polls this file (fsr4_layer.c read_live_ctrl). */ + fun writeControl(context: Context, engine: GameUpscaler.Engine, sharpness: Int, npuSync: Boolean, enabled: Boolean = true) { + runCatching { + val dir = runDir(context).apply { mkdirs() } + val ctrl = File(dir, "ctrl") + val staged = File(dir, "ctrl.tmp") + val effective = GameUpscaler.effectiveEngine(engine, npuArch() != null) + staged.writeText(GameUpscaler.controlText(effective, sharpness, npuSync, enabled)) + staged.renameTo(ctrl) + }.onFailure { Log.w(TAG, "could not write the upscaler control file", it) } + } + + /** What the layer reports, if it wrote in the last few seconds. */ + fun status(context: Context, nowMs: Long = System.currentTimeMillis()): GameUpscaler.Status? { + val file = File(runDir(context), "status") + if (!file.isFile || nowMs - file.lastModified() > 5000) return null + return runCatching { GameUpscaler.parseStatus(file.readText()) }.getOrNull() + } + + fun anyGame(config: GameEnvironment.Config): Boolean = config.games.keys.any { GameUpscaler.choice(config, it) != null } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt index d14086ffc5..0028a55972 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt @@ -210,6 +210,7 @@ private val METRICS = listOf( HudMetric("showNet", R.string.hud_metric_network), HudMetric("showResolution", R.string.hud_metric_resolution), HudMetric("showProton", R.string.hud_metric_proton), + HudMetric("showUpscale", R.string.hud_metric_upscale), HudMetric("showSession", R.string.hud_metric_session), HudMetric("showClock", R.string.hud_metric_clock), ) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index d804a4fa56..1954c933b3 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -983,6 +983,38 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron save { com.droiddeck.launcher.session.GameEnvironmentStore.setGameResolution(it, scope, choice) } } var editResolution by remember(scope) { mutableStateOf(false) } + val upKey = "game-settings-upscale" + val upEngineKey = "game-settings-upscale-engine" + val upSharpKey = "game-settings-upscale-sharp" + val upscale = current?.let { com.droiddeck.launcher.core.GameUpscaler.choice(it, scope) } + val npuHere = remember { com.droiddeck.launcher.session.UpscaleComponent.npuArch() != null } + val upFiles by com.droiddeck.launcher.session.UpscaleComponent.state.collectAsState() + val modeLabels = mapOf( + com.droiddeck.launcher.core.GameUpscaler.Mode.FSR_XESS to stringResource(R.string.game_upscaler_mode_fsr), + com.droiddeck.launcher.core.GameUpscaler.Mode.DLSS to stringResource(R.string.game_upscaler_mode_dlss), + com.droiddeck.launcher.core.GameUpscaler.Mode.NATIVE_FSR4 to stringResource(R.string.game_upscaler_mode_native), + ) + val engineLabels = mapOf( + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_LITE_GPU to stringResource(R.string.game_upscaler_engine_fsr4_lite), + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_FULL_GPU to stringResource(R.string.game_upscaler_engine_fsr4_full), + com.droiddeck.launcher.core.GameUpscaler.Engine.XESS to stringResource(R.string.game_upscaler_engine_xess), + com.droiddeck.launcher.core.GameUpscaler.Engine.BASIC to stringResource(R.string.game_upscaler_engine_basic), + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_NPU to stringResource(R.string.game_upscaler_engine_fsr4_npu), + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_LITE_NPU to stringResource(R.string.game_upscaler_engine_fsr4_lite_npu), + ) + val upOff = stringResource(R.string.game_upscaler_off) + val filesLabel = when (val f = upFiles) { + is com.droiddeck.launcher.session.UpscaleComponent.State.Downloading -> stringResource(R.string.game_upscaler_files_downloading, (f.progress * 100).toInt()) + is com.droiddeck.launcher.session.UpscaleComponent.State.Failed -> stringResource(R.string.game_upscaler_files_failed, f.message) + else -> if (upscale != null && com.droiddeck.launcher.session.UpscaleComponent.ready(appContext, + com.droiddeck.launcher.session.UpscaleComponent.groups(upscale.engine, npuHere))) + stringResource(R.string.game_upscaler_files_ready) else stringResource(R.string.game_upscaler_files_missing) + } + fun pickUpscale(choice: com.droiddeck.launcher.core.GameUpscaler.Choice?) { + save { com.droiddeck.launcher.session.GameEnvironmentStore.setGameUpscaler(it, scope, choice) } + if (choice != null) com.droiddeck.launcher.session.UpscaleComponent.ensure(appContext, + com.droiddeck.launcher.session.UpscaleComponent.groups(choice.engine, npuHere)) + } AnchoredMenu(host.open == key, onDismiss = { if (host.open == key) host.open = null }, title = stringResource(R.string.game_settings_menu_title, game.name)) { first -> MenuItem(stringResource(R.string.game_no_steam_title), checked = noSteam, enabled = ready, detail = stringResource(R.string.game_no_steam_detail), focusRequester = first) { @@ -1014,6 +1046,37 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron }, trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) }, ) { host.open = syncKey } + MenuItem( + stringResource(R.string.game_upscaler_title), checked = false, enabled = ready, + detail = upscale?.let { modeLabels[it.mode] } ?: upOff, + trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) }, + ) { host.open = upKey } + if (upscale != null) { + MenuItem( + stringResource(R.string.game_upscaler_engine), checked = false, enabled = ready, + detail = engineLabels[com.droiddeck.launcher.core.GameUpscaler.effectiveEngine(upscale.engine, npuHere)], + trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) }, + ) { host.open = upEngineKey } + MenuItem( + stringResource(R.string.game_upscaler_sharpness), checked = false, enabled = ready, + detail = stringResource(R.string.game_upscaler_sharpness_value, upscale.sharpness), + trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) }, + ) { host.open = upSharpKey } + if (upscale.mode == com.droiddeck.launcher.core.GameUpscaler.Mode.DLSS) { + MenuItem(stringResource(R.string.game_upscaler_sigfix), checked = upscale.signatureFix, enabled = ready) { + pickUpscale(upscale.copy(signatureFix = !upscale.signatureFix)) + } + } + if (upscale.engine.npu && npuHere) { + MenuItem(stringResource(R.string.game_upscaler_npu_sync), checked = upscale.npuSync, enabled = ready) { + pickUpscale(upscale.copy(npuSync = !upscale.npuSync)) + } + } + MenuItem(stringResource(R.string.game_upscaler_files), checked = false, enabled = ready, detail = filesLabel) { + com.droiddeck.launcher.session.UpscaleComponent.ensure(appContext, + com.droiddeck.launcher.session.UpscaleComponent.groups(upscale.engine, npuHere)) + } + } } MenuItem(stringResource(R.string.game_settings_default), checked = false, enabled = ready, detail = stringResource(R.string.game_settings_default_detail)) { @@ -1030,6 +1093,36 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron } } } + AnchoredMenu(host.open == upKey, onDismiss = { if (host.open == upKey) host.open = null }, title = stringResource(R.string.game_upscaler_title)) { first -> + MenuItem(upOff, checked = upscale == null, enabled = ready, focusRequester = first) { + host.open = key + pickUpscale(null) + } + com.droiddeck.launcher.core.GameUpscaler.Mode.entries.forEach { mode -> + MenuItem(modeLabels.getValue(mode), checked = upscale?.mode == mode, enabled = ready) { + host.open = key + pickUpscale((upscale ?: com.droiddeck.launcher.core.GameUpscaler.Choice(mode)).copy(mode = mode)) + } + } + } + AnchoredMenu(host.open == upEngineKey, onDismiss = { if (host.open == upEngineKey) host.open = null }, title = stringResource(R.string.game_upscaler_engine)) { first -> + com.droiddeck.launcher.core.GameUpscaler.Engine.entries.filter { !it.npu || npuHere }.forEachIndexed { index, engine -> + MenuItem(engineLabels.getValue(engine), checked = upscale?.engine == engine, enabled = ready && upscale != null, + focusRequester = if (index == 0) first else null) { + host.open = key + upscale?.let { pickUpscale(it.copy(engine = engine)) } + } + } + } + AnchoredMenu(host.open == upSharpKey, onDismiss = { if (host.open == upSharpKey) host.open = null }, title = stringResource(R.string.game_upscaler_sharpness)) { first -> + com.droiddeck.launcher.core.GameUpscaler.sharpnessSteps.forEachIndexed { index, value -> + MenuItem(stringResource(R.string.game_upscaler_sharpness_value, value), checked = upscale?.sharpness == value, + enabled = ready && upscale != null, focusRequester = if (index == 0) first else null) { + host.open = key + upscale?.let { pickUpscale(it.copy(sharpness = value)) } + } + } + } AnchoredMenu(host.open == resKey, onDismiss = { if (host.open == resKey) host.open = null }, title = stringResource(R.string.game_res_title)) { first -> MenuItem(matchScreen, checked = resolution == null, enabled = ready, focusRequester = first) { pickResolution(null) } com.droiddeck.launcher.core.GameResolution.scales.forEach { scale -> diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index ae00595556..de4e460b30 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -937,6 +937,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont Text(stringResource(R.string.fex_next_launch), fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)) TextureFilteringGroup(host, a) { key -> focus.track(page, key) } + if (a.steam || a.direct) DrawerUpscalerGroup(host, a) { key -> focus.track(page, key) } if (a.steam || a.direct) SettingsGroup(stringResource(R.string.game_settings_title)) { DrawerFexPresetRow(host, a, focus.track(page, "fex")) DrawerNoSteamRow(host, a, focus.track(page, "no-steam")) @@ -1652,6 +1653,51 @@ private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (Stri } } +/** The selected game's in-game upscaler: engine and sharpness switch live (the layer polls its control file). */ +@Composable +private fun DrawerUpscalerGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val appId = a.selectedGameProfileId ?: return + val context = LocalContext.current.applicationContext + val scope = appId.toString() + var choice by remember(scope) { + mutableStateOf(runCatching { com.droiddeck.launcher.core.GameUpscaler.choice(com.droiddeck.launcher.session.GameEnvironmentStore.read(context), scope) }.getOrNull()) + } + val current = choice ?: return + val npuHere = remember { com.droiddeck.launcher.session.UpscaleComponent.npuArch() != null } + var status by remember { mutableStateOf(null) } + LaunchedEffect(scope) { + while (true) { + status = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { com.droiddeck.launcher.session.UpscaleComponent.status(context) } + delay(1000) + } + } + val engines = com.droiddeck.launcher.core.GameUpscaler.Engine.entries.filter { !it.npu || npuHere }.map { engine -> + engine to stringResource(when (engine) { + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_LITE_GPU -> R.string.game_upscaler_engine_fsr4_lite + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_FULL_GPU -> R.string.game_upscaler_engine_fsr4_full + com.droiddeck.launcher.core.GameUpscaler.Engine.XESS -> R.string.game_upscaler_engine_xess + com.droiddeck.launcher.core.GameUpscaler.Engine.BASIC -> R.string.game_upscaler_engine_basic + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_NPU -> R.string.game_upscaler_engine_fsr4_npu + com.droiddeck.launcher.core.GameUpscaler.Engine.FSR4_LITE_NPU -> R.string.game_upscaler_engine_fsr4_lite_npu + }) + } + val sharpness = com.droiddeck.launcher.core.GameUpscaler.sharpnessSteps.map { it to stringResource(R.string.game_upscaler_sharpness_value, it) } + fun applyChoice(next: com.droiddeck.launcher.core.GameUpscaler.Choice) { + choice = next + Thread({ + com.droiddeck.launcher.session.UpscaleComponent.writeControl(context, next.engine, next.sharpness, next.npuSync) + runCatching { com.droiddeck.launcher.session.GameEnvironmentStore.setGameUpscaler(context, scope, next) } + }, "upscale-live").start() + } + SettingsGroup(stringResource(R.string.game_upscaler_title)) { + ChoiceRow(host, "upscale-engine", stringResource(R.string.game_upscaler_engine), + status?.let { "${it.backendTag} · ${it.render} → ${it.output} · " + String.format(java.util.Locale.ROOT, "%.1f ms", if (it.npu) it.npuMs else it.gpuMs) }, + engines, current.engine, chipModifier = track("upscale-engine")) { engine -> applyChoice(current.copy(engine = engine)) } + ChoiceRow(host, "upscale-sharpness", stringResource(R.string.game_upscaler_sharpness), null, + sharpness, current.sharpness, chipModifier = track("upscale-sharpness")) { value -> applyChoice(current.copy(sharpness = value)) } + } +} + private fun signed(v: Int) = if (v > 0) "+$v" else "$v" @Composable diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3627ce6603..913dcab14c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -552,6 +552,27 @@ Starts with Steam Starts without Steam Game resolution + In-game upscaler + Off + FSR and XeSS games + DLSS games + Native FSR 4 + Upscaler + FSR 4 Lite + FSR 4 + XeSS 3 + Basic temporal + FSR 4 on NPU + FSR 4 Lite on NPU + Sharpness + %1$d%% + DLSS signature fix + NPU sync + Upscaler files + Ready + Not downloaded + Downloading %1$d%% + Failed: %1$s Settings %1$s Settings Default @@ -768,6 +789,7 @@ Network Resolution Proton version + In-game upscaler Session time Clock Temperatures diff --git a/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt b/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt new file mode 100644 index 0000000000..b4f4fe253a --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt @@ -0,0 +1,59 @@ +package com.droiddeck.launcher.core + +import org.junit.Assert.* +import org.junit.Test + +class GameUpscalerTest { + @Test fun aChoiceRoundTripsThroughTheGameEnvironment() { + val choice = GameUpscaler.Choice(GameUpscaler.Mode.DLSS, GameUpscaler.Engine.XESS, 70, npuSync = true, signatureFix = true) + val config = GameUpscaler.withChoice(GameEnvironment.Config(), "42", choice) + assertEquals(choice, GameUpscaler.choice(config, "42")) + assertNull(GameUpscaler.choice(config, "43")) + } + + @Test fun offRemovesOnlyTheUpscalerEntries() { + val start = GameEnvironment.Config().withEntries("42", mapOf("FEX_MULTIBLOCK" to "0")) + val on = GameUpscaler.withChoice(start, "42", GameUpscaler.Choice(GameUpscaler.Mode.FSR_XESS)) + val off = GameUpscaler.withChoice(on, "42", null) + assertEquals(mapOf("FEX_MULTIBLOCK" to "0"), off.games["42"]) + } + + @Test fun theSignatureFixIsOnlyKeptForDlss() { + val fsr = GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.FSR_XESS, signatureFix = true)) + assertFalse(fsr.containsKey(GameUpscaler.SIGFIX)) + val dlss = GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.DLSS, signatureFix = true)) + assertEquals("1", dlss[GameUpscaler.SIGFIX]) + } + + @Test fun unknownValuesFallBackToDefaults() { + val config = GameEnvironment.Config().withEntries("7", mapOf( + GameUpscaler.MODE to "fsr", GameUpscaler.ENGINE to "bogus", GameUpscaler.SHARPNESS to "250")) + val choice = GameUpscaler.choice(config, "7")!! + assertEquals(GameUpscaler.DEFAULT_ENGINE, choice.engine) + assertEquals(100, choice.sharpness) + assertNull(GameUpscaler.choice(GameEnvironment.Config().withEntries("7", mapOf(GameUpscaler.MODE to "x")), "7")) + } + + @Test fun npuEnginesRunOnTheGpuWithoutAnNpu() { + assertEquals(GameUpscaler.Engine.FSR4_FULL_GPU, GameUpscaler.effectiveEngine(GameUpscaler.Engine.FSR4_NPU, false)) + assertEquals(GameUpscaler.Engine.FSR4_LITE_GPU, GameUpscaler.effectiveEngine(GameUpscaler.Engine.FSR4_LITE_NPU, false)) + assertEquals(GameUpscaler.Engine.FSR4_NPU, GameUpscaler.effectiveEngine(GameUpscaler.Engine.FSR4_NPU, true)) + assertEquals(GameUpscaler.Engine.XESS, GameUpscaler.effectiveEngine(GameUpscaler.Engine.XESS, false)) + } + + @Test fun theControlFileUsesTheLayersKeys() { + assertEquals("enabled=1\nbackend=fsr4_1_lite_gpu\nsharpness=0.55\nnpu_sync=0\n", + GameUpscaler.controlText(GameUpscaler.Engine.FSR4_LITE_GPU, 55, npuSync = false, enabled = true)) + } + + @Test fun theLayersStatusFileParses() { + val status = GameUpscaler.parseStatus( + "layer=1\nengine=fsr4\nbackend=fsr4_1_lite_gpu\nbackend_tag=FSR4.1-Lite-GPU\nactive=1\nnpu=0\n" + + "render=960x540\noutput=1920x1080\ngpu_us=3250\nhtp_us=0\nreason=ok\nts_ms=99\n")!! + assertTrue(status.active) + assertEquals("FSR4.1-Lite-GPU", status.backendTag) + assertEquals(3.25f, status.gpuMs, 0.001f) + assertEquals("1920x1080", status.output) + assertNull(GameUpscaler.parseStatus("active=1\n")) + } +} diff --git a/tools/bionic-runtime/tool/launch.sh b/tools/bionic-runtime/tool/launch.sh index 8e52a857da..0a9c298f0b 100644 --- a/tools/bionic-runtime/tool/launch.sh +++ b/tools/bionic-runtime/tool/launch.sh @@ -51,6 +51,7 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do DXVK_LOG_PATH|VKD3D_LOG_FILE|MESA_LOG_FILE) ;; DROIDDECK_GPU_LOAD|DROIDDECK_GPU_LOAD_DIR|DROIDDECK_VRAM_CAP|DROIDDECK_VRAM_CAP_MB|DROIDDECK_DISPLAY_DRIVER) ;; DROIDDECK_GUEST_ROOT) ;; + DROIDDECK_UPSCALE|DROIDDECK_UPSCALE_*|WINEDLLPATH|ADSP_LIBRARY_PATH|PROTON_ENABLE_NVAPI|DXVK_ENABLE_NVAPI|WINE_HIDE_NVIDIA_GPU) ;; VKD3D_FEATURE_LEVEL|VKD3D_SHADER_MODEL|vk_x11_strict_image_count) ;; *) unset "$v" 2>/dev/null ;; esac @@ -85,7 +86,10 @@ echo "driver $DRVDIR" RTD=$APP/.wayland-rt export VK_ICD_FILENAMES=$PACK/adapter/icd.json ADRENOTOOLS_DRIVER_PATH=$DRVDIR/ ADRENOTOOLS_HOOKS_PATH=$PACK/lib export ADRENOTOOLS_DRIVER_NAME=$(drvlib "$DRVDIR") -export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-gamescope-0} +# The in-game upscaler's layer is in the APK; DroidDeck writes its manifest to DROIDDECK_UPSCALE_LAYER. +UPSCALE_LAYER="" +[ -n "${DROIDDECK_UPSCALE:-}" ] && [ -n "${DROIDDECK_UPSCALE_LAYER:-}" ] && [ -d "$DROIDDECK_UPSCALE_LAYER" ] && UPSCALE_LAYER=":$DROIDDECK_UPSCALE_LAYER" +export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer$UPSCALE_LAYER ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-gamescope-0} export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=1 [ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter diff --git a/tools/bionic-runtime/tool/proton b/tools/bionic-runtime/tool/proton index a054905b2f..9e6478fb10 100644 --- a/tools/bionic-runtime/tool/proton +++ b/tools/bionic-runtime/tool/proton @@ -103,6 +103,21 @@ case "$verb" in done # The HUD's GPU-load folder is a guest path; the bionic game writes to it by its Android path. [ -n "${DROIDDECK_GPU_LOAD_DIR:-}" ] && { DROIDDECK_GPU_LOAD_DIR=$(real "$DROIDDECK_GPU_LOAD_DIR"); export DROIDDECK_GPU_LOAD_DIR; } + # The in-game upscaler's folders and files (droiddeck-game-env sets them as guest paths); the bridge folder on + # WINEDLLPATH and the NPU skeleton folder at the head of ADSP_LIBRARY_PATH as well. + for v in DROIDDECK_UPSCALE_DIR DROIDDECK_UPSCALE_CTRL_FILE DROIDDECK_UPSCALE_STATUS_FILE DROIDDECK_UPSCALE_NATIVELIB_DIR; do + [ -n "${!v:-}" ] && { printf -v "$v" '%s' "$(real "${!v}")"; export "${v?}"; } + done + if [ -n "${DROIDDECK_UPSCALE:-}" ] && [ -n "${WINEDLLPATH:-}" ]; then + out="" + IFS=: read -r -a parts <<< "$WINEDLLPATH" + for part in "${parts[@]}"; do [ -n "$part" ] && out="${out:+$out:}$(real "$part")"; done + WINEDLLPATH=$out; export WINEDLLPATH + fi + if [ -n "${DROIDDECK_UPSCALE:-}" ] && [ -n "${ADSP_LIBRARY_PATH:-}" ]; then + head=${ADSP_LIBRARY_PATH%%;*} + ADSP_LIBRARY_PATH="$(real "$head")${ADSP_LIBRARY_PATH#"$head"}"; export ADSP_LIBRARY_PATH + fi # So are the graphics log locations Detailed graphics logs or game debugging set for this launch. for v in DXVK_LOG_PATH VKD3D_LOG_FILE MESA_LOG_FILE; do [ -n "${!v:-}" ] && { printf -v "$v" '%s' "$(real "${!v}")"; export "${v?}"; } diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 1e02ad4be2..b758b6667c 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -1080,6 +1080,153 @@ def directaudio_settings(env): return env +# The in-game upscaler (tools/upscale, ported from Winlator-NeuralScale, GPL-3.0): bridge DLLs stand in for the +# game's DLSS / FidelityFX / FSR 2/3 / XeSS DLLs and hand each frame to VK_LAYER_DROIDDECK_upscale. The app keeps +# the game's choice in DROIDDECK_UPSCALE_MODE (fsr, dlss, native) and DROIDDECK_UPSCALE_ENGINE/_SHARPNESS/_NPU_SYNC. +UPSCALE_ROOT = "/usr/local/lib/droiddeck-upscale" +UPSCALE_RUN = "/run/droiddeck-hud/upscale" +UPSCALE_MODES = ("fsr", "dlss", "native") +UPSCALE_ENGINES = ("fsr4_1_lite_gpu", "fsr4_1_full_gpu", "xess3_gpu", "fsr3_gpu", "fsr4_0_npu", "fsr4_1_lite_npu") +UPSCALE_NPU_FALLBACK = {"fsr4_0_npu": "fsr4_1_full_gpu", "fsr4_1_lite_npu": "fsr4_1_lite_gpu"} +UPSCALE_FSR_DLLS = ("libxess", "ffx_fsr3upscaler_x64", "ffx_fsr2_api_x64", "amd_fidelityfx_vk", "amd_fidelityfx_dx12", + "amd_fidelityfx_upscaler_vk", "amd_fidelityfx_upscaler_dx12", "amd_fidelityfx_loader_dx12") +UPSCALE_DLSS_DLLS = ("nvngx", "_nvngx", "nvngx_dlss", "nvapi64") +UPSCALE_XESS = "wl_xess_official.dll" +NV_SIGNATURE_OVERRIDE = "{41FCC608-8496-4DEF-B43E-7D9BD675A6FF}" +# CurrentControlSet is a link to ControlSet001 in Wine's registry, so only ControlSet001 is written. +NGX_KEYS = ("Software\\NVIDIA Corporation\\Global\\NGXCore", + "System\\ControlSet001\\Services\\nvlddmkm\\NGXCore") +NGX_SIGNATURE_KEYS = ("Software\\NVIDIA Corporation\\Global", + "System\\ControlSet001\\Services\\nvlddmkm") + + +def upscale_registry(prefix): + """NVIDIA's NGX core location and its signature override, which DLSS games read to load nvngx.dll (DLSS mode only).""" + path = os.path.join(prefix, "pfx", "system.reg") + if not os.path.isfile(path): + return False + with open(path, encoding="utf-8", errors="replace") as reg: + text = reg.read() + # Section names in Wine's registry files double their backslashes. + present = {line[1:line.find("]")].replace("\\\\", "\\").lower() + for line in text.splitlines() if line.startswith("[") and "]" in line} + stamp = int(time_now()) + added = [] + for key in NGX_KEYS: + if key.lower() not in present: + added.append("[%s] %d\n\"Enable\"=dword:00000001\n\"FullPath\"=\"C:\\\\windows\\\\system32\"\n" + "\"NGXPath\"=\"C:\\\\windows\\\\system32\"\n" % (key.replace("\\", "\\\\"), stamp)) + for key in NGX_SIGNATURE_KEYS: + if key.lower() not in present: + added.append("[%s] %d\n\"%s\"=hex:01\n" % (key.replace("\\", "\\\\"), stamp, NV_SIGNATURE_OVERRIDE)) + if not added: + return False + with open(path, "a", encoding="utf-8") as reg: + reg.write("\n" + "\n".join(added)) + return True + + +def time_now(): + import time + return time.time() + + +def upscale_xess(prefix, data): + """Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32.""" + source = os.path.join(data, "xess", UPSCALE_XESS) + if not os.path.isfile(source): + return "XeSS runtime not downloaded" + target = os.path.join(prefix, "pfx", "drive_c", "windows", "system32", UPSCALE_XESS) + if os.path.isfile(target) and os.path.getsize(target) == os.path.getsize(source): + return None + staged = target + ".droiddeck-tmp" + with open(source, "rb") as src, open(staged, "wb") as dst: + while True: + chunk = src.read(1 << 20) + if not chunk: + break + dst.write(chunk) + os.replace(staged, target) + return None + + +def upscale_settings(env, prefix): + """The game's upscaler choice -> DLL overrides, bridge folder, layer switch and the files the layer reads.""" + mode = (env.get("DROIDDECK_UPSCALE_MODE") or "").strip().lower() + if mode not in UPSCALE_MODES: + return env, [] + notes = [] + bridges = UPSCALE_ROOT + "/bridges" + data = UPSCALE_ROOT + "/data" + if not os.path.isfile(os.path.join(bridges, "x86_64-windows", "libxess.dll")): + return env, ["in-game upscaler chosen but its bridge pack is not installed; launched without it"] + result = dict(env) + engine = (env.get("DROIDDECK_UPSCALE_ENGINE") or "").strip().lower() + if engine not in UPSCALE_ENGINES: + engine = "fsr4_1_lite_gpu" + if engine in UPSCALE_NPU_FALLBACK and env.get("DROIDDECK_UPSCALE_NPU") != "1": + notes.append("no usable NPU on this device: %s runs as %s" % (engine, UPSCALE_NPU_FALLBACK[engine])) + engine = UPSCALE_NPU_FALLBACK[engine] + try: + sharpness = min(100, max(0, int(env.get("DROIDDECK_UPSCALE_SHARPNESS") or "55"))) + except ValueError: + sharpness = 55 + result["DROIDDECK_UPSCALE"] = "1" + result["DROIDDECK_UPSCALE_DIR"] = data + "/fsr4" + result["DROIDDECK_UPSCALE_BACKEND"] = engine + result["DROIDDECK_UPSCALE_ENGINE"] = engine + result["DROIDDECK_UPSCALE_SHARPNESS"] = "%.2f" % (sharpness / 100.0) + result["DROIDDECK_UPSCALE_NPU_SYNC"] = "sync" if env.get("DROIDDECK_UPSCALE_NPU_SYNC") == "1" else "async" + result["DROIDDECK_UPSCALE_PRESET"] = "auto" + result["DROIDDECK_UPSCALE_POWER"] = env.get("DROIDDECK_UPSCALE_POWER") or "balanced" + result["DROIDDECK_UPSCALE_CTRL_FILE"] = UPSCALE_RUN + "/ctrl" + result["DROIDDECK_UPSCALE_STATUS_FILE"] = UPSCALE_RUN + "/status" + result["DROIDDECK_UPSCALE_NATIVELIB_DIR"] = data + "/jni" + result["DROIDDECK_UPSCALE_VRAM_OVERRIDE"] = "0" + result["ADSP_LIBRARY_PATH"] = data + "/fsr4/adsp;/vendor/dsp/cdsp;/vendor/lib/rfsa/adsp;/system/lib/rfsa/adsp" + own = result.get("WINEDLLPATH") + result["WINEDLLPATH"] = bridges + (":" + own if own else "") + overrides = ["%s=b,n" % name for name in UPSCALE_FSR_DLLS] + ["wl_xess_official=n"] + dxvk = None + if mode == "dlss": + overrides += ["%s=b,n" % name for name in UPSCALE_DLSS_DLLS] + result["DROIDDECK_UPSCALE_SPOOF_DLSS"] = "1" + result["DROIDDECK_UPSCALE_GPU_SPOOF"] = "rtx" + result["PROTON_ENABLE_NVAPI"] = "1" + result["DXVK_ENABLE_NVAPI"] = "1" + result["WINE_HIDE_NVIDIA_GPU"] = "0" + dxvk = 'dxgi.hideNvidiaGpu = False; dxgi.customVendorId = 10de; dxgi.customDeviceId = 1f08; dxgi.customDeviceDesc = "NVIDIA GeForce RTX 2060"' + if env.get("DROIDDECK_UPSCALE_SIGFIX") == "1": + result["DROIDDECK_UPSCALE_SIGFIX"] = "1" + try: + if prefix and upscale_registry(prefix): + notes.append("NVIDIA NGX registry entries added to the prefix (DLSS mode)") + except OSError as error: + notes.append("NGX registry entries not written (%s)" % error) + elif mode == "native": + result["DROIDDECK_UPSCALE_SPOOF_DLSS"] = "0" + result["DROIDDECK_UPSCALE_GPU_SPOOF"] = "rdna4" + result.setdefault("VKD3D_SHADER_MODEL", "6_8") + dxvk = 'dxgi.customVendorId = 1002; dxgi.customDeviceId = 7550; dxgi.customDeviceDesc = "AMD Radeon RX 9070 XT"' + else: + result["DROIDDECK_UPSCALE_SPOOF_DLSS"] = "0" + result["DROIDDECK_UPSCALE_GPU_SPOOF"] = "off" + if dxvk: + current = result.get("DXVK_CONFIG", "").strip().rstrip(";").strip() + result["DXVK_CONFIG"] = current + "; " + dxvk if current else dxvk + own = result.get("WINEDLLOVERRIDES") + result["WINEDLLOVERRIDES"] = (own + ";" if own else "") + ";".join(overrides) + if engine == "xess3_gpu" and prefix: + try: + problem = upscale_xess(prefix, data) + except OSError as error: + problem = str(error) + if problem: + notes.append("XeSS: %s; the layer falls back to FSR" % problem) + notes.append("in-game upscaler: mode %s, engine %s, sharpness %d%%" % (mode, engine, sharpness)) + return result, notes + + DIRT_GAMES = {"dirt3_game": "dirt3", "showdown": "dirtshowdown", "showdown_avx": "dirtshowdown"} DIRT_WS2 = "/usr/local/lib/droiddeck-dirt/ws2_32.dll" DIRT_MARKER = b"droiddeck-dirt-ws2_32" @@ -1771,6 +1918,9 @@ def main(): env = dict(env, **installer) print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr) if waiting: + env, upscale_notes = upscale_settings(env, prefix_path) + for note in upscale_notes: + print("droiddeck-game-env: " + note, file=sys.stderr) before_debug = env env = apply_game_debug_logs(env, config, debug_dir) if env is not before_debug: diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index b7b658f21b..1118771663 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -24,6 +24,67 @@ STATE = tempfile.TemporaryDirectory() COMPAT["main"].__globals__["COMPAT_DIR"] = STATE.name +class UpscalerSettingsTest(unittest.TestCase): + def setUp(self): + self.root = tempfile.mkdtemp() + Path(self.root, "bridges/x86_64-windows").mkdir(parents=True) + Path(self.root, "bridges/x86_64-windows/libxess.dll").write_bytes(b"MZ") + self.patch = patch.dict(MODULE["upscale_settings"].__globals__, {"UPSCALE_ROOT": self.root}) + self.patch.start() + + def tearDown(self): + self.patch.stop() + shutil.rmtree(self.root) + + def test_off_leaves_the_environment_alone(self): + env = {"DROIDDECK_UPSCALE_MODE": "off", "WINEDLLOVERRIDES": "dxgi=n"} + self.assertEqual((env, []), MODULE["upscale_settings"](env, None)) + + def test_fsr_mode_overrides_the_upscaler_dlls_without_spoofing(self): + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "WINEDLLOVERRIDES": "dxgi=n"}, None) + self.assertEqual("1", env["DROIDDECK_UPSCALE"]) + self.assertTrue(env["WINEDLLOVERRIDES"].startswith("dxgi=n;libxess=b,n;")) + self.assertNotIn("nvapi64", env["WINEDLLOVERRIDES"]) + self.assertNotIn("DXVK_CONFIG", env) + self.assertEqual(self.root + "/bridges", env["WINEDLLPATH"]) + self.assertEqual("off", env["DROIDDECK_UPSCALE_GPU_SPOOF"]) + + def test_dlss_mode_spoofs_an_nvidia_gpu(self): + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss", "DXVK_CONFIG": "a = 1"}, None) + self.assertIn("nvngx=b,n", env["WINEDLLOVERRIDES"]) + self.assertIn("nvapi64=b,n", env["WINEDLLOVERRIDES"]) + self.assertEqual("1", env["PROTON_ENABLE_NVAPI"]) + self.assertTrue(env["DXVK_CONFIG"].startswith("a = 1; dxgi.hideNvidiaGpu = False; dxgi.customVendorId = 10de")) + + def test_npu_engines_fall_back_to_the_gpu_without_an_npu(self): + env, notes = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_1_lite_npu"}, None) + self.assertEqual("fsr4_1_lite_gpu", env["DROIDDECK_UPSCALE_BACKEND"]) + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_1_lite_npu", + "DROIDDECK_UPSCALE_NPU": "1"}, None) + self.assertEqual("fsr4_1_lite_npu", env["DROIDDECK_UPSCALE_BACKEND"]) + + def test_without_the_bridge_pack_the_game_starts_without_the_upscaler(self): + os.unlink(os.path.join(self.root, "bridges/x86_64-windows/libxess.dll")) + env = {"DROIDDECK_UPSCALE_MODE": "fsr"} + result, notes = MODULE["upscale_settings"](env, None) + self.assertEqual(env, result) + self.assertTrue(notes) + + def test_ngx_registry_entries_are_added_once(self): + prefix = tempfile.mkdtemp() + try: + Path(prefix, "pfx").mkdir() + Path(prefix, "pfx/system.reg").write_text("WINE REGISTRY Version 2\n\n[Software\\\\Wine] 1\n") + self.assertTrue(MODULE["upscale_registry"](prefix)) + self.assertFalse(MODULE["upscale_registry"](prefix)) + text = Path(prefix, "pfx/system.reg").read_text() + self.assertIn("[Software\\\\NVIDIA Corporation\\\\Global\\\\NGXCore]", text) + self.assertIn('"FullPath"="C:\\\\windows\\\\system32"', text) + self.assertNotIn("CurrentControlSet", text) + finally: + shutil.rmtree(prefix) + + class SupergiantDotnetReporterTest(unittest.TestCase): def test_allows_the_builtin_mscoree_for_supergiant_reporter(self): game = mock.Mock(files={"basecampbugreporter.native.dll"})