Compare commits

..
28 changed files with 146 additions and 496 deletions

No files matched your search

@@ -232,16 +232,6 @@ static VkResult timed_wait(VkFence fence, uint64_t timeout) {
return g_dev_state == -2 ? VK_ERROR_DEVICE_LOST : VK_ERROR_UNKNOWN;
int64_t t0 = perf_now();
VkResult r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, timeout);
if (r == VK_TIMEOUT) {
droiddeck_log("gpu", "GPU fence delayed: retaining frame resources until completion");
/* A scheduling delay does not invalidate the device. Keep this submission's
* resources and call stack alive, as the main render path already does. */
do {
r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, UINT64_MAX);
} while (r == VK_TIMEOUT);
if (r == VK_SUCCESS)
droiddeck_log("gpu", "GPU fence completed: continuing presentation");
}
perf_add(&g_perf.wait_ns, &g_perf.wait_max_ns, &g_perf.waits, perf_now() - t0);
if (r != VK_SUCCESS && r != VK_ERROR_DEVICE_LOST)
quarantine_pending_work(r, "fence wait");
@@ -430,28 +430,21 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
*/
private fun useMaliFallback(missing: String?): String {
val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity)
val venusByUser = venusExplicit()
val venus = MaliAutoRoute.venusStandsIn(
com.droiddeck.launcher.session.VenusComponent.available(activity), oldVulkan == null,
SessionPrefs.venus(activity), venusByUser, gpu.name,
)
val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity)
if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in")
val ownership = MaliAutoRoute.fallbackOwnership(
venus,
SessionPrefs.vkBridge(activity), bridgeExplicit(),
SessionPrefs.venus(activity), venusByUser,
SessionPrefs.venus(activity), venusExplicit(),
)
if (venus && !SessionPrefs.venus(activity)) {
SessionPrefs.setVenus(activity, true)
if (SessionPrefs.vkBridge(activity) && !bridgeExplicit())
SessionPrefs.setVkBridge(activity, false)
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (!venus) {
val venusOff = SessionPrefs.venus(activity) && !venusByUser
val bridgeOn = !SessionPrefs.vkBridge(activity)
if (venusOff) SessionPrefs.clearVenus(activity)
if (bridgeOn) SessionPrefs.setVkBridge(activity, true)
if (venusOff || bridgeOn || ownership != MaliAutoRoute.NONE) SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (!venus && !SessionPrefs.vkBridge(activity)) {
SessionPrefs.setVkBridge(activity, true)
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (ownership != MaliAutoRoute.NONE) {
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
}
@@ -474,7 +467,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
/** A pair is installed for this Mali: the route Auto switched on in its place goes off again. */
private fun endMaliFallback() {
when (SessionPrefs.maliFallbackByAuto(activity)) {
"venus" -> SessionPrefs.clearVenus(activity)
"venus" -> SessionPrefs.setVenus(activity, false)
"bridge" -> SessionPrefs.setVkBridge(activity, false)
else -> return
}
@@ -26,12 +26,6 @@ internal object MaliAutoRoute {
fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route
fun venusStandsIn(available: Boolean, hostVulkanOk: Boolean, venusOn: Boolean, venusExplicit: Boolean, gpuName: String): Boolean =
available && hostVulkanOk && if (venusExplicit) venusOn else !venusStallsOn(gpuName)
// Steam's web helper dies on its first window through Venus on these (#2879), so the bridge stands in.
fun venusStallsOn(gpuName: String): Boolean = gpuName.contains("G2-Ultra", ignoreCase = true)
fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean =
mali && installedPair && ownsRoute != NONE
}
@@ -6349,10 +6349,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1))
setIntent(intent)
if (::pip.isInitialized) pip.refresh(true)
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
SessionState.steamVr = true
steamVrAutoTried = false
}
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) requestSteamVr()
if (intent.action == SessionService.ACTION_HOME_GUIDE) {
handleHomeGuideIntent(intent)
} else if (intent.action == SessionService.ACTION_RESUME) {
@@ -6441,7 +6438,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private val questSteamVrRequest = object : Runnable {
override fun run() {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) &&
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start")
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start")
else requestSteamVr()
}
uiHandler.postDelayed(this, 1000)
}
}
@@ -6500,6 +6500,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
updateHeadTracker()
}
private fun requestSteamVr() {
SessionState.steamVr = true
steamVrAutoTried = false
steamVrInstallTried = false
}
private fun steamVrAction(action: String) {
if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) {
startActivity(android.content.Intent(this, QuestXrActivity::class.java))
@@ -6977,6 +6983,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return
if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true
Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})")
if (action == "install") Toast.makeText(this, R.string.cardboard_steamvr_installing, Toast.LENGTH_LONG).show()
steamVrAction(action)
}
@@ -951,6 +951,7 @@ internal object EnhancedSessionLogShare {
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
"rpcs3", "RPCS3.log",
"droiddeck-steamvr-launch.log", "droiddeck-vrstartup.log",
)
private val KNOWN_COMPONENT_PATTERNS = listOf(
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
@@ -1,6 +1,7 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.gpu.SteamVr
import java.io.File
/**
@@ -32,4 +33,7 @@ object QuestSteamVrLaunch {
fun takeRequest(context: Context): Boolean =
QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete()
fun opensDirectly(status: SteamVr.Status?): Boolean =
status == SteamVr.Status.READY || status == SteamVr.Status.RUNNING
}
@@ -1229,11 +1229,6 @@ object SessionPrefs {
prefs(context).edit().putBoolean("venus", on).apply()
}
/** Venus off with no choice stored, so that Auto turning it off does not read as the user's own choice. */
fun clearVenus(context: Context) {
prefs(context).edit().remove("venus").apply()
}
fun setVkBridge(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("vkBridge", on).putBoolean("bridgeFellBack", false).apply()
}
@@ -50,28 +50,4 @@ class MaliAutoRouteTest {
assertTrue(MaliAutoRoute.userChoice(true, MaliAutoRoute.VENUS, MaliAutoRoute.BRIDGE))
assertFalse(MaliAutoRoute.userChoice(false, MaliAutoRoute.NONE, MaliAutoRoute.BRIDGE))
}
@Test
fun venusTheUserSwitchedOffIsNotSwitchedBackOn() {
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, true, "Mali-G715"))
assertTrue(MaliAutoRoute.venusStandsIn(true, true, true, true, "Mali-G2-Ultra-NX MC12"))
}
@Test
fun venusIsAutosStandInOnlyWhereSteamStartsThroughIt() {
assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G2-Ultra-NX MC12"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, true, false, "Mali-G2-Ultra-NX MC16"))
assertFalse(MaliAutoRoute.venusStandsIn(false, true, true, true, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, false, true, true, "Mali-G715"))
}
@Test
fun venusThatAutoTurnedOffIsStillAutosToTurnOn() {
// Auto clears the stored key when it moves to the bridge: a stored "off" would read as the user's own choice.
val cleared = MaliAutoRoute.userChoice(keyStored = false, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS)
val writtenOff = MaliAutoRoute.userChoice(keyStored = true, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS)
assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, cleared, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, writtenOff, "Mali-G715"))
}
}
@@ -114,6 +114,23 @@ class EnhancedSessionLogShareTest {
SessionLogShare.clear(app)
}
@Test fun steamVrLaunchLogsAreSharedUnderTheirNames() {
val session = tmp.newFolder("2026-11-29-05-steam")
session.resolve("session.log").writeText("startup ok\n")
val steam = session.resolve("steam").apply { mkdirs() }
steam.resolve("droiddeck-steamvr-launch.log").writeText("downloading SteamVR (571 MB)\n")
steam.resolve("droiddeck-vrstartup.log").writeText("vrstartup ok\n")
steam.resolve("unknown-tool.log").writeText("other\n")
val zips = EnhancedSessionLogShare.create(app, session)
val names = zips.flatMap { zip -> ZipFile(zip).use { archive -> archive.entries().toList().map { it.name } } }
assertTrue(names.contains("${session.name}/steam/droiddeck-steamvr-launch.log"))
assertTrue(names.contains("${session.name}/steam/droiddeck-vrstartup.log"))
assertTrue(names.none { it.endsWith("/unknown-tool.log") })
SessionLogShare.clear(app)
}
@Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() {
val session = tmp.newFolder("2026-11-04-02-game")
session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n")
@@ -0,0 +1,24 @@
package com.droiddeck.launcher.session
import com.droiddeck.launcher.gpu.SteamVr
import org.junit.Assert.assertEquals
import org.junit.Test
class QuestSteamVrLaunchTest {
@Test fun aLibraryRequestOpensTheImmersiveViewOnlyWhenSteamVrIsInstalled() {
assertEquals(
setOf(SteamVr.Status.READY, SteamVr.Status.RUNNING),
SteamVr.Status.values().filter { QuestSteamVrLaunch.opensDirectly(it) }.toSet(),
)
assertEquals(false, QuestSteamVrLaunch.opensDirectly(null))
}
@Test fun aRequestThatHasToInstallSteamVrGoesThroughTheAutomaticInstallThenStart() {
assertEquals("install", SteamVr.autoAction(SteamVr.Status.NOT_INSTALLED, requested = true, loading = false,
steamSession = true, startTried = false, installTried = false))
assertEquals(null, SteamVr.autoAction(SteamVr.Status.INSTALLING, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
assertEquals("start", SteamVr.autoAction(SteamVr.Status.READY, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
}
}
-9
View File
@@ -193,15 +193,6 @@ A Unity game under FEX (`UnityPlayer.dll` for Windows builds under Proton,
turns it off: without TSO such games can deadlock or crash (seen with Megabonk
and Crab Game). A FEX preset chosen for the game itself still applies.
An Inno Setup installer added as a game runs with the Stability preset's FEX
settings (full TSO, full x87 precision, no multiblock). Under the default
Performance + TSO preset the 32-bit setup stub corrupts its own paths and stops
with Wine's "Path not fpund." dialog (#1277, #3067). The stub is found by the
setup loader's offset-table ID in its resources, or by the `Inno` marker that
loaders older than 5.1.5 keep at offset 0x30. GOG installs avoid the stub by
extracting natively. A FEX preset chosen for the installer's own entry still
applies.
Games launched through Proton get `vblank_mode=0`, so OpenGL does not wait for
each screen refresh. Wine asks for a swap interval of 1 on every OpenGL window, and WineD3D's front-buffer
drawing (DirectDraw, Direct3D 1–7) never lowers it, so those games ran at the
-13
View File
@@ -150,19 +150,6 @@ The SPIR-V version the driver gets:
- This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga
(`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust.
Geometry shaders:
- The Mali-G610's driver (r38p1) crashes compiling Zink's geometry shaders, always at the same
place (SIGSEGV at 0x40 in `cmpbe_v2_compile_multiple_shaders`): its shader for `GL_QUADS`, and
a GLSL geometry shader that only passes triangles on.
- A geometry shader that only passes triangles on, from a plain Vulkan program, does not crash it
but draws nothing, in SPIR-V 1.0, 1.3 and 1.6, with and without the layer.
- Zink writes them in SPIR-V 1.6 with the Vulkan memory model, which the version cap leaves alone.
Lowering them would not help, since the plain shader draws nothing at 1.0 and 1.3 either.
- On ARM GPUs the layer reports no `geometryShader` to Zink (engine name `mesa zink`). Mesa then
splits quads into triangles itself, and Zink still offers OpenGL 3.2. DXVK keeps the feature: it
needs it for D3D10 and 11.
- `DROIDDECK_MALI_COMPAT_NO_GS=0` keeps the feature for Zink, `=1` hides it from every application.
Files:
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
- `pipeline.c`: pipelines, shader modules, viewports.
+4 -2
View File
@@ -145,8 +145,10 @@ verification against the actual phone's Steam version after installation.
The helper serializes installation/startup and avoids restarting an active
DroidDeck SteamVR session. Library launch diagnostics are in
`${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr/library-launch.log`; normal runtime
logs remain in `vrstartup.log` and Steam's logs directory. It does not intercept
`droiddeck-steamvr-launch.log` in Steam's logs directory, next to
`droiddeck-vrstartup.log`, and Share logs includes both. On a Quest the helper
only asks the app for SteamVR: the app installs it if needed, showing that it is
downloading, then opens the immersive view. It does not intercept
arbitrary external `steam://` URLs or change VR game launch arguments.
Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is
+4
View File
@@ -83,6 +83,10 @@ and display timing, and returns owned stereo images tagged with the latest eye p
SteamVR haptics return through the tracking bridge. No root or separate XR APK
is required. Other devices retain their existing SteamVR start behavior.
Play on SteamVR in Steam's library does the same: if SteamVR is not installed yet,
DroidDeck shows that it is downloading SteamVR, installs it, then opens the
immersive view.
The left Touch menu button is SteamVR's system button and toggles its dashboard.
The right Meta button remains reserved by the headset OS.
@@ -66,69 +66,6 @@ DOTNET_FEX = {
"FEX_HALFBARRIERTSOENABLED": "1",
"FEX_X87REDUCEDPRECISION": "0",
}
STABILITY_FEX = dict(DOTNET_FEX, FEX_MULTIBLOCK="0")
# Setup loader offset-table IDs, as innoextract's known_setup_loader_versions lists them. Loaders
# from 5.1.5 keep the table in a resource; older ones also put "Inno" at file offset 0x30.
INNO_LOADER_IDS = (b"rDlPtS", b"nS5W7dT\x83\xaa\x1b\x0fj")
INNO_RESOURCE_LIMIT = 4 << 20
def is_inno_setup(path):
try:
with open(path, "rb") as exe:
head = exe.read(4096)
if head[:2] != b"MZ":
return False
if head[0x30:0x34] == b"Inno":
return True
pe = int.from_bytes(head[0x3C:0x40], "little")
if head[pe:pe + 4] != b"PE\0\0" or int.from_bytes(head[pe + 4:pe + 6], "little") != 0x14C:
return False
count = int.from_bytes(head[pe + 6:pe + 8], "little")
table = pe + 24 + int.from_bytes(head[pe + 20:pe + 22], "little")
for entry in range(table, table + 40 * count, 40):
if head[entry:entry + 8].rstrip(b"\0") == b".rsrc":
exe.seek(int.from_bytes(head[entry + 20:entry + 24], "little"))
size = int.from_bytes(head[entry + 16:entry + 20], "little")
resources = exe.read(min(size, INNO_RESOURCE_LIMIT))
return any(marker in resources for marker in INNO_LOADER_IDS)
except OSError:
pass
return False
STORE_LAUNCHER = ".droiddeck-launch.bat"
STORE_SIDECAR = ".droiddeck-store.json"
def store_game_exe(exe):
if os.path.basename(exe).lower() != STORE_LAUNCHER:
return exe
folder = os.path.dirname(exe)
try:
with open(os.path.join(folder, STORE_SIDECAR), encoding="utf-8") as source:
sidecar = json.load(source)
except (OSError, ValueError):
return exe
target = sidecar.get("exe") if isinstance(sidecar, dict) else None
if not isinstance(target, str) or not target.strip() or "\0" in target:
return exe
normalized = target.replace("\\", "/")
if ":" in normalized or normalized.startswith("/") or ".." in normalized.split("/"):
return exe
relative = os.path.normpath(normalized)
if os.path.isabs(relative) or relative in (".", "..") or relative.startswith(".." + os.sep):
return exe
candidate = os.path.join(folder, relative)
if not os.path.isfile(candidate):
return exe
root = os.path.realpath(folder)
try:
if os.path.commonpath((root, os.path.realpath(candidate))) != root:
return exe
except ValueError:
return exe
return candidate
def game_files(exe):
@@ -152,7 +89,6 @@ def game_files(exe):
class Game:
def __init__(self, exe, args, app_id=""):
exe = store_game_exe(exe)
self.exe = exe
self.args = args
self.app_id = app_id
@@ -255,12 +191,6 @@ def split_second_x87_fip(game):
return {"FEX_JITFEATURES": "enablex87fip"}, [], "Split/Second: FEX x87 FIP emulation on (its SecuROM stops with error 8016 without it)"
@fix
def inno_setup_stability(game):
if is_inno_setup(game.exe):
return STABILITY_FEX, [], "Inno Setup installer: FEX Stability settings (under Performance + TSO the 32-bit setup stub corrupts its own paths)"
@fix
def doom_2016_swapchain_images(game):
if "doomx64vk.exe" in game.files and game.stem in ("doomx64", "doomx64vk"):
@@ -343,7 +273,7 @@ def with_system_settings(text, settings):
# The game ignores -ini: overrides and deletes a writable Engine.ini after reading it, so this runs at every launch.
def dragon_quest_monsters_4_mesh_detail(exe, env):
project = Path(store_game_exe(exe)).stem.split("-", 1)[0]
project = Path(exe).stem.split("-", 1)[0]
if not project.lower().startswith("dragonquestmonsters4"):
return
prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx"
@@ -468,7 +398,7 @@ def zomboid_rewrite(node):
def project_zomboid_jvm(command):
if len(command) <= 2:
return
exe = Path(store_game_exe(command[2]))
exe = Path(command[2])
if not exe.stem.lower().startswith("projectzomboid"):
return
settings = exe.with_suffix(".json")
@@ -791,15 +721,12 @@ def apply_config(env, config, app_id, fixes=None):
def render_path_defaults(command, env):
if len(command) < 3 or command[1] != "waitforexitandrun":
return None
exe = Path(store_game_exe(command[2]))
if exe.name.lower() != "spintires.exe":
if len(command) < 3 or command[1] != "waitforexitandrun" or Path(command[2]).name.lower() != "spintires.exe":
return None
own = env.get("DXVK_CONFIG", "")
if re.search(r"(?:^|;)\s*dxvk\.tilerMode\s*=", own) or env.get("DXVK_CONFIG_FILE"):
return None
if Path("dxvk.conf").is_file() or exe.with_name("dxvk.conf").is_file():
if Path("dxvk.conf").is_file() or Path(command[2]).with_name("dxvk.conf").is_file():
return None
driver = env.get("VK_DRIVER_FILES", env.get("VK_ICD_FILENAMES", ""))
if Path(driver).parent.name != "DD-Turnip_v0.4.0":
@@ -1363,7 +1290,7 @@ def dirt_ws2_wanted(command, env):
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
if len(command) < 3 or not prefix or not os.path.isfile(DIRT_WS2):
return None
game = DIRT_GAMES.get(os.path.splitext(os.path.basename(store_game_exe(command[2])))[0].lower())
game = DIRT_GAMES.get(os.path.splitext(os.path.basename(command[2]))[0].lower())
if not game or not dirt_telemetry_on(prefix, game) or proton_has_dirt_fix(command[0]):
return None
return prefix if os.path.lexists(prefix_ws2(prefix)) else None
@@ -1420,7 +1347,7 @@ def ego_core_plan(command, env):
count = windows_core_count(env)
if not count or len(command) < 3:
return None
folder = Path(store_game_exe(command[2])).parent
folder = Path(command[2]).parent
path = folder / EGO_RESTRICTIONS
try:
raw = path.read_bytes()
@@ -1749,26 +1676,14 @@ def main():
if note:
print("droiddeck-game-env: " + note, file=sys.stderr)
else:
# An installer started with the run verb gets the same Stability settings as one started with
# waitforexitandrun; explicit game settings still win over them in apply_config.
installer = {}
if len(command) > 2 and command[1] == "run" and is_inno_setup(command[2]):
installer = dict(STABILITY_FEX)
print("droiddeck-game-env: Inno Setup installer: FEX Stability settings", file=sys.stderr)
path = Path.home() / ".config/droiddeck/game-environment.json"
try:
with path.open(encoding="utf-8") as source:
config = json.load(source)
synced = sync_config(config, app_id)
if installer:
# A FEX preset chosen for the game itself still wins, as on every other launch path.
game = config.get("games", {}).get(app_id, {})
synced["games"][app_id].update({k: v for k, v in game.items() if k in STABILITY_FEX})
env = apply_config(env, synced, app_id, installer)
env = apply_config(env, sync_config(config, app_id), app_id)
except FileNotFoundError:
env = dict(env, **installer)
pass
except (OSError, ValueError, TypeError, AttributeError):
env = dict(env, **installer)
print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr)
if waiting:
before_debug = env
@@ -224,23 +224,15 @@ if [ -n "${DD_VK_DRIVER:-}" ]; then
unset dd_icd_lib
fi
dd_webhelper_layout() {
local layout
if [ -n "${DD_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then
printf '%s\n' "$DD_VKBRIDGE_WEBHELPER_ARGS"
return
fi
if [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
elif [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
echo stock
return
fi
# ANGLE switches must not replace the helper's stable single-process layout.
layout="--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
if [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
layout="$layout --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
elif [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
else
layout="$layout --use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
echo "--use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
fi
printf '%s\n' "$layout"
}
dd_now_ms() {
if [ -n "${EPOCHREALTIME:-}" ]; then
@@ -546,10 +546,10 @@ VR_JS = r"""
def launch_steamvr():
say("SteamVR library launch: using the DroidDeck ARM64 helper")
state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr")
logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs")
try:
os.makedirs(state, exist_ok=True)
with open(os.path.join(state, "library-launch.log"), "a") as log:
os.makedirs(logs, exist_ok=True)
with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log:
return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL,
stdout=log, stderr=subprocess.STDOUT, start_new_session=True)
except OSError as e:
@@ -103,15 +103,15 @@ case "${1:-status}" in
launch)
exec 8>"$state/launch.lock"
flock -n 8 || exit 0
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to install SteamVR if needed and open the Quest's immersive view"
exit 0
fi
if ! installed; then
"$0" install || exit $?
while [ -f "$state/installing" ]; do sleep 1; done
fi
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR"
exit 0
fi
"$0" start
;;
status)
+1 -57
View File
@@ -203,17 +203,10 @@ static void test_handle_map_null_key(void)
map_free(&map);
}
static int zink_instance_table;
static struct object mock_zink_instance = {&zink_instance_table};
static struct object mock_arm = {&instance_table};
static struct object mock_zink_arm = {&zink_instance_table}, mock_zink_other = {&zink_instance_table};
static VkResult VKAPI_CALL mock_create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator,
VkInstance *instance)
{
const VkApplicationInfo *app = info->pApplicationInfo;
bool zink = app && app->pEngineName && !strcmp(app->pEngineName, "mesa zink");
*instance = (VkInstance)(zink ? &mock_zink_instance : &mock_instance);
*instance = (VkInstance)&mock_instance;
return VK_SUCCESS;
}
@@ -230,7 +223,6 @@ static void VKAPI_CALL mock_features(VkPhysicalDevice physical, VkPhysicalDevice
{
memset(features, 0, sizeof(*features));
features->dualSrcBlend = physical == (VkPhysicalDevice)&mock_capable;
features->geometryShader = VK_TRUE;
}
static void VKAPI_CALL mock_features2(VkPhysicalDevice physical, VkPhysicalDeviceFeatures2 *features)
@@ -242,8 +234,6 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi
{
memset(properties, 0, sizeof(*properties));
strcpy(properties->deviceName, "mock");
bool arm = physical == (VkPhysicalDevice)&mock_arm || physical == (VkPhysicalDevice)&mock_zink_arm;
properties->vendorID = arm ? 0x13b5 : 0;
properties->limits.maxFragmentDualSrcAttachments = physical == (VkPhysicalDevice)&mock_capable;
}
@@ -395,50 +385,6 @@ static void destroy_device(VkDevice device)
((PFN_vkDestroyDevice)layer_gdpa(device, "vkDestroyDevice"))(device, NULL);
}
static void test_geometry_shader_hidden_from_zink(void)
{
VkPhysicalDeviceFeatures features;
PFN_vkGetPhysicalDeviceFeatures plain_features =
(PFN_vkGetPhysicalDeviceFeatures)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures");
PFN_vkGetPhysicalDeviceFeatures2 plain_features2 =
(PFN_vkGetPhysicalDeviceFeatures2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures2");
VkPhysicalDeviceFeatures2 queried = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
plain_features((VkPhysicalDevice)&mock_lacking, &features);
assert(features.geometryShader);
plain_features((VkPhysicalDevice)&mock_arm, &features);
assert(features.geometryShader);
plain_features2((VkPhysicalDevice)&mock_arm, &queried);
assert(queried.features.geometryShader);
VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pEngineName = "mesa zink"};
VkLayerInstanceLink link = {NULL, mock_gipa, NULL};
VkLayerInstanceCreateInfo loader = {VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO, NULL, VK_LAYER_LINK_INFO, {&link}};
VkInstanceCreateInfo info = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = &loader,
.pApplicationInfo = &app};
VkInstance zink;
assert(((PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance"))(&info, NULL, &zink) == VK_SUCCESS);
assert(zink == (VkInstance)&mock_zink_instance);
PFN_vkGetPhysicalDeviceFeatures zink_features =
(PFN_vkGetPhysicalDeviceFeatures)layer_gipa(zink, "vkGetPhysicalDeviceFeatures");
PFN_vkGetPhysicalDeviceFeatures2 zink_features2 =
(PFN_vkGetPhysicalDeviceFeatures2)layer_gipa(zink, "vkGetPhysicalDeviceFeatures2");
zink_features((VkPhysicalDevice)&mock_zink_arm, &features);
assert(!features.geometryShader && features.dualSrcBlend);
zink_features2((VkPhysicalDevice)&mock_zink_arm, &queried);
assert(!queried.features.geometryShader && queried.features.dualSrcBlend);
zink_features((VkPhysicalDevice)&mock_zink_other, &features);
assert(features.geometryShader);
setenv("DROIDDECK_MALI_COMPAT_NO_GS", "0", 1);
zink_features((VkPhysicalDevice)&mock_zink_arm, &features);
assert(features.geometryShader);
setenv("DROIDDECK_MALI_COMPAT_NO_GS", "1", 1);
plain_features((VkPhysicalDevice)&mock_lacking, &features);
assert(!features.geometryShader);
unsetenv("DROIDDECK_MALI_COMPAT_NO_GS");
((PFN_vkDestroyInstance)layer_gipa(zink, "vkDestroyInstance"))(zink, NULL);
}
static const VkPipelineColorBlendAttachmentState dual_attachment = {
VK_TRUE, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, VK_BLEND_OP_ADD,
VK_BLEND_FACTOR_SRC1_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_OP_ADD, 0xf,
@@ -629,7 +575,6 @@ int main(int argc, char **argv)
setenv("WINEPREFIX", "/nonexistent", 1);
unsetenv("DROIDDECK_MALI_COMPAT");
unsetenv("DROIDDECK_MALI_COMPAT_TRACE");
unsetenv("DROIDDECK_MALI_COMPAT_NO_GS");
VkNegotiateLayerInterface negotiate = {LAYER_NEGOTIATE_INTERFACE_STRUCT, NULL, 2, NULL, NULL, NULL};
assert(vkNegotiateLoaderLayerInterfaceVersion(&negotiate) == VK_SUCCESS);
layer_gipa = negotiate.pfnGetInstanceProcAddr;
@@ -642,7 +587,6 @@ int main(int argc, char **argv)
PFN_vkCreateInstance create_instance = (PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance");
assert(create_instance(&info, NULL, &instance) == VK_SUCCESS);
test_geometry_shader_hidden_from_zink();
test_lacking_device();
test_capable_device();
test_depth_compare_op();
-158
View File
@@ -1741,94 +1741,6 @@ class GameEnvironmentTest(unittest.TestCase):
(asylum / name).touch()
self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], []))
def test_store_launcher_resolves_the_game_executable_from_the_sidecar(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp) / "BatmanArkhamCity"
bin_dir = root / "Binaries/Win32"
bin_dir.mkdir(parents=True)
for name in ("Batman2.exe", "BatmanAC.exe"):
(bin_dir / name).touch()
launcher = root / ".droiddeck-launch.bat"
launcher.touch()
(root / ".droiddeck-store.json").write_text(json.dumps({
"store": "epic", "id": "Egret", "title": "Batman Arkham City",
"exe": "Binaries/Win32/Batman2.exe", "launcher": ".droiddeck-launch.bat",
}))
env, extra, notes = MODULE["engine_fixes"](str(launcher), [])
self.assertEqual((env, extra), ({"FEX_X87REDUCEDPRECISION": "0"}, []))
self.assertTrue(notes)
home = Path(tmp) / "home"
config = home / ".config/droiddeck/game-environment.json"
config.parent.mkdir(parents=True)
config.write_text(json.dumps({"version": 1, "shared": {"FEX_X87REDUCEDPRECISION": "1"}}))
probe = home / "proton"
probe.write_text("#!" + sys.executable + "\nimport os, sys\n"
"print(os.environ.get('FEX_X87REDUCEDPRECISION', ''))\n"
"print(sys.argv[2])\n")
probe.chmod(0o755)
base = {k: v for k, v in os.environ.items() if not k.startswith(("FEX_", "WINE", "PROTON", "DROIDDECK", "DD_", "STEAM"))}
base.update(HOME=str(home), STEAM_COMPAT_DATA_PATH=str(home / "compatdata/3648205350"))
result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "waitforexitandrun", str(launcher)],
env=base, text=True, capture_output=True, check=True)
self.assertEqual(result.stdout.splitlines(), ["0", str(launcher)])
self.assertIn("Batman: Arkham City: FEX with full x87 precision", result.stderr)
rebirth = Path(tmp) / "FF7Rebirth"
rebirth_exe = rebirth / "End/Binaries/Win64/ff7rebirth_.exe"
rebirth_exe.parent.mkdir(parents=True)
rebirth_exe.touch()
rebirth_launcher = rebirth / ".droiddeck-launch.bat"
rebirth_launcher.touch()
(rebirth / ".droiddeck-store.json").write_text(json.dumps({
"store": "epic", "id": "ff7", "title": "FF7 Rebirth",
"exe": r"End\Binaries\Win64\ff7rebirth_.exe", "launcher": ".droiddeck-launch.bat",
}))
self.assertEqual(MODULE["engine_fixes"](str(rebirth_launcher), [])[0], {"VKD3D_FEATURE_LEVEL": "12_2"})
def test_store_launcher_ignores_missing_invalid_or_escaping_sidecar_paths(self):
with tempfile.TemporaryDirectory() as tmp:
outside = Path(tmp) / "Outside"
outside.mkdir()
outside_exe = outside / "BatmanAC.exe"
outside_exe.touch()
root = Path(tmp) / "Game"
sub = root / "sub"
sub.mkdir(parents=True)
(root / "real.exe").touch()
(sub / "nested.exe").touch()
(root / "escape.exe").symlink_to(outside_exe)
(root / "linkdir").symlink_to(outside)
launcher = root / ".droiddeck-launch.bat"
launcher.touch()
sidecar = root / ".droiddeck-store.json"
resolve = MODULE["store_game_exe"]
self.assertEqual(resolve(str(launcher)), str(launcher))
for payload in ("not-json", "[]", json.dumps({"exe": ""}), json.dumps({"exe": 123}),
json.dumps({"exe": "missing.exe"}), json.dumps({"exe": "sub"}),
json.dumps({"exe": "../Outside/BatmanAC.exe"}),
json.dumps({"exe": "sub/../real.exe"}),
json.dumps({"exe": r"sub\..\real.exe"}),
json.dumps({"exe": "linkdir/../real.exe"}),
json.dumps({"exe": "sub/../../Outside/BatmanAC.exe"}),
json.dumps({"exe": str(outside_exe)}),
json.dumps({"exe": r"C:\Windows\notepad.exe"}),
json.dumps({"exe": "escape.exe"})):
with self.subTest(payload=payload):
sidecar.write_text(payload)
self.assertEqual(resolve(str(launcher)), str(launcher))
sidecar.write_text(json.dumps({"exe": "real.exe"}))
self.assertEqual(resolve(str(launcher)), str(root / "real.exe"))
sidecar.write_text(json.dumps({"exe": "sub/nested.exe"}))
self.assertEqual(resolve(str(launcher)), str(sub / "nested.exe"))
other_bat = root / "custom.bat"
other_bat.touch()
self.assertEqual(resolve(str(other_bat)), str(other_bat))
def test_split_second_gets_x87_fip_unless_the_game_sets_jit_features(self):
with tempfile.TemporaryDirectory() as tmp:
game = Path(tmp) / "SplitSecond"
@@ -1850,76 +1762,6 @@ class GameEnvironmentTest(unittest.TestCase):
config["games"] = {"297860": {"FEX_JITFEATURES": "off"}}
self.assertEqual(MODULE["apply_config"]({}, config, "297860", env)["FEX_JITFEATURES"], "off")
def test_inno_setup_installers_get_the_stability_preset_over_the_default(self):
stability = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "1", "FEX_MEMCPYSETTSOENABLED": "1",
"FEX_HALFBARRIERTSOENABLED": "1", "FEX_X87REDUCEDPRECISION": "0", "FEX_MULTIBLOCK": "0"}
performance_tso = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "0", "FEX_MEMCPYSETTSOENABLED": "0",
"FEX_HALFBARRIERTSOENABLED": "0", "FEX_X87REDUCEDPRECISION": "1", "FEX_MULTIBLOCK": "1"}
def loader(path, resources=b"", machine=0x14C, section=b".rsrc", legacy=False):
dos = bytearray(0x80)
dos[:2] = b"MZ"
dos[0x3C:0x40] = (0x80).to_bytes(4, "little")
if legacy:
dos[0x30:0x34] = b"Inno"
header = b"PE\0\0" + machine.to_bytes(2, "little") + (1).to_bytes(2, "little") + bytes(12) \
+ (0xE0).to_bytes(2, "little") + bytes(2)
entry = section.ljust(8, b"\0") + bytes(8) + len(resources).to_bytes(4, "little") \
+ (0x400).to_bytes(4, "little") + bytes(16)
path.write_bytes((bytes(dos) + header + bytes(0xE0) + entry).ljust(0x400, b"\0") + resources)
return str(path)
with tempfile.TemporaryDirectory() as tmp:
folder = Path(tmp)
table = bytes(64) + b"rDlPtS\xcd\xe6\xd7{\x0b*" + bytes(64)
installers = [
loader(folder / "setup.exe", table),
loader(folder / "setup_game_1.0.exe", bytes(64) + b"nS5W7dT\x83\xaa\x1b\x0fj"),
loader(folder / "old_setup.exe", legacy=True),
]
for installer in installers:
env, extra, notes = MODULE["engine_fixes"](installer, [])
self.assertEqual((env, extra), (stability, []), installer)
self.assertTrue(notes)
config = {"version": 1, "shared": performance_tso}
self.assertEqual({k: v for k, v in MODULE["apply_config"]({}, config, "42", env).items() if k in stability},
stability)
config["games"] = {"42": {"FEX_MULTIBLOCK": "1"}}
self.assertEqual(MODULE["apply_config"]({}, config, "42", env)["FEX_MULTIBLOCK"], "1")
not_installers = [
loader(folder / "Game.exe", bytes(256)),
loader(folder / "Game64.exe", table, machine=0x8664),
loader(folder / "Data.exe", table, section=b".data"),
folder / "missing.exe",
]
(folder / "notes.exe").write_bytes(b"rDlPtS\xcd\xe6\xd7{\x0b*")
not_installers.append(folder / "notes.exe")
for other in not_installers:
self.assertEqual(MODULE["engine_fixes"](str(other), []), ({}, [], []), other)
# The run verb skips engine_fixes; an installer started that way still gets Stability.
probe = folder / "proton"
probe.write_text("#!" + sys.executable + "\nimport json, os\nprint(json.dumps(dict(os.environ)))\n")
probe.chmod(0o755)
base = {**os.environ, **performance_tso, "HOME": tmp, "STEAM_COMPAT_DATA_PATH": str(folder / "compatdata/42")}
def run_verb(program):
out = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "run", program],
env=base, text=True, capture_output=True, check=True).stdout
return {name: value for name, value in json.loads(out).items() if name in stability}
self.assertEqual(run_verb(installers[0]), stability)
self.assertEqual(run_verb(str(folder / "Game.exe")), performance_tso)
config_path = folder / ".config/droiddeck/game-environment.json"
config_path.parent.mkdir(parents=True)
config_path.write_text(json.dumps({"version": 1, "shared": {"WINEESYNC": "1"}}))
self.assertEqual(run_verb(installers[0]), stability)
config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": "1"}}}))
self.assertEqual(run_verb(installers[0]), {**stability, "FEX_MULTIBLOCK": "1"})
config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": None}}}))
self.assertNotIn("FEX_MULTIBLOCK", run_verb(installers[0]))
def test_d3dgear_capture_hook_beside_the_game_is_turned_off(self):
with tempfile.TemporaryDirectory() as tmp:
game = Path(tmp) / "The Crew 2"
+8 -9
View File
@@ -6,7 +6,6 @@ from pathlib import Path
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
KEYS = ("DD_VKBRIDGE_WEBHELPER_ARGS", "DD_VKBRIDGE_CEF_ANGLE", "DD_VKBRIDGE_CEF_VULKAN")
BASE = "--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
def layout_function():
@@ -28,14 +27,14 @@ class WebhelperLayoutTest(unittest.TestCase):
def test_angle_on_vulkan_brings_chromiums_vulkan_compositing(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan"),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
def test_vulkan_compositing_can_be_left_off_without_zygotes(self):
def test_vulkan_compositing_can_be_left_off(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_CEF_VULKAN="0"),
BASE + " --use-gl=angle --use-angle=vulkan")
"--use-gl=angle --use-angle=vulkan")
def test_other_angle_backends_get_only_the_angle_switches(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
def test_explicit_layout_wins(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_WEBHELPER_ARGS="--x +Y"),
@@ -58,10 +57,10 @@ class WebhelperLayoutTest(unittest.TestCase):
env = {k: v for k, v in os.environ.items() if k not in KEYS}
run = lambda **s: subprocess.run(["bash", "-c", "set -u\n" + script], env={**env, **s},
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(), BASE + " --use-gl=angle --use-angle=vulkan")
self.assertEqual(run(), "--use-gl=angle --use-angle=vulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN="1"),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
def test_empty_settings_are_kept_as_set(self):
script = ': "${DD_VKBRIDGE_CEF_ANGLE=vulkan}" "${DD_VKBRIDGE_CEF_VULKAN=0}"\n' + layout_function() + "dd_webhelper_layout\n"
@@ -70,7 +69,7 @@ class WebhelperLayoutTest(unittest.TestCase):
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE=""), "stock")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN=""),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
if __name__ == "__main__":
+4 -2
View File
@@ -1003,13 +1003,15 @@ class SwitchToDesktopTest(unittest.TestCase):
self.assertEqual(patched["launch_steamvr"].call_count, 2)
def test_vr_launch_runs_helper_without_shell_in_background(self):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": tmp}):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"HOME": tmp}):
with mock.patch.object(self.globals["subprocess"], "Popen") as popen:
LIVE["launch_steamvr"]()
self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],))
self.assertTrue(popen.call_args.kwargs["start_new_session"])
self.assertNotIn("shell", popen.call_args.kwargs)
self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists())
self.assertEqual(popen.call_args.kwargs["stdout"].name,
str(Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log"))
self.assertTrue((Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log").exists())
def test_the_request_goes_to_steamos_session_select(self):
helper = LIVE["Helper"]("/steam", 1)
+26
View File
@@ -274,6 +274,32 @@ class SteamVrHelperTest(unittest.TestCase):
self.assertTrue(vrpath.is_file())
self.assertTrue(xr.is_symlink())
def launch(self):
self.executable(self.commands / 'curl', 'echo curl >> "$CURL_CALLS"; exit 22')
self.environment['CURL_CALLS'] = str(self.root / 'curl-calls')
self.helper.chmod(0o755)
return subprocess.run(['sh', str(self.helper), 'launch'], env=self.environment,
capture_output=True, text=True, timeout=5)
def test_quest_launch_hands_a_missing_steamvr_to_the_app_without_downloading_it(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
state = self.runtime / 'droiddeck-steamvr'
state.mkdir(parents=True)
(state / 'quest-immersive').touch()
result = self.launch()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertTrue((state / 'xr-request').is_file())
self.assertFalse((self.root / 'curl-calls').exists())
self.assertFalse((state / 'installing').exists())
def test_launch_elsewhere_still_installs_a_missing_steamvr_itself(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
result = self.launch()
self.assertEqual(result.returncode, 1)
self.assertIn('download failed', result.stdout)
self.assertTrue((self.root / 'curl-calls').is_file())
self.assertFalse((self.runtime / 'droiddeck-steamvr/xr-request').exists())
if __name__ == '__main__':
unittest.main()
+5 -17
View File
@@ -47,18 +47,13 @@ static int g_dev_state, g_base_black;
static uintptr_t g_dev = 1;
static struct { int64_t wait_ns, wait_max_ns; unsigned waits; } g_perf;
static VkResult answer;
static unsigned timeouts, wait_calls;
static unsigned destroyed, unmapped, freed_memory, forgotten, errors;
static int64_t perf_now(void) { return 10; }
static void perf_add(int64_t *s, int64_t *m, unsigned *c, int64_t d) { *s+=d; *m=d; ++*c; }
static void __attribute__((unused)) droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; ++errors; }
#define LOGE(...) droiddeck_log("error", __VA_ARGS__)
static VkResult wait_fn(uintptr_t dev, unsigned n, const VkFence *f, int all, uint64_t timeout) {
(void)dev; (void)n; (void)f; (void)all;
++wait_calls;
if (wait_calls > 1) assert(timeout == UINT64_MAX);
if (timeouts) { --timeouts; return VK_TIMEOUT; }
return answer;
(void)dev; (void)n; (void)f; (void)all; (void)timeout; return answer;
}
static void unmap_fn(uintptr_t dev, uintptr_t mem) { (void)dev; (void)mem; ++unmapped; }
static void destroy_fn(uintptr_t dev, uintptr_t img, void *allocator) { (void)dev; (void)img; (void)allocator; ++destroyed; }
@@ -109,15 +104,8 @@ int main(void) {
vkp_image_destroy(image());
assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1);
for (unsigned delays=1; delays<=3; ++delays) {
g_dev_state=1; g_base_black=1; answer=VK_SUCCESS;
timeouts=delays; wait_calls=0;
assert(timed_wait(1, 1000)==VK_SUCCESS);
assert(g_dev_state==1 && g_base_black==1 && wait_calls==delays+1);
}
g_dev_state=1; g_base_black=1; answer=VK_ERROR_UNKNOWN; wait_calls=0;
assert(timed_wait(1, 1000)==VK_ERROR_UNKNOWN);
g_dev_state=1; g_base_black=1; answer=VK_TIMEOUT;
assert(timed_wait(1, 1000)==VK_TIMEOUT);
assert(g_dev_state!=1 && g_dev_state!=-2); /* pending work is not DEVICE_LOST */
struct vkp_image *pending=image();
vkp_image_destroy(pending);
@@ -128,14 +116,14 @@ int main(void) {
assert(errors==first_errors); /* one terminal diagnostic, no repeated recovery */
free(pending); /* fake GPU exists only in this test */
g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY; wait_calls=0; timeouts=1;
g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY;
assert(timed_wait(1, 1000)==VK_ERROR_OUT_OF_HOST_MEMORY);
assert(g_dev_state!=1 && g_dev_state!=-2);
pending=image(); vkp_image_destroy(pending);
assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1);
free(pending);
g_dev_state=1; answer=VK_ERROR_DEVICE_LOST; wait_calls=0; timeouts=2;
g_dev_state=1; answer=VK_ERROR_DEVICE_LOST;
assert(timed_wait(1, 1000)==VK_ERROR_DEVICE_LOST);
assert(g_dev_state==1); /* existing caller performs genuine device-loss cleanup */
return 0;
+4 -7
View File
@@ -111,18 +111,15 @@ int __android_log_print(int, const char *, const char *, ...);
def test_later_framegen_surface_lost_idle_failure(self):
self.run_scenario('later-surface-lost')
def test_blit_wait_error_same_size_shm_upload(self):
self.run_scenario('shm-wait-error')
def test_finite_blit_timeout_same_size_shm_upload(self):
self.run_scenario('shm-timeout')
def test_blit_wait_error_same_size_pixel_upload(self):
self.run_scenario('pixel-wait-error')
def test_finite_blit_timeout_same_size_pixel_upload(self):
self.run_scenario('pixel-timeout')
def test_lost_device_shm_upload_keeps_cpu_snapshot(self):
self.run_scenario('lost-shm-upload')
def test_delayed_blit_completes_and_next_frame_renders(self):
self.run_scenario('blit-delayed')
def test_normal_present(self):
self.run_scenario('normal')
+6 -19
View File
@@ -7,7 +7,7 @@ struct vk_api g_vk;
static unsigned operations, acquires, submits, markers, waits, idle_calls, resets;
static unsigned destroys, releases, lost_notifications, presented_notifications;
static VkResult idle_answer, fence_answer, acquire_answer, present_answer;
static unsigned fail_acquire_at, fence_timeouts;
static unsigned fail_acquire_at;
static int generated;
/* Every work-issuing callback is an oracle: no GPU operation after a terminal
@@ -19,9 +19,7 @@ static VkResult acquire(VkDevice d, VkSwapchainKHR s, uint64_t t, VkSemaphore a,
}
static VkResult idle(VkDevice d) { live(); ++idle_calls; return idle_answer; }
static VkResult wait_fences(VkDevice d, uint32_t n, const VkFence *f, VkBool32 all, uint64_t t) {
live(); ++waits;
if (fence_timeouts) { --fence_timeouts; return VK_TIMEOUT; }
return fence_answer;
live(); ++waits; return fence_answer;
}
static VkResult submit(VkQueue q, uint32_t n, const VkSubmitInfo *s, VkFence f) {
live(); ++submits; if (!s->commandBufferCount) ++markers; return VK_SUCCESS;
@@ -237,7 +235,7 @@ static void acquire_failure(int later, VkResult result) {
free(g_images); /* test-owned fake resources only */
}
static void upload_wait_error(int single_pixel) {
static void upload_timeout(int single_pixel) {
setup(0);
uint8_t bytes[48], saved[48], data[16];
memset(bytes, 0xa5, sizeof(bytes)); memset(data, 0x3c, sizeof(data));
@@ -253,7 +251,7 @@ static void upload_wait_error(int single_pixel) {
assert(bytes[3] == 0x3c && bytes[0] == 0xa5 && releases == 1);
memcpy(saved, bytes, sizeof(saved));
struct vkp_image dst = {.image = (VkImage)(uintptr_t)9, .blit_dst = 1, .w = img->w, .h = img->h};
fence_answer = VK_ERROR_OUT_OF_HOST_MEMORY;
fence_answer = VK_TIMEOUT;
assert(vkp_blit_image(img, &dst, -1) == -1);
assert(g_dev_state == -3 && submits == 1 && waits == 1);
memset(data, 0x7e, sizeof(data));
@@ -281,8 +279,8 @@ int main(int argc, char **argv) {
else if (!strcmp(name, "first-surface-lost")) acquire_failure(0, VK_ERROR_SURFACE_LOST_KHR);
else if (!strcmp(name, "later-out-of-date")) acquire_failure(1, VK_ERROR_OUT_OF_DATE_KHR);
else if (!strcmp(name, "later-surface-lost")) acquire_failure(1, VK_ERROR_SURFACE_LOST_KHR);
else if (!strcmp(name, "shm-wait-error")) upload_wait_error(0);
else if (!strcmp(name, "pixel-wait-error")) upload_wait_error(1);
else if (!strcmp(name, "shm-timeout")) upload_timeout(0);
else if (!strcmp(name, "pixel-timeout")) upload_timeout(1);
else if (!strcmp(name, "lost-shm-upload")) {
setup(0);
uint8_t bytes[64], data[16];
@@ -297,17 +295,6 @@ int main(int argc, char **argv) {
free(img.recovery_pixels);
free(g_images);
} else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); }
else if (!strcmp(name, "blit-delayed")) {
setup(0);
struct vkp_image src = {.image = (VkImage)(uintptr_t)7, .w = 1, .h = 1};
struct vkp_image dst = {.image = (VkImage)(uintptr_t)8, .w = 1, .h = 1, .blit_dst = 1};
fence_timeouts = 3;
assert(vkp_blit_image(&src, &dst, -1) == 0);
assert(g_dev_state == 1 && submits == 1 && waits == 4 && destroys == 0);
assert(vkp_blit_image(&src, &dst, -1) == 0);
assert(g_dev_state == 1 && submits == 2 && waits == 5 && destroys == 0);
free(g_images);
}
else if (!strcmp(name, "normal") || !strcmp(name, "framegen")) {
int extra = !strcmp(name, "framegen"); setup(extra);
assert(vkp_render(64, 64, NULL, 0) == 0 && g_dev_state == 1);
-26
View File
@@ -344,31 +344,12 @@ static void report_limits(VkPhysicalDeviceLimits *limits, uint32_t gaps)
}
}
/* Mali's driver crashes compiling Zink's geometry shaders (SIGSEGV at 0x40 in
* cmpbe_v2_compile_multiple_shaders) and takes the render server and the application with it; a plain
* one draws nothing. Zink draws GL_QUADS through one; without the feature Mesa splits quads into
* triangles itself. DXVK needs the feature for D3D10 and 11, so only Zink loses it.
* DROIDDECK_MALI_COMPAT_NO_GS=0 keeps it for Zink, =1 hides it from every application. */
static bool hide_geometry_shader(struct instance *inst, VkPhysicalDevice physical_device)
{
const char *setting = getenv("DROIDDECK_MALI_COMPAT_NO_GS");
if (setting && *setting)
return strcmp(setting, "1") == 0;
if (!inst->zink)
return false;
VkPhysicalDeviceProperties properties;
inst->GetPhysicalDeviceProperties(physical_device, &properties);
return properties.vendorID == 0x13b5; /* ARM */
}
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures(VkPhysicalDevice physical_device,
VkPhysicalDeviceFeatures *features)
{
struct instance *inst = instance_from_handle(physical_device);
inst->GetPhysicalDeviceFeatures(physical_device, features);
report_features(features, physical_device_gaps(inst, physical_device));
if (hide_geometry_shader(inst, physical_device))
features->geometryShader = VK_FALSE;
}
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice physical_device,
@@ -382,8 +363,6 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice ph
inst->GetPhysicalDeviceFeatures2(physical_device, features);
relink(dropped, dropped_count);
report_features(&features->features, gaps);
if (hide_geometry_shader(inst, physical_device))
features->features.geometryShader = VK_FALSE;
if (tracing()) {
char chain[512] = "";
size_t used = 0;
@@ -484,8 +463,6 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo
inst->key = dispatch_key(*instance);
inst->handle = *instance;
inst->active = wanted();
const char *engine = info->pApplicationInfo ? info->pApplicationInfo->pEngineName : NULL;
inst->zink = engine && strcmp(engine, "mesa zink") == 0;
inst->gipa = gipa;
pthread_mutex_init(&inst->lock, NULL);
#define LOAD(name) inst->name = (PFN_vk##name)gipa(*instance, "vk" #name);
@@ -647,9 +624,6 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physical_dev
if (properties.limits.maxFragmentInputComponents < components)
components = properties.limits.maxFragmentInputComponents;
dev->max_varying_locations = components / 4;
if (inst->active && hide_geometry_shader(inst, physical_device))
layer_log("geometryShader is hidden from %s: the driver crashes compiling geometry shaders",
inst->zink ? "Zink" : "every application");
pthread_mutex_lock(&global_lock);
dev->next = devices;
-1
View File
@@ -63,7 +63,6 @@ struct instance {
void *key;
VkInstance handle;
bool active;
bool zink; /* the engine is Mesa's Zink */
PFN_vkGetInstanceProcAddr gipa;
PFN_vkDestroyInstance DestroyInstance;
PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;