mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9aa10e10e1 | ||
|
|
69f4d4addb | ||
|
|
babf97222f | ||
|
|
0cde5ce565 | ||
|
|
898b637648 | ||
|
|
18102ef58f | ||
|
|
4f06ea814f | ||
|
|
35fc6e3d69 | ||
|
|
13968e722f | ||
|
|
18469cbc4c | ||
|
|
0cb6afbff6 | ||
|
|
e422ab68a7 | ||
|
|
04a67aa765 | ||
|
|
e5d7bddfdb | ||
|
|
772f83cf95 | ||
|
|
d47ed325fd | ||
|
|
d83c18417d | ||
|
|
bb5c53a793 | ||
|
|
73442ad3e0 | ||
|
|
bba89b7c11 | ||
|
|
ffe46fe53b | ||
|
|
4626cb309d | ||
|
|
0750f2d0f5 | ||
|
|
aa4997b306 | ||
|
|
7aa54ab9c7 | ||
|
|
d32433d995 | ||
|
|
85bfb69306 | ||
|
|
83de9e38b4 | ||
|
|
a23f402724 | ||
|
|
aabacc106d | ||
|
|
537b52585a | ||
|
|
379198e4e6 | ||
|
|
971b74b594 | ||
|
|
9b21ea2e90 | ||
|
|
1a621bcffa | ||
|
|
01d7338610 | ||
|
|
74ece6c854 | ||
|
|
db5a03039e | ||
|
|
94754fea04 | ||
|
|
c18aa23ac2 | ||
|
|
94bcfca5c0 | ||
|
|
b9a535170e | ||
|
|
b6457b0cf7 | ||
|
|
217817fa83 | ||
|
|
d78ff7ddc7 | ||
|
|
f2309c8a09 | ||
|
|
491106ac3c | ||
|
|
c0af05f103 | ||
|
|
02d57b2a78 | ||
|
|
b4210b5a67 | ||
|
|
63311bdeaf | ||
|
|
7972c18e50 |
No files matched your search
@@ -307,9 +307,6 @@ jobs:
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe"
|
||||
|
||||
- name: Build the LSE atomics emulator for ARMv8.0 CPUs
|
||||
run: bash tools/linuxfs/lse-emu/build.sh app/src/main/assets/linuxfs
|
||||
|
||||
- name: Check the preloads
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -328,6 +325,9 @@ jobs:
|
||||
- name: Build the DiRT 3 / DiRT Showdown ws2_32 stand-in
|
||||
run: python3 tools/components/prepare.py dirt-ws2
|
||||
|
||||
- name: Build the DLSS / FSR / XeSS upscale bridges
|
||||
run: python3 tools/components/prepare.py upscale-bridges
|
||||
|
||||
- name: Cache graphics driver inputs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -955,7 +955,6 @@ jobs:
|
||||
with:
|
||||
artifact: droiddeck-signed
|
||||
variant: standard
|
||||
fail_on_detection: true
|
||||
secrets: inherit
|
||||
|
||||
packs:
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
jq -r --arg n "$2" '.assets // [] | .[] | select(.name == $n) | .digest // empty'
|
||||
}
|
||||
commit=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$BUILD_RUN" --jq .head_sha 2>/dev/null || echo "$GITHUB_SHA")
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt epic; do
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt epic upscale; do
|
||||
file="packs/$name.tar.zst"
|
||||
[ -f "$file" ] || { echo "::error::$name.tar.zst is missing from Build APK run $BUILD_RUN"; exit 1; }
|
||||
sha=$(sha256sum "$file" | cut -d' ' -f1)
|
||||
|
||||
+4
-2
@@ -95,7 +95,7 @@ def trackingPack = rootProject.file('tools/packs/tracking/release.env').readLine
|
||||
def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
||||
.findAll { it.contains('=') && !it.startsWith('#') }
|
||||
.collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] }
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic', 'upscale'].collectEntries { name ->
|
||||
def pack = file("build/packs/${name}.tar.zst")
|
||||
if (!pack.isFile()) {
|
||||
if (ciBuild && !unitTestsOnly) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
@@ -203,11 +203,13 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.testkey
|
||||
// TEST BUILD ONLY (Red Magic NPU test, no root): run-as reaches the app's files. Never merge.
|
||||
debuggable true
|
||||
}
|
||||
}
|
||||
|
||||
androidResources {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>droiddeck-rockstar:<dir>droiddeck-dirt:<dir>droiddeck-epic:<dir>directaudio:<dir>hybris'
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>droiddeck-rockstar:<dir>droiddeck-dirt:<dir>droiddeck-epic:<dir>droiddeck-upscale:<dir>directaudio:<dir>hybris'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
|
||||
@@ -41,6 +41,7 @@ message(STATUS "dd-fg chain: win-fg ${DDFG_UPSTREAM} (src ${DDFG_CHAIN_HASH})")
|
||||
|
||||
add_subdirectory(waylandcomp)
|
||||
add_subdirectory(questxr)
|
||||
add_subdirectory(../../../../tools/upscale/layer upscale_layer)
|
||||
add_library(sdnative SHARED sdnative/sdnative.c)
|
||||
target_link_libraries(sdnative log)
|
||||
|
||||
|
||||
@@ -191,6 +191,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var gamescopeRealtime by mutableStateOf(false)
|
||||
private var paceCores by mutableStateOf(true)
|
||||
private var gpuClockPin by mutableStateOf(false)
|
||||
private var prootNoSeccomp by mutableStateOf(false)
|
||||
private var prootFastPath by mutableStateOf(true)
|
||||
private var nativeUserland by mutableStateOf(true)
|
||||
private var desktopAsUser by mutableStateOf(false)
|
||||
private var cursorComposite by mutableStateOf(true)
|
||||
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
|
||||
@@ -3122,7 +3125,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
fsyncFirst = fsyncFirst,
|
||||
gamescopeRealtime = gamescopeRealtime,
|
||||
gpuClockPin = gpuClockPin,
|
||||
nativeDesktopAvailable = com.droiddeck.launcher.runtime.NativeGuest.nextSession(this), desktopAsUser = desktopAsUser, cursorComposite = cursorComposite,
|
||||
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, desktopAsUser = desktopAsUser, cursorComposite = cursorComposite,
|
||||
guestHostname = guestHostname, phantomWarning = phantomWarning,
|
||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||
onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on },
|
||||
@@ -3136,6 +3139,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on },
|
||||
onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on },
|
||||
onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on },
|
||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
|
||||
onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on },
|
||||
onDesktopAsUser = { on -> SessionPrefs.setDesktopAsUser(this, on); desktopAsUser = on },
|
||||
onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
|
||||
onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) },
|
||||
@@ -3458,6 +3464,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
gamescopeRealtime = SessionPrefs.gamescopeRealtime(this)
|
||||
paceCores = SessionPrefs.paceCores(this)
|
||||
gpuClockPin = SessionPrefs.gpuClockPin(this)
|
||||
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
|
||||
prootFastPath = SessionPrefs.prootFastPath(this)
|
||||
nativeUserland = SessionPrefs.nativeUserland(this)
|
||||
desktopAsUser = SessionPrefs.desktopAsUser(this)
|
||||
cursorComposite = SessionPrefs.cursorComposite(this)
|
||||
guestHostname = SessionPrefs.guestHostname(this)
|
||||
|
||||
@@ -3862,6 +3862,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
presentationFaultHint()?.let { return it }
|
||||
if (log == null || !log.isFile) return null
|
||||
return try {
|
||||
var enosys = 0
|
||||
var fexMissing = false
|
||||
val size = log.length()
|
||||
val text = java.io.RandomAccessFile(log, "r").use { f ->
|
||||
@@ -3872,6 +3873,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
String(bytes, Charsets.ISO_8859_1)
|
||||
}
|
||||
text.lineSequence().forEach { line ->
|
||||
if (line.contains("Function not implemented")) enosys++
|
||||
if (line.contains(FEX_MISSING)) fexMissing = true
|
||||
}
|
||||
val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence())
|
||||
@@ -3893,6 +3895,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
} else if (fexMissing) {
|
||||
val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program)
|
||||
EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true)
|
||||
} else if (enosys >= 8) {
|
||||
EndHint(resources.getQuantityString(R.plurals.session_hint_enosys, enosys, enosys,
|
||||
getString(R.string.perf_title), getString(R.string.perf_seccomp), getString(R.string.perf_xalia)))
|
||||
} else null
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
|
||||
@@ -571,6 +571,7 @@ object AgentHost {
|
||||
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path)
|
||||
if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1")
|
||||
LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ object AgentNative {
|
||||
fun run(context: Context, request: JSONObject, timeoutMs: Long): JSONObject {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
com.droiddeck.launcher.session.SessionFiles.stage(context, root)
|
||||
// with the setting off, staging leaves the rootfs as proot wants it
|
||||
if (!com.droiddeck.launcher.session.SessionPrefs.nativeUserland(context)) NativeGuest.prepare(context, root)
|
||||
if (!NativeGuest.available(root)) throw AgentException("NATIVE_UNAVAILABLE", "The rootfs has no native hook or glibc loader yet; start a session once")
|
||||
val argvJson = request.optJSONArray("argv") ?: throw AgentException("INVALID_REQUEST", "argv is required")
|
||||
val argv = (0 until argvJson.length()).map { argvJson.getString(it) }
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import java.io.File
|
||||
|
||||
object CpuFeatures {
|
||||
internal fun lacksAtomics(cpuInfo: String): Boolean {
|
||||
val cores = cpuInfo.lineSequence()
|
||||
.filter { it.substringBefore(':').trim() == "Features" }
|
||||
.map { it.substringAfter(':').trim().split(Regex("\\s+")) }
|
||||
.toList()
|
||||
return cores.isNotEmpty() && cores.any { "atomics" !in it }
|
||||
}
|
||||
|
||||
val lacksAtomics: Boolean by lazy {
|
||||
runCatching { lacksAtomics(File("/proc/cpuinfo").readText()) }.getOrDefault(false)
|
||||
}
|
||||
}
|
||||
@@ -291,12 +291,9 @@ object DeviceReport {
|
||||
k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up")
|
||||
k("gamescope realtime", SessionPrefs.gamescopeRealtime(context))
|
||||
k("pace cores", SessionPrefs.paceCores(context))
|
||||
k("guest runtime policy", "native preferred with PRoot fallback")
|
||||
k("guest runtime", when (com.droiddeck.launcher.runtime.NativeGuest.sessionMode) {
|
||||
true -> "native"
|
||||
false -> "PRoot"
|
||||
null -> if (com.droiddeck.launcher.runtime.NativeGuest.enabled(context)) "native available" else "native unavailable"
|
||||
})
|
||||
k("proot without seccomp", SessionPrefs.prootNoSeccomp(context))
|
||||
k("native userland (no proot)", SessionPrefs.nativeUserland(context))
|
||||
k("proot fast path", SessionPrefs.prootFastPath(context))
|
||||
k("proot binary", LinuxRuntime.prootSource(context) + " " + LinuxRuntime.prootBinary(context).path)
|
||||
k("proot fast path (eligible)", com.droiddeck.launcher.runtime.ProotFastPath.enabled(context))
|
||||
k("Guest host name", SessionPrefs.guestHostname(context))
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
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),
|
||||
SGSR2("sgsr2_gpu", false),
|
||||
FSR4_NPU("fsr4_1_full_npu", true),
|
||||
FSR4_LITE_NPU("fsr4_1_lite_npu", true);
|
||||
|
||||
companion object {
|
||||
/** Saved before full FSR 4.1 replaced FSR 4.0 on the NPU (NeuralScale r5). */
|
||||
private const val LEGACY_FSR4_NPU = "fsr4_0_npu"
|
||||
|
||||
fun byId(id: String?): Engine? {
|
||||
val key = id?.trim()?.lowercase()
|
||||
return if (key == LEGACY_FSR4_NPU) FSR4_NPU else entries.firstOrNull { it.id == key }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 = true,
|
||||
)
|
||||
|
||||
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] != "0",
|
||||
)
|
||||
}
|
||||
|
||||
fun entries(choice: Choice?): Map<String, String> = 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")
|
||||
// DLSS games need NGX to accept the bridge DLLs; on unless the player switched it off (stored as "0").
|
||||
if (choice.mode == Mode.DLSS) put(SIGFIX, if (choice.signatureFix) "1" else "0")
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ internal object DroidDeckHudConfig {
|
||||
"showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "0", "showLow001" to "0",
|
||||
"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",
|
||||
)
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ enum class DroidDeckHudSize(val token: String, val label: String) {
|
||||
PILL("pill", "Pill"),
|
||||
MINIMAL("minimal", "Minimal"),
|
||||
MEGA("mega", "Mega"),
|
||||
STRIP("strip", "Strip"),
|
||||
SIDE_STRIP("side_strip", "Side strip");
|
||||
STRIP("strip", "Strip");
|
||||
|
||||
fun next(): DroidDeckHudSize {
|
||||
val all = values()
|
||||
@@ -75,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",
|
||||
@@ -97,11 +97,6 @@ enum class DroidDeckHudSize(val token: String, val label: String) {
|
||||
"showCPUUsage", "showTemp", "showVram", "showRAM", "showBattery", "showBatteryTemp", "showBatteryTime",
|
||||
"showPower", "showDisplay", "showHdr", "showGpuModel",
|
||||
),
|
||||
SIDE_STRIP to listOf(
|
||||
"showFPS", "showFPSGraph", "showAvg", "showLow1",
|
||||
"showGPULoad", "showGpuTemp", "showCPUUsage", "showTemp", "showRAM", "showVram",
|
||||
"showPower", "showBattery", "showBatteryTemp", "showBatteryTime",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -116,7 +111,6 @@ enum class DroidDeckHudSize(val token: String, val label: String) {
|
||||
MEGA to DroidDeckHudStyle(row = 11.5f, unit = 11.5f * 0.62f, pad = 10f, lineGap = 3.5f, labelGap = 7f,
|
||||
band = 9.5f, gutter = 16f),
|
||||
STRIP to DroidDeckHudStyle(row = 11.5f, unit = 11.5f * 0.8f, pad = 10f, lineGap = 0f, labelGap = 13f),
|
||||
SIDE_STRIP to DroidDeckHudStyle(row = 11.5f, unit = 9f, pad = 8f, lineGap = 4f, labelGap = 4f, key = 9f),
|
||||
)
|
||||
|
||||
fun rowsFor(size: DroidDeckHudSize, values: Map<String, String>): List<String> =
|
||||
|
||||
@@ -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 = ""
|
||||
@@ -283,6 +284,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 ?: "" }
|
||||
|
||||
@@ -573,7 +576,6 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
if (s == null) { contentW = 0f; contentH = 0f; return }
|
||||
if (dock != DroidDeckHudDock.NONE) { buildDockTab(); return }
|
||||
if (size == DroidDeckHudSize.STRIP) { buildStrip(s); return }
|
||||
if (size == DroidDeckHudSize.SIDE_STRIP) { buildSideStrip(s); return }
|
||||
buildRows(s)
|
||||
if (contentW <= 0f || contentH <= 0f) return
|
||||
if (size == DroidDeckHudSize.PILL) addSubtleClock(sp(10f), leftAligned = true)
|
||||
@@ -685,8 +687,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
finishPanel(panel, halfRound = halfRound)
|
||||
}
|
||||
|
||||
private fun finishPanel(panel: RectF, halfRound: Boolean, maxRadius: Float = sp(56f), inset: Float = panelInset()) {
|
||||
val r = if (halfRound) panel.height() / 2f else min(panel.height() / 2f, maxRadius)
|
||||
private fun finishPanel(panel: RectF, halfRound: Boolean) {
|
||||
val r = if (halfRound) panel.height() / 2f else min(panel.height() / 2f, sp(56f))
|
||||
val margin = outlineWidth() + sp(4f)
|
||||
fun curveIn(top: Float, bottom: Float): Float {
|
||||
val d = max(max(panel.top + r - top, bottom - (panel.bottom - r)), 0f)
|
||||
@@ -704,8 +706,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
for (t in tileRects) right = max(right, t.right + curveIn(t.top, t.bottom) + margin)
|
||||
panel.right = max(right, panel.left + sp(6f) + r)
|
||||
dPanel = panel; dRadius = r
|
||||
contentW = panel.right + inset
|
||||
contentH = panel.bottom + inset
|
||||
contentW = panel.right + panelInset()
|
||||
contentH = panel.bottom + panelInset()
|
||||
}
|
||||
|
||||
private fun clockTimeString(): String = DateFormat.getTimeFormat(context).format(Date())
|
||||
@@ -779,6 +781,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
|
||||
}
|
||||
@@ -816,6 +819,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))
|
||||
}
|
||||
@@ -937,58 +941,6 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildSideStrip(s: HudMetrics.Snapshot) {
|
||||
val style = size.style
|
||||
val inset = sp(5f)
|
||||
val panelWidth = sp(86f)
|
||||
val pad = sp(style.pad)
|
||||
val left = inset + pad
|
||||
val right = inset + panelWidth - pad
|
||||
val markHeight = sp(12f)
|
||||
val markTop = inset + sp(6f)
|
||||
val markLeft = left - DroidDeckMark.inkLeftFor(markHeight)
|
||||
headerMark = RectF(markLeft, markTop, markLeft + DroidDeckMark.widthFor(markHeight), markTop + markHeight)
|
||||
dDividerTop = markTop + markHeight + sp(6f)
|
||||
|
||||
if (showClockTime) {
|
||||
val clock = clockTimeString()
|
||||
val clockPx = sp(8.5f)
|
||||
val clockWidth = measure(clock, clockPx)
|
||||
if (right - clockWidth >= markLeft + DroidDeckMark.inkRightFor(markHeight) + sp(4f)) {
|
||||
val baseline = markTop + (markHeight + capHeight(clockPx)) / 2f
|
||||
glyphs.add(Glyph(right - clockWidth, baseline, clock, blend(colDim), clockPx))
|
||||
}
|
||||
}
|
||||
|
||||
val labelPx = sp(style.key)
|
||||
val rowPx = sp(style.row)
|
||||
val unitPx = sp(style.unit)
|
||||
val lineGap = sp(style.lineGap)
|
||||
var y = dDividerTop + sp(6f)
|
||||
for (key in size.rowsIn(storedOrder)) {
|
||||
if (!switchOn(key)) continue
|
||||
if (key == "showFPSGraph") {
|
||||
val height = sp(15f)
|
||||
graphRect = RectF(left, y, right, y + height)
|
||||
y += height + lineGap
|
||||
continue
|
||||
}
|
||||
|
||||
val valuePx = if (key == "showFPS") sp(16f) else rowPx
|
||||
val row = reading(key, s, labelPx, valuePx, unitPx)
|
||||
val available = right - left - measure(row.label.text, labelPx) - sp(style.labelGap)
|
||||
val fit = (available / runWidth(row.vals)).coerceIn(0f, 1f)
|
||||
val values = row.vals.map { Span(it.text, it.color, it.sizePx * fit, it.glow) }
|
||||
val baseline = y - ascent(valuePx)
|
||||
placeRun(left, baseline, listOf(row.label))
|
||||
placeRun(right - runWidth(values), baseline, values)
|
||||
y += lineH(valuePx) + lineGap
|
||||
}
|
||||
|
||||
val panel = RectF(inset, inset, inset + panelWidth, y + sp(7f))
|
||||
finishPanel(panel, halfRound = false, maxRadius = sp(11f), inset = inset)
|
||||
}
|
||||
|
||||
private fun buildStrip(s: HudMetrics.Snapshot) {
|
||||
val rowPx = sp(11.5f); val unitPx = rowPx * 0.8f; val fpsPx = sp(15f)
|
||||
val padX = sp(10f); val groupGap = sp(13f)
|
||||
|
||||
@@ -156,13 +156,7 @@ object InputLibraries {
|
||||
update(context) { library ->
|
||||
library.copy(layouts = library.layouts.map { layout ->
|
||||
if (layout.id != layoutId || !layout.editable) layout
|
||||
else {
|
||||
fun updateSticks(elements: List<InputSurfaceElement>) = elements.map {
|
||||
if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = it.hideStickAtRest, adaptiveCapture = on)
|
||||
else it
|
||||
}
|
||||
layout.copy(elements = updateSticks(layout.elements), rotated = updateSticks(layout.rotated))
|
||||
}
|
||||
else layout.copy(elements = layout.elements.map { if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = on) else it })
|
||||
})
|
||||
}
|
||||
}.onSuccess { ControllerPrefs.setAdaptiveSticks(context, on) }.isSuccess
|
||||
@@ -334,8 +328,7 @@ object InputLibraries {
|
||||
for (e in list) elements.put(JSONObject().put("id", e.id).put("kind", e.kind.name)
|
||||
.put("control", e.control.id).put("name", e.name).put("x", e.x.toDouble()).put("y", e.y.toDouble())
|
||||
.put("width", e.width.toDouble()).put("height", e.height.toDouble()).put("floating", e.floating).put("hideWhenIdle", e.hideWhenIdle).put("mouseGestures", e.mouseGestures).put("toggle", e.toggle).put("icon", e.icon).put("image", e.image)
|
||||
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown)
|
||||
.put("adaptiveCapture", e.adaptiveCapture))
|
||||
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown))
|
||||
}
|
||||
|
||||
private fun decodeElements(array: JSONArray) = array.objects(64).map { e ->
|
||||
@@ -343,8 +336,7 @@ object InputLibraries {
|
||||
e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(),
|
||||
e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"),
|
||||
e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""),
|
||||
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false),
|
||||
if (e.isNull("adaptiveCapture")) null else e.optBoolean("adaptiveCapture", false))
|
||||
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false))
|
||||
}
|
||||
|
||||
internal fun encode(library: InputLibrary): String {
|
||||
|
||||
@@ -32,7 +32,7 @@ data class SavedInputLayout(
|
||||
fun withQuickButton(button: InputCommand, shown: Boolean) =
|
||||
copy(style = style.copy(hidden = if (shown) style.hidden - button else style.hidden + button))
|
||||
fun derived(id: String, name: String) = copy(id = id, name = name, origin = origin ?: this.id)
|
||||
val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.adaptiveStick }
|
||||
val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.floating && it.hideWhenIdle }
|
||||
fun supports(role: InputRole) = screen.supports(role) && when (template) {
|
||||
InputLayoutTemplate.OVERLAY -> role == InputRole.PRIMARY
|
||||
InputLayoutTemplate.DECK, InputLayoutTemplate.TRACKPAD -> role == InputRole.SECONDARY
|
||||
|
||||
@@ -37,12 +37,7 @@ data class InputSurfaceElement(
|
||||
val buttonShape: InputButtonShape = InputButtonShape.ROUNDED,
|
||||
val showLabel: Boolean = true,
|
||||
val alwaysShown: Boolean = false,
|
||||
val adaptiveCapture: Boolean? = null,
|
||||
) {
|
||||
// Old layouts encoded Adaptive sticks as Floating + Hide when idle.
|
||||
val adaptiveStick get() = kind == InputElementKind.STICK && floating && (adaptiveCapture ?: hideWhenIdle)
|
||||
val hideStickAtRest get() = hideWhenIdle && (adaptiveCapture != null || !adaptiveStick)
|
||||
|
||||
val hasClick get() = kind == InputElementKind.STICK || kind == InputElementKind.TRACKPAD
|
||||
|
||||
fun bounded() = copy(x = x.coerceIn(0f, 0.97f), y = y.coerceIn(0f, 0.97f),
|
||||
|
||||
@@ -188,7 +188,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
settings.mapping[it.id] != ControllerPrefs.OFF && (it.id != "guide" || settings.steamButton) && (it.id != "qam" || settings.qamButton)
|
||||
}.map { c ->
|
||||
InputSurfaceElement(requireNotNull(InputControl.fromId(c.id)), (c.cx - c.halfW) / width, (c.cy - c.halfH) / height,
|
||||
2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, adaptiveCapture = if (c.stick >= 0) settings.adaptiveSticks else null,
|
||||
2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, hideWhenIdle = c.stick >= 0 && settings.adaptiveSticks,
|
||||
buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let { if (previousStickGeometry) widenStickPreviously(it) else widenStick(it) }.bounded()
|
||||
}.toMutableList()
|
||||
if (settings.keyboardButton) result += keyboard()
|
||||
|
||||
@@ -37,10 +37,8 @@ object OnScreenLayout {
|
||||
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
|
||||
trackpads: Boolean? = null): List<InputSurfaceElement> {
|
||||
val placed = placeElements(context, saved, width, height, safe, buttonsOnly, dock, rearButtons, trackpads)
|
||||
// Docked sticks stay visible and only pick up touches inside their own bounds.
|
||||
return if (dock == null) placed else placed.map {
|
||||
if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false, adaptiveCapture = false) else it
|
||||
}
|
||||
// Below the game a stick covers nothing, so it keeps its base in view instead of appearing only under the thumb.
|
||||
return if (dock == null) placed else placed.map { if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false) else it }
|
||||
}
|
||||
|
||||
private fun placeElements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
||||
|
||||
@@ -288,26 +288,12 @@ object BwrapSpawner {
|
||||
}
|
||||
|
||||
private fun preload(session: List<Bind>, rootfs: String, env: MutableMap<String, String>): List<Bind> {
|
||||
val configured = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines()
|
||||
?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: emptyList()
|
||||
val lseDisabled = env["LSE_EMU"] == "0"
|
||||
val libs = configured.filterNot { lseDisabled && it.endsWith("/liblse_emu.so") }
|
||||
val inherited = env["LD_PRELOAD"]?.split(Regex("[\\s:]+"))
|
||||
?.filter { it.isNotEmpty() && !(lseDisabled && it.substringAfterLast('/') == "liblse_emu.so") }
|
||||
?: emptyList()
|
||||
if (libs.isEmpty()) {
|
||||
if (lseDisabled) {
|
||||
if (inherited.isEmpty()) env.remove("LD_PRELOAD")
|
||||
else env["LD_PRELOAD"] = inherited.joinToString(":")
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
val libs = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines()
|
||||
?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: return emptyList()
|
||||
if (libs.isEmpty()) return emptyList()
|
||||
val binds = ArrayList<Bind>()
|
||||
val paths = libs.map { lib -> "$PRELOAD_DIR/${lib.substringAfterLast('/')}".also { binds.add(Bind(rootfs + lib, it)) } }
|
||||
env["LD_PRELOAD"] = (paths + inherited).joinToString(":")
|
||||
if (libs.any { it.endsWith("/liblse_emu.so") }) {
|
||||
env.putIfAbsent("LSE_EMU", "1")
|
||||
}
|
||||
env["LD_PRELOAD"] = (paths + listOfNotNull(env["LD_PRELOAD"]?.takeIf { it.isNotBlank() })).joinToString(":")
|
||||
File(rootfs, NET_LINK).takeIf { it.isFile }?.let { binds.add(Bind(it.path, "/$NET_LINK")) }
|
||||
env["FAKE_EVDEV_DIR"]?.let { File(it).parent }?.let { dev ->
|
||||
binds.addAll(bindsFor(session, rootfs, dev, dev))
|
||||
@@ -577,15 +563,12 @@ object BwrapSpawner {
|
||||
|
||||
private fun run(context: Context, plan: Plan, client: LocalSocket, out: DataOutputStream, id: Int) {
|
||||
val verbose = plan.env["DROIDDECK_PROOT_VERBOSE"]?.toIntOrNull()
|
||||
val nativeSession = NativeGuest.forSession(context)
|
||||
val native = if (nativeSession) nativeLaunch(context, plan) else null
|
||||
val native = if (NativeGuest.forSession(context)) nativeLaunch(context, plan) else null
|
||||
val builder = if (native != null) {
|
||||
ProcessBuilder(native.first).redirectErrorStream(true)
|
||||
.directory(File(hostPath(plan.binds, plan.root.path, plan.cwd)).takeIf { it.isDirectory } ?: plan.root)
|
||||
.also { b -> b.environment().apply { clear(); putAll(native.second) } }
|
||||
} else {
|
||||
val reason = if (nativeSession) "sandbox native launch unavailable" else "parent guest uses PRoot"
|
||||
Log.i(TAG, "Flatpak: using PRoot ($reason)")
|
||||
val cmd = LinuxRuntime.prootPrefix(context, plan.root, plan.cwd)
|
||||
if (verbose != null) { cmd.add("-v"); cmd.add(verbose.toString()) }
|
||||
plan.binds.forEach { cmd.add("-b"); cmd.add(it.spec) }
|
||||
@@ -602,6 +585,7 @@ object BwrapSpawner {
|
||||
putAll(prootEnvironment(plan, envTool))
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path)
|
||||
if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1")
|
||||
LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.droiddeck.launcher.core.HostProcess
|
||||
import com.droiddeck.launcher.session.OrphanReaper
|
||||
import com.droiddeck.launcher.session.SessionFiles
|
||||
import com.droiddeck.launcher.session.SessionPaths
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@@ -66,6 +67,7 @@ object GuestCommand {
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path)
|
||||
if (linkDir != null) put("PROOT_L2S_DIR", linkDir.path)
|
||||
if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1")
|
||||
fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> put(k, v) } }
|
||||
LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ object NativeGuest {
|
||||
}
|
||||
|
||||
fun enabled(context: Context): Boolean =
|
||||
available(LinuxRuntime.rootDir(context))
|
||||
SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context))
|
||||
|
||||
/**
|
||||
* Whether the next session will start natively. The session stages the hook from the APK before
|
||||
* it starts, so the rootfs's loader decides, and a runtime still to be
|
||||
* it starts, so only the setting and the rootfs's loader decide, and a runtime still to be
|
||||
* installed will have one.
|
||||
*/
|
||||
fun nextSession(context: Context): Boolean =
|
||||
willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context))
|
||||
SessionPrefs.nativeUserland(context) && willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context))
|
||||
|
||||
internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null
|
||||
|
||||
@@ -39,7 +39,7 @@ object NativeGuest {
|
||||
|
||||
/**
|
||||
* Whether a session's helpers (root commands, Flatpak sandboxes, installers) run natively: the
|
||||
* session's own mode while one runs, as the rootfs is only
|
||||
* session's own mode while one runs, as the setting can change under it and the rootfs is only
|
||||
* prepared for native programs at a session's start.
|
||||
*/
|
||||
fun forSession(context: Context): Boolean = sessionMode ?: enabled(context)
|
||||
@@ -104,11 +104,8 @@ object NativeGuest {
|
||||
private fun hostProgram(root: File, program: String): File = File(root, program.removePrefix("/"))
|
||||
|
||||
/** The environment of the session process: the hook's root, the mounts proot used to make, the preload list. */
|
||||
fun sessionEnvironment(
|
||||
root: File, binds: List<String>, program: String, hostname: String? = null, lseEmu: String? = null,
|
||||
): Map<String, String> {
|
||||
val preload = preloadList(root).filterNot { lseEmu == "0" && it.substringAfterLast('/') == "liblse_emu.so" }
|
||||
val lse = lseEmu ?: "1".takeIf { preload.any { it.substringAfterLast('/') == "liblse_emu.so" } }
|
||||
fun sessionEnvironment(root: File, binds: List<String>, program: String, hostname: String? = null): Map<String, String> {
|
||||
val preload = preloadList(root)
|
||||
return linkedMapOf(
|
||||
"DDNATV_ROOT" to root.path,
|
||||
"DDNATV_EXEC" to execLoader.orEmpty(),
|
||||
@@ -116,7 +113,6 @@ object NativeGuest {
|
||||
"DDNATV_HOSTNAME" to hostname.orEmpty(),
|
||||
"DDNATV_BINDS" to binds.joinToString("|") { if (it.contains(':')) it else "$it:$it" },
|
||||
"DDNATV_PRELOAD" to preload.joinToString(":"),
|
||||
"LSE_EMU" to lse.orEmpty(),
|
||||
"LD_PRELOAD" to (preload.map { File(root, it.removePrefix("/")).path } + hook(root).path).joinToString(":"),
|
||||
).filterValues { it.isNotEmpty() }
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.runtime
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
|
||||
@@ -11,14 +12,17 @@ object ProotFastPath {
|
||||
const val LIBRARY = "/usr/local/lib/libddfastpath.so"
|
||||
const val MAX_BINDS = 256
|
||||
|
||||
internal fun allows(source: String, native: Boolean): Boolean =
|
||||
!native && source == LinuxRuntime.PROOT_PACK
|
||||
fun allows(preference: Boolean, noSeccomp: Boolean, source: String, nativeUserland: Boolean = false): Boolean =
|
||||
preference && !noSeccomp && !nativeUserland && source == LinuxRuntime.PROOT_PACK
|
||||
|
||||
fun enabled(context: Context, native: Boolean = NativeGuest.forSession(context)): Boolean {
|
||||
if (native) return false
|
||||
fun enabled(context: Context): Boolean {
|
||||
val preference = SessionPrefs.prootFastPath(context)
|
||||
val noSeccomp = SessionPrefs.prootNoSeccomp(context)
|
||||
val nativeUserland = SessionPrefs.nativeUserland(context)
|
||||
val source = LinuxRuntime.prootSource(context)
|
||||
val on = allows(source, native)
|
||||
if (!on) Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot")
|
||||
val on = allows(preference, noSeccomp, source, nativeUserland)
|
||||
if (preference && !noSeccomp && !nativeUserland && !on)
|
||||
Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot")
|
||||
return on
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.os.Process
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.HostProcess
|
||||
import com.droiddeck.launcher.session.OrphanReaper
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import org.json.JSONObject
|
||||
import java.io.DataInputStream
|
||||
import java.io.DataOutputStream
|
||||
@@ -127,6 +128,7 @@ object RootSpawner {
|
||||
clear()
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path)
|
||||
if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1")
|
||||
LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,8 +343,7 @@ object BottomDesktop {
|
||||
LinuxRuntime.commandWithBinds(context, current.root, binds, guest)
|
||||
}
|
||||
val environment = if (current.nativeUserland) {
|
||||
val lseEmu = current.guest.lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=')
|
||||
com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context), lseEmu)
|
||||
com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context))
|
||||
.map { (k, v) -> "$k=$v" }.toTypedArray()
|
||||
} else current.hostEnvironment
|
||||
val line = command.joinToString(" ") { it.replace("\\", "\\\\").replace(" ", "\\ ") }
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.os.ParcelFileDescriptor
|
||||
import android.system.Os
|
||||
import android.system.OsConstants
|
||||
import com.droiddeck.launcher.core.LogRedactor
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.runtime.BattleNet
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import org.json.JSONArray
|
||||
@@ -26,7 +25,6 @@ import java.nio.channels.SeekableByteChannel
|
||||
import java.nio.file.FileVisitResult
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.LinkOption
|
||||
import java.nio.file.NoSuchFileException
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.SimpleFileVisitor
|
||||
import java.nio.file.StandardOpenOption
|
||||
@@ -223,7 +221,7 @@ internal object EnhancedSessionLogShare {
|
||||
Category.values().map { category ->
|
||||
val budget = budgets.getValue(category)
|
||||
val records = ArrayList<Record>()
|
||||
val selected = candidates.filter { it.category == category }.sortedBy(::sharePriority)
|
||||
val selected = candidates.filter { it.category == category }
|
||||
val zip = File(out, "DroidDeck-${folder.name}-${category.suffix}.zip")
|
||||
ZipOutputStream(zip.outputStream().buffered()).use { archive ->
|
||||
val names = HashSet<String>()
|
||||
@@ -618,8 +616,7 @@ internal object EnhancedSessionLogShare {
|
||||
redactionLearningComplete: Boolean,
|
||||
) {
|
||||
val entries = JSONArray()
|
||||
val (discovery, rest) = records.partition { it.origin == "discovery" }
|
||||
(discovery + rest).take(MAX_MANIFEST_RECORDS).forEach { record ->
|
||||
records.take(MAX_MANIFEST_RECORDS).forEach { record ->
|
||||
entries.put(JSONObject().apply {
|
||||
put("entry", record.entry)
|
||||
put("origin", record.origin)
|
||||
@@ -683,15 +680,6 @@ internal object EnhancedSessionLogShare {
|
||||
categoryCounts[category] = (categoryCounts[category] ?: 0) + 1
|
||||
}
|
||||
}
|
||||
fun addRecentLogs(root: File, entryPrefix: String, origin: String) {
|
||||
val scan = walk(root, remaining(maxFiles, out.size))
|
||||
truncated = truncated || scan.truncated
|
||||
partial = partial || scan.partial
|
||||
val base = root.toPath().toAbsolutePath().normalize()
|
||||
scan.files.asSequence().filter { recent(it) && it.name.endsWith(".log", true) }.forEach { file ->
|
||||
add(file, root, "$entryPrefix/${base.relativize(file.toPath().toAbsolutePath().normalize()).joinToString("/")}", origin)
|
||||
}
|
||||
}
|
||||
CRITICAL_SESSION_FILES.forEach { name ->
|
||||
File(folder, name).takeIf { it.exists() }?.let { add(it, folder, "${folder.name}/$name", "session-critical") }
|
||||
}
|
||||
@@ -725,7 +713,16 @@ internal object EnhancedSessionLogShare {
|
||||
add(source.file, source.root, source.entry, "battlenet")
|
||||
}
|
||||
} else {
|
||||
battleNetRoots(context).forEach { (prefix, root) -> addRecentLogs(root, "battlenet/$prefix", "battlenet") }
|
||||
battleNetRoots(context).forEach { (prefix, root) ->
|
||||
val scan = walk(root, remaining(maxFiles, out.size))
|
||||
truncated = truncated || scan.truncated
|
||||
partial = partial || scan.partial
|
||||
scan.files.asSequence().filter { recent(it) && it.name.endsWith(".log", true) }
|
||||
.forEach { file ->
|
||||
val relative = root.toPath().toAbsolutePath().normalize().relativize(file.toPath().toAbsolutePath().normalize()).joinToString("/")
|
||||
add(file, root, "battlenet/$prefix/$relative", "battlenet")
|
||||
}
|
||||
}
|
||||
}
|
||||
val sessionScan = walk(folder, remaining(maxFiles, out.size))
|
||||
truncated = truncated || sessionScan.truncated
|
||||
@@ -736,9 +733,6 @@ internal object EnhancedSessionLogShare {
|
||||
if (relative == EnhancedDiagnostics.MANIFEST_FILE) return@forEach
|
||||
add(file, folder, "${folder.name}/$relative", "session")
|
||||
}
|
||||
val antiCheat = antiCheatRoots(context)
|
||||
partial = partial || antiCheat.partial
|
||||
antiCheat.roots.forEach { (appId, root) -> addRecentLogs(root, "anticheat/$appId", "anticheat") }
|
||||
if (SessionPaths.current()?.canonicalFile == folder.canonicalFile && !File(folder, "steam").exists()) {
|
||||
val steam = File(SessionPrefs.activeSteamRoot(context), "logs")
|
||||
val scan = directFiles(steam, remaining(maxFiles, out.size))
|
||||
@@ -754,8 +748,7 @@ internal object EnhancedSessionLogShare {
|
||||
private fun sharePriority(candidate: Candidate): Int = when {
|
||||
candidate.origin == "session-critical" -> 0
|
||||
candidate.origin == "session" && candidate.category == Category.GAMES -> 1
|
||||
candidate.origin == "anticheat" -> 2
|
||||
else -> 3
|
||||
else -> 2
|
||||
}
|
||||
|
||||
private fun remaining(maxFiles: Int, found: Int): Int = (maxFiles - found + 1).coerceAtLeast(0)
|
||||
@@ -829,39 +822,6 @@ internal object EnhancedSessionLogShare {
|
||||
return ScanResult(files, truncated, partial)
|
||||
}
|
||||
|
||||
private class AntiCheatRoots(val roots: List<Pair<String, File>>, val partial: Boolean)
|
||||
|
||||
private fun antiCheatRoots(context: Context): AntiCheatRoots {
|
||||
var partial = false
|
||||
val seen = HashSet<String>()
|
||||
val dirs = runCatching { Library.compatdataDirs(context) }.getOrElse { partial = true; emptyList() }
|
||||
val roots = dirs.flatMapIndexed { library, compatdata ->
|
||||
val prefixes = compatdata.listFiles() ?: run { partial = true; emptyArray() }
|
||||
prefixes.filter { !Files.isSymbolicLink(it.toPath()) }.mapNotNull { prefix ->
|
||||
val appId = steamAppId(prefix.name) ?: return@mapNotNull null
|
||||
val root = File(prefix, EAC_LOG_DIR)
|
||||
val directory = try {
|
||||
Files.readAttributes(root.toPath(), BasicFileAttributes::class.java, LinkOption.NOFOLLOW_LINKS).isDirectory
|
||||
} catch (_: NoSuchFileException) {
|
||||
false
|
||||
} catch (_: Exception) {
|
||||
partial = true
|
||||
false
|
||||
}
|
||||
if (!directory) return@mapNotNull null
|
||||
val base = "$appId/library${library + 1}"
|
||||
val key = base.takeIf { seen.add(it) } ?: "$base-${prefix.name}".takeIf { seen.add(it) }
|
||||
if (key != null) key to root else { partial = true; null }
|
||||
}
|
||||
}
|
||||
return AntiCheatRoots(roots, partial)
|
||||
}
|
||||
|
||||
private fun steamAppId(name: String): String? =
|
||||
name.takeIf { SIGNED_APP_ID.matches(it) }?.toLongOrNull()
|
||||
?.takeIf { it in Int.MIN_VALUE.toLong()..0xffffffffL }
|
||||
?.let { (it and 0xffffffffL).toString() }
|
||||
|
||||
private fun battleNetRoots(context: Context): List<Pair<String, File>> {
|
||||
val drive = File(BattleNet.prefix(context), "pfx/drive_c")
|
||||
val data = File(drive, "ProgramData/Battle.net")
|
||||
@@ -968,9 +928,7 @@ internal object EnhancedSessionLogShare {
|
||||
val normalized = name.replace('\\', '/').trimStart('/')
|
||||
val parts = normalized.split('/')
|
||||
if (normalized.isEmpty() || parts.any { it.isEmpty() || it == "." || it == ".." }) return null
|
||||
return parts.mapIndexed { index, part ->
|
||||
if (index == 1 && parts[0] == "anticheat" && APP_ID.matches(part)) part else safeComponent(part)
|
||||
}.joinToString("/")
|
||||
return parts.joinToString("/") { safeComponent(it) }
|
||||
}
|
||||
|
||||
private fun safeComponent(value: String): String {
|
||||
@@ -983,7 +941,7 @@ internal object EnhancedSessionLogShare {
|
||||
|
||||
private fun category(entry: String): Category {
|
||||
val value = entry.lowercase(Locale.US)
|
||||
if (value.startsWith("battlenet/") || value.startsWith("anticheat/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") ||
|
||||
if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") ||
|
||||
value.contains("droiddeck-esync/") || GAME_LOG.matches(value.substringAfterLast('/')) ||
|
||||
listOf("proton", "wine", "dxvk", "vkd3d", "battle.net", "game-debug", "bionic").any(value::contains)) return Category.GAMES
|
||||
if (listOf("wayland", "gamescope", "xwayland", "vulkan", "gpu", "mesa", "egl", "glx", "drm", "compositor", "frame-trace").any(value::contains)) return Category.GRAPHICS
|
||||
@@ -992,7 +950,7 @@ internal object EnhancedSessionLogShare {
|
||||
|
||||
private val GAME_LOG = Regex("steam-[0-9]+\\.(log|txt)")
|
||||
private val KNOWN_COMPONENTS = setOf(
|
||||
"steam", "graphics", "games", "battlenet", "anticheat", "anticheatlauncher.log", "client", "agent", "setup", "stores", "tools",
|
||||
"steam", "graphics", "games", "battlenet", "client", "agent", "setup", "stores", "tools",
|
||||
"droiddeck", "droiddeck-esync", "session.log", "app.log", "wayland.log", "audio.log",
|
||||
"device.txt", "network.txt", "events.jsonl", "memory.csv", "capture.json", "crash.log",
|
||||
"frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json",
|
||||
@@ -1003,15 +961,11 @@ internal object EnhancedSessionLogShare {
|
||||
private val KNOWN_COMPONENT_PATTERNS = listOf(
|
||||
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
|
||||
Regex("steam-[0-9]+\\.(?:log|txt)"),
|
||||
Regex("library[0-9]+(?:--?[0-9]{1,10})?"),
|
||||
Regex("(?:battle\\.net-[0-9]+|battle\\.net-setup-[0-9]+|Agent-[0-9]+)\\.log"),
|
||||
Regex("(?:Agent\\.[0-9]+|bna_[0-9]+)"),
|
||||
Regex("stores-[0-9]{4}-[0-9]{2}-[0-9]{2}\\.log"),
|
||||
Regex("library[0-9]{1,3}"),
|
||||
Regex("entry-[0-9a-f]{16}(?:\\.[a-z0-9]{1,8})?"),
|
||||
)
|
||||
private val APP_ID = Regex("[0-9]{1,10}")
|
||||
private val SIGNED_APP_ID = Regex("-?[0-9]{1,10}")
|
||||
private val SAFE_SUFFIX = Regex("\\.[A-Za-z0-9]{1,8}$")
|
||||
private val CRITICAL_SESSION_FILES = listOf(
|
||||
"session.log", "app.log", "wayland.log", "audio.log", "device.txt", "network.txt",
|
||||
@@ -1019,7 +973,6 @@ internal object EnhancedSessionLogShare {
|
||||
)
|
||||
private const val RECENT_MILLIS = 7L * 24 * 60 * 60 * 1000
|
||||
private const val STORE_LOG_SCAN = 512
|
||||
private const val EAC_LOG_DIR = "pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat"
|
||||
private const val COPY_BUFFER_BYTES = 64 * 1024
|
||||
private const val TRACE_SCAN_BYTES = 16L * 1024 * 1024
|
||||
private const val LEGACY_LOG_MAX_BYTES = 8L * 1024 * 1024
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,16 +2,10 @@ package com.droiddeck.launcher.session
|
||||
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.FileVisitResult
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.SimpleFileVisitor
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
|
||||
internal object PageCacheTrim {
|
||||
private const val TAG = "PageCacheTrim"
|
||||
internal const val MIN_FILE_BYTES = 8L shl 20
|
||||
private const val MIN_FILE_BYTES = 8L shl 20
|
||||
private const val POLL_MS = 3000L
|
||||
private const val RESCAN_MS = 120_000L
|
||||
|
||||
@@ -43,7 +37,7 @@ internal object PageCacheTrim {
|
||||
if (mem != null && shouldTrim(mem, baseline)) {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - scanned > RESCAN_MS) {
|
||||
files = roots().flatMap { root -> bigFiles(root) }
|
||||
files = roots().flatMap { root -> root.walkTopDown().onEnter { !java.nio.file.Files.isSymbolicLink(it.toPath()) }.filter { it.isFile && it.length() >= MIN_FILE_BYTES }.toList() }
|
||||
scanned = now
|
||||
}
|
||||
val began = System.nanoTime()
|
||||
@@ -62,34 +56,6 @@ internal object PageCacheTrim {
|
||||
}, "page-cache-trim").apply { isDaemon = true }.start()
|
||||
}
|
||||
|
||||
// java.io's directory listing hands raw entry names to JNI NewStringUTF, which aborts the
|
||||
// process on names that are not valid UTF-8; NIO decodes them with replacement instead.
|
||||
// Without FOLLOW_LINKS, symlinked directories are never descended into, like the old onEnter,
|
||||
// except that a starting directory that is itself a link has to be resolved first; a link
|
||||
// whose target has vanished yields an empty result instead of an error.
|
||||
internal fun bigFiles(root: File): List<File> {
|
||||
val out = ArrayList<File>()
|
||||
val start = root.toPath()
|
||||
val real = if (Files.isSymbolicLink(start)) {
|
||||
try {
|
||||
start.toRealPath()
|
||||
} catch (_: IOException) {
|
||||
return out
|
||||
}
|
||||
} else start
|
||||
Files.walkFileTree(real, object : SimpleFileVisitor<Path>() {
|
||||
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||
if (attrs.isRegularFile && attrs.size() >= MIN_FILE_BYTES) out.add(file.toFile())
|
||||
return FileVisitResult.CONTINUE
|
||||
}
|
||||
|
||||
override fun visitFileFailed(file: Path, error: IOException): FileVisitResult = FileVisitResult.CONTINUE
|
||||
|
||||
override fun postVisitDirectory(dir: Path, error: IOException?): FileVisitResult = FileVisitResult.CONTINUE
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
private fun drop(file: File) {
|
||||
PageCacheNative.fadviseDontNeed(file.path)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.CpuFeatures
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.runtime.BwrapSpawner
|
||||
import com.droiddeck.launcher.runtime.DesktopCatalog
|
||||
@@ -23,10 +22,6 @@ object SessionFiles {
|
||||
private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad"
|
||||
const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio"
|
||||
private const val STAGED_LEDGER = "usr/local/.droiddeck-staged"
|
||||
internal const val LSE_EMU = "usr/local/lib/droiddeck-lse/liblse_emu.so"
|
||||
|
||||
internal fun lsePreload(lacksAtomics: Boolean, staged: Boolean, lseEmu: String? = null): String =
|
||||
if (lacksAtomics && staged && lseEmu != "0") "/$LSE_EMU\n" else ""
|
||||
private const val IME_MANIFEST = "usr/local/share/droiddeck/ime-files.json"
|
||||
private const val IME_DEFAULT_MODE = 420
|
||||
val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread")
|
||||
@@ -107,23 +102,10 @@ object SessionFiles {
|
||||
}
|
||||
|
||||
private val STAGE_LOCK = Any()
|
||||
@Volatile private var activeSessionLseEmu: String? = null
|
||||
|
||||
fun stage(context: Context, root: File, startsSession: Boolean = false) =
|
||||
stage(context, root, startsSession, lseEmu = null)
|
||||
fun stage(context: Context, root: File, startsSession: Boolean = false) = synchronized(STAGE_LOCK) { stageNow(context, root, startsSession) }
|
||||
|
||||
fun stage(context: Context, root: File, startsSession: Boolean, lseEmu: String?) =
|
||||
synchronized(STAGE_LOCK) {
|
||||
val selection = if (startsSession) {
|
||||
activeSessionLseEmu = lseEmu
|
||||
lseEmu
|
||||
} else {
|
||||
lseEmu ?: activeSessionLseEmu
|
||||
}
|
||||
stageNow(context, root, startsSession, selection)
|
||||
}
|
||||
|
||||
private fun stageNow(context: Context, root: File, startsSession: Boolean, lseEmu: String?) {
|
||||
private fun stageNow(context: Context, root: File, startsSession: Boolean) {
|
||||
if (DesktopCatalog.desktopInstalled(root) && !DesktopCatalog.desktopFromPack(root)) try { DesktopCatalog.cleanLegacy(context) }
|
||||
catch (e: Exception) { Log.w(TAG, "LXQt cleanup will retry next session", e) }
|
||||
GameEnvironmentStore.publish(context)
|
||||
@@ -277,6 +259,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" }
|
||||
@@ -299,8 +286,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",
|
||||
LSE_EMU to LSE_EMU,
|
||||
) + 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)
|
||||
}
|
||||
@@ -362,22 +348,20 @@ object SessionFiles {
|
||||
stageImeFiles(context, root, ledger)
|
||||
ledger.save()
|
||||
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
||||
val preload = StringBuilder(lsePreload(CpuFeatures.lacksAtomics, File(root, LSE_EMU).isFile, lseEmu))
|
||||
preload.append("/usr/local/lib/libddsession.so\n")
|
||||
val preload = StringBuilder("/usr/local/lib/libddsession.so\n")
|
||||
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
|
||||
preload.append("/usr/local/lib/libfakeinput.so\n")
|
||||
}
|
||||
com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root)
|
||||
val native = com.droiddeck.launcher.runtime.NativeGuest.available(root)
|
||||
val nativePreload = preload.toString()
|
||||
if (ProotFastPath.enabled(context, native)) {
|
||||
val nativeUserland = SessionPrefs.nativeUserland(context)
|
||||
if (nativeUserland) com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root)
|
||||
if (ProotFastPath.enabled(context)) {
|
||||
val library = com.droiddeck.launcher.agent.AgentEnv.fastPathLibrary(context)
|
||||
preload.append(library + "\n")
|
||||
if (startsSession && library != ProotFastPath.LIBRARY) Log.i(TAG, "fast path preload: $library (debugging override)")
|
||||
}
|
||||
val etc = File(root, "etc").apply { mkdirs() }
|
||||
File(etc, "droiddeck").mkdirs()
|
||||
FileUtils.writeString(File(etc, "droiddeck/native-preload"), nativePreload)
|
||||
FileUtils.writeString(File(etc, "droiddeck/native-preload"), preload.toString())
|
||||
val staged = File(etc, "ld.so.preload.staged")
|
||||
if (!FileUtils.writeString(staged, preload.toString())
|
||||
|| !staged.renameTo(File(etc, "ld.so.preload"))) {
|
||||
|
||||
@@ -1181,9 +1181,21 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("mountSharedStorage", on).apply()
|
||||
}
|
||||
|
||||
fun prootNoSeccomp(context: Context): Boolean = prefs(context).getBoolean("prootNoSeccomp", false)
|
||||
|
||||
fun setProotNoSeccomp(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("prootNoSeccomp", on).apply()
|
||||
}
|
||||
|
||||
fun nativeUserland(context: Context): Boolean = prefs(context).getBoolean("nativeUserland", true)
|
||||
|
||||
/** The session's long-lived programs run in worker processes Android does not count (GuestWorkers). */
|
||||
fun childProcessHandoff(context: Context): Boolean = prefs(context).getBoolean("childProcessHandoff", true)
|
||||
|
||||
fun setNativeUserland(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("nativeUserland", on).apply()
|
||||
}
|
||||
|
||||
/** Whether the Plasma desktop, and so its apps and shells, runs as an ordinary user instead of root (native userland only). */
|
||||
fun desktopAsUser(context: Context): Boolean = prefs(context).getBoolean("desktopAsUser", false)
|
||||
|
||||
@@ -1191,6 +1203,12 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("desktopAsUser", on).apply()
|
||||
}
|
||||
|
||||
fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true)
|
||||
|
||||
fun setProotFastPath(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("prootFastPath", on).apply()
|
||||
}
|
||||
|
||||
fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", true)
|
||||
|
||||
fun setCursorComposite(context: Context, on: Boolean) {
|
||||
|
||||
@@ -47,7 +47,6 @@ import com.droiddeck.launcher.input.SteamControllerBle
|
||||
import com.droiddeck.launcher.runtime.BwrapSpawner
|
||||
import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.runtime.NativeGuest
|
||||
import com.droiddeck.launcher.runtime.ProotFastPath
|
||||
import com.droiddeck.launcher.runtime.UserApps
|
||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
||||
@@ -567,7 +566,6 @@ class SessionService : Service() {
|
||||
.onFailure { Log.w(TAG, "agent environment skipped", it) }
|
||||
val agentEnvironment = nextAgentEnvironment.getOrDefault(emptyList())
|
||||
val customEnvironment = extraEnv()
|
||||
val lseEmu = (customEnvironment + agentEnvironment).lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=')
|
||||
try {
|
||||
if (systemVulkan) {
|
||||
SystemVulkanDriver.prepare(this)
|
||||
@@ -577,7 +575,7 @@ class SessionService : Service() {
|
||||
}
|
||||
pruneSystemVulkanRuntime()
|
||||
}
|
||||
SessionFiles.stage(this, root, startsSession = true, lseEmu = lseEmu)
|
||||
SessionFiles.stage(this, root, startsSession = true)
|
||||
} catch (error: Exception) {
|
||||
Log.e(TAG, "Could not prepare the session graphics runtime", error)
|
||||
failSession(gen, "GRAPHICS_RUNTIME_FAILED", getString(R.string.session_graphics_runtime_failed), -1)
|
||||
@@ -785,13 +783,12 @@ class SessionService : Service() {
|
||||
SessionEvents.step("shm-clear") { FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm")) }
|
||||
|
||||
val sharedStorage = LinuxRuntime.sharedStorage(this)
|
||||
val nativeUserland = NativeGuest.enabled(this)
|
||||
val fastPath = ProotFastPath.enabled(this, nativeUserland)
|
||||
val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage, fastPath)
|
||||
val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage)
|
||||
val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this)
|
||||
synchronized(stopLock) {
|
||||
if (gen == sessionGen && SessionState.running) com.droiddeck.launcher.runtime.NativeGuest.sessionMode = nativeUserland
|
||||
}
|
||||
val fastPathKey = if (fastPath) {
|
||||
val fastPathKey = if (ProotFastPath.enabled(this)) {
|
||||
val prootBinds = LinuxRuntime.binds(
|
||||
this, sessionRoot, runtimeDir, sharedStorage, binds,
|
||||
)
|
||||
@@ -812,14 +809,16 @@ class SessionService : Service() {
|
||||
LinuxRuntime.rememberSessionBinds(sessionBindSpecs)
|
||||
com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1))
|
||||
} else {
|
||||
val reason = if (NativeGuest.loader(root) == null) "missing glibc loader" else "missing native hook"
|
||||
Log.i(TAG, "guest runtime: using PRoot ($reason)")
|
||||
LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, guest)
|
||||
}
|
||||
|
||||
val prootEnv = HostEnvironment()
|
||||
prootEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path
|
||||
prootEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path
|
||||
if (SessionPrefs.prootNoSeccomp(this)) {
|
||||
prootEnv["PROOT_NO_SECCOMP"] = "1"
|
||||
if (!nativeUserland) Log.i(TAG, "proot: seccomp acceleration off by request")
|
||||
}
|
||||
fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> prootEnv[k] = v } }
|
||||
for (key in listOf("PROOT_PROFILE", "PROOT_PROFILE_SLOW_US")) {
|
||||
guest.lastOrNull { it.startsWith("$key=") }?.substringAfter('=')?.let { prootEnv[key] = it }
|
||||
@@ -831,7 +830,7 @@ class SessionService : Service() {
|
||||
if (drives > 0) Log.i(TAG, "$drives Wine drive links given their guest paths back")
|
||||
val hostEnv = if (nativeUserland) HostEnvironment().also { env ->
|
||||
Log.i(TAG, "native userland: no proot (${sessionBindSpecs.size} mounts)")
|
||||
com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this), lseEmu)
|
||||
com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this))
|
||||
.forEach { (k, v) -> env[k] = v }
|
||||
} else prootEnv
|
||||
|
||||
@@ -1138,6 +1137,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)) }
|
||||
@@ -1313,7 +1314,6 @@ class SessionService : Service() {
|
||||
sessionRoot: File,
|
||||
runtimeDir: File,
|
||||
sharedStorage: File?,
|
||||
fastPath: Boolean,
|
||||
): ArrayList<String> {
|
||||
val binds = ArrayList<String>()
|
||||
if (controllersOn) binds.add(fakeInputDir.path + ":/dev/input")
|
||||
@@ -1447,7 +1447,7 @@ class SessionService : Service() {
|
||||
if (storageDiagnosticLibrary != null && library != null) libraries.add(SecondaryLibrary.CARD_GUESTS[0] to library.label)
|
||||
val gamesLibraries = GameStorage.gamesFolderLibraries(this)
|
||||
if (gamesLibraries.isNotEmpty()) {
|
||||
var room = if (fastPath) {
|
||||
var room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size
|
||||
} else Int.MAX_VALUE
|
||||
for (games in gamesLibraries) {
|
||||
@@ -1489,7 +1489,7 @@ class SessionService : Service() {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
val room = if (fastPath) {
|
||||
val room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size
|
||||
} else Int.MAX_VALUE
|
||||
val content = SecondaryLibrary.contentPath(entry.host)
|
||||
@@ -1518,7 +1518,7 @@ class SessionService : Service() {
|
||||
if (problem != null) {
|
||||
Log.w(TAG, "x86-64 steam library: $problem")
|
||||
} else try {
|
||||
val room = if (fastPath) {
|
||||
val room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size
|
||||
} else Int.MAX_VALUE
|
||||
val extra = SecondaryLibrary.binds(filesDir, x64, listOf(GameStorage.X64_CARD_GUEST)).drop(1)
|
||||
@@ -1540,7 +1540,7 @@ class SessionService : Service() {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
val room = if (fastPath) {
|
||||
val room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size
|
||||
} else Int.MAX_VALUE
|
||||
val extra = SecondaryLibrary.binds(filesDir, entry.x64Host, listOf(entry.x64Guest)).drop(1)
|
||||
@@ -1576,7 +1576,7 @@ class SessionService : Service() {
|
||||
try {
|
||||
val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() }
|
||||
val volumes = org.json.JSONArray()
|
||||
var room = if (fastPath) {
|
||||
var room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size
|
||||
} else Int.MAX_VALUE
|
||||
for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) {
|
||||
|
||||
@@ -0,0 +1,444 @@
|
||||
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 = "71c140d9e5586f659251c3ebc602f2d21923655c"
|
||||
const val XESS_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 commit: String = UPSTREAM_COMMIT,
|
||||
) {
|
||||
val url get() = "https://raw.githubusercontent.com/$UPSTREAM/$commit/$upstreamPath"
|
||||
}
|
||||
|
||||
val FILES = listOf(
|
||||
DataFile(Group.CORE, "fsr4/fsr3_accumulate.spv", "app/src/main/assets/fsr4/fsr3_accumulate.spv", "98054410f4d3b6fad3020b174982a5e68d2fc5a4d546a90f9e13ea646b32c180", 23840L),
|
||||
DataFile(Group.CORE, "fsr4/fsr3_prepare.spv", "app/src/main/assets/fsr4/fsr3_prepare.spv", "86e99b0e7e83e74729b016c3089deafdc9c2dc09b27305d009a8942dd0fe19da", 15036L),
|
||||
DataFile(Group.CORE, "fsr4/fsr3_rcas.spv", "app/src/main/assets/fsr4/fsr3_rcas.spv", "13e276049ecc18eb7b53f6de1f76f58eb1a60c6f4251870f3647b20478b05710", 11644L),
|
||||
DataFile(Group.CORE, "fsr4/fsr411_full/performance/fsr411_full_zc_i8.wpack", "app/src/main/assets/fsr4/fsr411_full/performance/fsr411_full_zc_i8.wpack", "8d36bb959d23ede5bb409959736c0d0b718bae58b363779126c0235b0fd10f7c", 137424L),
|
||||
DataFile(Group.CORE, "fsr4/fsr411_full/performance/fsr411_full_zc_s8.wpack", "app/src/main/assets/fsr4/fsr411_full/performance/fsr411_full_zc_s8.wpack", "ef445437e3d48c64f993a60407183f675d05aadd82c7c29b93e61c53308ab28e", 137256L),
|
||||
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", "ff1270ab046cd190e9edf0d76cc5d5fda34a27a2de719e8352b4dcaeeed3e3bb", 3456L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0002.spv", "app/src/main/assets/fsr4/fsr412_lite/0002.spv", "c47c6282830916e9314f0153c4abd782736b6cee3992e8db301937b42ec44141", 120964L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0003.spv", "app/src/main/assets/fsr4/fsr412_lite/0003.spv", "0797d2053df579930c2907a3f1e91c8a39c44cae4e471eca4c243075a787d572", 3492L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0004.spv", "app/src/main/assets/fsr4/fsr412_lite/0004.spv", "e7d3651fb730c8b543aaae332f760d352d555e3f8e5899c055b46fc007c80bbc", 3928L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0005.spv", "app/src/main/assets/fsr4/fsr412_lite/0005.spv", "0bacdbf39bead28f5012ca09a6d8243e501b3328065e29c2b5bdfc93f5ae3ffa", 201880L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0006.spv", "app/src/main/assets/fsr4/fsr412_lite/0006.spv", "f58da749701f226994560878cad3b98f01db0557feea4d9445ae84ed6b2049a2", 3892L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0007.spv", "app/src/main/assets/fsr4/fsr412_lite/0007.spv", "c8088556c624f601cb9adf280ba0a4b6fa54068c1f60a0ebc26c11dad81a44c3", 279304L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0008.spv", "app/src/main/assets/fsr4/fsr412_lite/0008.spv", "9e5f48d397020f1fd8706f554adce0adb88641cd06dd054252f1f2f58f1566e5", 3508L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/0009.spv", "app/src/main/assets/fsr4/fsr412_lite/0009.spv", "23cc6f3c09546cbca7c70130de931324f9262d13a5f894ebedac78d0e94ef43f", 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", "05bbe60c6a0310044df99f2e7fe6af0b6644780305c98bc6fd6287de7b954cf0", 57232L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/fsr412_lite_zc_i8.wpack", "app/src/main/assets/fsr4/fsr412_lite/fsr412_lite_zc_i8.wpack", "5a00ff5e9a444708ce66b17a12fa8ffc2a3bdbd798399a0d26807de121ab2140", 27440L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/fsr412_lite_zc_s8.wpack", "app/src/main/assets/fsr4/fsr412_lite/fsr412_lite_zc_s8.wpack", "f45ab49039ad27041ebc6edd76de54d14246693445e53362d94b4a9514ae65a7", 27272L),
|
||||
DataFile(Group.CORE, "fsr4/fsr412_lite/weights.bin", "app/src/main/assets/fsr4/fsr412_lite/weights.bin", "4b9898da719dc2dca5dc45fd71dec5f80bdb9886a580fe3038af59efe637d55e", 27392L),
|
||||
DataFile(Group.CORE, "fsr4/sgsr2_activate.spv", "app/src/main/assets/fsr4/sgsr2_activate.spv", "45aabce377d4cc9522ea9d954d9f069e1618ac0c9656ef2be6fd317369ae3140", 13456L),
|
||||
DataFile(Group.CORE, "fsr4/sgsr2_convert.spv", "app/src/main/assets/fsr4/sgsr2_convert.spv", "71afffb95978f0dc61d3f39f266eb61e5c803b17574a3595726e4c55bb581872", 14600L),
|
||||
DataFile(Group.CORE, "fsr4/sgsr2_upscale.spv", "app/src/main/assets/fsr4/sgsr2_upscale.spv", "bf7fe1247894919349fef91f8fa41ee256cb58dd7cf87f682db43108f9dcd1ec", 29748L),
|
||||
// Upstream dropped Intel's XeSS runtime in cb3ae04e (v5.0-r2); DroidDeck keeps fetching it from a0ab6b0f.
|
||||
DataFile(Group.XESS, "xess/wl_xess_official.dll", "app/src/main/assets/fsr4_bridge/wl_xess_official.dll", "251659dd84a3e84de67c886a4186e01f3eca49b00641906fe38bb6b807e5d5b7", 77795704L, XESS_COMMIT),
|
||||
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),
|
||||
)
|
||||
|
||||
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>(State.Missing)
|
||||
val state: StateFlow<State> = 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 NPU this phone has: its Hexagon HTP generation and whether its own QNN libraries run it. */
|
||||
data class Npu(val arch: String, val systemLibs: Boolean)
|
||||
|
||||
private val SYSTEM_QNN = listOf("libQnnHtp.so", "libQnnHtpPrepare.so", "libQnnSystem.so")
|
||||
private val SYSTEM_STUB = Regex("libQnnHtpV(\\d{2,3})Stub\\.so")
|
||||
|
||||
/**
|
||||
* The HTP generation of the phone's own QNN runtime, when the vendor offers it to apps (listed in
|
||||
* public.libraries.txt): named by its one libQnnHtpV<NN>Stub.so. Null when absent or ambiguous.
|
||||
*/
|
||||
internal fun systemNpuArch(libDir: File = File("/vendor/lib64"), publicList: File = File("/vendor/etc/public.libraries.txt")): String? {
|
||||
val listed = runCatching {
|
||||
publicList.readLines().map { it.trim() }.filter { it.isNotEmpty() && !it.startsWith("#") }.map { it.substringBefore(' ') }.toSet()
|
||||
}.getOrNull() ?: return null
|
||||
if (!SYSTEM_QNN.all { it in listed && File(libDir, it).isFile }) return null
|
||||
val archs = libDir.list().orEmpty().filter { it in listed }.mapNotNull { SYSTEM_STUB.matchEntire(it)?.groupValues?.get(1) }.distinct()
|
||||
return archs.singleOrNull()?.let { "v$it" }
|
||||
}
|
||||
|
||||
private val systemNpu: String? by lazy { runCatching { systemNpuArch() }.getOrNull() }
|
||||
|
||||
/**
|
||||
* This phone's NPU, or null. The phone's own QNN runtime first (any HTP generation, nothing to download);
|
||||
* else the bundled QNN files: v79 on the Snapdragon 8 Elite, v81 on the 8 Elite Gen 5.
|
||||
*/
|
||||
fun npu(model: String = SocNames.model()): Npu? {
|
||||
systemNpu?.let { return Npu(it, systemLibs = true) }
|
||||
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 Npu(arch, systemLibs = false).takeIf { fastrpc }
|
||||
}
|
||||
|
||||
fun npuArch(model: String = SocNames.model()): String? = npu(model)?.arch
|
||||
|
||||
fun groups(engine: GameUpscaler.Engine, npu: Boolean = npuArch() != null): Set<Group> = buildSet {
|
||||
add(Group.CORE)
|
||||
if (engine == GameUpscaler.Engine.XESS) add(Group.XESS)
|
||||
if (engine.npu && npu && UpscaleComponent.npu()?.systemLibs != true) add(Group.NPU)
|
||||
}
|
||||
|
||||
/** The bridge DLLs (tools/upscale/bridges/build.sh), each in both Wine PE folders. */
|
||||
private val BRIDGE_NAMES = listOf(
|
||||
"_nvngx.dll", "amd_fidelityfx_dx12.dll", "amd_fidelityfx_loader_dx12.dll", "amd_fidelityfx_upscaler_dx12.dll",
|
||||
"amd_fidelityfx_upscaler_vk.dll", "amd_fidelityfx_vk.dll", "ffx_fsr2_api_x64.dll", "ffx_fsr3upscaler_x64.dll",
|
||||
"libxess.dll", "nvapi64.dll", "nvngx.dll", "nvngx_dlss.dll",
|
||||
)
|
||||
internal val BRIDGE_FILES = listOf("x86_64-windows", "aarch64-windows").flatMap { arch -> BRIDGE_NAMES.map { "$arch/$it" } }
|
||||
|
||||
fun filesReady(context: Context, groups: Set<Group>): 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 =
|
||||
BRIDGE_FILES.all { File(bridgesDir(context), it).let { f -> f.isFile && f.length() > 0 } }
|
||||
|
||||
/** Everything a game with [groups] needs: the data files and the bridge DLLs. */
|
||||
fun ready(context: Context, groups: Set<Group>): Boolean = filesReady(context, groups) && bridgesReady(context)
|
||||
|
||||
/** Fetches what [groups] still lack (data files, then the bridge DLLs) in the background. */
|
||||
fun ensure(context: Context, groups: Set<Group>, onDone: (Boolean) -> Unit = {}) {
|
||||
val app = context.applicationContext
|
||||
if (ready(app, groups)) {
|
||||
mutableState.value = State.Ready
|
||||
onDone(true)
|
||||
return
|
||||
}
|
||||
synchronized(lock) {
|
||||
if (busy) return
|
||||
busy = true
|
||||
}
|
||||
Thread({
|
||||
val ok = try {
|
||||
val files = filesReady(app, groups) || download(app, groups)
|
||||
// Staged DLLs are refreshed when the pack or local copy changed; a download only when none are staged.
|
||||
val bridges = files && (if (bridgesReady(app)) stageBridges(app) else fetchBridges(app))
|
||||
when {
|
||||
bridges -> mutableState.value = State.Ready
|
||||
files -> mutableState.value = State.Failed("upscaler DLLs not installed")
|
||||
}
|
||||
bridges
|
||||
} 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<Group>): 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(context, 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))
|
||||
}
|
||||
Log.i(TAG, "upscaler files ready (${wanted.size} files, groups $groups)")
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Folders that may hold a local copy (same layout as the upstream tree): the app's own external
|
||||
* files folders, readable without any storage permission, then Download/droiddeck-upscale.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
private fun localRoots(context: Context): List<File> =
|
||||
context.getExternalFilesDirs(null).orEmpty().filterNotNull().map { File(it, LOCAL_COPY) } +
|
||||
File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY")
|
||||
|
||||
/** A local copy of [f] (see [localRoots]), used when its SHA-256 matches. */
|
||||
private fun copyLocal(context: Context, f: DataFile, part: File): Boolean = localRoots(context).any { root ->
|
||||
runCatching {
|
||||
val local = File(root, f.relative)
|
||||
if (!local.isFile || !local.canRead() || local.length() != f.size || sha256(local) != f.sha256) return@runCatching 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) }
|
||||
}
|
||||
|
||||
/** The add-on pack's bridges/ (fetched now when there is no local copy), staged into the rootfs. */
|
||||
private fun fetchBridges(context: Context): Boolean {
|
||||
val pack = AddonPack.UPSCALE
|
||||
if (!pack.installed(context) && localBridges(context) == null && pack.available) pack.await(context)
|
||||
return stageBridges(context)
|
||||
}
|
||||
|
||||
/** Content hash of a local bridges/ tree: CI builds every DLL with the same date, and sizes often stay the same. */
|
||||
internal fun localVersion(source: File): String {
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
for (name in BRIDGE_FILES) {
|
||||
digest.update(name.toByteArray())
|
||||
digest.update(sha256(File(source, name)).toByteArray())
|
||||
}
|
||||
return digest.digest().take(8).joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** A complete, readable bridges/ tree in one of [localRoots]: builds without a published pack. */
|
||||
private fun localBridges(context: Context): File? = localRoots(context).map { File(it, "bridges") }.firstOrNull { dir ->
|
||||
runCatching { BRIDGE_FILES.all { File(dir, it).let { f -> f.isFile && f.canRead() && f.length() > 0 } } }.getOrDefault(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the bridge DLLs from the add-on pack (or the local tree) into the rootfs, once per version. True only
|
||||
* when every one of [BRIDGE_FILES] is in place afterwards.
|
||||
*/
|
||||
@Synchronized
|
||||
fun stageBridges(context: Context): Boolean {
|
||||
val packDir = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context)
|
||||
val pack = packDir?.let { File(it, "bridges") }
|
||||
val source = pack?.takeIf { dir -> BRIDGE_FILES.all { File(dir, it).isFile } } ?: localBridges(context)
|
||||
if (source == null) {
|
||||
val ready = bridgesReady(context)
|
||||
if (!ready) Log.w(TAG, "upscaler bridges: no add-on pack and no readable local copy")
|
||||
return ready
|
||||
}
|
||||
val version = if (packDir != null && source == pack) packDir.name else "local-" + localVersion(source)
|
||||
val target = bridgesDir(context)
|
||||
val stamp = File(target, BRIDGES_STAMP)
|
||||
if (bridgesReady(context) && runCatching { stamp.readText() }.getOrNull() == version) return true
|
||||
var copied = 0
|
||||
for (name in BRIDGE_FILES) {
|
||||
val from = File(source, name)
|
||||
val out = File(target, name)
|
||||
out.parentFile?.mkdirs()
|
||||
val staged = File(out.path + ".staged")
|
||||
val ok = runCatching {
|
||||
from.inputStream().use { input -> staged.outputStream().use { output -> input.copyTo(output) } }
|
||||
staged.length() == from.length() && staged.renameTo(out)
|
||||
}.getOrDefault(false)
|
||||
staged.delete()
|
||||
if (ok) copied++ else Log.w(TAG, "upscaler bridge $name not staged from $source")
|
||||
}
|
||||
val ok = copied == BRIDGE_FILES.size && bridgesReady(context)
|
||||
if (ok) runCatching { stamp.writeText(version) }
|
||||
Log.i(TAG, "upscaler bridges staged from $version: $copied/${BRIDGE_FILES.size} files")
|
||||
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 its HTP generation), and the bionic layer's manifest folder. */
|
||||
fun guestEnv(context: Context): List<String> {
|
||||
runCatching { runDir(context).mkdirs() }
|
||||
val here = npu()
|
||||
return listOfNotNull(
|
||||
"DROIDDECK_UPSCALE_NPU=" + (if (here != null) "1" else "0"),
|
||||
here?.let { "DROIDDECK_UPSCALE_HTP_ARCH=${it.arch}" },
|
||||
"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
|
||||
// Runs on the session-start thread, before the game copies the DLLs: ensure() returns at once when DLLs are
|
||||
// staged, so a newer pack or local copy is staged here.
|
||||
if (bridgesReady(context)) runCatching { stageBridges(context) }.onFailure { Log.w(TAG, "upscaler DLLs not refreshed", it) }
|
||||
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 }
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.core.AddonPack
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.SessionEvents
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.AchievementNotifications
|
||||
@@ -148,6 +149,7 @@ object GogComet {
|
||||
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path)
|
||||
if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1")
|
||||
LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.droiddeck.launcher.core.AddonPack
|
||||
import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.runtime.ProotFastPath
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import org.json.JSONObject
|
||||
import java.io.Closeable
|
||||
@@ -106,6 +107,7 @@ internal object Xodus {
|
||||
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path)
|
||||
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path)
|
||||
if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1")
|
||||
fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } }
|
||||
LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
}
|
||||
if (!a.hudOn) return@SettingsGroup
|
||||
val size = DroidDeckHudSize.from(cfg["hudSize"])
|
||||
ChoiceRow(host, "hud-size", stringResource(R.string.hud_size),
|
||||
stringResource(if (size == DroidDeckHudSize.SIDE_STRIP) R.string.hud_size_side_strip_hint else R.string.hud_size_hint),
|
||||
ChoiceRow(host, "hud-size", stringResource(R.string.hud_size), stringResource(R.string.hud_size_hint),
|
||||
listOf(
|
||||
DroidDeckHudSize.FULL to stringResource(R.string.hud_size_full),
|
||||
DroidDeckHudSize.TILES to stringResource(R.string.hud_size_tiles),
|
||||
@@ -48,7 +47,6 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
DroidDeckHudSize.MINIMAL to stringResource(R.string.hud_size_minimal),
|
||||
DroidDeckHudSize.MEGA to stringResource(R.string.hud_size_mega),
|
||||
DroidDeckHudSize.STRIP to stringResource(R.string.hud_size_strip),
|
||||
DroidDeckHudSize.SIDE_STRIP to stringResource(R.string.hud_size_side_strip),
|
||||
),
|
||||
size, chipModifier = track("hud-size")) { a.onHudSetting("hudSize", it.token) }
|
||||
ChoiceRow(host, "hud-hold", stringResource(R.string.hud_hold), null,
|
||||
@@ -213,6 +211,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),
|
||||
)
|
||||
|
||||
@@ -1134,6 +1134,39 @@ 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.SGSR2 to stringResource(R.string.game_upscaler_engine_sgsr2),
|
||||
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) {
|
||||
@@ -1165,6 +1198,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)) {
|
||||
@@ -1181,6 +1245,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 ->
|
||||
|
||||
@@ -67,18 +67,8 @@ internal fun InputElementProperties(element: InputSurfaceElement, action: InputA
|
||||
}
|
||||
if (element.kind == InputElementKind.STICK) {
|
||||
val host = rememberMenuHost()
|
||||
val adaptive = element.adaptiveCapture ?: element.adaptiveStick
|
||||
ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) {
|
||||
onChange(element.copy(floating = it, hideWhenIdle = element.hideStickAtRest, adaptiveCapture = adaptive))
|
||||
}
|
||||
if (element.floating) {
|
||||
ToggleRow(host, "element-adaptive-capture", stringResource(R.string.input_adaptive_capture), null, element.adaptiveStick) {
|
||||
onChange(element.copy(hideWhenIdle = element.hideStickAtRest, adaptiveCapture = it))
|
||||
}
|
||||
}
|
||||
ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideStickAtRest) {
|
||||
onChange(element.copy(hideWhenIdle = it, adaptiveCapture = adaptive))
|
||||
}
|
||||
ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) { onChange(element.copy(floating = it)) }
|
||||
ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideWhenIdle) { onChange(element.copy(hideWhenIdle = it)) }
|
||||
}
|
||||
val host = rememberMenuHost()
|
||||
if ((element.kind == InputElementKind.BUTTON || element.kind == InputElementKind.TRIGGER) && element.icon == 0 && element.image.isEmpty() ||
|
||||
|
||||
@@ -236,11 +236,11 @@ class InputSurfaceView(
|
||||
super.dispatchDraw(canvas)
|
||||
}
|
||||
}
|
||||
canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || it.adaptiveStick) }
|
||||
canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || adaptive(it)) }
|
||||
for (element in customLayout) {
|
||||
val source = pad?.let { InputSurfaceSource(it, inputRole, element).also { s -> elementSources += s } }
|
||||
canvas.addView(when (element.kind) {
|
||||
InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideStickAtRest && pad != null)
|
||||
InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideWhenIdle && pad != null)
|
||||
InputElementKind.TRACKPAD -> TrackpadView(context, element.control == InputControl.RIGHT_PAD, captioned = element.showLabel,
|
||||
stock = element.id == "legacy:${element.control.id}", source = source)
|
||||
InputElementKind.DPAD -> DirectionPad(context, element, source)
|
||||
@@ -641,7 +641,7 @@ class InputSurfaceView(
|
||||
private val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE }
|
||||
private val knob = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
|
||||
val adaptive get() = element.adaptiveStick
|
||||
val adaptive get() = adaptive(element)
|
||||
|
||||
fun reach() = min(width, height) * if (classic(element)) CLASSIC_REACH else PANEL_REACH
|
||||
|
||||
@@ -859,6 +859,8 @@ class InputSurfaceView(
|
||||
private val TEXT_DIM = Color.rgb(0x7A, 0x80, 0x8A)
|
||||
private val KNOB = Color.rgb(0x2A, 0x2D, 0x33)
|
||||
|
||||
private fun adaptive(element: InputSurfaceElement) = element.kind == InputElementKind.STICK && element.floating && element.hideWhenIdle
|
||||
|
||||
private fun classic(element: InputSurfaceElement) = (element.id == "legacy:${element.control.id}" || element.id == "builtin:keyboard") &&
|
||||
(element.buttonShape == InputButtonShape.CIRCLE || element.buttonShape == InputButtonShape.PILL)
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ fun PerformancePage(
|
||||
fsyncFirst: Boolean,
|
||||
gamescopeRealtime: Boolean,
|
||||
gpuClockPin: Boolean,
|
||||
nativeDesktopAvailable: Boolean,
|
||||
prootNoSeccomp: Boolean,
|
||||
prootFastPath: Boolean,
|
||||
nativeUserland: Boolean,
|
||||
desktopAsUser: Boolean,
|
||||
cursorComposite: Boolean,
|
||||
guestHostname: String,
|
||||
@@ -63,6 +65,9 @@ fun PerformancePage(
|
||||
onFsyncFirst: (Boolean) -> Unit,
|
||||
onGamescopeRealtime: (Boolean) -> Unit,
|
||||
onGpuClockPin: (Boolean) -> Unit,
|
||||
onProotNoSeccomp: (Boolean) -> Unit,
|
||||
onProotFastPath: (Boolean) -> Unit,
|
||||
onNativeUserland: (Boolean) -> Unit,
|
||||
onDesktopAsUser: (Boolean) -> Unit,
|
||||
onCursorComposite: (Boolean) -> Unit,
|
||||
onGuestHostname: (String) -> Unit,
|
||||
@@ -147,6 +152,26 @@ fun PerformancePage(
|
||||
stringResource(R.string.perf_fastsync_hint),
|
||||
fastSync, onChange = onFastSync,
|
||||
)
|
||||
ToggleRow(
|
||||
host, "seccomp", stringResource(R.string.perf_seccomp),
|
||||
stringResource(R.string.perf_seccomp_hint),
|
||||
prootNoSeccomp, onChange = onProotNoSeccomp,
|
||||
)
|
||||
ToggleRow(
|
||||
host, "fastpath", stringResource(R.string.perf_fastpath),
|
||||
when {
|
||||
nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot)
|
||||
prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp)
|
||||
else -> stringResource(R.string.perf_fastpath_hint)
|
||||
},
|
||||
prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland,
|
||||
onChange = onProotFastPath,
|
||||
)
|
||||
ToggleRow(
|
||||
host, "nativeuserland", stringResource(R.string.perf_native_userland),
|
||||
stringResource(R.string.perf_native_userland_hint),
|
||||
nativeUserland, onChange = onNativeUserland,
|
||||
)
|
||||
ToggleRow(
|
||||
host, "cursorcomposite", stringResource(R.string.perf_cursor_composite),
|
||||
stringResource(R.string.perf_cursor_composite_hint),
|
||||
@@ -173,8 +198,8 @@ fun PerformancePage(
|
||||
}
|
||||
ToggleRow(
|
||||
host, "desktopasuser", stringResource(R.string.perf_desktop_as_user),
|
||||
stringResource(R.string.perf_desktop_as_user_hint),
|
||||
desktopAsUser && nativeDesktopAvailable, enabled = nativeDesktopAvailable,
|
||||
stringResource(if (nativeUserland) R.string.perf_desktop_as_user_hint else R.string.perf_desktop_as_user_needs_native),
|
||||
desktopAsUser && nativeUserland, enabled = nativeUserland,
|
||||
onChange = onDesktopAsUser,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1113,6 +1113,7 @@ private fun DrawerGamePage(host: MenuHost, a: DrawerActions, track: (String) ->
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp))
|
||||
}
|
||||
TextureFilteringGroup(host, a, track)
|
||||
if (a.steam || a.direct) DrawerUpscalerGroup(host, a, track)
|
||||
ComponentsDrawerPage(host, a, track)
|
||||
ComponentDownloadsDrawerGroup(
|
||||
host = host,
|
||||
@@ -1917,6 +1918,52 @@ 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<com.droiddeck.launcher.core.GameUpscaler.Status?>(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.SGSR2 -> R.string.game_upscaler_engine_sgsr2
|
||||
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
|
||||
|
||||
@@ -85,6 +85,9 @@ internal object SettingsIndex {
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_esync, "esync", "sync", "wine"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_fsync, "fsync", "sync", "wine"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_fastsync, "ntsync", "sync", "wine"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_seccomp, "proot"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_fastpath, "proot"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_native_userland, "proot"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_cursor_composite, "mouse", "cursor"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_hostname, "name"),
|
||||
s(SettingsSection.PERFORMANCE, R.string.perf_desktop_as_user, "root", "user", "sudo", "fakeroot"),
|
||||
|
||||
@@ -14,7 +14,6 @@ import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
@@ -89,7 +88,7 @@ object Themes {
|
||||
var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED)
|
||||
private set
|
||||
|
||||
@Volatile var rgbHue = 0f
|
||||
var rgbHue by mutableStateOf(0f)
|
||||
private set
|
||||
|
||||
fun moveRgbHue(hue: Float) {
|
||||
@@ -238,36 +237,8 @@ fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCA
|
||||
val context = LocalContext.current
|
||||
remember(context) { Themes.loadGradient(context) }
|
||||
val id = theme ?: SessionPrefs.theme(context)
|
||||
val solid = if (id == Themes.INNER_GAMER) {
|
||||
rememberInnerGamerPalette(Themes.rgbSpeed)
|
||||
} else {
|
||||
Themes.byId(id)
|
||||
}
|
||||
DroidDeckThemePalette(solid, appScale, frost, content)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun rememberInnerGamerPalette(speed: Int): Palette = key(speed) {
|
||||
val start = remember { Themes.rgbHue }
|
||||
val animatedHue by rememberInfiniteTransition(label = "innerGamer").animateFloat(
|
||||
start, start + 360f,
|
||||
infiniteRepeatable(
|
||||
tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing),
|
||||
RepeatMode.Restart,
|
||||
),
|
||||
label = "hue",
|
||||
)
|
||||
val steppedHue by remember {
|
||||
derivedStateOf {
|
||||
((animatedHue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP
|
||||
}
|
||||
}
|
||||
SideEffect { Themes.moveRgbHue(steppedHue) }
|
||||
Themes.innerGamer(steppedHue)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DroidDeckThemePalette(solid: Palette, appScale: Int, frost: FrostChoice?, content: @Composable () -> Unit) {
|
||||
if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed)
|
||||
val solid = Themes.byId(id)
|
||||
val look = frost?.let { frostLook(solid, it) }
|
||||
val p = if (look == null) solid else solid.frosted(look)
|
||||
val baseDensity = LocalDensity.current
|
||||
@@ -315,3 +286,17 @@ private val ContentDirected = Typography().run {
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InnerGamerHue(speed: Int) {
|
||||
key(speed) { InnerGamerCycle(speed) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InnerGamerCycle(speed: Int) {
|
||||
val start = remember { Themes.rgbHue }
|
||||
val hue by rememberInfiniteTransition(label = "innerGamer").animateFloat(
|
||||
start, start + 360f, infiniteRepeatable(tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing), RepeatMode.Restart), label = "hue",
|
||||
)
|
||||
val stepped = ((hue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP
|
||||
SideEffect { Themes.moveRgbHue(stepped) }
|
||||
}
|
||||
@@ -74,7 +74,6 @@
|
||||
<string name="input_keep_shared">Keep shared</string>
|
||||
<string name="input_independent_copy">Independent copy</string>
|
||||
<string name="input_floating_stick">Start stick at touch position</string>
|
||||
<string name="input_adaptive_capture">Adaptive touch area</string>
|
||||
<string name="input_hide_idle">Hide stick when not in use</string>
|
||||
<string name="input_tools">Tools</string>
|
||||
<string name="input_quick_auto">Auto (%1$s)</string>
|
||||
|
||||
@@ -541,6 +541,28 @@
|
||||
<string name="game_steam_with">Starts with Steam</string>
|
||||
<string name="game_steam_without">Starts without Steam</string>
|
||||
<string name="game_res_title">Game resolution</string>
|
||||
<string name="game_upscaler_title">In-game upscaler</string>
|
||||
<string name="game_upscaler_off">Off</string>
|
||||
<string name="game_upscaler_mode_fsr">FSR and XeSS games</string>
|
||||
<string name="game_upscaler_mode_dlss">DLSS games</string>
|
||||
<string name="game_upscaler_mode_native">Native FSR 4</string>
|
||||
<string name="game_upscaler_engine">Upscaler</string>
|
||||
<string name="game_upscaler_engine_fsr4_lite">FSR 4 Lite</string>
|
||||
<string name="game_upscaler_engine_fsr4_full">FSR 4</string>
|
||||
<string name="game_upscaler_engine_xess">XeSS 3</string>
|
||||
<string name="game_upscaler_engine_basic">Basic temporal</string>
|
||||
<string name="game_upscaler_engine_sgsr2">Snapdragon GSR 2</string>
|
||||
<string name="game_upscaler_engine_fsr4_npu">FSR 4 on NPU</string>
|
||||
<string name="game_upscaler_engine_fsr4_lite_npu">FSR 4 Lite on NPU</string>
|
||||
<string name="game_upscaler_sharpness">Sharpness</string>
|
||||
<string name="game_upscaler_sharpness_value">%1$d%%</string>
|
||||
<string name="game_upscaler_sigfix">DLSS signature fix</string>
|
||||
<string name="game_upscaler_npu_sync">NPU sync</string>
|
||||
<string name="game_upscaler_files">Upscaler files</string>
|
||||
<string name="game_upscaler_files_ready">Ready</string>
|
||||
<string name="game_upscaler_files_missing">Not downloaded</string>
|
||||
<string name="game_upscaler_files_downloading">Downloading %1$d%%</string>
|
||||
<string name="game_upscaler_files_failed">Failed: %1$s</string>
|
||||
<string name="game_settings_card">Settings</string>
|
||||
<string name="game_settings_menu_title">%1$s Settings</string>
|
||||
<string name="game_settings_default">Default</string>
|
||||
@@ -737,8 +759,6 @@
|
||||
<string name="hud_size_minimal">Minimal</string>
|
||||
<string name="hud_size_mega">Mega</string>
|
||||
<string name="hud_size_strip">Strip</string>
|
||||
<string name="hud_size_side_strip">Side strip</string>
|
||||
<string name="hud_size_side_strip_hint">Drag the column to either side of the game. Tap the HUD to cycle sizes.</string>
|
||||
<string name="hud_locked">Lock in place</string>
|
||||
<string name="hud_locked_hint">Drag the HUD to move it. While it is locked, on-screen controls under it still work.</string>
|
||||
<string name="hud_hold">Long press</string>
|
||||
@@ -777,6 +797,7 @@
|
||||
<string name="hud_metric_network">Network</string>
|
||||
<string name="hud_metric_resolution">Resolution</string>
|
||||
<string name="hud_metric_proton">Proton version</string>
|
||||
<string name="hud_metric_upscale">In-game upscaler</string>
|
||||
<string name="hud_metric_session">Session time</string>
|
||||
<string name="hud_metric_clock">Clock</string>
|
||||
<string name="hud_group_temps">Temperatures</string>
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import com.droiddeck.launcher.session.SessionFiles
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class CpuFeaturesTest {
|
||||
@Test fun anArmv80CpuLacksAtomics() {
|
||||
val cpuInfo = """
|
||||
processor : 0
|
||||
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
|
||||
processor : 1
|
||||
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
|
||||
""".trimIndent()
|
||||
assertTrue(CpuFeatures.lacksAtomics(cpuInfo))
|
||||
}
|
||||
|
||||
@Test fun oneCoreWithoutAtomicsIsEnough() {
|
||||
val cpuInfo = """
|
||||
processor : 0
|
||||
Features : fp asimd atomics
|
||||
processor : 4
|
||||
Features : fp asimd
|
||||
""".trimIndent()
|
||||
assertTrue(CpuFeatures.lacksAtomics(cpuInfo))
|
||||
}
|
||||
|
||||
@Test fun anArmv82CpuHasAtomics() {
|
||||
val cpuInfo = """
|
||||
processor : 0
|
||||
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
|
||||
""".trimIndent()
|
||||
assertFalse(CpuFeatures.lacksAtomics(cpuInfo))
|
||||
}
|
||||
|
||||
@Test fun noFeatureLinesMeansNoEmulation() {
|
||||
assertFalse(CpuFeatures.lacksAtomics("processor : 0\n"))
|
||||
assertFalse(CpuFeatures.lacksAtomics(""))
|
||||
}
|
||||
|
||||
@Test fun theEmulatorIsPreloadedFirstOnlyWhenNeededAndStaged() {
|
||||
assertEquals("/usr/local/lib/droiddeck-lse/liblse_emu.so\n", SessionFiles.lsePreload(lacksAtomics = true, staged = true))
|
||||
assertEquals("", SessionFiles.lsePreload(lacksAtomics = true, staged = false))
|
||||
assertEquals("", SessionFiles.lsePreload(lacksAtomics = false, staged = true))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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 fsr40NpuChoicesSavedEarlierRunFullFsr4OnTheNpu() {
|
||||
val config = GameEnvironment.Config().withEntries("7", mapOf(
|
||||
GameUpscaler.MODE to "fsr", GameUpscaler.ENGINE to "fsr4_0_npu"))
|
||||
assertEquals(GameUpscaler.Engine.FSR4_NPU, GameUpscaler.choice(config, "7")!!.engine)
|
||||
assertEquals("fsr4_1_full_npu", GameUpscaler.Engine.FSR4_NPU.id)
|
||||
assertEquals(GameUpscaler.Engine.SGSR2, GameUpscaler.Engine.byId("sgsr2_gpu"))
|
||||
}
|
||||
|
||||
@Test fun dlssGamesHaveTheSignatureFixOnUnlessSwitchedOff() {
|
||||
val saved = GameEnvironment.Config().withEntries("7", mapOf(GameUpscaler.MODE to "dlss"))
|
||||
assertTrue(GameUpscaler.choice(saved, "7")!!.signatureFix)
|
||||
assertEquals("1", GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.DLSS))[GameUpscaler.SIGFIX])
|
||||
val off = GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.DLSS, signatureFix = false))
|
||||
assertEquals("0", off[GameUpscaler.SIGFIX])
|
||||
val reread = GameUpscaler.choice(GameEnvironment.Config().withEntries("7", off), "7")!!
|
||||
assertFalse(reread.signatureFix)
|
||||
}
|
||||
|
||||
@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"))
|
||||
}
|
||||
}
|
||||
@@ -133,38 +133,6 @@ class DroidDeckHudPanelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun sideStripOffersOnlyTheOnePercentLow() {
|
||||
val readings = DroidDeckHudSize.SIDE_STRIP.rows
|
||||
assertEquals(listOf("showLow1"), readings.filter { it.startsWith("showLow") })
|
||||
}
|
||||
|
||||
@Test fun sideStripFitsOneSideOfAWideScreenAndUsesItsOwnReadingOrder() {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
val view = DroidDeckHudView(app)
|
||||
val config = DroidDeckHudConfig.DEFAULTS + mapOf(
|
||||
"hudSize" to "side_strip",
|
||||
"hudOrder" to "strip:showCPUUsage|showRAM;side_strip:showRAM|showFPS|showFPSGraph",
|
||||
"showClock" to "0",
|
||||
)
|
||||
view.applyConfig(DroidDeckHudConfig.encode(config))
|
||||
view.showForTest(SNAPSHOT, "DXVK", 0L)
|
||||
|
||||
val density = app.resources.displayMetrics.density
|
||||
val height = (360 * density).toInt()
|
||||
val width = height * 21 / 9
|
||||
val sideMargin = (width - height * 16 / 9) / 2
|
||||
view.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.AT_MOST),
|
||||
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST),
|
||||
)
|
||||
|
||||
assertTrue("HUD fits in one side margin", view.measuredWidth <= sideMargin)
|
||||
assertTrue("HUD is taller than it is wide", view.measuredHeight > view.measuredWidth)
|
||||
assertTrue("RAM is first", view.linesForTest().first().startsWith("RAM"))
|
||||
assertTrue("FPS is second", view.linesForTest()[1].startsWith("FPS"))
|
||||
assertTrue("The graph is inside the column", view.graphForTest()!!.right < view.measuredWidth)
|
||||
}
|
||||
|
||||
@Test fun everySizeDrawsTheDPanelWithEverythingInsideIt() {
|
||||
val stats = FrameStats()
|
||||
var now = 1_000_000_000L
|
||||
|
||||
@@ -467,7 +467,6 @@ class InputLibraryTest {
|
||||
val enabled = InputLibraries.read(context)
|
||||
val changed = enabled.layouts.single { it.id == overlay.id }
|
||||
assertEquals(true, changed.adaptiveSticks)
|
||||
assertTrue(changed.elements.filter { it.kind == InputElementKind.STICK }.all { !it.hideStickAtRest && it.adaptiveCapture == true })
|
||||
assertTrue(ControllerPrefs.read(context).adaptiveSticks)
|
||||
assertEquals(overlay.elements.filter { it.kind != InputElementKind.STICK }, changed.elements.filter { it.kind != InputElementKind.STICK })
|
||||
assertEquals(library.layouts.filter { it.id != overlay.id }, enabled.layouts.filter { it.id != overlay.id })
|
||||
|
||||
@@ -336,20 +336,6 @@ class OnScreenLayoutTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun dockedSticksStayVisibleWithoutExpandingTheirTouchArea() {
|
||||
val custom = InputSurfaceElement(InputControl.LS, .2f, .2f, .2f, .3f,
|
||||
id = "custom-stick", hideWhenIdle = true, adaptiveCapture = true)
|
||||
val layout = SavedInputLayout("custom", "Custom", listOf(custom), aspect = 1.5f)
|
||||
val overlay = OnScreenLayout.elements(context, layout, 1200, 800, Rect()).single()
|
||||
assertTrue(overlay.adaptiveStick)
|
||||
assertTrue(overlay.hideStickAtRest)
|
||||
val docked = OnScreenLayout.elements(context, layout, 1200, 800, Rect(),
|
||||
dock = OnScreenLayout.Dock(false, false)).single()
|
||||
assertFalse(docked.adaptiveStick)
|
||||
assertFalse(docked.hideStickAtRest)
|
||||
assertTrue(docked.floating)
|
||||
}
|
||||
|
||||
@Test fun dockedControlsStayInsideTheSafeAreaAtTheDefaultSizeWithoutAControllerKit() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE)
|
||||
ControllerPrefs.setSize(context, 100)
|
||||
|
||||
@@ -251,52 +251,6 @@ class BwrapSpawnerPlanTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun sandboxesSwitchOnTheLseEmulatorWhenItIsPreloaded() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val rootfs = LinuxRuntime.rootDir(context)
|
||||
val emu = File(rootfs, "usr/local/lib/droiddeck-lse/liblse_emu.so").apply { parentFile?.mkdirs(); writeText("") }
|
||||
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/droiddeck-lse/liblse_emu.so\n") }
|
||||
try {
|
||||
val plan = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp")), dir)
|
||||
assertEquals("/run/droiddeck-preload/liblse_emu.so", plan.env["LD_PRELOAD"])
|
||||
assertEquals("1", plan.env["LSE_EMU"])
|
||||
assertFalse(plan.env.containsKey("LSE_EMU_PATCH"))
|
||||
val chosen = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp"))
|
||||
.apply { getJSONObject("env").put("LSE_EMU_PATCH", "0") }, dir)
|
||||
assertEquals("0", chosen.env["LSE_EMU_PATCH"])
|
||||
assertEquals("1", chosen.env["LSE_EMU"])
|
||||
for (inherited in listOf(
|
||||
"/run/droiddeck-preload/liblse_emu.so /custom.so",
|
||||
"/custom.so:/run/droiddeck-preload/liblse_emu.so",
|
||||
)) {
|
||||
val disabled = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp"))
|
||||
.apply {
|
||||
getJSONObject("env").put("LSE_EMU", "0")
|
||||
getJSONObject("env").put("LD_PRELOAD", inherited)
|
||||
}, dir)
|
||||
assertEquals("0", disabled.env["LSE_EMU"])
|
||||
assertEquals("/custom.so", disabled.env["LD_PRELOAD"])
|
||||
assertFalse(disabled.binds.any { it.guest == "/run/droiddeck-preload/liblse_emu.so" })
|
||||
}
|
||||
} finally {
|
||||
listOf(emu, preload).forEach { it.delete() }
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun sandboxesLeaveTheLseSwitchesAloneWithoutTheEmulator() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val rootfs = LinuxRuntime.rootDir(context)
|
||||
val lib = File(rootfs, "usr/local/lib/libddsession.so").apply { parentFile?.mkdirs(); writeText("") }
|
||||
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/libddsession.so\n") }
|
||||
try {
|
||||
val plan = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp")), dir)
|
||||
assertFalse(plan.env.containsKey("LSE_EMU"))
|
||||
assertFalse(plan.env.containsKey("LSE_EMU_PATCH"))
|
||||
} finally {
|
||||
listOf(lib, preload).forEach { it.delete() }
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun zypakLaunchesTheBrowserWithoutItsSandbox() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val app = File(runtime, "app").apply { File(this, "bin").mkdirs() }
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class NativeGuestDefaultsTest {
|
||||
@Test fun savedRuntimeOverridesDoNotDisableNativeExecution() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit()
|
||||
.putBoolean("nativeUserland", false)
|
||||
.putBoolean("prootFastPath", false)
|
||||
.putBoolean("prootNoSeccomp", true)
|
||||
.apply()
|
||||
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
val hook = NativeGuest.hook(root)
|
||||
val loader = File(root, "usr/lib/ld-linux-aarch64.so.1")
|
||||
hook.parentFile?.mkdirs()
|
||||
loader.writeText("fixture")
|
||||
try {
|
||||
assertTrue(NativeGuest.nextSession(context))
|
||||
assertFalse(NativeGuest.enabled(context))
|
||||
hook.writeText("fixture")
|
||||
assertTrue(NativeGuest.enabled(context))
|
||||
assertFalse(ProotFastPath.enabled(context, native = true))
|
||||
} finally {
|
||||
hook.delete()
|
||||
loader.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,27 +94,6 @@ class NativeGuestTest {
|
||||
assertTrue(env.getValue("LD_PRELOAD").replace(File.separatorChar, '/').endsWith("usr/lib/libddnatv-hook.so"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun disablingLseKeepsItOutOfTheLoaderAndItsDescendants() {
|
||||
val root = rootWithLoader()
|
||||
val emulator = "/usr/lib/liblse_emu.so"
|
||||
val session = "/usr/lib/libddsession.so"
|
||||
listOf(emulator, session).forEach { File(root, it.removePrefix("/")).writeText("") }
|
||||
File(root, "etc/droiddeck").mkdirs()
|
||||
File(root, "etc/droiddeck/native-preload").writeText("$emulator\n$session\n")
|
||||
|
||||
val enabled = NativeGuest.sessionEnvironment(root, emptyList(), "/usr/bin/env")
|
||||
assertEquals("1", enabled["LSE_EMU"])
|
||||
assertEquals("$emulator:$session", enabled["DDNATV_PRELOAD"])
|
||||
assertTrue(enabled.getValue("LD_PRELOAD").startsWith(File(root, emulator.removePrefix("/")).path + ":"))
|
||||
|
||||
val disabled = NativeGuest.sessionEnvironment(root, emptyList(), "/usr/bin/env", lseEmu = "0")
|
||||
assertEquals("0", disabled["LSE_EMU"])
|
||||
assertEquals(session, disabled["DDNATV_PRELOAD"])
|
||||
assertEquals(listOf(File(root, session.removePrefix("/")).path, NativeGuest.hook(root).path),
|
||||
disabled.getValue("LD_PRELOAD").split(':'))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theProgramTheLoaderRunsIsNamedInItsEnvironment() {
|
||||
val root = rootWithLoader()
|
||||
|
||||
@@ -27,12 +27,14 @@ class ProotFastPathTest {
|
||||
}
|
||||
|
||||
@Test fun fastPathStaysOffForTheRootfsProot() {
|
||||
assertTrue(ProotFastPath.allows(source = LinuxRuntime.PROOT_PACK, native = false))
|
||||
assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_ROOTFS, native = false))
|
||||
assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_MISSING, native = false))
|
||||
assertTrue(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_PACK))
|
||||
assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_ROOTFS))
|
||||
assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_MISSING))
|
||||
assertFalse(ProotFastPath.allows(preference = false, noSeccomp = false, source = LinuxRuntime.PROOT_PACK))
|
||||
assertFalse(ProotFastPath.allows(preference = true, noSeccomp = true, source = LinuxRuntime.PROOT_PACK))
|
||||
}
|
||||
|
||||
@Test fun fastPathStaysOffWithoutProot() {
|
||||
assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_PACK, native = true))
|
||||
assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_PACK, nativeUserland = true))
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
|
||||
class PageCacheTrimTest {
|
||||
private val meminfo = "MemFree: 1048576 kB\nActive(file): 2097152 kB\nInactive(file): 1048576 kB\n"
|
||||
@@ -17,31 +15,4 @@ class PageCacheTrimTest {
|
||||
@Test fun skipsSmallBuildUp() = assertFalse(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(2000 * 1024, 1200 * 1024), 1000 * 1024))
|
||||
@Test fun skipsWhenPlentyFree() = assertFalse(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(6000 * 1024, 5000 * 1024), 1000 * 1024))
|
||||
@Test fun lowFreeAcceptsSmallerBuildUp() = assertTrue(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(500 * 1024, 1200 * 1024), 1000 * 1024))
|
||||
|
||||
@Test fun bigFilesSkipLinksButEnterALinkedRoot() {
|
||||
fun big(dir: Path, name: String): Path = Files.createFile(dir.resolve(name)).also {
|
||||
java.io.RandomAccessFile(it.toFile(), "rw").use { it.setLength(PageCacheTrim.MIN_FILE_BYTES + 1) }
|
||||
}
|
||||
val base = Files.createTempDirectory("dd-trim")
|
||||
try {
|
||||
val root = Files.createDirectories(base.resolve("root"))
|
||||
val outside = Files.createDirectories(base.resolve("outside"))
|
||||
val big = big(root, "big.bin")
|
||||
big(Files.createDirectories(root.resolve("sub")), "nested.bin")
|
||||
Files.createFile(root.resolve("small.bin"))
|
||||
big(outside, "outside.bin")
|
||||
Files.createSymbolicLink(root.resolve("linked-dir"), outside)
|
||||
Files.createSymbolicLink(root.resolve("linked-file"), big)
|
||||
val rootLink = Files.createSymbolicLink(base.resolve("root-link"), root)
|
||||
|
||||
val expected = listOf("big.bin", "nested.bin")
|
||||
assertEquals(expected, PageCacheTrim.bigFiles(root.toFile()).map { it.name }.sorted())
|
||||
assertEquals(expected, PageCacheTrim.bigFiles(rootLink.toFile()).map { it.name }.sorted())
|
||||
|
||||
val dangling = Files.createSymbolicLink(base.resolve("dangling"), base.resolve("gone"))
|
||||
assertTrue(PageCacheTrim.bigFiles(dangling.toFile()).isEmpty())
|
||||
} finally {
|
||||
base.toFile().deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.assumeFilePermissionsEnforced
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -9,7 +8,6 @@ import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.zip.ZipFile
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
@@ -146,136 +144,6 @@ class SessionLogShareZipTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theEasyAntiCheatLauncherLogsFromGamePrefixesComeAlong() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val session = File(LinuxRuntime.logDir(app), "2026-12-05-09-steam").apply { mkdirs() }
|
||||
val out = File(app.getExternalFilesDir(null), "agent-logs/anticheat")
|
||||
val prefix = File(SessionPrefs.steamRoot(app, SessionPrefs.activeSteamClientArch(app)), "steamapps/compatdata/976730")
|
||||
val second = File(app.getExternalFilesDir(null), "second-library-${UUID.randomUUID()}").apply { mkdirs() }
|
||||
val library = SteamLibraries.add(app, second.path) as SteamLibraries.AddResult.Added
|
||||
try {
|
||||
File(session, "session.log").writeText("booted\n")
|
||||
val eac = File(prefix, "pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat/4815162342").apply { mkdirs() }
|
||||
File(eac, "anticheatlauncher.log").writeText("[Error] Launch Error: 261\n")
|
||||
File(eac, "old.log").apply {
|
||||
writeText("stale\n")
|
||||
setLastModified(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30))
|
||||
}
|
||||
val secondEac = File(second, "steamapps/compatdata/976730/pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat/b1d0a8c3").apply { mkdirs() }
|
||||
File(secondEac, "anticheatlauncher.log").writeText("[Error] Launch Error: 206\n")
|
||||
val signedEac = File(prefix.parentFile, "-1768546955/pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat/0a1b").apply { mkdirs() }
|
||||
File(signedEac, "anticheatlauncher.log").writeText("[Error] Launch Error: 30005\n")
|
||||
val unsignedEac = File(prefix.parentFile, "2526420341/pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat/0a1b").apply { mkdirs() }
|
||||
File(unsignedEac, "anticheatlauncher.log").writeText("[Error] Launch Error: 30007\n")
|
||||
|
||||
val zip = EnhancedSessionLogShare.createLegacy(app, session, outputDirectory = out)!!
|
||||
ZipFile(zip).use { archive ->
|
||||
val logs = archive.entries().toList().filter { it.name.startsWith("anticheat/976730/") }
|
||||
assertEquals(2, logs.size)
|
||||
assertTrue(logs.all { it.name.endsWith("/anticheatlauncher.log") && !it.name.contains("4815162342") })
|
||||
val texts = logs.map { archive.getInputStream(it).bufferedReader().readText() }
|
||||
assertTrue(texts.any { it.contains("Launch Error: 261") })
|
||||
assertTrue(texts.any { it.contains("Launch Error: 206") })
|
||||
val aliases = archive.entries().toList().filter { it.name.startsWith("anticheat/2526420341/") }
|
||||
assertEquals(2, aliases.size)
|
||||
assertEquals(2, aliases.map { it.name.split('/')[2] }.filter { it.startsWith("library1") }.toSet().size)
|
||||
val aliasTexts = aliases.map { archive.getInputStream(it).bufferedReader().readText() }
|
||||
assertTrue(aliasTexts.any { it.contains("Launch Error: 30005") })
|
||||
assertTrue(aliasTexts.any { it.contains("Launch Error: 30007") })
|
||||
}
|
||||
} finally {
|
||||
SteamLibraries.remove(app, library.entry.id)
|
||||
out.deleteRecursively()
|
||||
session.deleteRecursively()
|
||||
prefix.deleteRecursively()
|
||||
File(prefix.parentFile, "-1768546955").deleteRecursively()
|
||||
File(prefix.parentFile, "2526420341").deleteRecursively()
|
||||
second.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theSessionsGameLogComesAlongWhenManyAntiCheatLogsAreFound() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val session = File(LinuxRuntime.logDir(app), "2026-12-05-11-steam").apply { mkdirs() }
|
||||
val out = File(app.getExternalFilesDir(null), "agent-logs/anticheat-flood")
|
||||
val compatdata = File(SessionPrefs.steamRoot(app, SessionPrefs.activeSteamClientArch(app)), "steamapps/compatdata")
|
||||
val prefixes = (0 until 300).map { File(compatdata, "${900000 + it}") }
|
||||
try {
|
||||
File(session, "session.log").writeText("booted\n")
|
||||
File(session, "steam-976730.log").writeText("proton: game started\n")
|
||||
prefixes.forEach { prefix ->
|
||||
val eac = File(prefix, "pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat/0a1b").apply { mkdirs() }
|
||||
File(eac, "anticheatlauncher.log").writeText("[Error] Launch Error: 206\n" + "x".repeat(64 * 1024))
|
||||
}
|
||||
|
||||
val zip = EnhancedSessionLogShare.createLegacy(app, session, outputDirectory = out)!!
|
||||
ZipFile(zip).use { archive ->
|
||||
val game = archive.entries().toList().single { it.name.endsWith("/steam-976730.log") }
|
||||
assertTrue(archive.getInputStream(game).bufferedReader().readText().contains("game started"))
|
||||
}
|
||||
} finally {
|
||||
out.deleteRecursively()
|
||||
session.deleteRecursively()
|
||||
prefixes.forEach { it.deleteRecursively() }
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aDiscoveryFailureStaysInTheManifestWhenRecordsPassTheLimit() {
|
||||
assumeFilePermissionsEnforced()
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val session = File(LinuxRuntime.logDir(app), "2026-12-05-10-steam").apply { mkdirs() }
|
||||
val out = File(app.getExternalFilesDir(null), "agent-logs/manifest-limit")
|
||||
val compatdata = File(SessionPrefs.steamRoot(app, SessionPrefs.activeSteamClientArch(app)), "steamapps/compatdata").apply { mkdirs() }
|
||||
try {
|
||||
repeat(300) {
|
||||
File(session, "part-$it.log").writeText("line $it\n")
|
||||
File(session, "wayland-$it.log").writeText("line $it\n")
|
||||
File(session, "proton-$it.log").writeText("line $it\n")
|
||||
}
|
||||
assertTrue(compatdata.setReadable(false, false))
|
||||
val zip = EnhancedSessionLogShare.createLegacy(app, session, outputDirectory = out)!!
|
||||
ZipFile(zip).use { archive ->
|
||||
val manifest = JSONObject(archive.getInputStream(archive.getEntry("diagnostics-manifest.json")).bufferedReader().readText())
|
||||
val entries = manifest.getJSONArray("entries")
|
||||
val reasons = (0 until entries.length()).map { entries.getJSONObject(it) }
|
||||
.filter { it.optString("origin") == "discovery" }.map { it.optString("reason") }
|
||||
assertTrue(entries.length() > 512)
|
||||
assertTrue(reasons.toString(), "filesystem-error" in reasons)
|
||||
}
|
||||
} finally {
|
||||
compatdata.setReadable(true, false)
|
||||
out.deleteRecursively()
|
||||
session.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aPrefixThatDeniesTheAntiCheatFolderIsRecordedAsADiscoveryFailure() {
|
||||
assumeFilePermissionsEnforced()
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val session = File(LinuxRuntime.logDir(app), "2026-12-05-12-steam").apply { mkdirs() }
|
||||
val out = File(app.getExternalFilesDir(null), "agent-logs/anticheat-denied")
|
||||
val compatdata = File(SessionPrefs.steamRoot(app, SessionPrefs.activeSteamClientArch(app)), "steamapps/compatdata")
|
||||
val prefix = File(compatdata, "976731")
|
||||
val users = File(prefix, "pfx/drive_c/users").apply { mkdirs() }
|
||||
try {
|
||||
File(session, "session.log").writeText("booted\n")
|
||||
assertTrue(users.setExecutable(false, false))
|
||||
val zip = EnhancedSessionLogShare.createLegacy(app, session, outputDirectory = out)!!
|
||||
ZipFile(zip).use { archive ->
|
||||
val manifest = JSONObject(archive.getInputStream(archive.getEntry("diagnostics-manifest.json")).bufferedReader().readText())
|
||||
val entries = manifest.getJSONArray("entries")
|
||||
val reasons = (0 until entries.length()).map { entries.getJSONObject(it) }
|
||||
.filter { it.optString("origin") == "discovery" }.map { it.optString("reason") }
|
||||
assertTrue(reasons.toString(), "filesystem-error" in reasons)
|
||||
}
|
||||
} finally {
|
||||
users.setExecutable(true, false)
|
||||
out.deleteRecursively()
|
||||
session.deleteRecursively()
|
||||
prefix.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun everyTextFileInTheZipIsScrubbedAndTheStoresAndToolsLogsComeAlong() {
|
||||
val logs = LinuxRuntime.logDir(app)
|
||||
val session = File(logs, "2026-10-08-01-steam").apply { mkdirs() }
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class UpscaleBridgeVersionTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun tree(name: String, nvngx: String): File {
|
||||
val dir = tmp.newFolder(name)
|
||||
for (file in UpscaleComponent.BRIDGE_FILES) {
|
||||
File(dir, file).apply { parentFile?.mkdirs() }.writeText(if (file.endsWith("/nvngx.dll")) nvngx else file)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
@Test fun aChangedDllWithTheSameSizeAndDateIsANewVersion() {
|
||||
val old = tree("old", "aaaa")
|
||||
val new = tree("new", "bbbb")
|
||||
for (file in UpscaleComponent.BRIDGE_FILES) {
|
||||
File(old, file).setLastModified(0)
|
||||
File(new, file).setLastModified(0)
|
||||
}
|
||||
assertNotEquals(UpscaleComponent.localVersion(old), UpscaleComponent.localVersion(new))
|
||||
}
|
||||
|
||||
@Test fun theSameFilesWithOtherDatesAreTheSameVersion() {
|
||||
val a = tree("a", "same")
|
||||
val b = tree("b", "same")
|
||||
File(b, UpscaleComponent.BRIDGE_FILES.first()).setLastModified(1_000_000)
|
||||
assertEquals(UpscaleComponent.localVersion(a), UpscaleComponent.localVersion(b))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class UpscaleComponentNpuTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private val runtime = listOf("libQnnHtp.so", "libQnnHtpPrepare.so", "libQnnSystem.so")
|
||||
|
||||
private fun vendor(libs: List<String>, listed: List<String> = libs): Pair<File, File> {
|
||||
val dir = tmp.newFolder("lib64")
|
||||
libs.forEach { File(dir, it).writeText("") }
|
||||
val list = tmp.newFile("public.libraries.txt")
|
||||
list.writeText("# vendor libraries apps may load\n" + listed.joinToString("\n") { "$it 64" } + "\n")
|
||||
return dir to list
|
||||
}
|
||||
|
||||
@Test fun thePhonesOwnRuntimeNamesItsHtpGeneration() {
|
||||
val (dir, list) = vendor(runtime + listOf("libQnnHtpV85Stub.so", "libcdsprpc.so"))
|
||||
assertEquals("v85", UpscaleComponent.systemNpuArch(dir, list))
|
||||
}
|
||||
|
||||
@Test fun librariesTheVendorDoesNotOfferToAppsDoNotCount() {
|
||||
val libs = runtime + "libQnnHtpV85Stub.so"
|
||||
val (dir, list) = vendor(libs, listed = libs - "libQnnHtpPrepare.so")
|
||||
assertNull(UpscaleComponent.systemNpuArch(dir, list))
|
||||
}
|
||||
|
||||
@Test fun twoStubGenerationsAreAmbiguous() {
|
||||
val (dir, list) = vendor(runtime + listOf("libQnnHtpV79Stub.so", "libQnnHtpV81Stub.so"))
|
||||
assertNull(UpscaleComponent.systemNpuArch(dir, list))
|
||||
}
|
||||
|
||||
@Test fun noPublicLibraryListMeansNoSystemRuntime() {
|
||||
assertNull(UpscaleComponent.systemNpuArch(tmp.newFolder("empty"), File(tmp.root, "missing.txt")))
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
@@ -21,7 +18,6 @@ import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34], manifest = Config.NONE, shadows = [JoyConPadTest.RecordingWriter::class])
|
||||
@@ -359,28 +355,6 @@ class InputSurfaceTouchTest {
|
||||
touch(MotionEvent.ACTION_UP, 1 to (490f to 170f))
|
||||
}
|
||||
|
||||
@Test @GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
fun adaptiveSticksDrawAtRestUnlessExplicitlyHidden() {
|
||||
val legacy = InputSurfaceElement(InputControl.LS, .3f, .3f, .2f, .4f, hideWhenIdle = true)
|
||||
fun idlePixel(e: InputSurfaceElement): Int {
|
||||
show(e)
|
||||
val target = element(view, e.id)
|
||||
val bitmap = Bitmap.createBitmap(target.width, target.height, Bitmap.Config.ARGB_8888)
|
||||
return try {
|
||||
target.draw(Canvas(bitmap))
|
||||
bitmap.getPixel(target.width / 2, target.height / 2)
|
||||
} finally {
|
||||
bitmap.recycle()
|
||||
}
|
||||
}
|
||||
assertTrue(Color.alpha(idlePixel(legacy)) > 0)
|
||||
val visible = legacy.copy(adaptiveCapture = true, hideWhenIdle = false)
|
||||
assertTrue(Color.alpha(idlePixel(visible)) > 0)
|
||||
assertTrue(view.takesTouchAt(10f, 300f))
|
||||
assertEquals(0, Color.alpha(idlePixel(visible.copy(hideWhenIdle = true))))
|
||||
assertTrue(view.takesTouchAt(10f, 300f))
|
||||
}
|
||||
|
||||
@Test fun adaptiveSticksCaptureAroundThemAndTheLeftOneToTheEdge() {
|
||||
val left = InputSurfaceElement(InputControl.LS, .3f, .3f, .2f, .4f, hideWhenIdle = true)
|
||||
val right = InputSurfaceElement(InputControl.RS, .6f, .3f, .2f, .4f, hideWhenIdle = true)
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
# Steam client on ARMv8.0 CPUs
|
||||
|
||||
## The crash
|
||||
|
||||
Valve's native arm64 Steam client stopped starting on ARMv8.0 CPUs after the April 15 2026
|
||||
build (client version 1776387948). The process dies with SIGILL right away, the session log
|
||||
shows `"$steam_root/steamrtarm64/steam" ... Illegal instruction` and `steam exited rc=132`,
|
||||
and the screen stays black.
|
||||
|
||||
The faulting instruction is an ARMv8.1 LSE atomic. The GDB trace in
|
||||
[ValveSoftware/steam-for-linux#13288](https://github.com/ValveSoftware/steam-for-linux/issues/13288)
|
||||
stops on `ldaddal x1, x0, [x0]`, with `swpa` and `casal` next to it. Earlier builds were most
|
||||
likely compiled with `-moutline-atomics`, which picks LL/SC or LSE at run time. Newer builds
|
||||
inline LSE. Valve has not replied on that issue, so the cause comes from the reporter's
|
||||
disassembly, not from Valve.
|
||||
|
||||
Affected cores are the ARMv8.0 ones without LSE: Cortex-A35, A53, A57, A72 and A73. A55, A75
|
||||
and later have it. On Android that covers the Snapdragon 4xx/6xx parts built on A53/A73 (for example the
|
||||
Snapdragon 685 with Adreno 610 in
|
||||
[Droid-Deck/DroidDeck#380](https://github.com/Droid-Deck/DroidDeck/issues/380)), plus the
|
||||
Nintendo Switch, Raspberry Pi 4 and older, and the Jetson Nano outside Android.
|
||||
`/proc/cpuinfo` shows it: the `Features` line has no `atomics`.
|
||||
|
||||
LSE is an ARMv8.1 feature. LSE-Emu users report the current client running on a Cortex-A57,
|
||||
so nothing later than LSE seems to be required yet.
|
||||
|
||||
## What other projects do
|
||||
|
||||
- [SildurFX/Switchdeck](https://github.com/SildurFX/Switchdeck) (Switch, L4T Linux) lets the
|
||||
client update once, then overlays `linuxarm64`, `steamrtarm64`, `steamui` and a `steam.cfg`
|
||||
from the April build. It works there because the install script controls the whole system.
|
||||
For us a pinned client is replaced by the self updater on its next start, which is why #380
|
||||
was closed.
|
||||
- [SildurFX/LSE-Emu](https://github.com/SildurFX/LSE-Emu) is a preload library by the same
|
||||
author, written to run the current arm64 client on the Switch. A SIGILL handler performs
|
||||
each LSE instruction with an LL/SC loop. With `LSE_EMU_PATCH=1` the first trap at a site
|
||||
writes an LL/SC stub within branch range and replaces the instruction with a `b` to it, so
|
||||
the site runs natively after that. It covers the full LSE set plus `LDAPR`. The author
|
||||
reports Steam, FEX, Proton games and ARMSX2 running on a Cortex-A57, with ARMSX2 close to
|
||||
native ARMv8.0 speed once patched. GPL-3.0, same as this repo.
|
||||
- [Azkali/proton-arm64-a57](https://github.com/Azkali/proton-arm64-a57) rebuilds Proton 11
|
||||
arm64 (Wine, DXVK, vkd3d-proton, FEX's WoW64 and ARM64EC DLLs) with
|
||||
`-march=armv8-a -mtune=cortex-a57`. Stock Proton 11 arm64 also SIGILLs on ARMv8.0
|
||||
(`wineboot` rc=132), so the client is not the only problem for games.
|
||||
- Some installers fall back to Valve's x86-64 client under FEX on CPUs without LSE. We already
|
||||
have that path (`DD_STEAM_CLIENT_ARCH=x86_64`, `droiddeck-steam-x64`), but it is slower and
|
||||
FEX itself has to be built without LSE.
|
||||
- [FrankNat996/armor](https://github.com/FrankNat996/armor) notes a separate problem: the arm64
|
||||
client's ELF segments are 4K aligned, so it SIGSEGVs at once on 16K page kernels.
|
||||
|
||||
## This change
|
||||
|
||||
The session vendors LSE-Emu (`tools/linuxfs/lse-emu`, upstream commit `8bc9548`). CI and
|
||||
`tools/build_local.sh` build it as `usr/local/lib/droiddeck-lse/liblse_emu.so` with
|
||||
`-march=armv8-a -mno-outline-atomics`. The build fails if the library contains LSE
|
||||
instructions itself.
|
||||
|
||||
When `/proc/cpuinfo` reports any core without `atomics`, `SessionFiles` puts the library first
|
||||
in the rootfs `/etc/ld.so.preload`. `BwrapSpawner` already turns that file into `LD_PRELOAD`
|
||||
for sandboxed processes. On CPUs with LSE nothing changes: the file is staged but not
|
||||
preloaded, and the library would also stay idle on its own because it checks `HWCAP_ATOMICS`.
|
||||
|
||||
`droiddeck-session` sees the library in `ld.so.preload` and exports `LSE_EMU=1`. Runtime
|
||||
instruction rewriting is disabled by default (`LSE_EMU_PATCH=0`): the emulator uses the slower
|
||||
SIGILL path rather than rewriting executable code while other threads may be running it. To
|
||||
opt in to patching for testing, set `LSE_EMU_PATCH=1` explicitly. With a session debug folder,
|
||||
the script also sets `LSE_EMU_LOG=$DD_DEBUG_DIR/lse_emu.log`, and `session.log` gets a line
|
||||
starting with `== cpu: no LSE atomics`.
|
||||
|
||||
The test APK targets SDK 34. To verify the expected `mprotect` restriction, run a controlled
|
||||
test executable containing a known-patchable, file-backed LSE instruction with
|
||||
`LSE_EMU_PATCH=1` under this APK configuration, and confirm `mprotect-failed` for that site.
|
||||
A normal Steam run alone cannot establish the restriction.
|
||||
|
||||
## Tests
|
||||
|
||||
`tools/tests/test_lse_emu.py` builds the library and a program that uses every LSE family
|
||||
(`ldadd` in all four sizes, `ldclr`, `ldeor`, `ldset`, `swp`, `ldsmax`, `ldumin`, `casal`,
|
||||
`caspal`) from four threads, and runs it under `qemu-aarch64 -cpu cortex-a57`:
|
||||
|
||||
- without the library the program dies with SIGILL
|
||||
- trapping alone runs every form and keeps the threaded counters exact
|
||||
- patching runs every form twice, so the second run goes through the generated stubs, both
|
||||
single threaded and with four threads
|
||||
- condition flags survive a patched `ldumax`/`ldsmaxb`, and `caspal` returns the current pair
|
||||
on a mismatch
|
||||
- without `LSE_EMU=1`, and on `-cpu neoverse-n1`, the library stays out of the way
|
||||
- a SIGILL handler the program installs itself still runs for an unrelated `udf`
|
||||
|
||||
The patch tests cannot run on an Apple Silicon Mac in an amd64 Docker container: qemu-aarch64
|
||||
there segfaults whenever code is written to an executable page after code on it has run, even
|
||||
in a ten line program without the library. CI runs them on x86 hardware.
|
||||
|
||||
## Fixes over upstream
|
||||
|
||||
The vendored copy carries two fixes found in review, both in the patched stubs and the
|
||||
emulation path:
|
||||
|
||||
- `LDSMAX`/`LDSMIN`/`LDUMAX`/`LDUMIN` stubs used `cmp`/`csel` and overwrote NZCV. They now
|
||||
save and restore it.
|
||||
- `CASP` with a 64-bit pair returned the `ldxp` result on a mismatch without a store. A 128-bit
|
||||
`ldxp` is only single-copy atomic once a `stxp` succeeds, so a concurrent update could give
|
||||
one old and one new half. Both the trap path and the stub now store the loaded pair back on a
|
||||
mismatch and retry if that store fails, as libatomic does.
|
||||
|
||||
Patching replaces an LSE instruction with a `b` while other threads may be running it.
|
||||
The architecture does not guarantee safe concurrent replacement for every instruction (including
|
||||
`LDADD`), so patching is opt-in and defaults to `LSE_EMU_PATCH=0`. This avoids that specific
|
||||
self-modifying-code race by keeping sites on the SIGILL emulation path, at the cost of speed.
|
||||
It does not eliminate all signal-handler compatibility risks: direct raw `rt_sigaction` syscalls,
|
||||
complex signal masks/flags, and applications that depend on exact kernel signal semantics still
|
||||
need dedicated tests. The handler forwarding is not a complete substitute for kernel delivery.
|
||||
|
||||
## Testing on a device
|
||||
|
||||
On an ARMv8.0 phone or handheld (no `atomics` in `/proc/cpuinfo`):
|
||||
|
||||
1. Install the test APK and start a Steam session.
|
||||
2. `session.log` should have `== cpu: no LSE atomics` and no `steam exited rc=132`.
|
||||
3. In the default-mode run, check that `lse_emu.log` contains a `start` record for the
|
||||
affected PID and that the process remains on the trap path. While Steam is running, its
|
||||
`exit` record may not exist yet: either confirm a `no-patch` record for that PID, or exit
|
||||
Steam normally before checking that its `exit` record has a nonzero `traps=` value. Confirm
|
||||
there are no `patched` records. Summarise events with
|
||||
`cut -d' ' -f2 lse_emu.log | sort | uniq -c`.
|
||||
Then repeat with `LSE_EMU_PATCH=1` explicitly set in the session environment. Do not require
|
||||
`mprotect-failed` for a valid trap-path run: `no-arena` means arena allocation failed before
|
||||
`mprotect` was attempted, so it is inconclusive about the SDK restriction. Check that
|
||||
restriction separately using the controlled patchable site described above. `unhandled`
|
||||
means an instruction the library does not cover.
|
||||
4. Compare UI responsiveness against an ARMv8.2 device, and note any `lse_emu: unhandled`
|
||||
lines in `session.log`.
|
||||
|
||||
## Still open
|
||||
|
||||
- Games. Proton 11 arm64 and Valve's FEX build need the same treatment. The preload reaches
|
||||
them when they inherit `LD_PRELOAD`, but pressure-vessel and static binaries can drop it,
|
||||
and FEX installs its own signal handlers with raw syscalls. An ARMv8.0 Proton build like
|
||||
Azkali's is the cleaner fix.
|
||||
- In #380 the session first died with SIGILL in the app's own `wl-compositor` thread, inside
|
||||
`turnip-sdk36/vulkan.ad08XX.so`, which is the A8xx driver build loaded on an Adreno 610.
|
||||
Picking the 6xx/7xx Turnip fixed it, and Auto picks that build once the driver release list
|
||||
is loaded. Nobody has checked yet whether our bundled driver builds avoid LSE. The preload
|
||||
cannot help there because the compositor is a bionic thread in the app process.
|
||||
- JIT code (anonymous memory) is never patched and always traps.
|
||||
- If Valve starts requiring something past LSE, the library prints
|
||||
`lse_emu: unhandled pc=... insn=...` and the client crashes as before.
|
||||
@@ -252,15 +252,13 @@ self-extractor stops at "Path not found", so the values it installs are applied
|
||||
`goggame-<id>.info`, and a script's own `setRegistry` entries always win over the built-in table.
|
||||
|
||||
The script's `supportData` actions run right after: files and folders from the game folder
|
||||
(`{app}`) or its support files (`{supportDir}`, `support/<id>/`) are copied to `{userdocs}`,
|
||||
`{localappdata}` or `{userappdata}` in the prefix, and `type: folder` without a source creates the
|
||||
folder. Mods such as one-click editions ship their `Plugins.txt` and INI files this way. The
|
||||
`savePath` action's `savePath` folder is created with the same path rules, including the common
|
||||
case where a one-click edition names it again as a `supportData` folder. Paths match without regard
|
||||
(`{app}`) or its support files (`{supportDir}`, `support/<id>/`) are copied to `{userdocs}` and
|
||||
`{localappdata}` in the prefix, and `type: folder` without a source creates the folder. Mods such
|
||||
as one-click editions ship their `Plugins.txt` and INI files this way. Paths match without regard
|
||||
to case, links are copied as links, and a path outside those folders is refused. A file the
|
||||
player already has is replaced only when the action says `overwrite`. `.droiddeck-gog-support` and
|
||||
`.droiddeck-gog-save-path` in the prefix hold the actions' hashes, so they run once per script
|
||||
revision and a player's later edits stay.
|
||||
player already has is replaced only when the action says `overwrite`. `.droiddeck-gog-support` in
|
||||
the prefix holds the actions' hash, so they run once per script revision and a player's later
|
||||
edits stay.
|
||||
|
||||
A GOG game's exe comes from its own manifest first: `goggame-<id>.info`'s play task in category
|
||||
`game` (`isPrimary` first), or a primary `launcher` task for launcher games, whose `path` stays
|
||||
|
||||
@@ -7,6 +7,182 @@ the timeline, then lessons and backlog. Companion to the README (what the app *d
|
||||
|
||||
---
|
||||
|
||||
## 2026-12-05 - `feat/neural-upscaler`: brought up to main, test build for the Red Magic (CI running)
|
||||
|
||||
- **Why:** user 12-05 ~17:4x EST: "bring our npu upscaling branch up to main and install it". The branch was 56
|
||||
commits behind main. The phone's DroidDeck had been moved to the Preview build of main `423f600d` at 17:45 EST
|
||||
through DroidDeck's own Updates screen, so the earlier test build (`97188d37`) was no longer installed.
|
||||
- **Built:** backup ref `refs/backup/20261205/feat-neural-upscaler-before-main-sync` (= `18102ef5`); merge of main
|
||||
`423f600d` = `898b6376`, no conflicts. Files changed on both sides: SessionService.kt, FrontEndSetup.kt,
|
||||
SessionOverlay.kt, strings.xml, droiddeck-game-env, test_game_environment.py (234 tests OK locally, isolated
|
||||
env). Main did not touch `tools/bionic-runtime/tool`, so the bionic patch script still applies. Test branch
|
||||
`test/neural-upscaler-rm12` = `f80d581e` (merge + the debuggable commit, never merge).
|
||||
- **CI:** Build APK 47579062115 (headSha `f80d581e`), Unit tests 47579064807 (headSha `898b6376`), both running.
|
||||
- **Next:** sign the pubg variant with the release key (b241ea7d), stage in the phone's Download with sha256,
|
||||
install over the Preview build (same signer, keeps data), check the bridges copy and the DroidDeck-Bionic tool
|
||||
patch, then a short launch check.
|
||||
- **Resume point:** if the session dies, check the two runs above; `bash /root/src/npu-rm/sign-stage.sh <build run>
|
||||
f80d581e` (temp key dir must exist; delete it after signing). Rollback = `/sdcard/Download/DroidDeck-0.7.11-pubg-rollback.apk`
|
||||
or the pulled Preview APK `/root/src/npu-rm/installed/now-1745.apk` (`adb install -r`).
|
||||
- **Also 12-05:** frame-stall cause found in code (not fixed yet): in the default async NPU mode the layer's
|
||||
recording thread waits on the CPU for the previous frame's NPU result (`fsr411_full_gpu.c` and `fsr412_lite.c`,
|
||||
up to 200 ms), and that result needs the GPU to finish the previous frame first, so CPU and GPU take turns.
|
||||
Planned fix: the next frame's command buffer waits on the GPU for a host-set event instead (switch to go back:
|
||||
`DROIDDECK_UPSCALE_NPU_CPU_WAIT=1`).
|
||||
|
||||
---
|
||||
|
||||
## 2026-12-04 - `feat/neural-upscaler`: Winlator-NeuralScale r5 ported, non-root parts only (CI running)
|
||||
|
||||
- **Why:** upstream r5 (`71c140d9`) adds full FSR 4.1 on the NPU, a ghosting fix, S8/U8 Lite graphs, Snapdragon GSR 2
|
||||
and D3D11 DLSS. The user asked for those five and nothing that needs root.
|
||||
- **Built:** `74ece6c8` = three-way merge of layer + bridges (base `a0ab6b0f`), new `sgsr2_gpu.c` + shaders,
|
||||
`wl_dxvk_interop.h`; data files re-pinned to `71c140d9` (89 files, sha256); new engine `sgsr2_gpu`, NPU engine id
|
||||
`fsr4_1_full_npu` (saved `fsr4_0_npu` maps to it: FSR 4.0 is gone upstream); XeSS 3 kept (upstream maps `xess` to
|
||||
FSR 3 and dropped Intel's runtime in `cb3ae04e`; we still fetch it from `a0ab6b0f`); NPU detection stays ours
|
||||
(`DROIDDECK_UPSCALE_NPU`), upstream's SoC list removed; full-FSR-4-on-Turnip guard now opt-in
|
||||
(`DROIDDECK_UPSCALE_FULL_OFF_ON_TURNIP=1`). Not ported: RootPerfManager, RootThermal*, GPU clock floor, bypass charging.
|
||||
- **Checked locally:** all 8 layer files compile and link for Android (clang, Khronos headers, -Wall clean); the
|
||||
glibc stub variant compiles; `tools/tests/test_game_environment.py` 231 OK (isolated HOME). Bridge DLLs: CI only.
|
||||
- **CI:** Build APK 47450218949 (`d6f8736e`) FAILED in "Prepare verified components": the glibc layer build has no
|
||||
`sys/system_properties.h` (upstream r5 include; my local check compiled with Android headers, so it missed it).
|
||||
Fix `1a621bcf` (include dropped, heartbeat write checked); `build-glibc.sh` now run locally with the container's gcc
|
||||
= builds, 0 warnings. Rerun Build APK 47450693166 (`23621838`) FAILED at the bridges: `nvngx.dll` did not link
|
||||
(merge kept our old D3D11 `PopulateParameters` line calling the removed "DLSS unavailable" helper). I had wrongly
|
||||
read a cache-hash line in run 1 as "bridges built". Fix in the next commit; all six DLLs now built locally with
|
||||
mingw-w64 13.2 (`tools/upscale/bridges/build.sh`), exports match.
|
||||
- **CI run 3:** Build APK 47451847785 GREEN on `e67bd76e` (= `379198e4` code + the debuggable-only commit): layer glibc
|
||||
built, 6 bridges match their exports, APK compiled. App unit tests (separate workflow) 47452868772 on `379198e4`:
|
||||
5512 tests, 0 failures (GameUpscalerTest 8, UpscaleComponentNpuTest 4).
|
||||
- **Installed (user yes, 19:23 EST):** Red Magic 12 Pro, pubg variant signed b241ea7d, installed sha256 `65e09d96`;
|
||||
the 24 new bridge DLLs copied to the app's external `droiddeck-upscale/bridges`.
|
||||
- **Bug found while staging:** the local-copy bridge stamp is `local-<libxess size>-<mtime>`; CI DLLs have mtime 0 and
|
||||
libxess.dll kept its size (31232), so the app would keep the old DLLs. Test worked around by removing the staged
|
||||
`.pack` (backup `.pack.bak-r5`); fix = stamp from the files' contents.
|
||||
- **First run (XeSS DX12 demo, 19:27 EST):** menu lists Snapdragon GSR 2 and FSR 4 on NPU; Full FSR 4.1 S8 graph compiled
|
||||
on the phone's V85 NPU in 2.65 s and ran zero-copy (GPU 6.5 ms + NPU 5.4 ms, 960x540 to 1080p); the depth stand-in
|
||||
for depth-less games logged. Most status rows were junk: the game still loaded the OLD bridge DLLs, because
|
||||
`ensure()` staged only when no DLLs were staged. Fix `aabacc10` (re-stage when present, content-hash stamp, test).
|
||||
For this test the 24 new DLLs were copied into the rootfs by hand (run-as), hashes == CI.
|
||||
- **CI:** Build APK 47455548997 (`50864970` = `aabacc10` + debuggable commit), unit tests 47455552638.
|
||||
- **Device results (19:37-19:58 EST, new DLLs):** XeSS DX12 round: every engine runs (Full NPU sync 4.6+3.3 ms,
|
||||
Full GPU 27.1 ms, Lite NPU 5.0+4.9, Lite GPU 7.2, SGSR 2 1.8, FSR 3 3.3, XeSS 11.6), BUT Full FSR 4.1 shows a black
|
||||
picture in DX12: 0 coloured pixels in 9/9 shots (`/root/src/npu-rm/tools/pngstat.py`), others 28-32k. XeSS Vulkan
|
||||
sample: Full shows the picture (GPU and NPU). DLSS sample with `-d3d11`: same NGX GetFeatureRequirements
|
||||
PlatformError as D3D12, raised before our bridge (D3D11 DLSS untested).
|
||||
- **Fixes:** `83de9e38` guard at dispatch: D3D12 frames on Turnip -> Lite (`FULL_ON_TURNIP=1` forces Full);
|
||||
`2446d48e` test switches `FULL_DIRECT_OUT=0` / `FULL_AUTO_EXPOSURE=0`. Prime suspect: the Tier 1.1 direct write
|
||||
into the game's output, which only D3D12 frames take (exactly 1920x1080 output). Upstream validated DX12 only with
|
||||
Cyberpunk 2077 (README).
|
||||
- **CI:** 47457143185 failed (flaky test_dircache_preload + IME download reset), cancelled; 47459802031 (`2446d48e`)
|
||||
green after a rerun of the IME download step. Staged APK sha256 `6f267e61`; user said "device is yours".
|
||||
- **Picture tests on `2446d48e` (installed 20:36 EST, `/root/src/npu-rm/fulltest.sh`):** A direct write off -> black
|
||||
0/6; C direct write + exposure pass off -> black 0/6 (hdr=1); E `VKD3D_DISABLE_EXTENSIONS=VK_EXT_descriptor_buffer`
|
||||
with the direct write on -> picture 5/6. Root cause: vkd3d-proton's own descriptor buffers in the command buffers
|
||||
the upscaler records into break Full's descriptor-buffer passes on Turnip.
|
||||
- **Fix `7aa54ab9`:** the layer hides `VK_EXT_descriptor_buffer` from games (still uses it itself;
|
||||
`APP_DESCRIPTOR_BUFFER=1` shows it); Lite fallback only when a game enables it anyway; test switches removed.
|
||||
CI Build APK 47463181144 (`26811a77`).
|
||||
- **12-05 device results (builds `26811a77`, then `3bd1d6f9`):** fix device-proven: XeSS DX12 sample Full GPU/NPU show the
|
||||
picture; measured all-engine rounds (4 shots each) DX12 + Vulkan: every engine shows the picture. Staging fix
|
||||
`0750f2d0` proven ("upscaler bridges staged from local-<hash>: 24/24", and again after a real DLL change).
|
||||
- **Cyberpunk 2077 (DX12, XeSS route):** Full FSR 4.1 NPU runs on the title scene, 795x360 -> 1590x720, GPU 6.0 ms +
|
||||
NPU 5.8 ms, picture correct. Gotcha: UserSettings.json options are read by `index`, not `value`.
|
||||
- **vkd3d descriptor buffers hidden vs shown (Cyberpunk title, Lite NPU):** ~135 vs ~126 fps (noise) -> the fix costs
|
||||
nothing.
|
||||
- **DLSS:** the NGX "PlatformError" was NGX's signature check; with `DROIDDECK_UPSCALE_SIGFIX=1` the DLSS sample passes it.
|
||||
D3D11 then failed in EvaluateFeature: upstream's `extract_ngx_dx11_res` zeroed VkImageCreateInfo, DXVK returns
|
||||
E_INVALIDARG unless sType is IMAGE_CREATE_INFO. Fix `ffe46fe5`. DLSS sample now runs Full FSR 4.1 NPU in D3D11
|
||||
(1280x720 -> 2560x1440, GPU 5.1 + NPU 4.6 ms, ~52 fps) and in D3D12 (GPU 5.1 + NPU 4.4-6.0 ms, ~49 fps).
|
||||
SIGFIX stays opt-in (default = user decision).
|
||||
- **CI:** Build APK 47488918399 (`5546b35e` = `ffe46fe5` + the debuggable-only commit), green; installed on the phone
|
||||
12-05 02:1x EST (sha256 `cfbc4be0`) with its CI-built bridge DLLs. Final device check with exactly these files is
|
||||
still owed (phone screen locked at 02:03 EST).
|
||||
- **Real-game DLSS still open:** Bright Memory: Infinite (UE4, D3D12) never loads the bridge's nvapi64.dll ("Failed to
|
||||
initialize NVAPI", no bridge log), so the signature-fix hooks do not run and NGX's own loader rejects the core
|
||||
("failed to load C:\windows\system32\_nvngx.dll", D3D12_Init FeatureNotSupported). Putting the DLLs into system32
|
||||
did not help (`73442ad3`, reverted in `bb5c53a7`). The game also picks its upscaler from its own menu.
|
||||
- **Not used:** a Deep Rock Galactic copy that carries a DRM-bypass DLL.
|
||||
- **Real-game DLSS (Bright Memory: Infinite), 12-05 02:2x-03:0x EST:** with nvapi64.dll + NGX DLLs in its system32
|
||||
(`04a67aa7` now does this in DLSS mode) the signature-fix hooks install and NGX reports "DLSS supported 1"; the game
|
||||
creates DLSS features (795x360 -> 1590x720, title 5 -> 20 fps). The bridge's new log shows attach ok, seam ready,
|
||||
images found, dispatch 1, yet the layer upscaled nothing (status reason ok, api None, 0x0). `e5d7bddf` guessed a
|
||||
full buffer table (not confirmed); cause found after: the layer read doorbells from the last mailbox (the XeSS
|
||||
bridge's), fixed by pairing markers with their mailbox (`e422ab68`).
|
||||
- **Device-proven 12-05 03:09-03:31 EST, Red Magic 12 Pro, signed test build 97188d37 (= feat 0cb6afbf + test
|
||||
marker, CI 47496699289 green; unit tests 47495215764: 5515 tests, 0 failures):**
|
||||
- Bright Memory: Infinite (D3D12, Unreal, Streamline): status `api=DLSS (DX12) 640x360 -> 1280x720`,
|
||||
FSR 4.1 Full on the NPU, GPU 4.7 ms + NPU 4-6 ms, HUD "FSR4.1-Full-NPU 4.4ms", picture correct, no crash.
|
||||
Its system32 holds the CI copies of nvapi64/_nvngx (placed by game-env `04a67aa7`).
|
||||
- DLSS demo with NO signature-fix entry in its settings (default on, `d47ed325`): bridge log shows the hooks
|
||||
(WinVerifyTrust/CryptQueryObject/nvngx redirect); D3D12 46.8-48.7 fps, D3D11 38.5-50.0 fps,
|
||||
1280x720 -> 2560x1440, no crash.
|
||||
- All-engine rounds (XeSS samples DX12 + Vulkan, 9 engine/sync specs each): every engine active with its own
|
||||
tag, picture present, same flicker pattern as the rounds before this change, no crash.
|
||||
- Open: Deep Rock Galactic not tested (the installed copy is a cracked build; not worked around).
|
||||
- **Cyberpunk A/B on the phone (12-05 04:33-05:06 EST, unplugged, build 97188d37):** game's own benchmark via launch
|
||||
option `-benchmark -skipStartScreen` (writes summary.json + frames.csv, exits); window 1590x720, upscaler runs on the
|
||||
game's XeSS Performance (795x360). One run each, native repeated last (same 11.41 avg = no heat drift).
|
||||
| setup | avg | 1% low | W (battery, benchmark only) | fps/W | GPU load (HUD) |
|
||||
|---|---|---|---|---|---|
|
||||
| native | 11.41 | 7.9 | 10.09 (repeat 9.67) | 1.13 | 99 % |
|
||||
| FSR 4.1 Full NPU | 12.25 | 8.5 | 9.71 | 1.26 | 92-93 % |
|
||||
| SGSR 2 | 15.89 | 10.0 | 12.79 | 1.24 | 99 % |
|
||||
| plain stretch (upscaler off live) | 15.67 | 9.6 | 10.39 | 1.51 | 99 % |
|
||||
Findings: (1) FSR 4.1 Full NPU costs ~18 ms per frame vs the plain stretch (81.6 vs 63.8 ms) while the status reports
|
||||
GPU 8.2 + NPU 6.2 ms and the GPU sits partly idle: the async NPU path still stalls each frame (same pattern as Bright
|
||||
Memory: 15 vs 20 fps). Open, not investigated. (2) With FSR 4.1 Full NPU on, Cyberpunk hangs on exit after the
|
||||
benchmark (black, GPU 0 %, process alive 6+ min); SGSR 2, stretch, native exit normally. Open. (3) Picture (zoomed
|
||||
crops at the same spot): FSR 4.1 close to native; SGSR 2 looks nearly as blocky as the plain stretch.
|
||||
The benchmark moves its camera at most 66 ms per frame: every run = 64.2 s of path (used to match screenshots).
|
||||
Report: /sdcard/Download/Cyberpunk-upscaler-test-RM12-20261205.html (phone).
|
||||
- **Correction (12-05 13:0x EST):** the report's "same spot" screenshot rows were NOT the same spot (e.g. native = a
|
||||
close-up of a woman, FSR 4.1 = the pool table, SGSR 2 = a man in smoke, stretch = the bar), and the zoomed crops
|
||||
were taken at different distances. The 66 ms route model itself holds (64.15-64.19 s in all five runs); the error
|
||||
was mapping screenshot clock times onto the benchmark. Finding (3) above is therefore not reliable.
|
||||
- **Fair test (12-05 13:2x EST, running):** same DroidDeck 720p (1590x720) and game settings for every setup; 7
|
||||
numbers runs (native, FSR 4.1 NPU and SGSR 2 at XeSS Performance 795x360 and Quality 1060x480, plain stretch,
|
||||
native repeat), then 6 picture runs with back-to-back raw screenshots, matched across runs by image. Phone on
|
||||
the charger: no watts this round. Scripts: npu-rm `cp-ab3.sh` / `cp-ab3-all.sh` (local test kit).
|
||||
Result at 1590x720 (one run each): native 11.25 fps, FSR 4.1 NPU Quality 10.33 (-8 %), Performance 11.67 (+4 %),
|
||||
SGSR 2 Quality 12.91 (+15 %), Performance 14.28 (+27 %), plain stretch 15.01 (+33 %); GPU load (HUD) 89-93 % with
|
||||
FSR 4.1, 98-99 % otherwise. Same-spot pictures: FSR 4.1 close to native at both settings; SGSR 2 shows a blocky
|
||||
mosaic on moving people and edges (our shader uses Qualcomm's 9-tap filter, so this looks like a setup problem;
|
||||
not checked yet); plain stretch is soft, not blocky. FSR 4.1 exit hang seen again in all 4 FSR 4.1 runs.
|
||||
- **Rerun at 1280x720 (user, 12-05 14:34-15:24 EST, done):** same plan with the game at 1280x720
|
||||
(`DROIDDECK_GAME_RESOLUTION`) on DroidDeck's 720p output; XeSS Quality 853x480, Performance 640x360. Phone
|
||||
unplugged. Warm native (battery 41-42 C) 13.23 / 13.44 fps (the first native run started at 36 C: 16.02, not
|
||||
used). FSR 4.1 NPU Quality 11.83 (-12 %), Performance 13.54 (+1 %); SGSR 2 Quality 14.91 (+11 %), Performance
|
||||
17.16 (+28 %); plain stretch 17.45 (+30 %). GPU load (HUD) 90-93 % with FSR 4.1, 98-99 % otherwise. Pictures at
|
||||
the same spots: same verdict as at 1590x720. Report replaced in the phone's Download
|
||||
(Cyberpunk-upscaler-test-RM12-20261205.html, 8 MB). Test-kit fixes: close Wine services left after the game
|
||||
(they kept a session open once), route start = after the last run of 5+ black frames. Cyberpunk restored
|
||||
(no DroidDeck entry, original UserSettings, launch option empty).
|
||||
- Lesson: phone temperature moves fps by ~20 % here (cool start 16.0 vs warm 13.4 fps, same setup); every
|
||||
numbers run must start at the same warmth, and a native repeat at the end is needed to see it.
|
||||
- **User decisions 12-05:** (1) signature fix ON by default in DLSS mode (switch stays, off is stored as `0`);
|
||||
(2) no PR yet: keep testing and fixing on the branch.
|
||||
|
||||
---
|
||||
|
||||
## 2026-12-04 - `feat/neural-upscaler`: NPU engines on the phone's own QNN runtime (Red Magic 12 Pro, no root)
|
||||
|
||||
- **Why:** the upscaler's NPU engines only knew the bundled QNN files for HTP v79/v81. The Red Magic 12 Pro (SM8975,
|
||||
HTP V85) ships Qualcomm's QNN runtime and lists it for apps in `/vendor/etc/public.libraries.txt`.
|
||||
- **Built:** main merged in (`94bcfca5`); `c18aa23a` + `94754fea`: the app takes the HTP generation from the vendor's
|
||||
`libQnnHtpV<NN>Stub.so` and passes `DROIDDECK_UPSCALE_HTP_ARCH`; the layer uses the bundled QNN files only for an
|
||||
arch whose skel came with them, else the vendor libraries by name; no NPU download group on such phones.
|
||||
- **CI:** Build APK 47341155158 green (test branch `test/neural-upscaler-rm12` = this + a debuggable-only commit,
|
||||
never merged; 47338667435 failed on a Maven 429 and on my `this.npu()` inside `buildSet`).
|
||||
- **Device test (Red Magic 12 Pro, DroidDeck-Bionic r104 with this branch's tool lines):** the NPU engines are offered
|
||||
in the game menu; XeSS SDK demos (DX12, Vulkan), 960x540 to 1080p: FSR 4 Lite on the NPU = NPU 1.3-1.6 ms per frame
|
||||
and 2-2.5 ms less GPU time than FSR 4 Lite on the GPU, picture correct; FSR 4.0 on the NPU (3.5-3.7 ms), XeSS 3
|
||||
(10 ms) and the basic upscaler run; the NPU graph compiles on the phone in about 2 s and loads from cache after.
|
||||
- **Open:** XeSS runtime missing on a game's first launch (staged before the prefix exists); DLSS demo stops at NGX
|
||||
GetFeatureRequirements (PlatformError) after the VC++ 14 component; FSR 4.1.2 log text names v81 on every arch.
|
||||
|
||||
---
|
||||
|
||||
## 2026-10-16/17 - `feat/x86-64-steam-client`: web helper on the GPU, org main, review rounds
|
||||
|
||||
- **x86-64 web helper on the GPU** (`f603a085`): the client's own steamwebhelper runs ANGLE's GL backend
|
||||
@@ -1444,6 +1620,11 @@ State: **main = `90c7574`** (PR #14 merge), main build run 35895701784. No tag,
|
||||
- `app/src/main/cpp/waylandcomp/` - the compositor (shared lineage with Bannerlator).
|
||||
|
||||
## Lessons learned (don't repeat these)
|
||||
|
||||
- Check the PRoot layer with `tools/upscale/layer/build-glibc.sh` and a real glibc gcc (`CC=/usr/bin/gcc` in the
|
||||
container), not clang with an Android target: Android headers hide glibc-only breaks (2026-12-04, r5 port).
|
||||
- Build the bridge DLLs locally (`apt install gcc-mingw-w64-x86-64`, `tools/upscale/bridges/build.sh <dir>`) before CI
|
||||
after any merge touching them; read the CI step's own output lines, not a hash line, before saying a step passed.
|
||||
- Nothing in teardown may do bulk filesystem work on the main thread (0.1.1's ANR).
|
||||
- A CI closure check on a multi-line variable must flatten it first (`libaaudio.so` refusal).
|
||||
- A runtime script must be named `bannerlator-*` or CI never packages it.
|
||||
|
||||
@@ -27,6 +27,9 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
|
||||
| droiddeck-esync | Settings › Performance (`droiddeck://settings/performance`) | esync, sync, wine |
|
||||
| droiddeck-fsync first | Settings › Performance (`droiddeck://settings/performance`) | fsync, sync, wine |
|
||||
| droiddeck-ntsync | Settings › Performance (`droiddeck://settings/performance`) | ntsync, sync, wine |
|
||||
| Run proot without seccomp | Settings › Performance (`droiddeck://settings/performance`) | proot |
|
||||
| proot fast path | Settings › Performance (`droiddeck://settings/performance`) | proot |
|
||||
| Run without proot (experimental) | Settings › Performance (`droiddeck://settings/performance`) | proot |
|
||||
| Draw the cursor inside gamescope | Settings › Performance (`droiddeck://settings/performance`) | mouse, cursor |
|
||||
| Host name | Settings › Performance (`droiddeck://settings/performance`) | name |
|
||||
| Desktop runs as a user | Settings › Performance (`droiddeck://settings/performance`) | root, user, sudo, fakeroot |
|
||||
|
||||
@@ -41,7 +41,7 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
|
||||
ANDROID_*|BOOTCLASSPATH|DEX2OATBOOTCLASSPATH|SYSTEMSERVERCLASSPATH|EXTERNAL_STORAGE|ASEC_MOUNTPOINT) ;;
|
||||
FAKE_*|SDL_*|DD_WIDTH|DD_HEIGHT|DD_VK_DRIVER|WINEDLLOVERRIDES) ;;
|
||||
DISPLAY|GAMESCOPE_WAYLAND_DISPLAY|FEX_*) ;;
|
||||
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|DROIDDECK_NO_STEAM|BANNER_AUDIO_DIRECT_*) ;;
|
||||
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|BANNER_AUDIO_DIRECT_*) ;;
|
||||
mesa_glthread|vblank_mode|ZINK_*|GALLIUM_HUD|GALLIUM_THREAD) ;;
|
||||
DD_SYNC|DD_FSYNC_FIRST|DD_SYNC_FALLBACK|PROTON_NO_ESYNC|PROTON_NO_FSYNC|PROTON_NO_NTSYNC|WINEESYNC) ;;
|
||||
PROTON_USE_D7VK) ;;
|
||||
@@ -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) ;;
|
||||
# droiddeck-game-env's original Xbox switches for this layer's Wine and the Xbox VKD3D-Proton build
|
||||
WINE_SPECIAL_APC_INTERRUPT|WINE_MF_DISPLAY_APERTURE|WINE_PRECISE_SLEEP) ;;
|
||||
@@ -92,7 +93,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=0
|
||||
echo "WSI forced XWayland bypass disabled (GAMESCOPE_WSI_FORCE_BYPASS=$GAMESCOPE_WSI_FORCE_BYPASS)"
|
||||
[ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter
|
||||
@@ -138,13 +142,6 @@ echo "sync ntsync=$WINENTSYNC esync=$WINEESYNC ssbs=${WINE_FORCE_SSBS:-0} tu_deb
|
||||
export WINESTEAMCLIENTPATH64=$ROOTFS/root/.local/share/Steam/androidarm64/libsteamclient.so
|
||||
# The layer sends a game's steamclient(64).dll to lsteamclient (and so to DroidDeck's Steam through the library
|
||||
# above) only with WINE_LSTEAMCLIENT set; without it Valve's Windows steamclient runs alone and SteamAPI_Init fails.
|
||||
# A game set to start without Steam has no Steam client behind lsteamclient, and a steamclient64.dll it brings itself
|
||||
# (a Steam emulator such as gbe_fork's ColdClient loader) would be replaced by it, so the game quit after its splash
|
||||
# screen. Such a game keeps its own; a WINE_LSTEAMCLIENT the player set wins.
|
||||
if [ -z "${WINE_LSTEAMCLIENT:-}" ] && on "${DROIDDECK_NO_STEAM:-}"; then
|
||||
echo "lsteamclient off: started without Steam"
|
||||
export WINE_LSTEAMCLIENT=0
|
||||
fi
|
||||
export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}
|
||||
# Steam Input data (Valve's Steam Deck layouts with game actions) lives in DroidDeck's /dev/shm; libsteamshm.so
|
||||
# points the Android library's shared memory there (it keeps its own in-process otherwise) and gives it the
|
||||
|
||||
@@ -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?}"; }
|
||||
|
||||
@@ -225,7 +225,6 @@ else
|
||||
external/MaliBridge/scripts/build-client-linux.sh "$d" aarch64-linux-gnu-gcc
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -o "$d/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-glprobe"
|
||||
bash tools/linuxfs/lse-emu/build.sh "$d"
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -Wextra -o "$d/usr/local/bin/droiddeck-clipboard" tools/linuxfs/clipboard/clipboard.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-clipboard"
|
||||
for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"tools/vr",
|
||||
"tools/ime",
|
||||
"tools/gpuload",
|
||||
"tools/upscale/layer",
|
||||
"app/src/main/cpp/waylandcomp/generated",
|
||||
"app/src/main/cpp/waylandcomp/src/headpose_shm.h",
|
||||
"app/src/main/cpp/waylandcomp/src/spatialpose_shm.h",
|
||||
@@ -29,7 +30,9 @@
|
||||
"app/src/main/assets/linuxfs/usr/local/share/droiddeck/ibus.profile",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-ime/ibus-engine-pinyin",
|
||||
"app/src/main/assets/linuxfs/usr/share/pyzy/db/android.db",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-gpuload/libVkLayer_droiddeck_gpuload.so"
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-gpuload/libVkLayer_droiddeck_gpuload.so",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale-layer/libVkLayer_droiddeck_upscale.so",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale-layer/VK_LAYER_DROIDDECK_upscale.json"
|
||||
],
|
||||
"ndk": true,
|
||||
"packages": [
|
||||
@@ -273,5 +276,41 @@
|
||||
"lld",
|
||||
"llvm"
|
||||
]
|
||||
},
|
||||
"upscale-bridges": {
|
||||
"script": "tools/components/recipes/upscale-bridges.sh",
|
||||
"inputs": [
|
||||
"tools/upscale/bridges",
|
||||
"tools/components/recipes/upscale-bridges.sh"
|
||||
],
|
||||
"outputs": [
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/_nvngx.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/amd_fidelityfx_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/amd_fidelityfx_loader_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/amd_fidelityfx_upscaler_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/amd_fidelityfx_upscaler_vk.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/amd_fidelityfx_vk.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/ffx_fsr2_api_x64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/ffx_fsr3upscaler_x64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/libxess.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/nvapi64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/nvngx.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/x86_64-windows/nvngx_dlss.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/_nvngx.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/amd_fidelityfx_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/amd_fidelityfx_loader_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/amd_fidelityfx_upscaler_dx12.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/amd_fidelityfx_upscaler_vk.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/amd_fidelityfx_vk.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/ffx_fsr2_api_x64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/ffx_fsr3upscaler_x64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/libxess.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/nvapi64.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/nvngx.dll",
|
||||
"app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/aarch64-windows/nvngx_dlss.dll"
|
||||
],
|
||||
"packages": [
|
||||
"gcc-mingw-w64-x86-64"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_
|
||||
tools/vr/build.sh --native "$D/usr/local/lib/droiddeck-vr"
|
||||
VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1) \
|
||||
tools/gpuload/build.sh --native "$D/usr/local/lib/droiddeck-gpuload"
|
||||
VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1) \
|
||||
tools/upscale/layer/build-glibc.sh "$D/usr/local/lib/droiddeck-upscale-layer"
|
||||
for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
|
||||
install -Dm644 "$script" "$D/usr/local/bin/$(basename "$script")"
|
||||
done
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
bash tools/upscale/bridges/build.sh app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges
|
||||
@@ -23,8 +23,8 @@ import prepare # noqa: E402
|
||||
# CI records identities under its runner labels and pinned NDK, not this host's.
|
||||
RUNNER_ARCHITECTURES = ('X64', 'ARM64')
|
||||
# The components job builds these outside the recipe registry.
|
||||
UNREGISTERED_INPUTS = ['.github/workflows/build.yml', 'tools/linuxfs/xclipse-layer', 'tools/linuxfs/lse-emu',
|
||||
'tools/venus/glprobe.c', 'tools/quest']
|
||||
UNREGISTERED_INPUTS = ['.github/workflows/build.yml', 'tools/linuxfs/xclipse-layer', 'tools/venus/glprobe.c',
|
||||
'tools/quest']
|
||||
|
||||
|
||||
def ci_environment(architecture, root):
|
||||
|
||||
@@ -31,9 +31,5 @@ for sym in vkNegotiateLoaderLayerInterfaceVersion vkGetInstanceProcAddr vkGetDev
|
||||
grep -qx "$sym" <<<"$XCLIPSE" || { echo "::error::the Xclipse layer does not export $sym"; exit 1; }
|
||||
done
|
||||
test -f "$D/usr/local/lib/droiddeck-xclipse/VkLayer_droiddeck_xclipse.json"
|
||||
LSE=$(syms "$D/usr/local/lib/droiddeck-lse/liblse_emu.so")
|
||||
for sym in sigaction signal sigprocmask pthread_sigmask prctl syscall; do
|
||||
grep -qx "$sym" <<<"$LSE" || { echo "::error::liblse_emu.so does not export $sym"; exit 1; }
|
||||
done
|
||||
test -f "$D/usr/local/bin/droiddeck-session"
|
||||
test -f "$D/usr/local/bin/droiddeck-proton-extra"
|
||||
@@ -1,23 +0,0 @@
|
||||
# LSE-Emu
|
||||
|
||||
`lse_emu.c` is a copy of [SildurFX/LSE-Emu](https://github.com/SildurFX/LSE-Emu) at commit
|
||||
`8bc9548ac6fd24a8d506b266b17ba8d0e71a9b01` (GPL-3.0-or-later) with two fixes, listed in
|
||||
`docs/arm-v8.0-steam-client.md` under "Fixes over upstream": NZCV kept across the min/max
|
||||
stubs, and a store-back on `CASP` mismatches so the returned pair is atomic. Carry them forward
|
||||
until upstream has them.
|
||||
|
||||
It is an `LD_PRELOAD` library that emulates the ARMv8.1 LSE atomic instructions (and `LDAPR`)
|
||||
on ARMv8.0 CPUs. A SIGILL handler performs each trapped instruction with an LL/SC loop. A GNU
|
||||
IFUNC resolver installs a minimal early handler on CPUs without LSE before dependency
|
||||
constructors, covering LSE instructions executed before the preload constructor. The early handler
|
||||
is removed after initialization unless `LSE_EMU=1` is set. With `LSE_EMU_PATCH=1` the first trap at a site
|
||||
writes an LL/SC stub nearby and replaces the instruction with a branch to it, so later runs do not trap.
|
||||
Patching is off by default. It is restricted to private file-backed executable mappings whose
|
||||
live file and offset still match the original mapping. Leave patching off for programs that
|
||||
can remap executable pages concurrently: checking the mapping cannot lock it against a remap.
|
||||
|
||||
The session stages it as `/usr/local/lib/droiddeck-lse/liblse_emu.so` and only lists it in
|
||||
`/etc/ld.so.preload` when `/proc/cpuinfo` has no `atomics` flag. See
|
||||
`docs/arm-v8.0-steam-client.md` for why.
|
||||
|
||||
To update, copy `lse_emu.c` from a newer upstream commit and change the commit above.
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
D=${1:?asset directory}
|
||||
CC=${CC:-aarch64-linux-gnu-gcc}
|
||||
STRIP=${STRIP:-aarch64-linux-gnu-strip}
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
out="$D/usr/local/lib/droiddeck-lse/liblse_emu.so"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
"$CC" -shared -fPIC -O2 -march=armv8-a -mno-outline-atomics -Wall -Wextra -Wno-unused-parameter \
|
||||
-Wl,-z,now,-z,max-page-size=65536 -o "$out" "$here/lse_emu.c" -ldl
|
||||
"$STRIP" --strip-unneeded "$out"
|
||||
disassembly=$("${OBJDUMP:-aarch64-linux-gnu-objdump}" -d "$out")
|
||||
if grep -qE $'\t((ld|st)(add|clr|eor|set|smax|smin|umax|umin)|swp|cas)[a-z]*\t' <<<"$disassembly"; then
|
||||
echo "::error::liblse_emu.so itself contains LSE instructions"; exit 1
|
||||
fi
|
||||
File diff suppressed because it is too large.
Load diff
@@ -573,11 +573,11 @@ def inspector_url(url):
|
||||
|
||||
|
||||
def cdp_eval(agent_dir, expression, target=None, await_promise=True, timeout=15, inspector=None,
|
||||
command_line_api=False, connect_timeout=5):
|
||||
command_line_api=False):
|
||||
if inspector is not None:
|
||||
url, name = inspector_url(inspector), "inspector"
|
||||
else:
|
||||
targets = [t for t in cdp_targets(agent_dir, timeout=connect_timeout) if t.get("webSocketDebuggerUrl")]
|
||||
targets = [t for t in cdp_targets(agent_dir) if t.get("webSocketDebuggerUrl")]
|
||||
want = target or "SharedJSContext"
|
||||
match = [t for t in targets if want in (t.get("title") or "") or want in (t.get("url") or "")]
|
||||
if not match:
|
||||
@@ -841,75 +841,6 @@ class KeyboardWatcher(threading.Thread):
|
||||
self.report(params.get("payload") == "true")
|
||||
|
||||
|
||||
NATIVE_SUSPEND_JS = r"""/* Template arguments are inserted by Python after validation. */
|
||||
async (operation, token, value, order) => {
|
||||
const root = globalThis;
|
||||
const leases = root.__droiddeckNativeSleep ??= { current: null, order: 0n, canceled: false };
|
||||
const sequence = BigInt(order);
|
||||
if (sequence < leases.order) return operation === "wake" ? "miss" : "expired";
|
||||
if (sequence > leases.order) {
|
||||
// An older renderer evaluation can arrive after a newer one. Only
|
||||
// the newest Android request may own a still-in-flight preparation,
|
||||
// including when its own preparation cannot start before deadline.
|
||||
leases.order = sequence;
|
||||
leases.canceled = false;
|
||||
if (leases.current && !leases.current.result) {
|
||||
leases.current.owner = token;
|
||||
leases.current.wake = false;
|
||||
} else {
|
||||
leases.current = null;
|
||||
}
|
||||
}
|
||||
const busy = () => root.SuspendResumeStore?.m_bSuspending === true;
|
||||
const user = root.SteamClient?.User;
|
||||
async function recover(lease) {
|
||||
if (leases.current !== lease || lease.recovered || !lease.wake || busy()) return;
|
||||
if (typeof user?.ResumeSuspendedGames !== "function") return;
|
||||
lease.recovered = true;
|
||||
try { await user.ResumeSuspendedGames(false); } catch { /* no session kick or retry */ }
|
||||
}
|
||||
|
||||
if (operation === "wake") {
|
||||
leases.canceled = true;
|
||||
const lease = leases.current;
|
||||
if (lease?.owner !== token) return "miss";
|
||||
lease.wake = true;
|
||||
// If login1 already signaled sleep and preparation had settled before
|
||||
// wake, its normal resume notification owns recovery. A late success
|
||||
// must recover again only because that notification could precede it.
|
||||
if (lease.result === "prepared" && value !== "signaled") void recover(lease);
|
||||
return "ack";
|
||||
}
|
||||
|
||||
if (leases.canceled) return "expired";
|
||||
const active = leases.current;
|
||||
// A reused in-flight call still requires wake recovery, even when
|
||||
// this request is too late to issue its own call.
|
||||
if (active && !active.result) return "coalesced";
|
||||
if (Date.now() >= value) return "expired";
|
||||
if (typeof user?.PrepareForSystemSuspend !== "function") return "unavailable";
|
||||
if (busy()) return "steam-busy";
|
||||
if (active) return active.result;
|
||||
const lease = { owner: token, result: null, wake: false, recovered: false };
|
||||
leases.current = lease;
|
||||
try {
|
||||
const reply = await user.PrepareForSystemSuspend();
|
||||
lease.result = reply?.result === 1 ? "prepared" : "rejected";
|
||||
} catch {
|
||||
lease.result = "uncertain";
|
||||
}
|
||||
if (lease.result === "prepared" && lease.wake) void recover(lease);
|
||||
return lease.result;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def native_suspend_lease(agent_dir, command, token, value, order):
|
||||
expression = "(" + NATIVE_SUSPEND_JS + ")(" + ", ".join(map(json.dumps, (command, token, value, order))) + ")"
|
||||
return cdp_eval(agent_dir, expression, timeout=1.45 if command == "prepare" else 0.75,
|
||||
connect_timeout=0.35).get("value")
|
||||
|
||||
|
||||
def steam_idle_inhibit(agent_dir, inhibit):
|
||||
expression = """(async want => {
|
||||
const toggle = () => new Promise(done => {
|
||||
@@ -1387,23 +1318,6 @@ def main(argv):
|
||||
time.sleep(0.5)
|
||||
print({True: "yes", False: "no"}.get(value, "unknown"))
|
||||
return {True: 0, False: 5}.get(value, 1)
|
||||
if argv and argv[0] in ("--steam-prepare-native-suspend", "--steam-wake-native-suspend"):
|
||||
if (len(argv) != 4 or re.fullmatch(r"[0-9a-f]{32}", argv[1]) is None or
|
||||
re.fullmatch(r"[1-9][0-9]{0,19}", argv[3]) is None):
|
||||
return 2
|
||||
prepare = argv[0] == "--steam-prepare-native-suspend"
|
||||
if prepare and (not argv[2].isascii() or not argv[2].isdigit() or len(argv[2]) > 14):
|
||||
return 2
|
||||
if not prepare and argv[2] not in ("signaled", "unsignaled", "uncertain"):
|
||||
return 2
|
||||
kind = "prepare" if prepare else "wake"
|
||||
value = int(argv[2]) if prepare else argv[2]
|
||||
try:
|
||||
result = native_suspend_lease(Path(base) / "agent", kind, argv[1], value, argv[3])
|
||||
except (AgentError, OSError, ValueError):
|
||||
result = "uncertain"
|
||||
print(result or "uncertain")
|
||||
return 0 if result in ("prepared", "ack", "miss") else 1
|
||||
if argv and argv[0] == "--steam-asleep":
|
||||
expression = """(() => {
|
||||
const store = globalThis.SuspendResumeStore;
|
||||
|
||||
@@ -1152,6 +1152,228 @@ 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", "sgsr2_gpu", "fsr4_1_full_npu",
|
||||
"fsr4_1_lite_npu")
|
||||
# fsr4_0_npu: saved before full FSR 4.1 replaced FSR 4.0 on the NPU.
|
||||
UPSCALE_ENGINE_ALIASES = {"fsr4_0_npu": "fsr4_1_full_npu"}
|
||||
UPSCALE_NPU_FALLBACK = {"fsr4_1_full_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_link(source, target, hard_link=True):
|
||||
"""target = source's bytes: a hard link when both are on one file system (and hard_link), else a copy. Kept when
|
||||
equal."""
|
||||
if os.path.isfile(target) and os.path.getsize(target) == os.path.getsize(source):
|
||||
with open(source, "rb") as a, open(target, "rb") as b:
|
||||
if a.read() == b.read():
|
||||
return
|
||||
staged = target + ".droiddeck-tmp"
|
||||
if os.path.lexists(staged):
|
||||
os.unlink(staged)
|
||||
try:
|
||||
if not hard_link:
|
||||
raise OSError("copy wanted")
|
||||
os.link(source, staged)
|
||||
except OSError:
|
||||
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)
|
||||
|
||||
|
||||
# DLSS games load nvapi64.dll and NGX's core from system32 only (NGXCore FullPath is C:\windows\system32), which
|
||||
# the bridge folder on WINEDLLPATH does not answer. Wine copies the bridges there only when a prefix is created with
|
||||
# the upscaler already on; Bright Memory: Infinite's prefix predates it: "Failed to initialize NVAPI", then NGX
|
||||
# "failed to load C:\windows\system32\_nvngx.dll". With these four in system32 NGX reports "DLSS supported 1".
|
||||
UPSCALE_NGX_FILES = ("nvapi64.dll", "_nvngx.dll", "nvngx.dll", "nvngx_dlss.dll")
|
||||
|
||||
|
||||
def upscale_ngx_files(prefix, bridges, dlss):
|
||||
"""DLSS mode: the bridge's NVAPI and NGX DLLs as files in the prefix's system32. Other modes: our copies go,
|
||||
so a game taken out of DLSS mode no longer sees the NVIDIA stand-in (other files there are left alone)."""
|
||||
system32 = os.path.join(prefix, "pfx", "drive_c", "windows", "system32")
|
||||
if not os.path.isdir(system32):
|
||||
return False
|
||||
for name in UPSCALE_NGX_FILES:
|
||||
source = os.path.join(bridges, "x86_64-windows", name)
|
||||
target = os.path.join(system32, name)
|
||||
if not os.path.isfile(source):
|
||||
continue
|
||||
if dlss:
|
||||
# A copy, not a hard link: something writing over the prefix's nvapi64.dll in place must not change
|
||||
# DroidDeck's staged bridge.
|
||||
upscale_link(source, target, hard_link=False)
|
||||
elif os.path.isfile(target) and os.path.getsize(target) == os.path.getsize(source):
|
||||
with open(source, "rb") as a, open(target, "rb") as b:
|
||||
if a.read() == b.read():
|
||||
os.unlink(target)
|
||||
return True
|
||||
|
||||
|
||||
def upscale_xess(prefix, data):
|
||||
"""Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32. A hard link
|
||||
when the prefix is on the same file system as the data, else a copy."""
|
||||
source = os.path.join(data, "xess", UPSCALE_XESS)
|
||||
if not os.path.isfile(source):
|
||||
return "XeSS runtime not downloaded"
|
||||
upscale_link(source, os.path.join(prefix, "pfx", "drive_c", "windows", "system32", UPSCALE_XESS))
|
||||
return None
|
||||
|
||||
|
||||
def upscale_control(engine, sharpness, npu_sync, run=None):
|
||||
"""The live switch file the layer polls, written from this game's settings at every launch: a file left by the
|
||||
previous game (or the in-game menu) would otherwise win over them."""
|
||||
run = run or UPSCALE_RUN
|
||||
os.makedirs(run, exist_ok=True)
|
||||
staged = os.path.join(run, "ctrl.%d" % os.getpid())
|
||||
with open(staged, "w") as f:
|
||||
f.write("enabled=1\nbackend=%s\nsharpness=%.2f\nnpu_sync=%d\n" % (engine, sharpness / 100.0, 1 if npu_sync else 0))
|
||||
os.replace(staged, os.path.join(run, "ctrl"))
|
||||
|
||||
|
||||
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()
|
||||
engine = UPSCALE_ENGINE_ALIASES.get(engine, engine)
|
||||
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"'
|
||||
# NGX rejects the bridge DLLs without the signature fix; on unless this game switched it off ("0").
|
||||
result["DROIDDECK_UPSCALE_SIGFIX"] = "0" if env.get("DROIDDECK_UPSCALE_SIGFIX") == "0" else "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)
|
||||
try:
|
||||
if prefix:
|
||||
upscale_ngx_files(prefix, bridges, True)
|
||||
except OSError as error:
|
||||
notes.append("NVAPI/NGX DLLs not placed in system32 (%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 prefix and mode != "dlss":
|
||||
try:
|
||||
upscale_ngx_files(prefix, bridges, False)
|
||||
except OSError:
|
||||
pass
|
||||
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)
|
||||
# Intel's runtime goes into every upscaler game once it is downloaded, so XeSS 3 also works when it is
|
||||
# picked in the in-game menu; a game started on XeSS 3 without it falls back to FSR.
|
||||
if prefix and (engine == "xess3_gpu" or os.path.isfile(os.path.join(data, "xess", UPSCALE_XESS))):
|
||||
try:
|
||||
problem = upscale_xess(prefix, data)
|
||||
except OSError as error:
|
||||
problem = str(error)
|
||||
if problem and engine == "xess3_gpu":
|
||||
notes.append("XeSS: %s; the layer falls back to FSR" % problem)
|
||||
try:
|
||||
upscale_control(engine, sharpness, env.get("DROIDDECK_UPSCALE_NPU_SYNC") == "1")
|
||||
except OSError as error:
|
||||
notes.append("upscaler control file not written (%s)" % error)
|
||||
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"
|
||||
@@ -1843,6 +2065,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:
|
||||
|
||||
@@ -7,7 +7,6 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import gi
|
||||
@@ -21,10 +20,6 @@ INTERFACE = NAME + ".Manager"
|
||||
UPOWER = "org.freedesktop.UPower"
|
||||
UPOWER_ROOT = "/org/freedesktop/UPower"
|
||||
NATIVE_PREPARE_MS = 1500
|
||||
STEAM_PREPARE_WAIT = 1.95
|
||||
STEAM_PREPARE_START_MS = 850
|
||||
STEAM_WAKE_WAIT = 1.25
|
||||
STEAM_WAKE_RETRY_DELAYS = (0, 0.2, 0.5)
|
||||
AGENT = Path(__file__).resolve().with_name("droiddeck-agent")
|
||||
ASLEEP_WAIT = 6
|
||||
INHIBIT_WAIT = 12
|
||||
@@ -60,10 +55,6 @@ class LoginManager:
|
||||
self.native_ready = self.directory / "steam-native-ready"
|
||||
self.pending = None
|
||||
self.pending_idle = False
|
||||
self.native_preparation = None
|
||||
self.native_signaled = False
|
||||
self.native_order = None
|
||||
self.native_wake_work = None
|
||||
self.waiting = set()
|
||||
self.timeout = None
|
||||
self.preparation = None
|
||||
@@ -99,7 +90,6 @@ class LoginManager:
|
||||
if self.pending:
|
||||
reply.return_dbus_error(NAME + ".OperationInProgress", "The session is already pausing")
|
||||
return
|
||||
self.cancel_native_wake()
|
||||
self.pending = uuid.uuid4().hex
|
||||
self.pending_idle = False
|
||||
self.notify(True)
|
||||
@@ -143,42 +133,19 @@ class LoginManager:
|
||||
return
|
||||
self.pending = token
|
||||
self.pending_idle = words[1:] == ["idle"]
|
||||
# Idle requests never take ownership of Steam preparation. Preserve any
|
||||
# earlier wake delivery so an in-flight prepare cannot outlive its wake.
|
||||
if not self.pending_idle:
|
||||
self.cancel_native_wake()
|
||||
self.waiting = {"hold"} if self.pending_idle else {"hold", "prepare"}
|
||||
self.hold(token, self.prepared, token, "hold")
|
||||
if self.pending_idle:
|
||||
return
|
||||
self.native_preparation = "pending"
|
||||
order = self.native_order = str(time.monotonic_ns())
|
||||
deadline = int(time.time() * 1000) + STEAM_PREPARE_START_MS
|
||||
|
||||
def prepare():
|
||||
_, out = agent("--steam-prepare-native-suspend", token, str(deadline), order, timeout=STEAM_PREPARE_WAIT)
|
||||
GLib.idle_add(self.steam_prepared, token, out.strip() or "uncertain")
|
||||
|
||||
threading.Thread(target=prepare, daemon=True).start()
|
||||
|
||||
def steam_prepared(self, token, outcome):
|
||||
self.check_state()
|
||||
if self.pending != token:
|
||||
return False
|
||||
self.native_preparation = outcome
|
||||
self.native_signaled = True
|
||||
print("== login1: Steam native preparation " + outcome, flush=True)
|
||||
self.notify(True)
|
||||
self.bus.flush(None, self.prepare_after_flush, token)
|
||||
return False
|
||||
|
||||
def prepare_after_flush(self, connection, result, token):
|
||||
try:
|
||||
connection.flush_finish(result)
|
||||
except GLib.Error as error:
|
||||
print("== login1: cannot prepare native sleep: " + str(error), file=sys.stderr)
|
||||
if self.pending == token:
|
||||
self.resume()
|
||||
self.resume()
|
||||
return
|
||||
self.check_state()
|
||||
if self.pending == token:
|
||||
@@ -302,49 +269,19 @@ class LoginManager:
|
||||
self.notify(True)
|
||||
self.bus.flush(None, self.finish_recovery, None)
|
||||
return
|
||||
token = self.pending
|
||||
idle = self.pending_idle
|
||||
native = self.native_preparation
|
||||
signaled = self.native_signaled
|
||||
order = self.native_order
|
||||
self.native_order = None
|
||||
self.pending = None
|
||||
self.pending_idle = False
|
||||
self.native_preparation = None
|
||||
self.native_signaled = False
|
||||
if self.preparation is not None:
|
||||
GLib.source_remove(self.preparation)
|
||||
self.preparation = None
|
||||
if self.timeout is not None:
|
||||
GLib.source_remove(self.timeout)
|
||||
self.timeout = None
|
||||
if not idle and (native is None or signaled):
|
||||
if not idle:
|
||||
self.notify(False)
|
||||
if native in ("pending", "uncertain", "coalesced") or native == "prepared" and not signaled:
|
||||
phase = "uncertain" if signaled else "unsignaled"
|
||||
self.deliver_native_wake(token, phase, order)
|
||||
self.release_later()
|
||||
|
||||
def cancel_native_wake(self):
|
||||
if self.native_wake_work is not None:
|
||||
self.native_wake_work.set()
|
||||
self.native_wake_work = None
|
||||
|
||||
def deliver_native_wake(self, token, phase, order):
|
||||
work = self.native_wake_work = threading.Event()
|
||||
|
||||
def deliver():
|
||||
for delay in STEAM_WAKE_RETRY_DELAYS:
|
||||
if work.wait(delay):
|
||||
return
|
||||
code, outcome = agent("--steam-wake-native-suspend", token, phase, order, timeout=STEAM_WAKE_WAIT)
|
||||
if code == 0 and outcome.strip() in ("ack", "miss"):
|
||||
return
|
||||
if not work.is_set():
|
||||
print("== login1: Steam native wake recovery not acknowledged", file=sys.stderr, flush=True)
|
||||
|
||||
threading.Thread(target=deliver, daemon=True).start()
|
||||
|
||||
def finish_recovery(self, connection, result, _data):
|
||||
try:
|
||||
connection.flush_finish(result)
|
||||
|
||||
Regular → Executable
-7
@@ -11,12 +11,6 @@ if [ "${DD_RAISE_NOFILE:-0}" = 1 ] && [ -z "${DD_INSIDE:-}" ]; then
|
||||
unset dd_nofile_was
|
||||
fi
|
||||
export HOME=${HOME:-/root}
|
||||
if grep -qs '/liblse_emu\.so$' /etc/ld.so.preload; then
|
||||
if [ "${LSE_EMU+x}" != x ]; then export LSE_EMU=1; fi
|
||||
# Runtime instruction rewriting is opt-in; the SIGILL emulation path remains available.
|
||||
export LSE_EMU_PATCH=${LSE_EMU_PATCH:-0}
|
||||
[ -n "${DD_DEBUG_DIR:-}" ] && export LSE_EMU_LOG=${LSE_EMU_LOG:-$DD_DEBUG_DIR/lse_emu.log}
|
||||
fi
|
||||
mode=${1:-desktop}
|
||||
shift || true
|
||||
|
||||
@@ -106,7 +100,6 @@ if [ -n "${DD_LOG:-}" ] && [ -z "${DD_INSIDE:-}" ]; then
|
||||
echo "== uid=$(id -u) size=${DD_WIDTH:-?}x${DD_HEIGHT:-?} icd=${VK_ICD_FILENAMES:-none}"
|
||||
echo "== gamescope: $(gamescope --version 2>&1 | head -1) at $(command -v gamescope)"
|
||||
echo "== rootfs: $(cat /.version 2>/dev/null || echo unversioned)"
|
||||
[ "${LSE_EMU:-}" = 1 ] && echo "== cpu: no LSE atomics (ARMv8.0); liblse_emu.so emulates them (log: ${LSE_EMU_LOG:-off})"
|
||||
fi
|
||||
|
||||
start_diagnostic_inventory() {
|
||||
|
||||
@@ -968,7 +968,6 @@ def prepare_gog(sidecar, compat_data, launch_dir):
|
||||
GOG_SCRIPTS = "goggame-*.script"
|
||||
GOG_REGISTRY_MARK = ".droiddeck-gog-registry"
|
||||
GOG_SUPPORT_MARK = ".droiddeck-gog-support"
|
||||
GOG_SAVE_PATH_MARK = ".droiddeck-gog-save-path"
|
||||
GOG_ROOTS = {"HKEY_LOCAL_MACHINE": "HKEY_LOCAL_MACHINE", "HKLM": "HKEY_LOCAL_MACHINE",
|
||||
"HKEY_CURRENT_USER": "HKEY_CURRENT_USER", "HKCU": "HKEY_CURRENT_USER",
|
||||
"HKEY_CLASSES_ROOT": "HKEY_CLASSES_ROOT", "HKCR": "HKEY_CLASSES_ROOT"}
|
||||
@@ -1717,7 +1716,7 @@ def prepare_steam_ea(argv, compat_data, launch_dir):
|
||||
return REPLACED
|
||||
|
||||
|
||||
def gog_script_actions(folder, name):
|
||||
def gog_support_actions(folder):
|
||||
found = []
|
||||
for script in sorted(Path(folder).glob(GOG_SCRIPTS)):
|
||||
product = script.name[len("goggame-"):-len(".script")]
|
||||
@@ -1727,34 +1726,17 @@ def gog_script_actions(folder, name):
|
||||
continue
|
||||
for action in actions if isinstance(actions, list) else []:
|
||||
install = action.get("install") if isinstance(action, dict) else None
|
||||
if isinstance(install, dict) and install.get("action") == name \
|
||||
if isinstance(install, dict) and install.get("action") == "supportData" \
|
||||
and isinstance(install.get("arguments"), dict):
|
||||
found.append((product, install["arguments"]))
|
||||
return found
|
||||
|
||||
|
||||
def gog_support_actions(folder):
|
||||
return gog_script_actions(folder, "supportData")
|
||||
|
||||
|
||||
def gog_case_child(path, part):
|
||||
exact = path / part
|
||||
try:
|
||||
if not exact.exists() and path.is_dir():
|
||||
return next((child for child in path.iterdir() if child.name.lower() == part.lower()), exact)
|
||||
except OSError:
|
||||
pass
|
||||
return exact
|
||||
|
||||
|
||||
def gog_support_bases(folder, product, pfx):
|
||||
user = Path(pfx) / "drive_c" / "users" / "steamuser"
|
||||
support = Path(folder) / "support" / product
|
||||
appdata = gog_case_child(user, "AppData")
|
||||
return {"app": Path(folder), "supportdir": support, "support": support,
|
||||
"userdocs": gog_case_child(user, "Documents"),
|
||||
"localappdata": gog_case_child(appdata, "Local"),
|
||||
"userappdata": gog_case_child(appdata, "Roaming")}
|
||||
"userdocs": user / "Documents", "localappdata": user / "AppData" / "Local"}
|
||||
|
||||
|
||||
def gog_inside(path, base):
|
||||
@@ -1773,7 +1755,10 @@ def gog_support_path(text, bases):
|
||||
base = bases[match.group(1).lower()]
|
||||
path = base
|
||||
for part in parts:
|
||||
path = gog_case_child(path, part)
|
||||
exact = path / part
|
||||
if not exact.exists() and path.is_dir():
|
||||
exact = next((child for child in path.iterdir() if child.name.lower() == part.lower()), exact)
|
||||
path = exact
|
||||
if path != base and not gog_inside(path.parent, base):
|
||||
return None
|
||||
return path, base
|
||||
@@ -1845,44 +1830,6 @@ def gog_support_data(folder, compat_data, proton):
|
||||
return "copied=%d%s" % (copied, note)
|
||||
|
||||
|
||||
def gog_save_paths(folder, compat_data, proton):
|
||||
actions = gog_script_actions(folder, "savePath")
|
||||
if not actions:
|
||||
return "none"
|
||||
pfx = Path(compat_data) / "pfx" if compat_data else None
|
||||
if not pfx or not (pfx / "drive_c" / "users" / "steamuser").is_dir():
|
||||
made = create_prefix(compat_data, proton)
|
||||
if made not in ("present", "created") or not (pfx / "drive_c" / "users" / "steamuser").is_dir():
|
||||
return "no-prefix"
|
||||
stamp = hashlib.sha256(json.dumps(actions, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
marker = pfx / GOG_SAVE_PATH_MARK
|
||||
try:
|
||||
if marker.is_file() and marker.read_text() == stamp:
|
||||
return "ready"
|
||||
except OSError:
|
||||
pass
|
||||
paths = skipped = 0
|
||||
for product, arguments in actions:
|
||||
bases = gog_support_bases(folder, product, pfx)
|
||||
found = gog_support_path(arguments.get("savePath") or arguments.get("target"), bases)
|
||||
if found is None:
|
||||
skipped += 1
|
||||
continue
|
||||
target, _root = found
|
||||
try:
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
paths += 1
|
||||
except OSError:
|
||||
skipped += 1
|
||||
note = " skipped=%d" % skipped if skipped else ""
|
||||
if not skipped:
|
||||
try:
|
||||
marker.write_text(stamp)
|
||||
except OSError:
|
||||
pass
|
||||
return "paths=%d%s" % (paths, note)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if os.environ.get("DROIDDECK_GOG_MAINTENANCE") == "1":
|
||||
return 0
|
||||
@@ -1929,7 +1876,6 @@ def main(argv):
|
||||
prepare_gog(sidecar, compat_data, launch_dir)
|
||||
log("gog registry: " + apply_gog_registry(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
log("gog support data: " + gog_support_data(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
log("gog save paths: " + gog_save_paths(folder, compat_data, os.environ.get("DD_STORE_PROTON", "")))
|
||||
if store == "rockstar":
|
||||
if game not in ROCKSTAR_TITLES and not rockstar_sdk(folder, sidecar):
|
||||
if compat_data:
|
||||
|
||||
@@ -56,38 +56,27 @@ static unsigned hash_of(const char *s, int kind, int mode, int flags) {
|
||||
return h;
|
||||
}
|
||||
|
||||
static struct entry *slot(unsigned h) {
|
||||
return &table[(h ^ (h >> 16)) % PATH_CACHE_SLOTS];
|
||||
}
|
||||
|
||||
static int cacheable(const char *path) {
|
||||
return path != NULL && path[0] == '/' && strlen(path) < PATH_CACHE_KEY_MAX && enabled();
|
||||
}
|
||||
|
||||
static struct entry *find(const char *path, int kind, int mode, int flags, unsigned h) {
|
||||
long long now = now_ns();
|
||||
struct entry *e = slot(h);
|
||||
|
||||
for (int i = 0; i < PATH_CACHE_SLOTS; i++) {
|
||||
struct entry *e = &table[i];
|
||||
if (e->stamp == 0 || e->hash != h || e->kind != kind || e->mode != mode || e->flags != flags) continue;
|
||||
if (now - e->stamp > PATH_CACHE_TTL_NS || strcmp(e->key, path) != 0) continue;
|
||||
return e;
|
||||
}
|
||||
return NULL;
|
||||
if (e->stamp == 0 || e->hash != h || e->kind != kind || e->mode != mode || e->flags != flags) return NULL;
|
||||
if (now_ns() - e->stamp > PATH_CACHE_TTL_NS || strcmp(e->key, path) != 0) return NULL;
|
||||
return e;
|
||||
}
|
||||
|
||||
static void store(const char *path, int kind, int mode, int flags, unsigned h, const char *value) {
|
||||
struct entry *e = find(path, kind, mode, flags, h);
|
||||
long long now = now_ns();
|
||||
struct entry *e = slot(h);
|
||||
char *copy = value != NULL ? strdup(value) : NULL;
|
||||
|
||||
if (value != NULL && copy == NULL) return;
|
||||
if (e == NULL) {
|
||||
e = &table[0];
|
||||
for (int i = 0; i < PATH_CACHE_SLOTS; i++) {
|
||||
if (table[i].stamp == 0 || now - table[i].stamp > PATH_CACHE_TTL_NS) {
|
||||
e = &table[i];
|
||||
break;
|
||||
}
|
||||
if (table[i].stamp < e->stamp) e = &table[i];
|
||||
}
|
||||
}
|
||||
free(e->value);
|
||||
e->value = copy;
|
||||
e->hash = h;
|
||||
@@ -95,7 +84,7 @@ static void store(const char *path, int kind, int mode, int flags, unsigned h, c
|
||||
e->mode = mode;
|
||||
e->flags = flags;
|
||||
memcpy(e->key, path, strlen(path) + 1);
|
||||
e->stamp = now;
|
||||
e->stamp = now_ns();
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
|
||||
@@ -542,35 +542,7 @@ static int zr_start(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pthread_key_t zr_key;
|
||||
static int zr_key_ready;
|
||||
static pthread_mutex_t zr_key_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static unsigned char zr_idle;
|
||||
|
||||
static void zr_key_make(void) {
|
||||
if (__atomic_load_n(&zr_key_ready, __ATOMIC_ACQUIRE)) return;
|
||||
pthread_mutex_lock(&zr_key_lock);
|
||||
if (!__atomic_load_n(&zr_key_ready, __ATOMIC_ACQUIRE)) {
|
||||
pthread_key_t key;
|
||||
if (pthread_key_create(&key, NULL) == 0) {
|
||||
if (pthread_getspecific(key) == NULL) {
|
||||
zr_key = key;
|
||||
__atomic_store_n(&zr_key_ready, 1, __ATOMIC_RELEASE);
|
||||
} else {
|
||||
pthread_key_delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&zr_key_lock);
|
||||
}
|
||||
|
||||
static void zr_key_child(void) {
|
||||
pthread_mutex_init(&zr_key_lock, NULL);
|
||||
}
|
||||
|
||||
static volatile unsigned char *zr_selector(void) {
|
||||
return __atomic_load_n(&zr_key_ready, __ATOMIC_ACQUIRE) ? (volatile unsigned char *)pthread_getspecific(zr_key) : NULL;
|
||||
}
|
||||
static __thread volatile unsigned char *zr_dispatch __attribute__((tls_model("initial-exec")));
|
||||
|
||||
int prctl(int option, ...) {
|
||||
va_list ap;
|
||||
@@ -580,32 +552,16 @@ int prctl(int option, ...) {
|
||||
unsigned long arg4 = va_arg(ap, unsigned long);
|
||||
unsigned long arg5 = va_arg(ap, unsigned long);
|
||||
va_end(ap);
|
||||
int arming = option == PR_SET_SYSCALL_USER_DISPATCH && arg2;
|
||||
if (arming) {
|
||||
zr_key_make();
|
||||
if (!__atomic_load_n(&zr_key_ready, __ATOMIC_ACQUIRE)) {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
volatile unsigned char *dispatch = zr_selector();
|
||||
volatile unsigned char *dispatch = zr_dispatch;
|
||||
unsigned char selector = dispatch != NULL ? *dispatch : 0;
|
||||
if (selector) *dispatch = 0;
|
||||
if (arming && pthread_setspecific(zr_key, dispatch != NULL ? (void *)dispatch : (void *)&zr_idle) != 0) {
|
||||
if (selector) *dispatch = selector;
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
long result = zr_sys(SYS_prctl, option, arg2, arg3, arg4, arg5);
|
||||
int failed = (unsigned long)result > -4096UL;
|
||||
if (arming) pthread_setspecific(zr_key, failed ? (void *)dispatch : (void *)arg5);
|
||||
if (selector) *dispatch = selector;
|
||||
int ready = __atomic_load_n(&zr_key_ready, __ATOMIC_ACQUIRE);
|
||||
if (failed) {
|
||||
if ((unsigned long)result > -4096UL) {
|
||||
errno = (int)-result;
|
||||
return -1;
|
||||
}
|
||||
if (option == PR_SET_SYSCALL_USER_DISPATCH && !arg2 && ready) pthread_setspecific(zr_key, NULL);
|
||||
if (option == PR_SET_SYSCALL_USER_DISPATCH) zr_dispatch = arg2 ? (volatile unsigned char *)arg5 : NULL;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
@@ -613,7 +569,7 @@ static void zr_handler(int sig, siginfo_t *info, void *context) {
|
||||
(void)sig;
|
||||
(void)context;
|
||||
if (info == NULL || info->si_code != SI_USER) return;
|
||||
volatile unsigned char *dispatch = zr_selector();
|
||||
volatile unsigned char *dispatch = zr_dispatch;
|
||||
unsigned char selector = dispatch != NULL ? *dispatch : 0;
|
||||
if (selector) *dispatch = 0;
|
||||
int saved = errno;
|
||||
@@ -642,7 +598,6 @@ static void zr_paths(void) {
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void zr_init(void) {
|
||||
pthread_atfork(NULL, NULL, zr_key_child);
|
||||
zr_paths();
|
||||
int fd = zr_open(zr_ctl);
|
||||
if (fd < 0) return;
|
||||
|
||||
+16
-136
@@ -41,73 +41,9 @@ static char **clean_env_for_system(char *const envp[]) {
|
||||
return new_env;
|
||||
}
|
||||
|
||||
static int preload_has_entry(const char *chain, const char *entry, size_t entry_len) {
|
||||
if (!chain || !entry_len) return 0;
|
||||
const char *p = chain;
|
||||
while (*p) {
|
||||
size_t len = strcspn(p, ": ");
|
||||
if (len == entry_len && memcmp(p, entry, len) == 0) return 1;
|
||||
p += len;
|
||||
if (*p) p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *merge_preload_env(const char *host, const char *mapped) {
|
||||
size_t host_len = host ? strlen(host) : 0;
|
||||
char *out = malloc(11 + host_len + 1 + strlen(mapped) + 1);
|
||||
if (!out) return NULL;
|
||||
memcpy(out, "LD_PRELOAD=", 11);
|
||||
size_t used = 11;
|
||||
if (host_len) {
|
||||
memcpy(out + used, host, host_len);
|
||||
used += host_len;
|
||||
}
|
||||
for (const char *p = mapped; *p; ) {
|
||||
size_t n = strcspn(p, ": ");
|
||||
if (n && !preload_has_entry(host, p, n)) {
|
||||
if (used > 11) out[used++] = ':';
|
||||
memcpy(out + used, p, n);
|
||||
used += n;
|
||||
}
|
||||
p += n;
|
||||
if (*p) p++;
|
||||
}
|
||||
out[used] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
// Filter the LSE emulator from colon/space-separated preload chains when explicitly disabled.
|
||||
static char *filter_lse_emu_preloads(const char *value, int lse_emu_disabled) {
|
||||
if (!value) return NULL;
|
||||
size_t len = strlen(value);
|
||||
char *out = malloc(len + 1);
|
||||
if (!out) return NULL;
|
||||
size_t used = 0;
|
||||
const char *p = value;
|
||||
while (*p) {
|
||||
size_t n = strcspn(p, ": ");
|
||||
if (n) {
|
||||
const char *base = p + n;
|
||||
while (base > p && base[-1] != '/' && base[-1] != ':' && base[-1] != ' ') base--;
|
||||
int is_lse_emu = n - (size_t)(base - p) == strlen("liblse_emu.so") &&
|
||||
memcmp(base, "liblse_emu.so", strlen("liblse_emu.so")) == 0;
|
||||
if (!(lse_emu_disabled && is_lse_emu)) {
|
||||
if (used) out[used++] = ':';
|
||||
memcpy(out + used, p, n);
|
||||
used += n;
|
||||
}
|
||||
}
|
||||
p += n;
|
||||
if (*p) p++;
|
||||
}
|
||||
out[used] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
// LD_PRELOAD with every absolute path that is not in the rootfs yet mapped into it. Entries are
|
||||
// separated by ':' or ' '. free() the result.
|
||||
static char *map_preload_paths(const char *value, int lse_emu_disabled) {
|
||||
static char *map_preload_paths(const char *value) {
|
||||
if (!value) return NULL;
|
||||
size_t cap = strlen(value) + (g_ddnatv_root_len + 1) * 16 + 16;
|
||||
char *out = malloc(cap);
|
||||
@@ -121,13 +57,6 @@ static char *map_preload_paths(const char *value, int lse_emu_disabled) {
|
||||
char entry[PATH_MAX];
|
||||
memcpy(entry, p, len);
|
||||
entry[len] = '\0';
|
||||
const char *base = strrchr(entry, '/');
|
||||
base = base ? base + 1 : entry;
|
||||
if (lse_emu_disabled && strcmp(base, "liblse_emu.so") == 0) {
|
||||
p += len;
|
||||
if (*p) p++;
|
||||
continue;
|
||||
}
|
||||
char buf[PATH_MAX];
|
||||
const char *mapped = entry[0] == '/' ? rewrite_path_in_root(entry, buf, sizeof(buf)) : entry;
|
||||
size_t mlen = strlen(mapped);
|
||||
@@ -143,13 +72,10 @@ static char *map_preload_paths(const char *value, int lse_emu_disabled) {
|
||||
return out;
|
||||
}
|
||||
|
||||
static void free_modified_env(char **modified_env, char *const orig_env[]);
|
||||
|
||||
static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const char *lib_path) {
|
||||
init_ddnatv_hook();
|
||||
int count = 0;
|
||||
int has_preload = 0;
|
||||
int lse_emu_disabled = 0;
|
||||
int has_root = 0;
|
||||
int has_tunables = 0;
|
||||
int has_path = 0;
|
||||
@@ -179,7 +105,6 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
switch (e[0]) {
|
||||
case 'L':
|
||||
if (strncmp(e, "LD_PRELOAD=", 11) == 0) { has_preload = 1; preload_value = e + 11; }
|
||||
else if (strncmp(e, "LSE_EMU=0", 9) == 0 && e[9] == '\0') lse_emu_disabled = 1;
|
||||
break;
|
||||
case 'G':
|
||||
if (strncmp(e, "GLIBC_TUNABLES=", 15) == 0) has_tunables = 1;
|
||||
@@ -215,12 +140,6 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
count++;
|
||||
}
|
||||
|
||||
char *filtered_host_chain = lse_emu_disabled ? filter_lse_emu_preloads(g_preload_host, 1) : NULL;
|
||||
if (lse_emu_disabled && g_preload_host && !filtered_host_chain) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
const char *host_preload = lse_emu_disabled ? (filtered_host_chain ? filtered_host_chain : "") : g_preload_host;
|
||||
char **new_env = calloc(count + 26, sizeof(char *));
|
||||
int dst = 0;
|
||||
// The user the program runs as (hardlinks.c): this process's, whatever the environment it passes
|
||||
@@ -238,45 +157,23 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
if (envp[i][0] == 'D' && (strncmp(envp[i], "DDNATV_USER=", 12) == 0 || strncmp(envp[i], "DDNATV_BECOME=", 14) == 0)) {
|
||||
continue;
|
||||
}
|
||||
if (lse_emu_disabled && envp[i][0] == 'D' && strncmp(envp[i], "DDNATV_PRELOAD=", 15) == 0) {
|
||||
char *filtered = filter_lse_emu_preloads(envp[i] + 15, 1);
|
||||
if (!filtered) {
|
||||
free_modified_env(new_env, envp);
|
||||
free(filtered_host_chain);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
size_t len = 15 + strlen(filtered) + 1;
|
||||
char *str = malloc(len);
|
||||
if (!str) {
|
||||
free(filtered);
|
||||
free_modified_env(new_env, envp);
|
||||
free(filtered_host_chain);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
snprintf(str, len, "DDNATV_PRELOAD=%s", filtered);
|
||||
new_env[dst++] = str;
|
||||
free(filtered);
|
||||
continue;
|
||||
}
|
||||
if (has_preload && envp[i][0] == 'L' && strncmp(envp[i], "LD_PRELOAD=", 11) == 0) {
|
||||
// ld.so opens these itself: the guest's paths are mapped to the rootfs, and the libraries every
|
||||
// program loads (DDNATV_PRELOAD) come first
|
||||
char *mapped = map_preload_paths(preload_value, lse_emu_disabled);
|
||||
char *mapped = map_preload_paths(preload_value);
|
||||
if (mapped) {
|
||||
char *str = merge_preload_env(host_preload, mapped);
|
||||
free(mapped);
|
||||
size_t chain = g_preload_host ? strlen(g_preload_host) : 0;
|
||||
int has_chain = chain > 0 && strstr(mapped, g_preload_host) != NULL;
|
||||
size_t len = 11 + chain + 1 + strlen(mapped) + 1;
|
||||
char *str = malloc(len);
|
||||
if (str) {
|
||||
if (chain > 0 && !has_chain) snprintf(str, len, "LD_PRELOAD=%s:%s", g_preload_host, mapped);
|
||||
else snprintf(str, len, "LD_PRELOAD=%s", mapped);
|
||||
new_env[dst++] = str;
|
||||
free(mapped);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (lse_emu_disabled) {
|
||||
free_modified_env(new_env, envp);
|
||||
free(filtered_host_chain);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
free(mapped);
|
||||
}
|
||||
}
|
||||
// If we have an explicit real executable, drop the inherited entry to replace with the fresh target
|
||||
@@ -314,13 +211,13 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
const char *hook = (!has_preload && g_ddnatv_root[0] != '\0') ? ddnatv_hook_library(hook_buf, sizeof(hook_buf)) : NULL;
|
||||
if (hook) {
|
||||
size_t hook_len = strlen(hook);
|
||||
size_t host_len = host_preload ? strlen(host_preload) + 1 : 0;
|
||||
size_t host_len = g_preload_host ? strlen(g_preload_host) + 1 : 0;
|
||||
size_t size = 11 + host_len + hook_len + 1;
|
||||
char *str = malloc(size);
|
||||
if (str) {
|
||||
size_t n = ddnatv_append(str, size, 0, "LD_PRELOAD=", 11);
|
||||
if (host_len) {
|
||||
n = ddnatv_append(str, size, n, host_preload, host_len - 1);
|
||||
n = ddnatv_append(str, size, n, g_preload_host, host_len - 1);
|
||||
n = ddnatv_append(str, size, n, ":", 1);
|
||||
}
|
||||
ddnatv_append(str, size, n, hook, hook_len);
|
||||
@@ -328,29 +225,13 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
}
|
||||
}
|
||||
if (!has_preload_list && g_preload_guest) {
|
||||
char *filtered = lse_emu_disabled ? filter_lse_emu_preloads(g_preload_guest, 1) : NULL;
|
||||
if (lse_emu_disabled && !filtered) {
|
||||
free_modified_env(new_env, envp);
|
||||
free(filtered_host_chain);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
const char *guest_preload = lse_emu_disabled ? filtered : g_preload_guest;
|
||||
if (guest_preload) {
|
||||
size_t len = strlen(guest_preload);
|
||||
char *str = malloc(15 + len + 1);
|
||||
if (!str) {
|
||||
free(filtered);
|
||||
free_modified_env(new_env, envp);
|
||||
free(filtered_host_chain);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
size_t len = strlen(g_preload_guest);
|
||||
char *str = malloc(15 + len + 1);
|
||||
if (str) {
|
||||
memcpy(str, "DDNATV_PRELOAD=", 15);
|
||||
memcpy(str + 15, guest_preload, len + 1);
|
||||
memcpy(str + 15, g_preload_guest, len + 1);
|
||||
new_env[dst++] = str;
|
||||
}
|
||||
free(filtered);
|
||||
}
|
||||
if (!has_root && g_ddnatv_root[0] != '\0') {
|
||||
char *str = malloc(PATH_MAX + 16);
|
||||
@@ -438,7 +319,6 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const
|
||||
new_env[dst++] = strdup("DEBCONF_NONINTERACTIVE_SEEN=true");
|
||||
}
|
||||
new_env[dst] = NULL;
|
||||
free(filtered_host_chain);
|
||||
return new_env;
|
||||
}
|
||||
|
||||
|
||||
@@ -483,11 +483,6 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
return -1;
|
||||
}
|
||||
char **new_env = ensure_hook_in_envp(envp, elf_target, ld_lib_path);
|
||||
if (!new_env) {
|
||||
free(new_argv);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
int ret = run_execve(orig_execve, ld_so, new_argv, new_env);
|
||||
if (errno == EACCES && chmod(ld_so, 0755) == 0) {
|
||||
// ld.so without its exec bit (an unusual restore): fix it once and retry
|
||||
@@ -512,11 +507,6 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
if (new_argv) {
|
||||
prepare_static_program(static_elf); // ld.so is a static program itself
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target, NULL);
|
||||
if (!ddnatv_env) {
|
||||
free(new_argv);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
int ret = run_execve(orig_execve, target, new_argv, ddnatv_env);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
@@ -569,10 +559,6 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
|
||||
if (static_elf) prepare_static_program(static_elf);
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target, NULL);
|
||||
if (!ddnatv_env) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
int ret = run_execve(orig_execve, target, argv, ddnatv_env);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
@@ -1035,7 +1021,6 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
|
||||
build_ld_library_path(orig_ep, probe.runpath, probe.runpath_is_rpath, elf_target, ld_lib_path, sizeof(ld_lib_path));
|
||||
char **new_envp = in_root ? ensure_hook_in_envp(orig_ep, elf_target, via_ld_so ? ld_lib_path : NULL)
|
||||
: clean_env_for_system(orig_ep);
|
||||
if (in_root && !new_envp) return ENOMEM;
|
||||
|
||||
int ret = -1;
|
||||
if (via_ld_so) {
|
||||
|
||||
@@ -98,6 +98,11 @@ pack powervr "$repo/app/src/main/assets/hybris" runtime.tzst version.txt
|
||||
[ ! -f "$linuxfs/droiddeck-ubisoft/droiddeck-upc.exe" ] || pack ubisoft "$linuxfs/droiddeck-ubisoft" droiddeck-upc.exe
|
||||
[ ! -f "$linuxfs/droiddeck-rockstar/Launcher64.exe" ] || pack rockstar "$linuxfs/droiddeck-rockstar" Launcher32.exe Launcher64.exe
|
||||
[ ! -f "$linuxfs/droiddeck-dirt/ws2_32.dll" ] || pack dirt "$linuxfs/droiddeck-dirt" ws2_32.dll
|
||||
upscale=(_nvngx.dll amd_fidelityfx_dx12.dll amd_fidelityfx_loader_dx12.dll amd_fidelityfx_upscaler_dx12.dll
|
||||
amd_fidelityfx_upscaler_vk.dll amd_fidelityfx_vk.dll ffx_fsr2_api_x64.dll ffx_fsr3upscaler_x64.dll
|
||||
libxess.dll nvapi64.dll nvngx.dll nvngx_dlss.dll)
|
||||
[ ! -f "$linuxfs/droiddeck-upscale/bridges/x86_64-windows/nvngx.dll" ] || pack upscale "$linuxfs/droiddeck-upscale" \
|
||||
"${upscale[@]/#/bridges/x86_64-windows/}" "${upscale[@]/#/bridges/aarch64-windows/}"
|
||||
[ ! -f "$linuxfs/droiddeck-epic/EpicGamesLauncher.exe" ] || pack epic "$linuxfs/droiddeck-epic" EpicGamesLauncher.exe
|
||||
|
||||
mkdir "$work/butler"
|
||||
|
||||
@@ -16,17 +16,19 @@ PACKS = Path('app/build/packs')
|
||||
PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxfs/usr/local/lib/droiddeck-comet/': 'comet',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft', 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/': 'rockstar',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-dirt/': 'dirt', 'assets/linuxfs/usr/local/lib/droiddeck-epic/': 'epic',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-upscale/': 'upscale',
|
||||
'assets/directaudio/': 'directaudio', 'assets/hybris/': 'powervr'}
|
||||
# DrWeb flags proot itself as Tool.Linux.Proot; the app runs the pack's copy through Android's linker.
|
||||
PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so')}
|
||||
# The loader is execve'd, which targetSdk 29+ allows only from the APK's native library directory.
|
||||
PROOT_LOADER = {'lib/arm64-v8a/libproot-loader.so': 'libproot-loader.so'}
|
||||
PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic',
|
||||
'upscale']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/dirt-ws2', 'tools/ubisoft-launcher', 'tools/rockstar-launcher', 'tools/epic-launcher', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/dirt-ws2', 'tools/upscale', 'tools/ubisoft-launcher', 'tools/rockstar-launcher', 'tools/epic-launcher', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/ime', 'tools/powervr', 'tools/hybris', 'tools/dxvk', 'tools/vulkan-wsi',
|
||||
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal',
|
||||
'tools/quest', 'tools/vr/src', 'tools/vr/driver_droiddeck', 'tools/vr/layer', 'tools/vr/build.sh',
|
||||
@@ -110,7 +112,6 @@ def required():
|
||||
['msiinfo', 'cabextract', '7z', '7z.so', 'libmsi-1.0.so.0', 'libgsf-1.so.114', 'libgcab-1.0.so.0']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-xclipse/' + name for name in
|
||||
['libVkLayer_droiddeck_xclipse.so', 'VkLayer_droiddeck_xclipse.json']]
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-lse/liblse_emu.so']
|
||||
paths += ['assets/linuxfs/usr/local/lib/droiddeck-vr/' + name for name in
|
||||
['droiddeck/bin/linuxarm64/driver_droiddeck.so', 'droiddeck/bin/linuxarm64/xr-display-mode',
|
||||
'droiddeck/driver.vrdrivermanifest',
|
||||
@@ -258,7 +259,7 @@ def windows_binaries(package):
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
packs = {name: pack_digests(root, name) for name in PACK_NAMES
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt', 'epic') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt', 'epic', 'upscale') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
for name, rel in PROOT_LOADER.items():
|
||||
if packs['proot'].get(rel) != data['outputs'][name]['sha256']:
|
||||
raise ValueError('Add-on pack proot is missing or has a stale ' + rel)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static volatile uint64_t value;
|
||||
|
||||
__attribute__((constructor))
|
||||
static void use_lse_before_preload_init(void) {
|
||||
uint64_t old;
|
||||
uint64_t increment = 1;
|
||||
__asm__ volatile("ldaddal %x1, %x0, [%2]"
|
||||
: "=r"(old)
|
||||
: "r"(increment), "r"(&value)
|
||||
: "memory");
|
||||
if (old != 0 || value != 1) _exit(91);
|
||||
}
|
||||
|
||||
void lse_emu_early_dependency_anchor(void) {}
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void lse_emu_early_dependency_anchor(void);
|
||||
|
||||
int main(void) {
|
||||
lse_emu_early_dependency_anchor();
|
||||
puts("early lse ok");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,300 +0,0 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ucontext.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_THREADS 8
|
||||
#define ROUNDS 20000
|
||||
|
||||
static uint64_t counter64;
|
||||
static uint32_t counter32;
|
||||
static uint16_t counter16;
|
||||
static uint8_t counter8;
|
||||
static uint64_t spin;
|
||||
|
||||
static void check(int ok, const char *what) {
|
||||
if (!ok) {
|
||||
printf("FAIL %s\n", what);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t ldaddal64(uint64_t *p, uint64_t v) {
|
||||
uint64_t old;
|
||||
__asm__ volatile("ldaddal %x1, %x0, [%2]" : "=r"(old) : "r"(v), "r"(p) : "memory");
|
||||
return old;
|
||||
}
|
||||
|
||||
static uint32_t ldadd32(uint32_t *p, uint32_t v) {
|
||||
uint32_t old;
|
||||
__asm__ volatile("ldadd %w1, %w0, [%2]" : "=r"(old) : "r"(v), "r"(p) : "memory");
|
||||
return old;
|
||||
}
|
||||
|
||||
static uint16_t ldaddlh(uint16_t *p, uint16_t v) {
|
||||
uint16_t old;
|
||||
__asm__ volatile("ldaddlh %w1, %w0, [%2]" : "=r"(old) : "r"(v), "r"(p) : "memory");
|
||||
return old;
|
||||
}
|
||||
|
||||
static uint8_t ldaddab(uint8_t *p, uint8_t v) {
|
||||
uint8_t old;
|
||||
__asm__ volatile("ldaddab %w1, %w0, [%2]" : "=r"(old) : "r"(v), "r"(p) : "memory");
|
||||
return old;
|
||||
}
|
||||
|
||||
static uint64_t casal64(uint64_t *p, uint64_t expected, uint64_t desired) {
|
||||
__asm__ volatile("casal %x0, %x2, [%1]" : "+r"(expected) : "r"(p), "r"(desired) : "memory");
|
||||
return expected;
|
||||
}
|
||||
|
||||
static void *worker(void *arg) {
|
||||
(void)arg;
|
||||
for (int i = 0; i < ROUNDS; i++) {
|
||||
ldaddal64(&counter64, 1);
|
||||
ldadd32(&counter32, 1);
|
||||
ldaddlh(&counter16, 1);
|
||||
ldaddab(&counter8, 1);
|
||||
uint64_t seen = __atomic_load_n(&spin, __ATOMIC_RELAXED);
|
||||
while (casal64(&spin, seen, seen + 1) != seen) seen = __atomic_load_n(&spin, __ATOMIC_RELAXED);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static volatile sig_atomic_t app_handler_ran;
|
||||
|
||||
static void app_sigill(int sig, siginfo_t *info, void *context) {
|
||||
(void)sig;
|
||||
(void)info;
|
||||
app_handler_ran = 1;
|
||||
((ucontext_t *)context)->uc_mcontext.pc += 4;
|
||||
}
|
||||
|
||||
static void simple_sigill(int sig) { (void)sig; }
|
||||
|
||||
static volatile sig_atomic_t once_calls, persistent_calls, once_saw_default;
|
||||
static void persistent_sigill(int sig) { (void)sig; persistent_calls++; }
|
||||
|
||||
static void once_sigill(int sig) {
|
||||
struct sigaction previous, next = {0};
|
||||
once_calls++;
|
||||
if (sigaction(sig, NULL, &previous) == 0 && previous.sa_handler == SIG_DFL)
|
||||
once_saw_default = 1;
|
||||
next.sa_handler = persistent_sigill;
|
||||
sigemptyset(&next.sa_mask);
|
||||
if (sigaction(sig, &next, NULL) != 0) _Exit(2);
|
||||
}
|
||||
|
||||
static void check_one_shot_action(void) {
|
||||
struct sigaction action = {0};
|
||||
action.sa_handler = once_sigill;
|
||||
action.sa_flags = SA_RESETHAND;
|
||||
sigemptyset(&action.sa_mask);
|
||||
check(sigaction(SIGILL, &action, NULL) == 0, "install one-shot SIGILL");
|
||||
check(raise(SIGILL) == 0, "deliver one-shot SIGILL");
|
||||
check(once_calls == 1 && once_saw_default, "one-shot consumed before calling handler");
|
||||
check(raise(SIGILL) == 0, "deliver replacement SIGILL");
|
||||
check(once_calls == 1 && persistent_calls == 1, "replacement survives one-shot consumption");
|
||||
}
|
||||
|
||||
|
||||
static void set_test_action(int variant) {
|
||||
struct sigaction sa = {0};
|
||||
sigemptyset(&sa.sa_mask);
|
||||
if (variant == 0) {
|
||||
sa.sa_handler = simple_sigill;
|
||||
sigaddset(&sa.sa_mask, SIGUSR1);
|
||||
} else {
|
||||
sa.sa_sigaction = app_sigill;
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sigaddset(&sa.sa_mask, SIGUSR2);
|
||||
}
|
||||
int attempt;
|
||||
for (attempt = 0; attempt < 10000; attempt++) {
|
||||
if (sigaction(SIGILL, &sa, NULL) == 0) return;
|
||||
check(errno == ENOMEM, "unexpected action publication failure");
|
||||
sched_yield();
|
||||
}
|
||||
check(0, "action slots stayed exhausted");
|
||||
}
|
||||
|
||||
static void *replace_test_action(void *unused) {
|
||||
(void)unused;
|
||||
for (int i = 0; i < 4096; i++) set_test_action(i & 1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *query_test_action(void *unused) {
|
||||
(void)unused;
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
struct sigaction sa;
|
||||
check(sigaction(SIGILL, NULL, &sa) == 0, "query SIGILL action");
|
||||
int a = sigismember(&sa.sa_mask, SIGUSR1);
|
||||
int b = sigismember(&sa.sa_mask, SIGUSR2);
|
||||
if (sa.sa_flags & SA_SIGINFO)
|
||||
check(sa.sa_sigaction == app_sigill && !a && b, "coherent siginfo snapshot");
|
||||
else
|
||||
check(sa.sa_handler == simple_sigill && a && !b, "coherent simple snapshot");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned int fork_readers_stop;
|
||||
|
||||
static void *read_during_fork(void *unused) {
|
||||
(void)unused;
|
||||
while (!__atomic_load_n(&fork_readers_stop, __ATOMIC_RELAXED)) {
|
||||
struct sigaction out;
|
||||
if (sigaction(SIGILL, NULL, &out) != 0) _Exit(4);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void check_forked_actions(void) {
|
||||
struct sigaction install = {0};
|
||||
install.sa_handler = simple_sigill;
|
||||
sigemptyset(&install.sa_mask);
|
||||
check(sigaction(SIGILL, &install, NULL) == 0, "install SIGILL before fork");
|
||||
pthread_t readers[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
check(pthread_create(&readers[i], NULL, read_during_fork, NULL) == 0, "start fork reader");
|
||||
for (int child = 0; child < 8; child++) {
|
||||
pid_t pid = fork();
|
||||
check(pid >= 0, "fork SIGILL snapshot child");
|
||||
if (pid == 0) {
|
||||
struct sigaction inherited;
|
||||
if (sigaction(SIGILL, NULL, &inherited) != 0 || inherited.sa_handler != simple_sigill) _Exit(2);
|
||||
for (int i = 0; i < 1024; i++)
|
||||
if (sigaction(SIGILL, &install, NULL) != 0) _Exit(3);
|
||||
_Exit(0);
|
||||
}
|
||||
int status = 0;
|
||||
check(waitpid(pid, &status, 0) == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0,
|
||||
"child keeps action and can recycle more than 256 slots");
|
||||
}
|
||||
__atomic_store_n(&fork_readers_stop, 1, __ATOMIC_RELAXED);
|
||||
for (int i = 0; i < 4; i++) check(pthread_join(readers[i], NULL) == 0, "join fork reader");
|
||||
}
|
||||
|
||||
static void check_reused_actions(void) {
|
||||
set_test_action(0);
|
||||
pthread_t threads[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
check(pthread_create(&threads[i], NULL, i < 2 ? replace_test_action : query_test_action, NULL) == 0,
|
||||
"start action worker");
|
||||
for (int i = 0; i < 4; i++) check(pthread_join(threads[i], NULL) == 0, "join action worker");
|
||||
}
|
||||
|
||||
static __attribute__((noinline)) void single_forms(void) {
|
||||
uint64_t v = 0xF0;
|
||||
uint64_t old;
|
||||
register uint64_t ldap_result __asm__("x0");
|
||||
register uintptr_t ldap_address __asm__("x1") = (uintptr_t)&v;
|
||||
__asm__ volatile(".inst 0xf8bfc020" : "=r"(ldap_result) : "r"(ldap_address) : "memory");
|
||||
check(ldap_result == v, "ldapr");
|
||||
__asm__ volatile("ldclral %x1, %x0, [%2]" : "=r"(old) : "r"((uint64_t)0x30), "r"(&v) : "memory");
|
||||
check(old == 0xF0 && v == 0xC0, "ldclral");
|
||||
__asm__ volatile("ldeora %x1, %x0, [%2]" : "=r"(old) : "r"((uint64_t)0xFF), "r"(&v) : "memory");
|
||||
check(old == 0xC0 && v == 0x3F, "ldeora");
|
||||
__asm__ volatile("ldsetl %x1, %x0, [%2]" : "=r"(old) : "r"((uint64_t)0x100), "r"(&v) : "memory");
|
||||
check(old == 0x3F && v == 0x13F, "ldsetl");
|
||||
__asm__ volatile("swpal %x1, %x0, [%2]" : "=r"(old) : "r"((uint64_t)7), "r"(&v) : "memory");
|
||||
check(old == 0x13F && v == 7, "swpal");
|
||||
|
||||
int64_t s = -5;
|
||||
int64_t sold;
|
||||
__asm__ volatile("ldsmax %x1, %x0, [%2]" : "=r"(sold) : "r"((int64_t)-9), "r"(&s) : "memory");
|
||||
check(sold == -5 && s == -5, "ldsmax keeps the larger value");
|
||||
uint32_t u = 10;
|
||||
uint32_t uold;
|
||||
__asm__ volatile("ldumin %w1, %w0, [%2]" : "=r"(uold) : "r"((uint32_t)3), "r"(&u) : "memory");
|
||||
check(uold == 10 && u == 3, "ldumin");
|
||||
|
||||
uint64_t pair[2] __attribute__((aligned(16))) = {1, 2};
|
||||
register uint64_t e0 __asm__("x4") = 1, e1 __asm__("x5") = 2, d0 __asm__("x6") = 3, d1 __asm__("x7") = 4;
|
||||
__asm__ volatile("caspal x4, x5, x6, x7, [%4]" : "+r"(e0), "+r"(e1) : "r"(d0), "r"(d1), "r"(pair) : "memory");
|
||||
check(e0 == 1 && e1 == 2 && pair[0] == 3 && pair[1] == 4, "caspal");
|
||||
register uint64_t m0 __asm__("x4") = 8, m1 __asm__("x5") = 9, n0 __asm__("x6") = 5, n1 __asm__("x7") = 6;
|
||||
__asm__ volatile("caspal x4, x5, x6, x7, [%4]" : "+r"(m0), "+r"(m1) : "r"(n0), "r"(n1), "r"(pair) : "memory");
|
||||
check(m0 == 3 && m1 == 4 && pair[0] == 3 && pair[1] == 4, "caspal returns the current pair on a mismatch");
|
||||
|
||||
uint64_t missed = casal64(&v, 99, 1);
|
||||
check(missed == 7 && v == 7, "casal leaves memory alone on a mismatch");
|
||||
|
||||
uint32_t m = 1;
|
||||
uint32_t mold;
|
||||
uint64_t eq;
|
||||
__asm__ volatile("cmp %w3, %w3\n\tldumax %w2, %w0, [%4]\n\tcset %1, eq"
|
||||
: "=&r"(mold), "=&r"(eq) : "r"((uint32_t)5), "r"((uint32_t)0), "r"(&m) : "memory", "cc");
|
||||
check(mold == 1 && m == 5 && eq == 1, "ldumax leaves the condition flags alone");
|
||||
int8_t b = -3;
|
||||
int8_t bold;
|
||||
__asm__ volatile("cmp %w3, %w3\n\tldsmaxb %w2, %w0, [%4]\n\tcset %1, eq"
|
||||
: "=&r"(bold), "=&r"(eq) : "r"((int32_t)-7), "r"((uint32_t)0), "r"(&b) : "memory", "cc");
|
||||
check(bold == -3 && b == -3 && eq == 1, "ldsmaxb leaves the condition flags alone");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc == 2 && strcmp(argv[1], "sigill-fork") == 0) {
|
||||
check_forked_actions();
|
||||
puts("sigill fork ok");
|
||||
return 0;
|
||||
}
|
||||
if (argc == 2 && strcmp(argv[1], "sigill-oneshot") == 0) {
|
||||
check_one_shot_action();
|
||||
puts("sigill one-shot ok");
|
||||
return 0;
|
||||
}
|
||||
if (argc == 2 && strcmp(argv[1], "sigill-actions") == 0) {
|
||||
check_reused_actions();
|
||||
puts("sigill actions ok");
|
||||
return 0;
|
||||
}
|
||||
int threads_wanted = argc > 1 ? atoi(argv[1]) : 4;
|
||||
check(threads_wanted >= 1 && threads_wanted <= MAX_THREADS, "thread count");
|
||||
single_forms();
|
||||
single_forms();
|
||||
|
||||
pthread_t threads[MAX_THREADS];
|
||||
int started = 0;
|
||||
for (; started < threads_wanted; started++) {
|
||||
int err = pthread_create(&threads[started], NULL, worker, NULL);
|
||||
if (err != 0) {
|
||||
for (int i = 0; i < started; i++) pthread_join(threads[i], NULL);
|
||||
fprintf(stderr, "pthread_create failed: %s\n", strerror(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < started; i++) {
|
||||
int err = pthread_join(threads[i], NULL);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "pthread_join failed: %s\n", strerror(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
uint64_t total = (uint64_t)threads_wanted * ROUNDS;
|
||||
check(counter64 == total, "64-bit counter");
|
||||
check(counter32 == (uint32_t)total, "32-bit counter");
|
||||
check(counter16 == (uint16_t)total, "16-bit counter");
|
||||
check(counter8 == (uint8_t)total, "8-bit counter");
|
||||
check(spin == total, "casal loop");
|
||||
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sa_sigaction = app_sigill;
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sigaction(SIGILL, &sa, NULL);
|
||||
__asm__ volatile("udf #0");
|
||||
check(app_handler_ran, "the program's own SIGILL handler still runs");
|
||||
|
||||
printf("lse ok\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -86,38 +86,6 @@ class ToolArguments(unittest.TestCase):
|
||||
self.assertEqual(switches, {name: kept.get(name) for name in switches})
|
||||
self.assertNotIn('OTHER', kept)
|
||||
|
||||
def test_start_without_steam_reaches_wine(self):
|
||||
text = LAUNCH.read_text()
|
||||
block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')]
|
||||
env = dict(PATH=os.environ['PATH'], DROIDDECK_BIONIC_KEEP='PATH', DROIDDECK_NO_STEAM='1')
|
||||
result = subprocess.run(['sh', '-c', block + 'env\n'], env=env, text=True, capture_output=True, check=True)
|
||||
self.assertIn('DROIDDECK_NO_STEAM=1', result.stdout.splitlines())
|
||||
|
||||
|
||||
def lsteamclient(**env):
|
||||
text = LAUNCH.read_text()
|
||||
on = re.search(r'^on\(\) \{.*\}$', text, re.M).group(0)
|
||||
last = 'export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}\n'
|
||||
block = text[text.index('# A game set to start without Steam'):text.index(last) + len(last)]
|
||||
script = on + '\n' + block + 'echo "value=$WINE_LSTEAMCLIENT"\n'
|
||||
result = subprocess.run(['sh', '-c', script], env=dict(env, PATH=os.environ['PATH']),
|
||||
text=True, capture_output=True, check=True)
|
||||
return result.stdout.splitlines()[-1].split('=', 1)[1]
|
||||
|
||||
|
||||
class SteamBridge(unittest.TestCase):
|
||||
def test_games_with_steam_use_lsteamclient(self):
|
||||
self.assertEqual('1', lsteamclient())
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='0'))
|
||||
|
||||
def test_a_game_started_without_steam_keeps_its_own_steamclient(self):
|
||||
for value in ('1', 'on', 'true', 'yes'):
|
||||
self.assertEqual('0', lsteamclient(DROIDDECK_NO_STEAM=value))
|
||||
|
||||
def test_the_players_value_wins(self):
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='1', WINE_LSTEAMCLIENT='1'))
|
||||
self.assertEqual('0', lsteamclient(WINE_LSTEAMCLIENT='0'))
|
||||
|
||||
|
||||
class SessionLogs(unittest.TestCase):
|
||||
SESSION = '/data/user/0/com.droiddeck.launcher/files/logs/2026-11-22-09-steam'
|
||||
|
||||
@@ -4,6 +4,7 @@ import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
@@ -24,6 +25,142 @@ 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.run = os.path.join(self.root, "run")
|
||||
self.patch = patch.dict(MODULE["upscale_settings"].__globals__, {"UPSCALE_ROOT": self.root, "UPSCALE_RUN": self.run})
|
||||
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_upscale_old_fsr4_npu_runs_full_fsr4_and_sgsr2_passes(self):
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_0_npu",
|
||||
"DROIDDECK_UPSCALE_NPU": "1"}, None)
|
||||
self.assertEqual("fsr4_1_full_npu", env["DROIDDECK_UPSCALE_BACKEND"])
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_1_full_npu"}, None)
|
||||
self.assertEqual("fsr4_1_full_gpu", env["DROIDDECK_UPSCALE_BACKEND"])
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "sgsr2_gpu"}, None)
|
||||
self.assertEqual("sgsr2_gpu", env["DROIDDECK_UPSCALE_BACKEND"])
|
||||
|
||||
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_the_control_file_follows_this_games_settings(self):
|
||||
Path(self.run).mkdir()
|
||||
Path(self.run, "ctrl").write_text("enabled=0\nbackend=fsr4_1_lite_gpu\nsharpness=0.55\nnpu_sync=0\n")
|
||||
_, notes = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "xess3_gpu",
|
||||
"DROIDDECK_UPSCALE_SHARPNESS": "40"}, None)
|
||||
self.assertEqual("enabled=1\nbackend=xess3_gpu\nsharpness=0.40\nnpu_sync=0\n", Path(self.run, "ctrl").read_text())
|
||||
self.assertFalse([n for n in notes if "control file" in n])
|
||||
|
||||
def test_the_xess_runtime_goes_into_any_upscaler_game_once_downloaded(self):
|
||||
prefix = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, prefix, True)
|
||||
Path(prefix, "pfx/drive_c/windows/system32").mkdir(parents=True)
|
||||
source = Path(self.root, "data/xess", MODULE["UPSCALE_XESS"])
|
||||
source.parent.mkdir(parents=True)
|
||||
source.write_bytes(b"MZ-xess")
|
||||
MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_1_lite_gpu"}, prefix)
|
||||
target = Path(prefix, "pfx/drive_c/windows/system32", MODULE["UPSCALE_XESS"])
|
||||
self.assertEqual(b"MZ-xess", target.read_bytes())
|
||||
self.assertEqual(source.stat().st_ino, target.stat().st_ino)
|
||||
|
||||
def test_dlss_mode_turns_the_signature_fix_on_unless_switched_off(self):
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, None)
|
||||
self.assertEqual("1", env["DROIDDECK_UPSCALE_SIGFIX"])
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss", "DROIDDECK_UPSCALE_SIGFIX": "0"}, None)
|
||||
self.assertEqual("0", env["DROIDDECK_UPSCALE_SIGFIX"])
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr"}, None)
|
||||
self.assertNotIn("DROIDDECK_UPSCALE_SIGFIX", env)
|
||||
def test_dlss_mode_puts_nvapi_and_ngx_in_system32_and_other_modes_take_ours_out(self):
|
||||
prefix = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, prefix, True)
|
||||
system32 = Path(prefix, "pfx/drive_c/windows/system32")
|
||||
system32.mkdir(parents=True)
|
||||
for name in ("nvapi64.dll", "_nvngx.dll", "nvngx.dll", "nvngx_dlss.dll"):
|
||||
Path(self.root, "bridges/x86_64-windows", name).write_bytes(b"MZ-v1-" + name.encode())
|
||||
MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, prefix)
|
||||
self.assertEqual(b"MZ-v1-nvapi64.dll", (system32 / "nvapi64.dll").read_bytes())
|
||||
self.assertEqual(b"MZ-v1-_nvngx.dll", (system32 / "_nvngx.dll").read_bytes())
|
||||
Path(self.root, "bridges/x86_64-windows/_nvngx.dll").unlink()
|
||||
Path(self.root, "bridges/x86_64-windows/_nvngx.dll").write_bytes(b"MZ-v2-_nvngx.dll")
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, prefix)
|
||||
self.assertEqual(b"MZ-v2-_nvngx.dll", (system32 / "_nvngx.dll").read_bytes())
|
||||
self.assertEqual("rtx", env["DROIDDECK_UPSCALE_GPU_SPOOF"])
|
||||
(system32 / "nvngx.dll").write_bytes(b"someone else's nvngx")
|
||||
env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr"}, prefix)
|
||||
self.assertEqual("off", env["DROIDDECK_UPSCALE_GPU_SPOOF"])
|
||||
self.assertFalse((system32 / "nvapi64.dll").exists())
|
||||
self.assertFalse((system32 / "_nvngx.dll").exists())
|
||||
self.assertEqual(b"someone else's nvngx", (system32 / "nvngx.dll").read_bytes())
|
||||
|
||||
|
||||
def test_a_game_started_on_xess_without_the_runtime_says_so(self):
|
||||
prefix = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, prefix, True)
|
||||
Path(prefix, "pfx/drive_c/windows/system32").mkdir(parents=True)
|
||||
_, notes = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "xess3_gpu"}, prefix)
|
||||
self.assertTrue([n for n in notes if "XeSS runtime not downloaded" in n])
|
||||
|
||||
def test_the_app_stages_every_dll_the_bridge_build_makes(self):
|
||||
repo = Path(__file__).resolve().parents[2]
|
||||
build = (repo / "tools/upscale/bridges/build.sh").read_text()
|
||||
built = set(re.search(r"names=\(([^)]*)\)", build).group(1).split())
|
||||
kotlin = (repo / "app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt").read_text()
|
||||
staged = set(re.findall(r'"([A-Za-z0-9_]+\.dll)"', kotlin[kotlin.index("BRIDGE_NAMES"):kotlin.index("BRIDGE_FILES")]))
|
||||
self.assertEqual(built, staged)
|
||||
|
||||
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 ProducerAcquireGameEnvironmentTest(unittest.TestCase):
|
||||
def test_prefixed_opt_in_enters_only_the_game_environment(self):
|
||||
key = "DROIDDECK_GAME_FRAME_ACQUIRE"
|
||||
|
||||
+2
-240
@@ -1,9 +1,7 @@
|
||||
from contextlib import contextmanager
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import signal
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
@@ -148,9 +146,9 @@ class SleepHandshakeTest(unittest.TestCase):
|
||||
staged.write_text("wake\n")
|
||||
staged.replace(self.dir / "steam-wake")
|
||||
|
||||
def request_native(self, token="1" * 32, idle=False):
|
||||
def request_native(self, token="1" * 32):
|
||||
staged = self.dir / "steam-native-sleep.tmp"
|
||||
staged.write_text(token + (" idle" if idle else "") + "\n")
|
||||
staged.write_text(token + "\n")
|
||||
staged.replace(self.dir / "steam-native-sleep")
|
||||
return token
|
||||
|
||||
@@ -327,132 +325,6 @@ class AsleepSteamTest(FakeAgentCase):
|
||||
"--steam-idle-inhibit", "off"], self.asked())
|
||||
|
||||
|
||||
@unittest.skipUnless(Gio and os.environ.get("DBUS_SESSION_BUS_ADDRESS"), "requires dbus-run-session and PyGObject")
|
||||
class NativePrepareTest(FakeAgentCase):
|
||||
AGENT_EXIT = 0
|
||||
|
||||
def prepare_agent(self, delay, fail_first_wake=False, gated=False):
|
||||
script = self.dir / "bin/droiddeck-agent"
|
||||
prepare = f'sleep {delay}'
|
||||
failed_wake = ':'
|
||||
if gated:
|
||||
prepare = f'while [ ! -f "{self.dir / "release-prepare"}" ]; do sleep 0.025; done'
|
||||
failed_wake = f'while [ ! -f "{self.dir / "release-wake"}" ]; do sleep 0.025; done'
|
||||
script.write_text(
|
||||
f'#!/bin/sh\necho "$@" >> "{self.dir / "agent-calls"}"\n'
|
||||
f'case "$1" in --steam-prepare-native-suspend) {prepare}; echo prepared;;\n'
|
||||
'--steam-wake-native-suspend)\n'
|
||||
f' if [ "{int(fail_first_wake)}" -eq 1 ] && [ ! -f "{self.dir / "wake-tried"}" ]; then\n'
|
||||
f' touch "{self.dir / "wake-tried"}"; {failed_wake}; echo uncertain; exit 1; fi\n'
|
||||
' echo ack;; esac\n'
|
||||
"exit 0\n"
|
||||
)
|
||||
|
||||
@contextmanager
|
||||
def gated_agent(self, fail_first_wake=False):
|
||||
self.prepare_agent(0, fail_first_wake=fail_first_wake, gated=True)
|
||||
release_prepare = self.dir / "release-prepare"
|
||||
release_wake = self.dir / "release-wake"
|
||||
try:
|
||||
yield release_prepare, release_wake
|
||||
finally:
|
||||
release_prepare.touch()
|
||||
release_wake.touch()
|
||||
|
||||
def test_native_prepare_precedes_real_sleep_and_normal_wake_does_not_call_recovery(self):
|
||||
with self.gated_agent() as (release_prepare, _):
|
||||
token = self.request_native()
|
||||
self.wait_for(lambda: "--steam-prepare-native-suspend" in self.asked())
|
||||
self.assertEqual(self.signals, [])
|
||||
release_prepare.touch()
|
||||
self.wait_for(lambda: self.signals == [True])
|
||||
self.wait_for(lambda: (self.dir / "steam-native-ready").exists())
|
||||
self.state(token, "paused")
|
||||
self.state(token, "awake")
|
||||
self.wait_for(lambda: self.signals == [True, False])
|
||||
self.assertNotIn("--steam-wake-native-suspend", self.asked())
|
||||
|
||||
def test_awake_during_rpc_never_notifies_or_publishes_a_stale_pause(self):
|
||||
with self.gated_agent() as (release_prepare, _):
|
||||
token = self.request_native()
|
||||
self.wait_for(lambda: "--steam-prepare-native-suspend" in self.asked())
|
||||
self.state(token, "awake")
|
||||
self.wait_for(lambda: "unsignaled" in self.asked())
|
||||
release_prepare.touch()
|
||||
time.sleep(0.6)
|
||||
self.assertFalse((self.dir / "steam-native-ready").exists())
|
||||
self.assertEqual(self.signals, [])
|
||||
subsequent = self.request_native("3" * 32)
|
||||
self.wait_for(lambda: (self.dir / "steam-native-ready").exists())
|
||||
self.assertEqual((self.dir / "steam-native-ready").read_text().strip(), subsequent)
|
||||
self.state(subsequent, "awake")
|
||||
self.wait_for(lambda: self.signals == [True, False])
|
||||
|
||||
def test_ambiguous_wake_retries_transient_discovery_with_same_token(self):
|
||||
with self.gated_agent(fail_first_wake=True) as (release_prepare, release_wake):
|
||||
token = self.request_native()
|
||||
self.wait_for(lambda: "--steam-prepare-native-suspend" in self.asked())
|
||||
self.state(token, "awake")
|
||||
self.wait_for(lambda: (self.dir / "wake-tried").exists())
|
||||
release_prepare.touch()
|
||||
release_wake.touch()
|
||||
self.wait_for(lambda: self.asked().count("--steam-wake-native-suspend") == 2)
|
||||
time.sleep(0.8)
|
||||
calls = (self.dir / "agent-calls").read_text().splitlines()
|
||||
wakes = [call.split() for call in calls if call.startswith("--steam-wake-native-suspend ")]
|
||||
self.assertEqual(len(wakes), 2)
|
||||
self.assertEqual(wakes[0], wakes[1])
|
||||
self.assertEqual(wakes[0][1:3], [token, "unsignaled"])
|
||||
prepare = next(call.split() for call in calls if call.startswith("--steam-prepare-native-suspend "))
|
||||
self.assertEqual(wakes[0][3], prepare[3])
|
||||
self.assertEqual(self.signals, [])
|
||||
|
||||
def test_new_sleep_request_cancels_retry_of_older_wake(self):
|
||||
with self.gated_agent(fail_first_wake=True) as (release_prepare, release_wake):
|
||||
first = self.request_native()
|
||||
self.wait_for(lambda: "--steam-prepare-native-suspend" in self.asked())
|
||||
self.state(first, "awake")
|
||||
self.wait_for(lambda: (self.dir / "wake-tried").exists())
|
||||
second = self.request_native("3" * 32)
|
||||
self.wait_for(lambda: second in self.asked())
|
||||
release_prepare.touch()
|
||||
release_wake.touch()
|
||||
time.sleep(0.9)
|
||||
self.assertEqual(self.asked().count("--steam-wake-native-suspend"), 1)
|
||||
self.state(second, "awake")
|
||||
|
||||
def test_idle_request_preserves_retry_of_older_wake(self):
|
||||
with self.gated_agent(fail_first_wake=True) as (release_prepare, release_wake):
|
||||
first = self.request_native()
|
||||
self.wait_for(lambda: "--steam-prepare-native-suspend" in self.asked())
|
||||
self.state(first, "awake")
|
||||
self.wait_for(lambda: (self.dir / "wake-tried").exists())
|
||||
release_prepare.touch()
|
||||
idle = self.request_native("3" * 32, idle=True)
|
||||
ready = self.dir / "steam-native-ready"
|
||||
self.wait_for(lambda: ready.exists() and ready.read_text().strip() == idle)
|
||||
self.state(idle, "paused")
|
||||
self.state(idle, "awake")
|
||||
release_wake.touch()
|
||||
self.wait_for(lambda: self.asked().count("--steam-wake-native-suspend") == 2)
|
||||
wakes = [call for call in (self.dir / "agent-calls").read_text().splitlines()
|
||||
if call.startswith("--steam-wake-native-suspend ")]
|
||||
self.assertEqual(wakes[0], wakes[1])
|
||||
self.assertEqual(wakes[0].split()[1:3], [first, "unsignaled"])
|
||||
self.assertEqual(self.asked().count("--steam-prepare-native-suspend"), 1)
|
||||
self.assertEqual(self.signals, [])
|
||||
|
||||
def test_timed_out_rpc_allows_sleep_and_wake_recovers_that_token(self):
|
||||
self.prepare_agent(6)
|
||||
token = self.request_native()
|
||||
self.wait_for(lambda: self.signals == [True], timeout=3.0)
|
||||
self.wait_for(lambda: (self.dir / "steam-native-ready").exists(), timeout=2.0)
|
||||
self.state(token, "paused")
|
||||
self.state(token, "awake")
|
||||
self.wait_for(lambda: self.signals == [True, False] and "uncertain" in self.asked())
|
||||
self.assertIn(token, self.asked())
|
||||
|
||||
|
||||
class WithNetworkManagerTest(SleepHandshakeTest):
|
||||
ARGS = ["--with-netmanager"]
|
||||
|
||||
@@ -470,115 +342,5 @@ class WithNetworkManagerTest(SleepHandshakeTest):
|
||||
self.assertEqual(self.owner(NAME), self.process.pid)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which("node"), "node is not installed")
|
||||
class NativeSleepLeaseTest(unittest.TestCase):
|
||||
def test_wake_and_prepare_ordering_in_the_renderer(self):
|
||||
result = subprocess.run(["node", "-e", NATIVE_LEASE_CASES, str(SCRIPT.with_name("droiddeck-agent"))],
|
||||
text=True, capture_output=True, timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("PASS nine native preparation lease sequences", result.stdout)
|
||||
|
||||
|
||||
NATIVE_LEASE_CASES = r'''const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const text = fs.readFileSync(process.argv[1], "utf8").match(/NATIVE_SUSPEND_JS = r"""([\s\S]*?)"""/)[1];
|
||||
const call = eval("(" + text + ")");
|
||||
const run = (op, token, value) => call(op, token, value, token === a ? "100" : "200");
|
||||
const a = "1".repeat(32);
|
||||
const b = "2".repeat(32);
|
||||
const future = () => Date.now() + 5000;
|
||||
let invoked, resumes, result;
|
||||
function setup() {
|
||||
delete globalThis.__droiddeckNativeSleep;
|
||||
globalThis.SuspendResumeStore = { m_bSuspending: false };
|
||||
invoked = resumes = 0;
|
||||
globalThis.SteamClient = { User: {
|
||||
PrepareForSystemSuspend() { invoked++; return new Promise(resolve => { result = resolve; }); },
|
||||
ResumeSuspendedGames(kick) { assert.equal(kick, false); resumes++; return Promise.resolve({ result: 1 }); }
|
||||
}};
|
||||
}
|
||||
(async () => {
|
||||
setup();
|
||||
assert.equal(await run("prepare", a, Date.now() - 1), "expired");
|
||||
assert.equal(await run("wake", a, "unsignaled"), "miss");
|
||||
assert.equal(await run("prepare", a, future()), "expired");
|
||||
assert.equal(invoked, 0);
|
||||
|
||||
setup();
|
||||
let prep = run("prepare", a, future());
|
||||
result({result: 1});
|
||||
assert.equal(await prep, "prepared");
|
||||
await run("wake", a, "signaled");
|
||||
assert.equal(resumes, 0);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
await run("wake", a, "unsignaled");
|
||||
result({result: 1});
|
||||
assert.equal(await prep, "prepared");
|
||||
await run("wake", a, "unsignaled");
|
||||
assert.equal(resumes, 1);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
result({result: 1});
|
||||
await prep;
|
||||
await run("wake", a, "uncertain");
|
||||
assert.equal(resumes, 1);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
await run("wake", a, "unsignaled");
|
||||
assert.equal(await run("prepare", b, future()), "coalesced");
|
||||
result({result: 1});
|
||||
await prep;
|
||||
assert.equal(invoked, 1);
|
||||
assert.equal(resumes, 0);
|
||||
await run("wake", b, "uncertain");
|
||||
assert.equal(resumes, 1);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
await run("wake", a, "unsignaled");
|
||||
globalThis.SuspendResumeStore.m_bSuspending = true;
|
||||
result({result: 1});
|
||||
await prep;
|
||||
assert.equal(resumes, 0);
|
||||
assert.equal(await run("prepare", b, future()), "steam-busy");
|
||||
assert.equal(invoked, 1);
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
assert.equal(await run("wake", a, "uncertain"), "ack");
|
||||
assert.equal(await run("prepare", b, Date.now() - 1), "coalesced");
|
||||
assert.equal(await run("wake", a, "uncertain"), "miss");
|
||||
assert.equal(await run("prepare", a, future()), "expired");
|
||||
result({result: 1});
|
||||
await prep;
|
||||
assert.equal(invoked, 1);
|
||||
assert.equal(resumes, 0);
|
||||
await run("wake", b, "uncertain");
|
||||
assert.equal(resumes, 1);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
assert.equal(await run("wake", b, "uncertain"), "ack");
|
||||
assert.equal(await run("prepare", b, future()), "expired");
|
||||
result({result: 1});
|
||||
await prep;
|
||||
assert.equal(invoked, 1);
|
||||
assert.equal(resumes, 1);
|
||||
|
||||
setup();
|
||||
prep = run("prepare", a, future());
|
||||
result({result: 1});
|
||||
await prep;
|
||||
assert.equal(await run("wake", a, "uncertain"), "ack");
|
||||
assert.equal(await run("wake", a, "uncertain"), "ack");
|
||||
assert.equal(resumes, 1);
|
||||
console.log("PASS nine native preparation lease sequences");
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
'''
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,141 +0,0 @@
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
TOOLS = Path(__file__).resolve().parents[1]
|
||||
SYSROOT = Path("/usr/aarch64-linux-gnu")
|
||||
|
||||
|
||||
def toolchain():
|
||||
if not (shutil.which("aarch64-linux-gnu-gcc") and shutil.which("qemu-aarch64") and SYSROOT.is_dir()):
|
||||
if os.environ.get("CI"):
|
||||
raise AssertionError("CI must install gcc-aarch64-linux-gnu, libc6-dev-arm64-cross and qemu-user")
|
||||
raise unittest.SkipTest("needs aarch64-linux-gnu-gcc, libc6-dev-arm64-cross and qemu-user")
|
||||
|
||||
|
||||
class LseEmuTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
toolchain()
|
||||
cls.tmp = tempfile.TemporaryDirectory(prefix="droiddeck-lse-")
|
||||
out = Path(cls.tmp.name)
|
||||
subprocess.run(["bash", str(TOOLS / "linuxfs/lse-emu/build.sh"), str(out)], check=True)
|
||||
cls.library = out / "usr/local/lib/droiddeck-lse/liblse_emu.so"
|
||||
cls.program = out / "lse-test"
|
||||
subprocess.run(["aarch64-linux-gnu-gcc", "-O1", "-march=armv8.1-a", "-Wall", "-Wextra", "-Werror", "-pthread",
|
||||
str(Path(__file__).with_name("lse_emu_test.c")), "-o", str(cls.program)], check=True)
|
||||
cls.early_library = out / "liblse_emu_early.so"
|
||||
subprocess.run(["aarch64-linux-gnu-gcc", "-shared", "-fPIC", "-O1", "-march=armv8.1-a", "-Wall", "-Wextra", "-Werror",
|
||||
str(Path(__file__).with_name("lse_emu_early_dependency.c")), "-o", str(cls.early_library)], check=True)
|
||||
cls.early_program = out / "lse-early-test"
|
||||
subprocess.run(["aarch64-linux-gnu-gcc", "-O1", "-Wall", "-Wextra", "-Werror",
|
||||
str(Path(__file__).with_name("lse_emu_early_main.c")), "-L", str(out),
|
||||
"-Wl,--no-as-needed", "-llse_emu_early", "-Wl,-rpath,$ORIGIN", "-o", str(cls.early_program)], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def run_on(self, cpu, *env, threads=4, program=None, program_args=None):
|
||||
command = ["qemu-aarch64",
|
||||
"-U", "LSE_EMU", "-U", "LSE_EMU_PATCH",
|
||||
"-U", "LSE_EMU_STATS", "-U", "LSE_EMU_LOG", "-U", "LSE_EMU_SKIP",
|
||||
"-cpu", cpu, "-L", str(SYSROOT)]
|
||||
for item in env:
|
||||
command += ["-E", item]
|
||||
args = [str(program or self.program)]
|
||||
if program_args is not None:
|
||||
args.extend(program_args)
|
||||
elif program is None:
|
||||
args.append(str(threads))
|
||||
return subprocess.run(command + args, capture_output=True, text=True, timeout=120)
|
||||
|
||||
def test_an_armv8_0_cpu_faults_without_the_emulator(self):
|
||||
result = self.run_on("cortex-a57")
|
||||
self.assertEqual(result.returncode, -4, result.stdout + result.stderr)
|
||||
|
||||
def test_dependency_constructor_can_execute_lse_before_preload_init(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1", program=self.early_program)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("early lse ok", result.stdout)
|
||||
|
||||
def test_trapping_alone_runs_every_form_on_an_armv8_0_cpu(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1", "LSE_EMU_STATS=1")
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("lse ok", result.stdout)
|
||||
self.assertRegex(result.stderr, r"traps=[1-9]\d* patched=0 ")
|
||||
|
||||
def test_concurrent_sigill_registrations_keep_recycled_snapshots_coherent(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1",
|
||||
program_args=["sigill-actions"])
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("sigill actions ok", result.stdout)
|
||||
|
||||
def test_child_inherits_the_sigill_handler_but_not_other_threads_action_slots(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1",
|
||||
program_args=["sigill-fork"])
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("sigill fork ok", result.stdout)
|
||||
|
||||
def test_oneshot_sigill_is_consumed_before_dispatch_and_replacement_survives(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1",
|
||||
program_args=["sigill-oneshot"])
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("sigill one-shot ok", result.stdout)
|
||||
|
||||
def patched(self, threads):
|
||||
log = Path(self.tmp.name) / f"patched-{threads}.log"
|
||||
log.unlink(missing_ok=True)
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=1", "LSE_EMU_PATCH=1",
|
||||
"LSE_EMU_STATS=1", f"LSE_EMU_LOG={log}", threads=threads)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("lse ok", result.stdout)
|
||||
self.assertRegex(result.stderr, r"patched=[1-9]\d* failed=0",
|
||||
f"{result.stderr}\nLSE log:\n{log.read_text() if log.is_file() else '<missing>'}")
|
||||
self.assertTrue(log.is_file(), "patch log was not created")
|
||||
instructions = [
|
||||
int(match, 16)
|
||||
for match in re.findall(r"patched pc=0x[0-9a-f]+ insn=0x([0-9a-f]+)", log.read_text())
|
||||
]
|
||||
self.assertTrue(
|
||||
any((insn & 0x3FFFFC00) == 0x38BFC000 for insn in instructions),
|
||||
"LDAPR did not use a generated stub",
|
||||
)
|
||||
self.assertFalse(
|
||||
any((insn & 0xBFA07C00) == 0x08207C00 for insn in instructions),
|
||||
"CASP must remain on the stack-safe trap path",
|
||||
)
|
||||
self.assertFalse(
|
||||
any(
|
||||
(insn & 0x3F200C00) == 0x38200000
|
||||
and ((insn >> 15) & 1) == 0
|
||||
and ((insn >> 12) & 7) >= 4
|
||||
for insn in instructions
|
||||
),
|
||||
"min/max must remain on the stack-safe trap path",
|
||||
)
|
||||
self.assertNotRegex(result.stderr, r"unhandled pc=.*insn=0x(?!0000000000000000(?:\n|$))[0-9a-f]{16}")
|
||||
|
||||
def test_patching_runs_every_form_on_an_armv8_0_cpu(self):
|
||||
self.patched(threads=1)
|
||||
|
||||
def test_patching_stays_atomic_across_threads(self):
|
||||
self.patched(threads=4)
|
||||
|
||||
def test_it_stays_off_without_the_switch(self):
|
||||
result = self.run_on("cortex-a57", f"LD_PRELOAD={self.library}", "LSE_EMU=0", "LSE_EMU_PATCH=0")
|
||||
self.assertEqual(result.returncode, -4, result.stdout + result.stderr)
|
||||
|
||||
def test_it_stays_off_on_a_cpu_with_lse(self):
|
||||
result = self.run_on("neoverse-n1", f"LD_PRELOAD={self.library}", "LSE_EMU=1", "LSE_EMU_STATS=1")
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertNotIn("traps=", result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,53 +0,0 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ENV = Path(__file__).resolve().parents[1] / "nativeguest/hook/env.c"
|
||||
|
||||
|
||||
class NativeHookPreloadListTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
p = Path(cls.tmp.name)
|
||||
env = ENV.read_text()
|
||||
helpers = env[env.index("static int preload_has_entry("):env.index("// Filter the LSE")]
|
||||
(p / "probe.c").write_text("""
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
""" + helpers + """
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
char *out = merge_preload_env(argv[1], argv[2]);
|
||||
if (!out) return 2;
|
||||
puts(out);
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
""")
|
||||
cls.probe = p / "probe"
|
||||
subprocess.run([os.environ.get("CC", "cc"), "-Wall", "-Wextra", "-Werror",
|
||||
str(p / "probe.c"), "-o", str(cls.probe)], check=True)
|
||||
|
||||
def merge(self, host, inherited):
|
||||
return subprocess.check_output([self.probe, host, inherited], text=True).strip()
|
||||
|
||||
def test_nested_exec_keeps_the_same_multi_entry_chain(self):
|
||||
host = "/root/session.so:/root/hook.so"
|
||||
original = host + ":user.so"
|
||||
for _ in range(3):
|
||||
original = self.merge(host, original).removeprefix("LD_PRELOAD=")
|
||||
self.assertEqual(host + ":user.so", original)
|
||||
|
||||
def test_partial_chain_keeps_host_order_and_exact_matches(self):
|
||||
self.assertEqual("LD_PRELOAD=/root/session.so:/root/hook.so:/root/hook.so.extra:custom.so",
|
||||
self.merge("/root/session.so:/root/hook.so",
|
||||
"/root/hook.so.extra /root/session.so:custom.so"))
|
||||
|
||||
def test_empty_custom_chain_keeps_only_the_host_chain(self):
|
||||
self.assertEqual("LD_PRELOAD=host.so", self.merge("host.so", ""))
|
||||
@@ -667,10 +667,6 @@ def support_data(**arguments):
|
||||
return {'install': {'action': 'supportData', 'arguments': arguments}, 'name': 'supportData'}
|
||||
|
||||
|
||||
def save_path(**arguments):
|
||||
return {'install': {'action': 'savePath', 'arguments': arguments}, 'name': 'saveFolders'}
|
||||
|
||||
|
||||
class GogSupportData(unittest.TestCase):
|
||||
def prefix(self, root):
|
||||
user = Path(root) / 'compat/pfx/drive_c/users/steamuser'
|
||||
@@ -854,117 +850,6 @@ class GogSupportData(unittest.TestCase):
|
||||
self.assertTrue((Path(root) / 'compat/pfx/drive_c/users/steamuser/Documents/My Games/G').is_dir())
|
||||
|
||||
|
||||
class GogSavePaths(unittest.TestCase):
|
||||
def prefix(self, root):
|
||||
user = Path(root) / 'compat/pfx/drive_c/users/steamuser'
|
||||
user.mkdir(parents=True)
|
||||
return user
|
||||
|
||||
def test_the_london_script_creates_its_save_path_and_keeps_player_settings(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='1897848199')
|
||||
user = self.prefix(root)
|
||||
support = folder / 'support/1897848199'
|
||||
(support / 'docs').mkdir(parents=True)
|
||||
(folder / '__AppData').mkdir()
|
||||
(folder / '__AppData/save.dat').write_text('save')
|
||||
for name in ('Fallout4Prefs.ini', 'Fallout4.ini'):
|
||||
(support / 'docs' / name).write_text('[Archive]\n')
|
||||
for name in ('DLCList.txt', 'Plugins.txt', 'UserDownloadedContent.txt'):
|
||||
(support / name).write_text('*LondonWorldSpace.esm\n')
|
||||
gog_script(folder, '1897848199', [
|
||||
save_path(savePath='{userdocs}/My Games/Fallout4', type='folder'),
|
||||
set_registry(root='HKLM', subkey='Software\\Bethesda Softworks\\Fallout4',
|
||||
valueName='Installed Path', valueData='{app}\\', valueType='string'),
|
||||
support_data(type='folder', target='{userdocs}/My Games/Fallout4'),
|
||||
support_data(type='folder', target='{localappdata}/Fallout4'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/docs/Fallout4Prefs.ini',
|
||||
target='{userdocs}/My Games/Fallout4/Fallout4Prefs.ini'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/docs/Fallout4.ini',
|
||||
target='{userdocs}/My Games/Fallout4/Fallout4.ini'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/DLCList.txt',
|
||||
target='{localappdata}/Fallout4/DLCList.txt'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/Plugins.txt',
|
||||
target='{localappdata}/Fallout4/Plugins.txt'),
|
||||
support_data(type='file', overwrite=True, source='{supportDir}/UserDownloadedContent.txt',
|
||||
target='{localappdata}/Fallout4/UserDownloadedContent.txt'),
|
||||
support_data(type='folder', overwrite=True, source='{app}/__AppData', target='{localappdata}/Fallout4'),
|
||||
])
|
||||
with patch.object(store, 'create_prefix') as create:
|
||||
self.assertEqual('copied=6', store.gog_support_data(folder, root + '/compat', '/proton'))
|
||||
self.assertEqual('paths=1', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_not_called()
|
||||
saves = user / 'Documents/My Games/Fallout4'
|
||||
self.assertTrue(saves.is_dir())
|
||||
self.assertEqual('[Archive]\n', (saves / 'Fallout4.ini').read_text())
|
||||
self.assertEqual('*LondonWorldSpace.esm\n', (user / 'AppData/Local/Fallout4/Plugins.txt').read_text())
|
||||
self.assertTrue((Path(root) / 'compat/pfx' / store.GOG_SAVE_PATH_MARK).is_file())
|
||||
(saves / 'my settings.ini').write_text('player')
|
||||
self.assertEqual('ready', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertEqual('player', (saves / 'my settings.ini').read_text())
|
||||
|
||||
def test_existing_prefix_base_names_keep_their_actual_case(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
user = self.prefix(root)
|
||||
(user / 'documents' / 'fixture').mkdir(parents=True)
|
||||
(user / 'aPPdATA' / 'roaming').mkdir(parents=True)
|
||||
gog_script(folder, '9', [
|
||||
save_path(savePath='{UserDocs}/Fixture/Saves'),
|
||||
save_path(savePath='{UserAppData}/Fixture/Settings'),
|
||||
])
|
||||
self.assertEqual('paths=2', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertTrue((user / 'documents/fixture/Saves').is_dir())
|
||||
self.assertTrue((user / 'aPPdATA/roaming/Fixture/Settings').is_dir())
|
||||
self.assertEqual({'documents', 'aPPdATA'}, {p.name for p in user.iterdir()})
|
||||
self.assertEqual({'roaming'}, {p.name for p in (user / 'aPPdATA').iterdir()})
|
||||
|
||||
def test_only_save_path_actions_create_known_folders(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
user = self.prefix(root)
|
||||
saves = user / 'Documents/My Games/Fallout4'
|
||||
saves.mkdir(parents=True)
|
||||
(saves / 'Fallout4Prefs.ini').write_text('player')
|
||||
gog_script(folder, '9', [
|
||||
set_registry(root='HKLM', subkey='Software\\Game', valueName='a', valueData='b', valueType='string'),
|
||||
{'install': {'action': 'createFolder', 'arguments': {'savePath': '{userdocs}/Other'}}},
|
||||
save_path(savePath='{windir}/evil'),
|
||||
save_path(savePath='{userdocs}/../../escape'),
|
||||
save_path(savePath='{userappdata}/Ubisoft/Anno1404/Config'),
|
||||
])
|
||||
self.assertEqual('paths=1 skipped=2', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertTrue((user / 'AppData/Roaming/Ubisoft/Anno1404/Config').is_dir())
|
||||
self.assertFalse((user / 'Documents/Other').exists())
|
||||
self.assertFalse((Path(root) / 'escape').exists())
|
||||
self.assertEqual('player', (saves / 'Fallout4Prefs.ini').read_text())
|
||||
self.assertFalse((Path(root) / 'compat/pfx' / store.GOG_SAVE_PATH_MARK).exists())
|
||||
|
||||
def test_without_save_paths_no_prefix_is_made(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
gog_script(folder, '9', [set_registry(root='HKLM', subkey='Software\\Game', valueName='a',
|
||||
valueData='b', valueType='string')])
|
||||
with patch.object(store, 'create_prefix') as create:
|
||||
self.assertEqual('none', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_not_called()
|
||||
|
||||
def test_a_missing_prefix_is_made_first(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog', ident='9')
|
||||
gog_script(folder, '9', [save_path(savePath='{userdocs}/My Games/G')])
|
||||
with patch.object(store, 'create_prefix', return_value='failed') as create:
|
||||
self.assertEqual('no-prefix', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
create.assert_called_once_with(root + '/compat', '/proton')
|
||||
|
||||
def made(compat_data, proton):
|
||||
self.prefix(root)
|
||||
return 'created'
|
||||
with patch.object(store, 'create_prefix', side_effect=made):
|
||||
self.assertEqual('paths=1', store.gog_save_paths(folder, root + '/compat', '/proton'))
|
||||
self.assertTrue((Path(root) / 'compat/pfx/drive_c/users/steamuser/Documents/My Games/G').is_dir())
|
||||
|
||||
|
||||
class GogRegistry(unittest.TestCase):
|
||||
def test_patch_registration_uses_authentic_build_and_the_prefix_registry_executable(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
|
||||
@@ -555,79 +555,6 @@ def swap_total_kb():
|
||||
return 0
|
||||
|
||||
|
||||
CROSS_THREAD = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef PR_SET_SYSCALL_USER_DISPATCH
|
||||
#define PR_SET_SYSCALL_USER_DISPATCH 59
|
||||
#endif
|
||||
|
||||
extern void *__libc_malloc(size_t);
|
||||
extern void *__libc_calloc(size_t, size_t);
|
||||
extern void *__libc_realloc(void *, size_t);
|
||||
|
||||
static int watching;
|
||||
static pid_t victim;
|
||||
static int allocations;
|
||||
|
||||
static void count(void) {
|
||||
if (__atomic_load_n(&watching, __ATOMIC_ACQUIRE) && gettid() == __atomic_load_n(&victim, __ATOMIC_RELAXED)) __atomic_add_fetch(&allocations, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
void *malloc(size_t n) { count(); return __libc_malloc(n); }
|
||||
void *calloc(size_t a, size_t b) { count(); return __libc_calloc(a, b); }
|
||||
void *realloc(void *p, size_t n) { count(); return __libc_realloc(p, n); }
|
||||
|
||||
static void *idle(void *arg) {
|
||||
(void)arg;
|
||||
sigset_t none;
|
||||
sigemptyset(&none);
|
||||
__atomic_store_n(&victim, gettid(), __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&watching, 1, __ATOMIC_RELEASE);
|
||||
sigsuspend(&none);
|
||||
__atomic_store_n(&watching, 0, __ATOMIC_RELEASE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
sigset_t urg;
|
||||
sigemptyset(&urg);
|
||||
sigaddset(&urg, SIGURG);
|
||||
pthread_sigmask(SIG_BLOCK, &urg, NULL);
|
||||
void *lib = dlopen(argv[1], RTLD_LAZY);
|
||||
if (lib == NULL) { puts(dlerror()); return 1; }
|
||||
int (*control)(int, ...) = (int (*)(int, ...))dlsym(lib, "prctl");
|
||||
volatile char selector = 0;
|
||||
if (argc > 2) {
|
||||
pthread_key_t key, last = 0;
|
||||
while (pthread_key_create(&key, NULL) == 0) last = key;
|
||||
int r = control(PR_SET_SYSCALL_USER_DISPATCH, 1, 0, 0, &selector);
|
||||
printf("refused %d %s\n", r, r != 0 && errno == EAGAIN ? "again" : "other");
|
||||
pthread_key_delete(last);
|
||||
printf("retried %d\n", control(PR_SET_SYSCALL_USER_DISPATCH, 1, 0, 0, &selector));
|
||||
return 0;
|
||||
}
|
||||
if (control(PR_SET_SYSCALL_USER_DISPATCH, 1, 0, 0, &selector) != 0) { puts("nodispatch"); return 0; }
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, idle, NULL);
|
||||
while (!__atomic_load_n(&watching, __ATOMIC_ACQUIRE)) usleep(1000);
|
||||
if (write(2, "signal\n", 7) != 7) return 1;
|
||||
kill(getpid(), SIGURG);
|
||||
pthread_join(thread, NULL);
|
||||
printf("allocations %d\n", allocations);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
@unittest.skipUnless(shutil.which("cc"), "needs a C compiler")
|
||||
class ZramPreloadTest(unittest.TestCase):
|
||||
@classmethod
|
||||
@@ -846,39 +773,6 @@ class ZramPreloadTest(unittest.TestCase):
|
||||
self.assertEqual([1], out["trimmed"], out)
|
||||
self.assertEqual([1], out["named"], out)
|
||||
|
||||
def test_a_signal_on_another_thread_allocates_nothing_after_dispatch_was_armed(self):
|
||||
source = self.dir / "crossthread.c"
|
||||
program = self.dir / "crossthread"
|
||||
source.write_text(CROSS_THREAD)
|
||||
subprocess.run(["cc", "-O2", "-pthread", "-o", str(program), str(source), "-ldl"], check=True)
|
||||
environment = dict(os.environ, GLIBC_TUNABLES="glibc.rtld.optional_static_tls=0", LD_DEBUG="bindings")
|
||||
for name in ("LD_PRELOAD", "LD_BIND_NOW"):
|
||||
environment.pop(name, None)
|
||||
result = subprocess.run([str(program), str(self.lib)], env=environment, capture_output=True, text=True, timeout=60)
|
||||
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
|
||||
if result.stdout.strip() == "nodispatch":
|
||||
self.skipTest("kernel lacks syscall user dispatch")
|
||||
self.assertEqual("allocations 0", result.stdout.strip())
|
||||
after = result.stderr.split("signal\n", 1)[1]
|
||||
self.assertNotIn("pthread_getspecific", after)
|
||||
refused = subprocess.run([str(program), str(self.lib), "exhaust"], env=environment, capture_output=True,
|
||||
text=True, timeout=60)
|
||||
self.assertEqual("refused -1 again\nretried 0", refused.stdout.strip())
|
||||
|
||||
def test_loads_at_runtime_without_spare_static_tls(self):
|
||||
loader = self.dir / "loader"
|
||||
source = self.dir / "loader.c"
|
||||
source.write_text("#include <dlfcn.h>\n#include <stdio.h>\n"
|
||||
"int main(int c, char **v) { (void)c; void *h = dlopen(v[1], RTLD_NOW);"
|
||||
" puts(h ? \"loaded\" : dlerror()); return h == NULL; }\n")
|
||||
subprocess.run(["cc", "-O2", "-o", str(loader), str(source), "-ldl"], check=True)
|
||||
environment = dict(os.environ, GLIBC_TUNABLES="glibc.rtld.optional_static_tls=0")
|
||||
environment.pop("LD_PRELOAD", None)
|
||||
result = subprocess.run([str(loader), str(self.lib)], env=environment, capture_output=True, text=True,
|
||||
timeout=60)
|
||||
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
|
||||
self.assertEqual("loaded", result.stdout.strip())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,86 @@
|
||||
# Upscale bridge DLLs
|
||||
|
||||
Windows x86-64 DLLs that stand in for a game's DLSS, FidelityFX (FSR 2, FSR 3, FidelityFX API) and
|
||||
XeSS libraries inside Wine. They do not upscale anything themselves: each frame's colour, depth,
|
||||
motion-vector and output images are written into a host-visible Vulkan mailbox buffer, and a
|
||||
`vkCmdUpdateBuffer` "doorbell" on a marker buffer tells the Android Vulkan layer to record the
|
||||
upscaler into the game's command buffer. The layer finds both buffers by their sizes and magic
|
||||
numbers. `fsr4_seam_proto.h` is that contract and is a verbatim copy of the fork's
|
||||
`app/src/main/cpp/fsr4npu/fsr4_seam_proto.h` (sha256 `a9f614c53ae9209edf0fa9c5acb0a27fdf923c08026362b23f60e1bcb39acd15`).
|
||||
It must stay byte-identical to the layer's copy. If the layer does not acknowledge a frame,
|
||||
the bridge blits the render-resolution image to the output (bilinear) so the game never shows
|
||||
stale memory. D3D12 games reach Vulkan through vkd3d-proton's `ID3D12DXVKInteropDevice1`.
|
||||
|
||||
| DLL | Source | Export list | Replaces |
|
||||
| --- | --- | --- | --- |
|
||||
| `amd_fidelityfx_vk.dll` | `wl_ffx_bridge.c` | `wl_ffx_bridge.def` | FidelityFX API (`ffxCreateContext`, `ffxDispatch`, ...) |
|
||||
| `amd_fidelityfx_dx12.dll`, `amd_fidelityfx_upscaler_vk.dll`, `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_loader_dx12.dll` | copies of `amd_fidelityfx_vk.dll` | | the same API under the other SDK file names |
|
||||
| `ffx_fsr3upscaler_x64.dll` | `wl_fsr23_bridge.c` | `ffx_fsr3upscaler_x64.def` | FSR 3.0 / 3.1 upscaler |
|
||||
| `ffx_fsr2_api_x64.dll` | `wl_fsr23_bridge.c` | `ffx_fsr2_api_x64.def` | FSR 2.0 / 2.1 / 2.2 |
|
||||
| `libxess.dll` | `wl_xess_bridge.c` | `libxess.def` | Intel XeSS 1.3 / 2.0 (D3D12 + Vulkan) |
|
||||
| `nvngx.dll` | `wl_ngx_bridge.c` | `nvngx.def` | NVIDIA NGX / DLSS Super Resolution (Vulkan + D3D12) |
|
||||
| `_nvngx.dll`, `nvngx_dlss.dll` | copies of `nvngx.dll` | | the names games and Streamline load NGX by |
|
||||
| `nvapi64.dll` | `wl_nvapi_shim.c` (+ `wl_ngx_hooks.h`) | `nvapi64.def` | NVAPI, reporting an RTX 2060 so games offer DLSS |
|
||||
|
||||
`wl_fsr23_bridge.c` exports both the FSR 2 and FSR 3 entry points, so both DLLs carry all 21.
|
||||
`nvngx.dll` exports the 88 `.def` names plus 9 that only its source marks `__declspec(dllexport)`. `build.sh`
|
||||
fails when a DLL's exports (from `x86_64-w64-mingw32-objdump -p`) differ from its `.def` plus
|
||||
its source's `dllexport` names.
|
||||
|
||||
When the XeSS 3.0 backend is selected, `wl_xess3_direct.h` loads Intel's XeSS SDK runtime as
|
||||
`wl_xess_official.dll` (from the DLL search path, then `C:\windows\system32`). When it is missing or
|
||||
fails, the frame goes to the layer flagged `WLFSR4_FLAG_XESS_FALLBACK` (FSR 3.1 on the GPU). That DLL is Intel's prebuilt binary and is not built here.
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
bash tools/upscale/bridges/build.sh OUT
|
||||
```
|
||||
|
||||
Needs `x86_64-w64-mingw32-gcc` (Ubuntu `gcc-mingw-w64-x86-64`) and `python3`. The output is
|
||||
deterministic (`-s`, `-Wl,--no-insert-timestamp`, linked under the bare DLL name because `ld`
|
||||
derives the image base from the output path). Every DLL is stamped as a Wine builtin the way
|
||||
`winebuild --builtin` does it: the 32-byte `"Wine builtin DLL"` signature, zero-padded, at file
|
||||
offset 0x40 (`pe.py stamp`). Wine then loads them from `WINEDLLPATH` when the override is
|
||||
`builtin`. The same x86-64 files are installed to `OUT/x86_64-windows/` and
|
||||
`OUT/aarch64-windows/`, because the ARM64EC Wine loads x86-64 builtins from the latter.
|
||||
|
||||
CI builds them with the `upscale-bridges` component recipe into
|
||||
`app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/`. The APK may not carry
|
||||
Windows executables (`tools/release/runtime_inputs.py`), so they ship in the `upscale` add-on
|
||||
pack (`tools/packs/build.sh`), whose entries are `bridges/{x86_64,aarch64}-windows/<dll>`.
|
||||
|
||||
## Environment
|
||||
|
||||
| Variable | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `DROIDDECK_UPSCALE_BACKEND` (then `DROIDDECK_UPSCALE_ENGINE`, `WINLATOR_FSR4_BACKEND`, `WINLATOR_FSR4_ENGINE`) | `fsr4_1_full_npu` | Backend the bridges assume until the layer writes its live control word: `fsr3_gpu`, `xess3_gpu`, `sgsr2_gpu`, `fsr4_1_lite_npu`, `fsr4_1_full_npu`, `fsr4_1_lite_gpu`, `fsr4_1_full_gpu` (`fsr4_0_npu` = `fsr4_1_full_npu`) |
|
||||
| `DROIDDECK_UPSCALE_VRAM_MB` (then `WINLATOR_FSR4_VRAM_MB`, `WRAPPER_VMEM_MAX_SIZE`) | DXGI adapter 0, else 12 GB | VRAM `nvapi64.dll` reports (512-65536 MB) |
|
||||
| `DROIDDECK_UPSCALE_SIGFIX=1` | on in DLSS mode (`droiddeck-game-env` sets `1` unless the game stores `0`) | `nvapi64.dll` patches the import tables of loaded modules (LoadLibrary*, GetProcAddress, GetFileAttributes*, CreateFileW, Reg*), redirects `nvngx`/`_nvngx` loads to `C:\windows\system32\_nvngx.dll`, fakes the NVIDIA signature-override registry keys, forces `WinVerifyTrust` success and redirects `CryptQueryObject` for `nvngx`/`amd_fidelityfx*`, so games that signature-check NGX load the bridge. Never applied to rdr2.exe, playrdr2.exe or gta5.exe |
|
||||
| `DROIDDECK_UPSCALE_LOG=1` | off | Hook messages appended to `C:\windows\temp\wl_fsr4_bridge.log` |
|
||||
|
||||
## Changes from the fork
|
||||
|
||||
- Until upstream r5, D3D11 NGX reported DLSS unavailable here (the fork returned success and rendered
|
||||
nothing). Since r5 the D3D11 entry points reach the Vulkan layer through DXVK's interop
|
||||
(`wl_dxvk_interop.h`), as upstream does.
|
||||
- The `nvapi64.dll` hooks follow `DROIDDECK_UPSCALE_SIGFIX`, which DLSS games get as `1` unless switched off (the fork
|
||||
always installed them). Without them NGX rejects the bridges (DLSS sample: `GetFeatureRequirements` PlatformError).
|
||||
- Logging is off unless `DROIDDECK_UPSCALE_LOG=1`; the fork always wrote the log.
|
||||
- `DROIDDECK_UPSCALE_*` variables are read first, the fork's names after them (`dd_env.h`).
|
||||
- `fsr4_seam_proto.h` is included from this folder instead of `../fsr4npu/`.
|
||||
- Built with Ubuntu's MinGW-w64 GCC (msvcrt) instead of the fork's PowerShell script; flags as in
|
||||
its `build_win_dlls.ps1` plus `-s` and `-Wl,--no-insert-timestamp`. The fork stamped the
|
||||
signature at install time; here it is stamped at build time.
|
||||
|
||||
Seam protocol, struct layouts, magics and backend IDs are unchanged.
|
||||
|
||||
## Credits and licence
|
||||
|
||||
Ported from [michaelisomer-cyber/Winlator-NeuralScale](https://github.com/michaelisomer-cyber/Winlator-NeuralScale)
|
||||
at `a0ab6b0f770e1a6786b4e68def46b4edb8baafd0`, updated to `71c140d9e5586f659251c3ebc602f2d21923655c` (r5: D3D11
|
||||
DLSS through DXVK's interop, `wl_dxvk_interop.h`) (`app/src/main/cpp/fsr4npu_win/`), GPL-3.0. That fork
|
||||
builds on [StevenMXZ/Winlator-Ludashi](https://github.com/StevenMXZ/Winlator-Ludashi). The NGX
|
||||
and NVAPI shims follow OptiScaler's approach (and fakenvapi's NVAPI interface). These files stay
|
||||
under the GPL-3.0, the licence of this repository (`LICENSE`); modified files say so in their
|
||||
first line.
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
mkdir -p "${1:?usage: build.sh <out-dir>}"
|
||||
out=$(cd "$1" && pwd)
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
cc=x86_64-w64-mingw32-gcc
|
||||
objdump=x86_64-w64-mingw32-objdump
|
||||
for tool in "$cc" "$objdump"; do
|
||||
command -v "$tool" >/dev/null || { echo "upscale-bridges: $tool not found (apt install gcc-mingw-w64-x86-64)" >&2; exit 1; }
|
||||
done
|
||||
cflags=(-O2 -fno-ipa-icf -shared -s -Wall -Wextra -Wno-unused-function -static-libgcc -I"$here"
|
||||
-ffile-prefix-map="$here"=. -Wl,--no-insert-timestamp)
|
||||
|
||||
build() {
|
||||
local name=$1 source=$2 definition=$3
|
||||
shift 3
|
||||
# ld derives the DLL's image base from the -o path, so link in $work under the bare name.
|
||||
(cd "$work" && "$cc" "${cflags[@]}" "$here/$source" "$here/$definition" "$@" -o "$name")
|
||||
python3 -I "$here/pe.py" verify "$work/$name" "$here/$definition" "$here/$source" "$objdump"
|
||||
python3 -I "$here/pe.py" stamp "$work/$name"
|
||||
}
|
||||
|
||||
build amd_fidelityfx_vk.dll wl_ffx_bridge.c wl_ffx_bridge.def -lm
|
||||
for name in amd_fidelityfx_dx12.dll amd_fidelityfx_upscaler_vk.dll amd_fidelityfx_upscaler_dx12.dll amd_fidelityfx_loader_dx12.dll; do
|
||||
cp "$work/amd_fidelityfx_vk.dll" "$work/$name"
|
||||
done
|
||||
build libxess.dll wl_xess_bridge.c libxess.def -lm
|
||||
build ffx_fsr3upscaler_x64.dll wl_fsr23_bridge.c ffx_fsr3upscaler_x64.def -lm
|
||||
build ffx_fsr2_api_x64.dll wl_fsr23_bridge.c ffx_fsr2_api_x64.def -lm
|
||||
build nvngx.dll wl_ngx_bridge.c nvngx.def -lm
|
||||
for name in _nvngx.dll nvngx_dlss.dll; do
|
||||
cp "$work/nvngx.dll" "$work/$name"
|
||||
done
|
||||
build nvapi64.dll wl_nvapi_shim.c nvapi64.def
|
||||
|
||||
names=(_nvngx.dll amd_fidelityfx_dx12.dll amd_fidelityfx_loader_dx12.dll amd_fidelityfx_upscaler_dx12.dll
|
||||
amd_fidelityfx_upscaler_vk.dll amd_fidelityfx_vk.dll ffx_fsr2_api_x64.dll ffx_fsr3upscaler_x64.dll
|
||||
libxess.dll nvapi64.dll nvngx.dll nvngx_dlss.dll)
|
||||
[ "$(ls "$work" | sort)" = "$(printf '%s\n' "${names[@]}" | sort)" ] || { echo "upscale-bridges: unexpected outputs" >&2; exit 1; }
|
||||
# The ARM64EC Wine loads x86-64 builtins from aarch64-windows as well.
|
||||
for arch in x86_64-windows aarch64-windows; do
|
||||
rm -rf "${out:?}/$arch"
|
||||
mkdir -p "$out/$arch"
|
||||
for name in "${names[@]}"; do
|
||||
install -m 644 "$work/$name" "$out/$arch/$name"
|
||||
done
|
||||
done
|
||||
@@ -0,0 +1,20 @@
|
||||
// DroidDeck: environment lookups shared by the upscale bridges.
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// Copies the first variable in the NULL-terminated list that is set and fits into buf.
|
||||
static DWORD dd_env_first(const char *const *names, char *buf, DWORD size) {
|
||||
for (; *names; names++) {
|
||||
DWORD n = GetEnvironmentVariableA(*names, buf, size);
|
||||
if (n > 0 && n < size) return n;
|
||||
}
|
||||
if (size) buf[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dd_env_is_on(const char *name) {
|
||||
char buf[8];
|
||||
DWORD n = GetEnvironmentVariableA(name, buf, sizeof buf);
|
||||
return n == 1 && buf[0] == '1';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
LIBRARY ffx_fsr2_api_x64.dll
|
||||
EXPORTS
|
||||
ffxFsr2ContextCreate
|
||||
ffxFsr2ContextDispatch
|
||||
ffxFsr2ContextGenerateReactiveMask
|
||||
ffxFsr2ContextDestroy
|
||||
ffxFsr2GetUpscaleRatioFromQualityMode
|
||||
ffxFsr2GetRenderResolutionFromQualityMode
|
||||
ffxFsr2GetJitterPhaseCount
|
||||
ffxFsr2GetJitterOffset
|
||||
ffxFsr2ResourceIsNull
|
||||
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user