Compare commits

...
Author SHA1 Message Date
The412Banner 49381484dd fix(bionic): put the game's logs where Share logs finds them
Shared session logs never held DroidDeck-Bionic's own log or its
graphics logs. launch.sh wrote them into the game's prefix, which Share
logs does not read, and dropped the log locations Detailed graphics logs
sets along with the rest of the guest environment.

- proton: names a game launch's folder in the session folder (the
  game's log folder when Detailed graphics logs made one, else
  games/<date>-bionic-<appid>) and passes the graphics log locations as
  Android paths.
- launch.sh: writes the game's log into that folder; the prefix's
  droiddeck-bionic.log points to it, since Share logs takes only files
  with one name. Keeps DXVK_LOG_PATH, VKD3D_LOG_FILE and MESA_LOG_FILE.
- EnhancedSessionLogShare: keeps the name droiddeck-bionic.log and
  files it with the games.
2026-11-23 01:32:33 +00:00
The412Banner f17d3ddaad fix(bionic): name guest files by their Android paths in store launches
DroidDeck-Bionic's Wine has Android's root on Z:, but DroidDeck's store
launch files and helpers name guest files by guest Z: paths. A Ubisoft
game then skipped its service and started directly (Watch_Dogs exited at
launch); the Epic parent stand-in, GOG/Rockstar registry values, reg.exe
imports and the EA probe pointed at the wrong tree in the same way.
Reported by 2-Shar on PR #3037.

- proton: map guest Z: paths in every run argument (also NAME=Z:..., as
  in an installer's /DIR=) and export DROIDDECK_GUEST_ROOT, the guest's
  root as this Wine names it; launch.sh keeps it.
- StoreLaunch: the Ubisoft service and the Epic parent stand-in start
  from %DD_R% (DROIDDECK_GUEST_ROOT, else Z:). An installed Ubisoft
  game's older launch file is rewritten at the next library scan.
- droiddeck-store-launch: windows_path() asks DroidDeck-Bionic's
  getcompatpath when that tool runs the game.
- droiddeck-gog-maintenance: name the tool for the registry step.
2026-11-23 00:44:48 +00:00
The412Banner 2aae4b2284 fix(bionic): address review findings
Launcher (tools/bionic-runtime/tool/launch.sh)
- The FEX code cache is also cleared when another FEX build wrote to it since this tool last ran the prefix:
  the stamp now holds the FEX ID and a fingerprint of the caches, saved after each run (also after
  runinprefix and when Steam stops the game).
- A game started by a launcher that then exits keeps the tool waiting: the wait goes on while any program
  of the prefix runs, apart from Wine's own services. The game is looked up in this prefix only, by its
  name as fixed text.
- The tool exits with Wine's status instead of 0.

Install scripts (droiddeck-game-env)
- A "run process" entry counts as done only when its hasrunkey value is a DWORD of at least its
  MinimumHasRunValue (1 by default), as Steam's evaluator decides; a 0 or a value of another type no longer
  lets the evaluator be skipped.

Helpers
- execshim: non-regular files (a FIFO) go to libc without a blocking open; libc functions are bound at load
  through atomic slots; relative posix_spawn paths with file actions are left to libc; the argument vector
  has room for its terminator when argv is empty.
- gstag: replies and errors are matched to their request's sequence number per connection; one bounded
  packet reader; destroyed windows leave the candidate and tagged lists; the focus override needs a live
  tagged window and a successful focus read; only gone candidates are pruned.
- steamshm: a new shared object is created and sized under a private name and then put in place in one
  step; both code redirects go in or neither, and unused trampolines are released.
- check-needed.py fails when readelf fails and ignores dangling links.
- The bionic runtime workflow also runs for tools/gpuload changes.

App and tool wrapper
- FEX twin downloads run once per name; a twin that a game's FEX choice still needs on an installed tool
  cannot be deleted.
- With proot on and no DroidDeck-Proton installed, a launch sent to DroidDeck-Bionic stops with a message
  instead of starting the bionic tool.
2026-11-22 17:56:19 -05:00
The412Banner dca443e3aa feat(bionic): DroidDeck-Bionic compatibility tool (Wine on Android's libc, no proot)
DroidDeck-Bionic is a Steam compatibility tool that runs the game itself with
Android's own libc (bionic) instead of glibc inside proot. Steam, the stores and
the session stay on DroidDeck's Linux side unchanged; only the game process
leaves proot. It is listed in the Proton list only when "Run without proot" is
on, and it is shipped as a pre-release runtime pack (DroidDeck-Bionic-12.8-rNN
on Droid-Deck/DroidDeck-Proton), never as the default for other users.

Runtime pack (tools/bionic-runtime, .github/workflows/build-bionic-runtime.yml)
- CI builds an aarch64 bionic pack: the Wine layer from The412Banner/proton-wine
  (bionic build), an exec shim, launcher (tool/launch.sh + proton verbs run,
  runinprefix, waitforexitandrun), gamescope's WSI layer (patches 0117 + 0119),
  DroidDeck's GPU-load layer, fake input (fakeinput_steam.cpp), GStreamer
  plugins, Zink/Fast OpenGL Mesa, DXVK, VKD3D-Proton, D7VK and FEX (ARM64EC).
- Games run on gamescope's X server; Steam store games reach DroidDeck's Steam
  (lsteamclient), Steam Input works (shared /dev/shm via libsteamshm), and
  Steam Cloud maps Windows save folders (tool name contains "Proton").
- DroidDeck's game settings, game-environment fixes, in-game layers and DXVK /
  VKD3D / FEX choices reach bionic games the same way they reach
  DroidDeck-Proton games (DD_* setting names).
- Prefixes stay compatible both ways with DroidDeck-Proton: dead links are
  removed, the tool's .NET stubs and comctl32 v6 survive Wine updates, a stale
  FEX code cache from another FEX build is cleared, drive Z: is the whole device.
- Store launches: Xbox (Windows exe path + Xbox runtime environment), GOG and
  Epic (.bat launchers, games that rename their process).

App changes (all additive)
- ProtonExtras / ProtonMenu / ExperimentalProtons / droiddeck-proton-extra:
  DroidDeck-Bionic pre-releases are checked and listed only with Run without
  proot on, in their own row (not under Experimental); updates replace the
  older build and carry the default tool and per-game picks over; deleting a
  tool removes links inside it, never what they point to.
- ProtonDefault: a default or game pick left on an older bionic build moves to
  the installed one; bionic picks start on DroidDeck-Proton when Run without
  proot is off.
- ComponentsManager / ComponentUpdates / ComponentUpdater / ComponentsPage /
  SessionOverlay: FEX components for DroidDeck-Bionic (bionic-stable on
  DroidDeck-Components); each tool is offered only FEX builds that fit it.
- SessionService: DROIDDECK_DISPLAY_DRIVER tells bionic games which Turnip the
  display uses when the chosen runtime driver has no Android build.
- steam-compatibility: with proot on, a launch sent to a DroidDeck-Bionic tool
  goes to the newest DroidDeck-Proton (picks stay as set); glibc FEX rows are
  never applied to a DroidDeck-Bionic tool.
- droiddeck-game-env: Steam's install-script evaluator is skipped when its
  scripts only run processes already marked as done.

Tests
- New: ComponentsBionicFexTest; extended ComponentsRepublishTest,
  ExperimentalProtonsTest, ProtonDefaultTest, ProtonExtrasTest,
  test_game_environment.py, test_proton_extra.py.

Device testing (Pocket FIT, Adreno 750; Pocket FIT Elite, Adreno 830)
- Steam (Brawlhalla online, Left 4 Dead 2 controller, Black Ops II, Steam
  Cloud), Xbox, GOG, Epic and Amazon games run; saves carry both ways between
  DroidDeck-Bionic and DroidDeck-Proton on Xbox, GOG, Epic and Amazon.
- Not tested: EA, Ubisoft, Battle.net (no owned game / not signed in).
2026-11-22 17:12:43 -05:00
DeathKhan 6ef8e2274e fix(ui): focused cards keep their solid ground under the highlight tint (#2909) 2026-11-22 17:11:29 -05:00
Kurt Himebauch 00525cde15 fix(session): picking a bottom-screen mode clears the menu restore left by a teardown (#3007) 2026-11-22 17:07:23 -05:00
MaxsTechReview 210c127446 feat(addons): add a CurseForge source to the addon browser (#3028)
* feat(addons): add a CurseForge source to the addon browser

Search and install CurseForge addons from the Download addons window by
driving the installed CurseForge app in the background: it starts minimized
on the session's X display with its inspector bound to 127.0.0.1, and the
window's own renderer services handle game detection, search, install and
shutdown. Sign-in stays inside the CurseForge app.

The Install buttons in the addon list now size to their label, so the label
is centered and the button matches the other compact buttons.

* fix(curseforge): secret inspector URL, hold mode and serialised starts

- Start CurseForge with its Node inspector on 127.0.0.1:0 and publish only
  the UUID websocket URL, kept in the 0700 state directory, so no fixed
  unauthenticated debug port is exposed.
- The agent evaluates through that URL instead of a fixed port.
- Add a hold mode that runs as a session program and stops the app on
  exit, and a lock so hold and start never launch twice.

* feat(addons): run CurseForge in a hidden session when none is running

- Opening the CurseForge source with no session starts one headlessly
  (offscreen compositor output, shared start path with SessionActivity via
  CompositorHost) running the CurseForge hold helper; leaving the dialog
  stops the app and that session. A session the user already had is
  reused and left running.
- Drop the "start a session" notice from every locale.
- Addon browser link: cleanup shares the link's lock off the UI thread,
  stops the app at once on close, refuses work after close and stops a
  launch that finishes after close.
- CurseForgeApp.start stops the app before every failed return.
- instanceFor returns no instance when the populated list has no match.

* Harden headless CurseForge session and helper lifecycle

Scope the hidden session to its id, roll back partial starts, release the
offscreen reader once the session ends, re-acquire the inspector when its
endpoint goes away, bound DevTools calls by one deadline, key the installed
snapshot by target, track the helper launch by pid start time and directory,
fail on lock errors, and update the HDR gate test to its new location.

* Map DevTools send failures and recheck the hidden session id

* fix(addons): bind the hidden session to the id it claims at launch

* Keep the CurseForge helper quiet when no launch is recorded
2026-11-22 17:02:35 -05:00
Tushar Gandhe 234e40157e feat(launcher): LT and RT step between the main tabs from anywhere in the launcher (#3035)
* feat(launcher): LT and RT step between the main tabs from anywhere in the launcher

LT and RT move to the previous and next main tab on every layout. The activity handles them before any page sees the key, so a focused control, an embedded Android view such as the terminal, or nothing being focused no longer swallows them; dialogs and popups keep their own keys. Pads that report the triggers only as axes, like the Xbox Wireless Controller, get an L2/R2 press when a trigger passes 60% of its travel; pads that send their own trigger keys are left alone.

* fix(launcher): trigger tab steps tick, drop a pending press on focus loss, and move once per pull

Controller haptics now ticks for L2 and R2. A synthetic trigger press waiting its 40 ms is cancelled when the launcher loses window focus or is destroyed, so a dialog that opens in between keeps the page behind it. Each pull is tracked: when a synthetic press has gone out, the pad's own trigger key for the same pull is swallowed instead of stepping a second tab.
2026-11-22 16:59:01 -05:00
Tushar Gandhe c3809c0a75 fix(ui): keep the Agent composer above the keyboard and release search fields on tap (#2852)
* fix(agent): keep the composer above the keyboard outside fullscreen

* fix(ui): release a search field when another control is tapped

* fix(ui): release the add-on search field in its dialog, and let a reopened search take focus

* fix(ui): a drag that returns to where it began does not release the search field
2026-11-22 16:58:57 -05:00
Tushar Gandhe 71b7b6efad fix(library): put the store accounts button on the right of the source chips, as on other pages (#2929) 2026-11-22 16:58:53 -05:00
Tushar Gandhe a0e7c1715a fix(ui): smaller game page link pills with a gap between rows (#2973) 2026-11-22 16:58:49 -05:00
MaxsTechReview 2c2d55058e fix(preload): open synthesized socket tables when the fd reopen is denied (#3034) 2026-11-22 16:20:34 -05:00
MaxsTechReview 7f61e514e6 chore: pin gamescope to the release with the opacity focus fix (#3031) 2026-11-22 14:27:08 -05:00
MaxsTechReview b891019b87 fix(steam-x64): keep the session's GL thunk for the x86 web helper (#3027)
* fix(steam-x64): keep the session's GL thunk for the x86 web helper

FEX's global AppConfig for steamwebhelper turns the GL thunk off and is
read after FEX_THUNKCONFIG, so the x86 helper used the rootfs's x86 Mesa.
Steam's browser compositor creates its window through SDL3 and GLX in
the helper's browser process, x86 Mesa faulted in driCreateNewScreen3
(SIGSEGV) about 11 s after each start, and the client restarted the
helper every 12 s.

For every global FEX AppConfig that turns off a thunk the session uses,
the launcher writes a local AppConfig with the session's thunk set. It
leaves local files with other content alone and removes its own files
when the client runs in software.

* fix(steam-x64): write FEX AppConfig overrides atomically

* fix(steam-x64): stage AppConfig overrides in a unique temporary file

* fix(steam-x64): publish AppConfig overrides without replacing a newer file
2026-11-22 14:16:34 -05:00
MaxsTechReview 1a29c65d4f fix(gamescope): choose focus again when a window's opacity crosses zero (#3030)
A window is a focus candidate only while _NET_WM_WINDOW_OPACITY is above
zero, but a change of that property never re-ran focus selection. A
layered window that maps fully transparent and fades in was skipped at
map time and stayed skipped once opaque, so a nested desktop session
hid its gamescope window and the game ran with nothing on screen.
2026-11-22 13:47:22 -05:00
MaxsTechReview ff5e4c7ac7 fix(preload): accept NETLINK_ROUTE multicast subscriptions (#3015)
* fix(preload): accept NETLINK_ROUTE multicast subscriptions

Programs that watch for network changes bind their route socket with
multicast groups or join them with NETLINK_ADD_MEMBERSHIP. The emulated
socket refused both with EACCES, and .NET's NetworkChange treats that as
fatal: CurseForge's Mods Agent failed to initialise with "Permission
denied" from NetworkChange.CreateSocket(), so the app never loaded its
library.

Real Linux lets unprivileged sockets join rtnetlink groups. Accept the
groups at bind and through ADD/DROP_MEMBERSHIP, report them from
getsockname(), and keep queries on the same socket working. No change
events are generated yet; queries still return the current snapshot.

* fix(preload): keep netlink group membership in the shared socket state

Memberships now live in the peer metadata the kernel holds for the socket, next to the port and cap ack, so they survive exec and a change made by one process after fork is seen by every process holding the socket.

* fix(session): answer denied /proc/net socket tables

Android's SELinux policy denies app processes every file under /proc/net.
.NET lists TCP listeners from /proc/net/tcp and tcp6 before it binds a
server port, so the CurseForge Mods Agent failed on every port with
"An error was encountered while querying information from the operating
system" on stock firmware. Denied tcp, tcp6, udp and udp6 reads now get a
header-only table, through open and openat as well as fopen, the same way
the route and interface tables already are.

* fix(session): keep synthesized socket tables read-only and file-only

Reopen the populated table read-only instead of duplicating its writable
descriptor, and leave O_DIRECTORY opens with their original failure.
2026-11-22 13:37:44 -05:00
MaxsTechReview 2d38f11b36 Build FEX's latest release, point releases included (#3026)
The FEX build pinned FEX-2610 and its tag checks only accepted four
digits, so FEX-2611.1 was never picked up. The build now takes the
latest release tag, and Fixed-upstream compares the four-digit release.
CMake 4.5 rejects DEPENDS in install(CODE), which stopped host thunk
builds; patch 0007 drops it.
2026-11-22 13:03:43 -05:00
MaxsTechReview fd2e1652ad fix(fex): invalidate translated code written through a later writable alias (#3020)
* fix(fex): invalidate translated code written through a later writable alias

x86-64 CoreCLR maps its W^X memfd writable after the executable view was
translated. Under SMCChecks=mtrack the new alias was never write-protected,
so writes through it did not invalidate stale translations. Protect the
overlapping part of an executable alias on mmap and mprotect.

* fix(fex): protect every writable alias in one mprotect range and build fmt without modules

* fix(fex): build without C++ module scanning or import std
2026-11-22 12:22:11 -05:00
Tushar Gandhe c6b6e7362e fix(ui): game page main action above its box, and tabs that scroll and slide (#2994) 2026-11-22 11:31:46 -05:00
MaxsTechReview cb7edbefd2 fix(input): show the main screen layout editor first, like the second screen (#3019)
The Screen visibility group sat above the Layout group on the Main screen page, so in landscape its description pushed Edit on screen below the fold and the page looked like it had no editor. The Layout group now comes first on both screens.
2026-11-22 10:56:03 -05:00
Kurt Himebauch a9b5994a91 fix(library): drop the card's bottom gradient when it has no text to show (#3017) 2026-11-22 10:52:25 -05:00
MaxsTechReview 42f25c2a6c fix(input): controls edited in portrait keep their places in the panel below the game (#3013)
* fix(input): controls edited in portrait keep their places in the panel below the game

The panel below the game in portrait always regenerated the stock
layout, so positions saved from the Controls editor were dropped and
only the button styling carried over. The panel now orients to the
portrait frame and fits the edited controls into the panel at their
saved proportions; untouched stock layouts keep the generated panel.

* Keep the Deck panel's trackpads and fitted sizes for edited portrait controls
2026-11-22 09:51:32 -05:00
MaxsTechReview 501debc7f6 fix(game-env): Dragon's Dogma 2 starts with its Wine detection off (#3011)
Dragon's Dogma 2 checks for Wine and takes a path that does not start.
Launches of Steam app 2054970 now append the game's own
/WineDetectionEnabled:False switch at launch time. Steam's stored Launch
Options are untouched, and a /WineDetectionEnabled: value the user already
passes keeps priority and is not repeated.
2026-11-22 09:31:40 -05:00
Tushar Gandhe 1f70d43fe2 feat(ui): a Launcher setting turns page swipes off, and edge swipes in landscape leave the page alone (#2924) 2026-11-22 07:26:39 -05:00
Tamim Kabir a8d03d687f fix(input): SDL 3 games no longer crash on the virtual pads' udev devices (#2915) 2026-11-22 02:43:32 -05:00
Kurt Himebauch 9cfab884d5 feat(session): the DroidDeck menu is a bottom-screen mode, and the controller stays with the game (#3001) 2026-11-22 00:16:49 -05:00
FX1922 aefa5a3c0d feat(session): split the display resolution into landscape and portrait (#2990)
## Summary

Splits the session resolution setting into two: **Landscape resolution**
and **Portrait resolution**. Each has the same options as the old
Resolution row, plus a Follow option so one orientation can mirror the
other.

## Why

A single resolution has to serve both orientations. Presets and Match
screen flip automatically in portrait, but a custom size is used exactly
as typed, so a landscape size in a portrait session is wrong. Users who
play in both orientations couldn't pick a good size for each.

## Behavior

- The Display tab shows **Landscape resolution** and, underneath it,
**Portrait resolution**. Both offer the full existing list: presets,
Match screen, Follow screen, scaled follow options and Custom.
- Each row has an extra option at the top. **Follow portrait** (on the
landscape row) and **Follow landscape** (on the portrait row) use the
other orientation's choice, so someone can set one resolution and let
the other mirror it. The label shows the size it resolves to.
- A session picks the landscape or portrait choice from its orientation.
This uses the same orientation check as the output size, so the
unfolded-controls layout still counts as landscape.
- Custom WxH sizes are flipped to match the target orientation when
followed, e.g. portrait following 1280x720 uses 720x1280.
- If both rows would follow each other, the other row is set to the
concrete size it currently resolves to, so there is never a loop and
nothing visibly changes.
- The glasses output keeps using the landscape resolution.
- Applies to the Steam and Desktop Display tabs, which share the same
row.

## Compatibility

- The existing saved choice (`displayResolution.<mode>`) is now the
landscape resolution, so existing users keep their setting.
- The portrait choice is stored as `displayResolution.portrait.<mode>`
and defaults to Follow landscape, so portrait sessions behave as before
until it is changed. The settings reset covers it through the existing
`displayResolution.` prefix.
- One visible difference: a typed landscape custom size, used as typed
in portrait before, now flips to portrait while portrait follows
landscape.

## Known limitation

"Follow screen" is still decided once when the session starts, not on
every rotation. Re-evaluating it on rotation could make the window
orientation flip repeatedly when no orientation is pinned.

## Changes

- `SessionDisplay`: `LINK_LANDSCAPE` / `LINK_PORTRAIT`, `isLink`,
`orientCustom`, `effectiveChoice`
- `SessionPrefs`: `resolutionStored` (raw value per orientation),
`resolutionChoice(..., portrait)`, `setResolutionChoice(..., portrait)`
with the loop guard, `resolutionChosen(..., portrait)`
- `SessionActivity`: `portraitOutput()` drives the output size,
follow-screen choice and follow scale; the Match-screen default for
programs that draw at the panel size checks the matching orientation
- `ResolutionRow`, `ModeSettingsDialog`, `FrontEndActivity`: two rows,
the Follow option, state and actions
- `DeviceReport`: logs landscape and portrait separately
- Strings: `display_resolution_landscape`,
`display_resolution_portrait`, `display_follow_landscape`,
`display_follow_portrait` in all 33 locales; the unused
`display_resolution` is removed
- Tests: `PortraitResolutionTest`

## Testing

- Unit tests added for the preference logic, follow resolution, loop
guard and reset.
2026-11-22 08:03:03 +03:00
MaxsTechReview 6de3c59d7c fix(venus): lower the guest's SPIR-V to 1.3 for the phone's shader compiler (#2587)
* fix(venus): lower the guest's SPIR-V to 1.3 for the phone's shader compiler

* fix(venus): lower SPIR-V to 1.3 for Mali drivers

* fix(venus): keep the SPIR-V cap valid and scoped to active layers

Cap inline compute pipeline code too, leave the shader hooks off when
the layer is turned off, strip clip and cull distances only where they
are emulated, and leave modules alone whose capabilities, decorations or
OpSelect results need a newer version or an undeclared extension.

* fix(venus): keep application pipeline chains read-only and check non-semantic imports

Inline stage code is handed to the driver through a copy of the stage's
pNext chain instead of being written into the application's create info,
pipeline hooks return VK_ERROR_OUT_OF_HOST_MEMORY when their allocations
fail, and a NonSemantic import is only lowered to SPIR-V 1.3 when the
module declares SPV_KHR_non_semantic_info.

* fix(venus): preserve valid pipeline and shader behavior

* fix(venus): lower compatible read-only shader parameters

* fix(venus): install SPIR-V 1.3 lowering hooks on Vulkan 1.2+ devices or emulated gaps
2026-11-21 23:52:56 -05:00
MaxsTechReview bc11653c15 fix(steam): start the web helper when Android refuses CPU pinning on every GPU (#2819) 2026-11-21 23:52:53 -05:00
MaxsTechReview d6496b2f96 feat(addons): install the CurseForge app and update addons per game (#2986)
* feat(addons): install the CurseForge app and update addons per game

The Addons tab installs the official CurseForge Linux app from its own
update feed, checks it against the feed's SHA-512, shows its version,
offers updates and removes it with the components delete button.

Installed addons show their .toc version and are checked against
WoWInterface by X-WoWI-ID or the recorded source of addons installed
from the Download window; Update replaces them in place.

The CurseForge web search chip is replaced by the app.

* fix(addons): address review on update ordering, flavor filter, origins lock and failed checks

* fix(addons): compact scrollable addon browser with list rows

* fix(addons): compare release times as instants and replace the sources file atomically

* fix(addons): open the addon browser at the top of the list

* Keep the addon browser's search focus and installed version in sync

* Track the search field's own focus in the addon browser

* Key the installed addon version by install target

* Install rar and 7z addon archives
2026-11-21 23:47:58 -05:00
MaxsTechReview 3577073ab9 fix(input): move and resize the on-screen D-pad as one control, per-control button size and sizes above 100% (#2996)
* fix(input): move and resize the D-pad as one control, per-control button size and sizes above 100%

* fix(input): controller art for copied layouts, keep the minimum size when shrinking the D-pad

Copies and per-game versions of the on-screen gamepad now draw the same controller art and placement as the original, and resizing the D-pad from a corner or the per-control slider keeps every arrow at a usable size.

* Keep other controls' moves when undoing a repeated resize
2026-11-21 23:47:35 -05:00
Kurt Himebauch a2587f4f20 fix(display): preserve padded layer buffer layouts (#2985)
* fix(display): preserve padded layer buffer layouts

* fix(display): fall back when layer allocation fails

* fix(display): write linear targets at their row pitch
2026-11-21 23:40:11 -05:00
Kurt Himebauch b2687701c1 build: run the local macOS build natively, with no emulation (#2999)
build: make the local macOS build run natively, with no emulation

On an arm64 Mac the x86/i386 session preloads were built in a linux/amd64
container under emulation, and the Rockstar launcher failed to link against
Homebrew's SJLJ i686 mingw. Both now build on the host's own architecture.

- build_local.sh: on arm64 build the x86 preloads in a native arm64 Debian
  bullseye container with the x86_64/i686 cross toolchains (glibc 2.31, as
  before); x86 hosts keep the native gcc-multilib path.
- build-x86-preloads.sh: X86_CROSS=1 selects the cross toolchains.
- rockstar-launcher/build-container.sh: build the launcher in a native
  Ubuntu container with a DWARF2 mingw, used on macOS only.
- vr/build.sh: stop aborting silently when ANDROID_NDK_HOME names an NDK
  that is not installed.
- build_local.sh: expand the empty stores_check array safely on bash 3.2 so
  the script reaches its signing step.
2026-11-21 22:51:27 -05:00
MaxsTechReviewandKurt Himebauch 378175c6ac feat(input): controller-specific on-screen controls with editor, rotation and tablet fixes (#2988)
* feat(input): restore controller-specific overlay designs

* fix(input): restore portrait controller layouts

* fix(input): fix duplicates, rotation and tablet placement in the controller overlays

- Hide the below-game controls while the layout editor is open, and give the
  editor the same cutout insets and optional Steam controls as the game view,
  so the editor never shows a second copy of a control.
- Keep a separate portrait frame for layouts edited in portrait. A layout
  edited in one orientation keeps the stock kit positions in the other instead
  of being stretched across.
- Anchor the overlay to the bottom of the screen and cap the portrait panel's
  physical size, so tablets keep the controls in the lower half.
- Put L2/L1 and R1/R2 side by side in every kit.
- List deleted stock controls in the editor's Add dialog so they can be
  restored, and keep removed rear buttons and trackpads removed.

* fix(input): scale edited overlay layouts around the controller artwork positions

* fix(input): keep stock landscape controls, color setting, keyboard action and displayed frame edits consistent

* fix(input): draw the layout editor with the kit artwork at the size it will be saved

The editor placed its controls in onSizeChanged, which runs during layout, so
the preview canvas was rebuilt or remeasured too late: new controls were laid
out at 0x0 and existing ones kept stale sizes, losing the kit D-pad artwork.
Placement now happens in onMeasure, before the canvas measures its children.

The editor preview used the saved button size instead of the slider value, so
the slider showed a different layout from the one Done saved.

D-pad pieces that joined or left the kit cross were never redrawn, so moving
one piece hid all four.

* fix(input): keep portrait rear buttons and trackpads where they were saved

A portrait save stores the rear buttons and trackpads only in the rotated
frame, but loading that frame only moved controls that already existed in the
main frame, so they were regenerated at the screen edges.

* fix(input): adopt the displayed portrait frame for layouts edited only in landscape

Button size and reset positions now switch to the frame on screen whenever the edited layout's
orientation differs from the editor, not only when a rotated frame exists, so a portrait change
is saved as the portrait frame instead of overwriting the landscape edits. The tools panel stays
open while that happens.

* fix(input): keep a separate button size for the rotated frame

* fix(input): take the shown frame's button size whenever editing switches orientation

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-21 20:11:21 -05:00
MaxsTechReview 183cbd9351 fix(preload): start apps that check for a single thread and stop the first-call allocation hang (#2995)
* fix(preload): look up the native glibc symbol version first so wrapped calls never allocate

On x86 the first dlvsym lookup asked for GLIBC_2.17, which only exists on arm64. The failed lookup makes glibc allocate, which deadlocks when the first wrapped call happens inside a program's own allocator setup. Each architecture now asks for its base version first.

* fix(zram): start the page-out worker per request instead of keeping a thread in every process

Every process that loaded the session preload carried a resident zr-worker thread from its constructor on. Programs that check they are single-threaded before forking or before unshare(CLONE_NEWUSER) failed, for example Chromium's zygote, which could not start its GPU process.

The signal handler now starts the worker with a raw clone on a stack the preload maps itself. The worker makes only raw system calls and exits when no request is left, so starting it from the handler is safe and idle processes stay single-threaded. When the worker cannot be started, the process trims inline in small steps as before.

* fix(preload): start the page-out worker with the same clone flags as a thread

Programs that filter clone to the flag set threads use, as browser
sandboxes do, now accept the worker. The kernel clears the stack-busy
word and wakes waiters when the worker exits.

* fix(preload): page out inline in single-threaded and self-sandboxed processes

A process with one thread may be about to check that it is single-threaded
before fork or unshare, and a process that added a seccomp filter after it
started may trap system calls into its own handler. Neither gets a worker
thread now; both trim inline in small steps as before.

* fix(preload): check the signalled thread's own seccomp filters before starting the worker

Read Seccomp_filters from /proc/thread-self/status so a thread that installed its own filter
without TSYNC trims inline instead of calling clone under that filter, and fall back to the
inline path when the signal mask cannot be changed.

* test(preload): start parked threads with SIGURG already blocked

* test(preload): count only page-out workers when checking for leftover threads
2026-11-21 20:11:18 -05:00
Kurt Himebauch 6af598b25e feat(launcher): tick haptics for controller navigation (#2993)
* feat(launcher): tick haptics for controller navigation, off for touch

* docs: regenerate settings map for controller haptics

* fix(launcher): tick for hat and stick navigation, which arrive as joystick-source keys

* fix(launcher): tick before the Components tab consumes L1/R1
2026-11-21 16:31:58 -05:00
FX192 86226910c3 Correct the tall-aspect game height expectation in the test 2026-11-22 00:09:51 +03:00
FX192 0399c3e510 Use the portrait resolution in the controls-below layout and size the game area to the output aspect 2026-11-21 23:50:19 +03:00
MaxsTechReview 088c8ff1cf fix(battlenet): follow the selected FEX instead of pinning an old build (#2987)
* fix(battlenet): follow the selected FEX instead of pinning a d2rfix build

The Battle.net prefix forced the newest FEXCore d2rfix package from the Nightlies listing, which stopped updating. Its fixes are in the bundled and nightly FEX, so the prefix now uses whatever FEX is selected. Existing d2rfix selections for the Battle.net profile are cleared once; any other choice is kept. The DXVK memory cap and Start without Steam defaults are now applied when a session starts.

* fix(battlenet): import the legacy plugin state before unpinning the Battle.net FEX
2026-11-21 15:31:18 -05:00
Kurt Himebauch 31dd8f9987 feat(session): arrange and hide in-session menu pages, round pinned end-session button (#2989)
* feat(session): arrange and hide the in-session menu pages

* fix(session): the end-session button is a true circle pinned to the right of the menu header

* fix(session): arrange-pages drag reads the current list; reset reloads the page layout even if the activity was recreated

* fix(session): Back leaves Arrange pages first; UI zoo previews don't save page layout

* fix(session): Back on a grabbed page row restores its order before anything else
2026-11-21 15:25:45 -05:00
FX192 567181d05f fix(session): let the portrait custom resolution dialog accept tall sizes 2026-11-21 22:56:29 +03:00
FX192 a9054aac3f fix(session): address review on the landscape and portrait resolution split
Accept generated portrait sizes on reload, use the right orientation and output target when deciding follow screen, show the real size behind each Follow option, treat a saved portrait Desktop resolution as chosen, and update the orientation hint in every locale.
2026-11-21 22:46:45 +03:00
FX192 50dace9958 feat(session): split the display resolution into landscape and portrait
Landscape and Portrait resolution rows with the same options, each with a Follow option so one can mirror the other. Existing choices stay as the landscape resolution and portrait follows landscape by default, so nothing changes until portrait is set.
2026-11-21 22:21:08 +03:00
FX1922 e06ca23f66 feat(session): add an Avoid notch toggle to the Steam display options (#2983)
## Summary

Adds an **Avoid notch** toggle to the Steam Display tab (under 16:9 game
fit). When it is on, the session is laid out inside the display cutout's
safe area, so the camera notch no longer covers part of the picture.

## Why

Sessions draw edge to edge under the notch. In landscape the notch cuts
into the side of the picture, and in portrait it sits on top of the
picture's upper edge. Today the only workaround is picking a smaller
custom resolution so the notch lands in the black bars. With this toggle
any resolution can be used, including Match screen, and the picture
stays clear of the notch.

## Behavior

- Off by default, so existing sessions are unchanged.
- Shown only in the Steam mode Display tab.
- The safe-area insets (left, top, right, bottom) are read from the
window's display cutout and applied as padding to the session root. The
picture, on-screen controls, HUD and overlays all stay inside it, so
cursor and touch mapping are unaffected.
- Read when the session starts and again when returning to it, and
re-applied when the window insets or configuration change (rotation,
fold, etc.), so toggling it from the launcher takes effect when you
return to the session.
- Not applied in picture-in-picture, glasses, second-screen or cardboard
output. The padding is cleared there.
- Devices without a cutout, or Android below 9 (API 28), are unaffected
because there are no cutout insets.
- Included in the settings reset and in the device report.

## Changes

- `SessionPrefs`: `avoidNotch` / `setAvoidNotch`, added to the reset key
list
- `ModeSettings` / `ModeSettingsActions` and the Display tab: new toggle
row
- `FrontEndActivity`: state, load and save for the toggle
- `SessionActivity`: `applyNotchInset()` driven by the decor view's
window insets, `readPrefs()` and configuration changes
- `DeviceReport`: logs the setting
- Strings: `display_avoid_notch` and `display_avoid_notch_hint` in all
33 locale files
- Test: `AvoidNotchPrefsTest` (default off, persists, reset turns it
off)

## Testing

- Unit tests added for the preference and the settings reset.
2026-11-21 18:25:32 +03:00
FX192 e57bc43f6a fix(session): map every activity-level touch into the surface space 2026-11-21 17:55:36 +03:00
FX192 3962b3e27f fix(session): convert activity-level mouse touches once, not control-forwarded ones 2026-11-21 17:42:14 +03:00
FX192 dc6b7f29cf fix(session): map activity-level mouse touches into the surface space 2026-11-21 17:34:36 +03:00
FX192 ca29850d04 fix(session): keep mouse, pen and unfolded layout correct with the notch inset
Map activity-level mouse and pen events into the surface's space, size the unfolded layout from the padded content area, re-evaluate the inset when the output moves to glasses, the bottom screen or cardboard, and use a clearer Arabic label.
2026-11-21 17:25:19 +03:00
FX192 c0cc3b46a0 feat(session): add an Avoid notch toggle to the Steam display options
Keeps the Steam session picture, controls and overlays inside the display cutout's safe area so the notch no longer covers part of the image, in landscape or portrait. Off by default.
2026-11-21 17:08:27 +03:00
Kurt HimebauchandK11MCH1 64b7339da9 feat(input): restyle Steam Deck buttons (#2966)
* feat(input): restyle Steam Deck buttons

* feat(input): add Steam overlay options

* fix(input): align floating overlay previews

* fix(input): polish floating Steam trackpads

* fix(input): restore overlay options on startup

* fix(input): restore original Steam Deck artwork

* fix(input): restore Steam Deck overlay geometry

* fix(input): keep the Steam Deck shortcut row apart on small screens

The Steam pill sits right of the keyboard by a density-based margin while
Select and Start sit at unit-scaled offsets from the middle, so on a small,
dense surface (800x450 at xxxhdpi) the Steam pill covered Select. Lay out
Steam, Select, Start and Quick Access left to right with an 8 dp gap.

* fix(input): fit the Steam Deck shortcut row inside the safe area

Clamping each pill on its own after spacing could move Quick Access back
onto Start when a cutout inset narrows the right side. Fit the keyboard,
Steam, Select, Start and Quick Access as one row: push each right past its
neighbour, pull the row back inside the right edge, and shrink the 8 dp gap
only when the row would not fit otherwise.

---------

Co-authored-by: K11MCH1 <81425424+K11MCH1@users.noreply.github.com>
2026-11-21 17:42:45 +09:00
MaxsTechReview 4349563fd1 feat(display): zero-copy presentation toggle and compositor display buffers (#2905)
* feat(display): zero-copy presentation toggle and compositor display buffers

Adds a Zero-copy presentation switch under Steam Settings, Display,
Session Display (on by default), and a display-buffer allocator in the
compositor: a Vulkan driver that states displayBuffers asks it for the
memory of the images it exports, so frames presented through the nested
compositor are gralloc buffers that go on the display layer without a
copy. Compressed buffers are offered only where the device's allocator
matches the layout the drivers render to; everything else stays on the
copy path.

The private buffer protocol is renamed to droiddeck-ahb-v1.

* fix(display): zero-copy frames keep the full refresh rate

Two buffers set on the game layer inside one refresh replaced each other, and a frame that slipped into the next refresh made the compositor hold and drop the on-time frame behind it. The layer now queues buffers, and a refresh takes a second frame when the one before it took none. The pacing tool no longer counts its dump time in the frame rate.

* Keep cropped scenes on the display layer and pace layer frames evenly

Accept any in-bounds source crop for the display layer and map the draw
geometry the same way the copy path does. Time layer frames against the
display's frame timeline, and when the game's rate is a steady whole
fraction of the refresh rate show each frame a fixed number of refreshes
after the last so uneven arrivals no longer reach the screen.

* List zero-copy in the settings map

* Hold display buffers until the display releases them

A buffer the game or gamescope rendered straight into went back to its
client as soon as the next one was latched, with the display's release
fence attached to the dma-buf. The KGSL driver does not wait on that
fence, so the client could draw into a buffer the panel was still
reading. Display buffers now wait for the release fence before the
release event, and gamescope composites only into output images the
host has released.

* Keep the game picture copy-free when an overlay has no display layer

When the display cannot give a second layer of its own to an overlay,
the compositor tells gamescope how many planes it can show directly.
gamescope then composes its overlays into the game picture, which still
reaches the display without a copy.

* feat(session): the panel refresh rate follows the session's frame rate

The session learns the panel's refresh rates and reports the refresh rate and
frame rate it wants. The panel moves to the highest rate the frame rate divides
evenly, frame generation counts at its output rate, and a panel whose rate the
system holds offers only that rate.

* feat(session): the panel follows a frame rate the game holds on its own

The compositor reports the game's frame rate once a second. A rate that
holds for three seconds and divides a panel rate becomes the content
rate when neither the app's limit nor the session's limiter is setting
the pace, so a game capped in its own settings gets a panel rate its
frames divide into. A rate that was dropped has to hold twice as long
before it is used again.

* Show generated frames on the game's display layer

With frame generation on, the game's own frames stay on their display
layer untouched and each generated frame is placed on the same layer
between them, timed across the game's frame interval. The compositor
pass is kept when effects, HDR routing or a cursor need it, or when the
panel cannot show the multiplied rate.

* Keep scaling, generated frames and HDR on the display layer

A scaler or frame generation with zero-copy on now draws once into the
display layer instead of falling back to the copied surface. HDR output
goes to the layer when the panel supports it; on a panel without HDR the
picture is tone-mapped on the same path, and the toggle is labelled to
match what the panel can do.

* Spread a frame limit the refresh rate does not divide evenly across refreshes

* Cover the spare-tick and panel-rate paths in the compositor source tests

* Pin the gamescope build with the display-plane, release, refresh and limiter patches

* Give the layer and terminal-caller harnesses the black fill state they compile against

* feat(display): switch HDR during a session without restarting the app

The compositor now offers HDR whenever the device can present it, and the
HDR setting only decides whether the session uses it. Both HDR switches set
gamescope's hdr_enabled, the compositor's HDR output and zero-copy for the
running session. gamescope patch 0139 lets hdr_enabled change after start.
The 'Restart the app to apply.' hint is removed from every locale.

* Remake the output images in the new format when HDR is switched during a session

* Pin the gamescope build that switches HDR during a session

* Apply a saved HDR opt-out at session start and keep HDR retries with their session

* Serialise the HDR output switch with the gate opening

* feat(display): keep the client's HDR setting and the session's in step

The session publishes its HDR state with the other device controls and the
client helper applies it to the client's own display setting. A change made in
the client is reported back and goes through the same switch the drawer and
Session Display use, so all three always show one value.

* fix(desktop): keep the display-buffer socket when the runtime directory is cleared

The desktop launcher removed everything in the runtime directory except the
compositor's Wayland socket, which took the display-buffer socket with it, so
no desktop program could ask for display buffers and every frame was copied.

* fix(display): the client's HDR setting follows the session in every client mode

The bridge only ran when a variable nothing sets was present, so the client's
HDR setting and the session's never met. It now runs whenever the session
publishes an HDR state, and a client that has no such setting is asked again
only every ten seconds.

* fix(display): harden display-buffer hand-off, layer fallbacks and HDR sync

- Stop closing a buffer handle's descriptor the allocator still owns, and free an allocation whose reply could not be sent.
- Rebuild the advertised buffer formats when zero-copy is switched during a session.
- Fall back to the copy path when a layer buffer cannot be allocated, and hide the game layer when it is skipped for a frame.
- Keep a release fence that has not signalled instead of rendering into a buffer the display still reads.
- Ignore a refresh-target reset from a client that does not own the target.
- Restart the content-rate measurement after a pause, clear it when the game stops, and lengthen engagement only for a rate that was released before.
- Compare colour conversions by their values, and read padded cursor buffers at their row width.
- Use the running session's mode for the HDR and zero-copy settings, probe the display before screen effects are pushed, retry a held panel mode, and ignore callbacks after the activity is destroyed.
- Write a newer HDR value while an earlier write is settling, and reapply the value after the bridge is reinstalled.
2026-11-21 00:26:50 -05:00
Kurt Himebauch f29f72d5d9 fix(input): restore Steam controller reattach (#2963) 2026-11-20 20:17:52 -05:00
K11MCH1andMaxsTechReview 367151be2c fix(epic): start parent-checking Epic titles under an EpicGamesLauncher.exe stand-in and stage their Rockstar SDK (#2932)
* fix(epic): start Epic titles that check their parent under an EpicGamesLauncher.exe stand-in

Rockstar's launcher only accepts an Epic copy of GTA V when a process
named EpicGamesLauncher.exe started it. DroidDeck's Epic client is a
Linux program, so the launcher logged "Epic Games Launcher not detected
as parent process", failed to relaunch through Epic and showed the game
as unowned.

- tools/epic-launcher: a small Windows EpicGamesLauncher.exe that starts
  the game with the rest of its own command line, unchanged, waits for
  it and returns its exit code. It ships as the epic add-on pack.
- The Epic .droiddeck-launch.bat runs the game through it for Epic
  titles known to need it (GTA V, GTA V Enhanced, RDR2, RDR, GTA SA DE,
  Returnal, Phantom Blade: Executioners), or for any Epic game whose
  per-game environment sets DD_EPIC_PARENT=1; DD_EPIC_PARENT=0 turns it
  off. Those titles also start without Steam's SteamAppId. Without the
  staged stand-in the game starts directly, as before.
- Steam launch options now reach Epic games (%*).
- The launch hook fetches the pack when such a title finds it missing.
- Rockstar's launcher found no Social Club SDK in the prefix and ran
  Social-Club-Setup.exe /silent, which never exits under Wine. For Epic
  titles that carry a Rockstar SDK installer, the hook now extracts the
  SDK from the launcher's own Redistributables copy (the version the
  launcher compares against) or, before the launcher is installed, from
  the game's copy, and registers it. It re-extracts when that installer
  changes and leaves the Rockstar Games Launcher key alone, so PlayGTAV
  still installs the launcher on first start.

* fix(epic): fetch the parent stand-in exactly when the game will use it; keep Cargo output out of source digests

The launch hook runs before droiddeck-game-env applies per-game
variables, so it now resolves DD_EPIC_PARENT through
droiddeck-game-env's own apply_config and game_id: an unlisted title
with DD_EPIC_PARENT=1 fetches the pack, a listed title with
DD_EPIC_PARENT=0 no longer waits for it.

runtime_inputs no longer hashes the target directory beside a Cargo.toml
under its source paths, so a local cargo build of a Windows helper does
not fail verify(). tools/epic-launcher gets the same .gitignore as the
other helpers.

* fix(epic): a DD_EPIC_PARENT in the game's sidecar env decides the stand-in fetch too

The .bat sets the sidecar's env before it reads DD_EPIC_PARENT, so that
value overrides the game environment there; the launch hook now gives it
the same precedence when deciding whether to fetch the pack.

* test(epic): keep an inherited DD_EPIC_PARENT out of the launch hook tests

---------

Co-authored-by: MaxsTechReview <maxjividen@gmail.com>
2026-11-21 09:56:31 +09:00
Kurt Himebauch 9925873764 revert(input): restore pre-overhaul controls (#2958) 2026-11-20 19:43:09 -05:00
Kurt Himebauch 33761c30ab fix(input): choosing the Gamepad layout in Steam mode keeps its gamepad actions (#2954)
Choosing a layout from the layout menu took the first actions saved for it.
Desktop and Steam mode both draw the stock Gamepad, and Desktop's actions
(stick moves the pointer, face buttons click and press Enter and Esc,
D-pad sends arrow keys) could come first, so Steam mode's on-screen pad
became a mouse and keyboard. A choice now takes the mode's own actions,
or any the other mode doesn't use, and a Steam-mode selection already
holding Desktop's actions is dropped on upgrade.
2026-11-20 15:31:42 -05:00
Kurt Himebauch 089c18b49d fix(input): keep custom layouts active on upgrade (#2950) 2026-11-20 14:44:46 -05:00
Kurt Himebauch cb8e70b940 fix(input): restore Steam and Quick Access shortcuts (#2948) 2026-11-20 14:42:52 -05:00
The412BannerandKurt Himebauch 3c0d25d83b fix(display): read linear client frames at their row pitch when the driver has no explicit modifier layouts (#2927)
* fix(display): read linear client frames at their row pitch when the driver has no explicit modifier layouts

* fix(display): keep row-pitch copied client frames eligible for layer presentation

* fix(display): order the readback layout change after the staging copy

* fix(display): skip the modifier import query when the driver lacks VK_EXT_image_drm_format_modifier

* test(display): the compositor's source-extracting tests follow the linear dma-buf helpers

vkp_image_destroy now frees through destroy_image_objects, render_impl stages
linear dma-bufs and the external-image release asks foreign_image; the two
tests that compile these functions out of vk_present.c extract or stub them,
with the image's new buffer fields in their fakes.

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-20 14:42:44 -05:00
Kurt Himebauch 6f45b5347d fix(input): the layout editor draws controls at their real size in portrait (#2949)
The editor is a dialog that starts at the default dialog size and is then
stretched to the full screen, so its preview could be laid out at a size it
was never measured at. Controls took their size from the earlier pass and
their position from the new one: in portrait, pills came out several times
taller and round buttons slid down. Each control is now sized from where the
canvas actually lays it out.
2026-11-20 13:57:12 -05:00
Kurt Himebauch a3e8b44145 fix(input): Remote Play connects again with the virtual pads present (#2946)
Since #1593 every process except the Steam client gets DroidDeck's udev
answers through dlsym. Steam's Remote Play client, streaming_client, is
an SDL3 program: for each input node it treats as a joystick, SDL3 asks
udev_device_get_driver for the device that udev_device_new_from_devnum
returned. The preload answered new_from_devnum with its own handle for a
virtual pad but did not answer get_driver, so the real libudev read the
handle as its own and streaming_client crashed before the stream opened.
It reaches that call whenever it can stat a pad node: the Xbox 360 pad,
Steam's own uinput gamepads, and since #2033 the pads it reads.

streaming_client now keeps the real libudev like the Steam client, and a
virtual pad answers get_driver with no driver, so other SDL3 programs no
longer crash on it.
2026-11-20 13:19:12 -05:00
Kurt Himebauch 0f37154933 fix(input): saved layouts keep their shape on a rotated screen, sticks aren't cut off and old gamepads are kept (#2945)
* fix(input): saved layouts keep their shape on a rotated screen, sticks aren't cut off and old gamepads are kept

- A layout shown on a screen much taller or wider than it was saved for is
  placed as one block (at the bottom in portrait) instead of anchoring each
  control by its own third, which tore clusters such as the face buttons apart
  in portrait and in the editor.
- A floating stick's base is drawn whole inside the overlay when the thumb
  lands near an edge; input still centres on the touch.
- The migration that makes old-editor gamepads follow the kit again also keeps
  a copy of each one that had kit positions, as "<name> (old layout)" with its
  actions, so players can choose their old layout again.

* fix(input): the old-layout copy keeps only actions it can use, fits the library's limits and leaves same-orientation screens alone

- Actions for kit buttons the old gamepad never placed stay on the kit-following
  gamepad and are dropped from the copy, which otherwise failed validation and
  stopped the library from loading.
- When the copy and its actions don't fit the layout, action or saved-size
  limits, the gamepad keeps its own positions instead.
- Block placement only applies when the screen and the layout differ in
  orientation; a 4:3 layout on a wide landscape screen keeps edge anchoring.
2026-11-20 13:19:08 -05:00
Kurt Himebauch 42133bec0b fix(input): the Xbox and PS buttons move to the bottom row of the floating gamepad (#2944)
The Steam kits keep their Steam and Quick Access buttons on the bottom row,
and Start and Select moved there too, but the Xbox kit's Guide button still
sat at the top centre of the screen and the PlayStation kits' PS button over
the middle of the game. Both now sit between Select and Start, where the real
pads have them, centred on the safe area like Select and Start.
2026-11-20 13:05:26 -05:00
Kurt Himebauch d7f43c26cd fix(input): Steam finds a DualShock or DualSense chosen mid-session (#2942)
* fix(input): Steam finds a DualShock or DualSense chosen mid-session

Android lets an app open a uevent netlink socket but not join its multicast
groups, and libudev joins none when no udev daemon runs, so the udev
monitors Steam's SDL opens heard nothing and the pad switch's add and remove
events reached no one. SDL only noticed a new PlayStation pad when the old
one happened to fail a read. A monitor left without a subscription is now
swapped for the session's stand-in under the same descriptor, so it
receives the injected events.

* test(preload): stub the udev monitor bind hook in the CDP guard build
2026-11-20 12:44:52 -05:00
Kurt Himebauch d5c83eae15 feat(input): describe on-screen layout choices, scope per-game layouts and delete unused ones (#2939)
* feat(input): describe on-screen layout choices, scope per-game layouts and delete unused ones

- The layout menu says what each choice is: "DroidDeck controls" work in
  every game and are edited here; "Steam touch controls" are each game's
  controls from Steam, for Steam games only.
- Layouts made with "+ New for <game>" (or "Just this game") are listed
  only for that game, marked "Just for <game>". Older ones are recognised
  by carrying the name of the game that draws them.
- Saved layouts nothing uses get a delete button in the menu. Deleting one
  also removes a profile that still uses it but can no longer be chosen,
  such as copies made by the old profile screen.
- A game set to Steam touch controls that runs without Steam shows a note
  under Layout instead of silently using the default.

* fix(input): a layout the built-in profile still lists can be deleted once another is chosen

Applying a layout used to write it into the Game profile; choosing another
now goes on top, so the profile's part is no longer drawn. Only parts a mode
actually draws count as in use, and deleting points the built-in profile
back at the stock layout.
2026-11-20 11:54:59 -05:00
Kurt Himebauch 83dc5f37e9 fix(session): launching the running game again resumes it instead of asking Steam twice (#2940)
* fix(session): launching the running game again resumes it instead of asking Steam twice

A front end that resumes a suspended player by launching the same game again
(Cocoon 3.07 does) made DroidDeck queue the game for Steam a second time,
and Steam answered with "An error occurred while launching this game: Game
already running" over the game.

queueSteamGame now resumes the session and returns when the requested game is
the current one and its process is running. A different game, or one that has
exited, still goes to Steam as before.

* fix(session): a relaunch during a pending freeze resumes too, and both game ID forms count as the same game
2026-11-20 11:40:17 -05:00
Kurt Himebauch d0022a35f9 fix(session): remove the keep-top guard from other displays (#2937)
* fix(session): remove the keep-top guard from other displays

#2763 put a transparent KeepTopActivity on every other display while a
session was on top, so lmkd killing that display's home could not move focus
off the session. A/B on a 12 GB AYN Thor (Android 13) and a Retroid Pocket
Duo (Android 16) found no case where it kept a session alive: with steady
pressure the bottom home (stock launcher or Cocoon) was killed up to 400
times per run without taking focus, and a burst big enough to matter makes
lmkd kill the session at adj 0 with or without the guard.

Its side effects were real:
- Android's ActivityRecordInputSink made the bottom screen ignore touch
  (worked around in #2910 by stepping aside on touch).
- Cocoon tracks each display's top activity, so it could not suspend or
  resume DroidDeck cleanly.
- The Thor's Game Assistant gives every app with an activity on top of the
  bottom display that display's volume, so DroidDeck's audio followed the
  bottom screen's volume slider.

Removes KeepTopActivity, the focus bounce and light pause, the memory
pressure trigger and their tests. onPause runs its departure cleanup every
time again.

tools/memory_guard_ab.py gains a burst mode, reads oom_score_adj without
su (lmkd kills the root manager app and su can then open its request screen
over the game), handles Android 13 dumps, a hung stop and a session that
does not start. docs/development/memory-guard-ab.md has the Thor results.

* test(session): the guard A/B fill mode starts its counter again, and a pressure run with no completed run fails

* test(session): the burst seed is rebuilt unless it is exactly 256 MiB

* test(session): the guard A/B burst takes its last partial chunk, and only a hog run that finished counts
2026-11-20 11:40:10 -05:00
MaxsTechReview acb2cba970 fix(ci): add-on packs compress the same on every runner (#2938)
The proot pack pin check failed on GitHub-hosted runners for PRs that do
not touch proot. The hosted image puts the latest upstream zstd (1.5.7)
in /usr/local/bin, while the self-hosted runners use zstd 1.5.5, and
zstd -19 output differs between those versions for identical tar input.

tools/packs/build.sh now compresses every pack with the zstd version
pinned in tools/packs/zstd/release.env: the system zstd when it is that
version, otherwise the checksum-verified upstream release built once
into the pack input cache.
2026-11-20 10:27:17 -05:00
Kurt Himebauch e58b463f54 fix(input): declutter the floating gamepad overlay (#2933) 2026-11-20 10:21:32 -05:00
Kurt Himebauch f5d879f222 feat(input): redesign on-screen controls (#2861) 2026-11-20 08:12:37 -05:00
Kurt Himebauch 11fb8f59d4 test(library): cover Hidden in tab ordering 2026-11-20 08:01:41 -05:00
Kurt Himebauch 97e0251e6a fix(input): preserve control visibility and routing 2026-11-20 07:48:12 -05:00
Kurt Himebauch 7c2955b058 fix(preview): use the mouse touch label 2026-11-20 07:33:23 -05:00
Kurt Himebauch ec1d5126c4 fix(input): reconcile the second-screen picker 2026-11-20 07:30:42 -05:00
Kurt Himebauch 56986b5999 fix(session): Home suspends a game another app launched, so Cocoon can resume it (#2919)
* fix(session): Home suspends a game another app launched, so Cocoon can resume it

A game launched from another front end (Cocoon, ES-DE, Daijisho...) or a
home-screen shortcut went into picture in picture on Home. Cocoon brings a
suspended player back by moving its task to the front, which Android ignores
for a task in picture in picture, and the floating game covered Cocoon's
Resume/Close bar. The game kept running instead of suspending, Cocoon's
Resume did nothing, and the only way back was the picture itself.

Automatic picture in picture now applies only to games DroidDeck launched
itself. For games launched by another app (the existing returnHome launch),
Home suspends the session, which is what Cocoon expects. The picture in
picture button still works for those games.

* fix(session): a new launch intent refreshes the automatic picture in picture rule at once
2026-11-20 01:37:02 -05:00
FX1922 a29315f7e0 fix(library): manage the Hidden tab from Manage stores (#2920)
The Hidden tab was the only Library tab missing from Manage stores, and
it was turned on from the Display options instead.

- Hidden is now listed in Manage stores, after Custom games by default,
with its own switch and drag handle like Favorites and Custom games
- It starts off, and a switch someone already turned on keeps its state
- Removes the Hidden entry from the Display options
- The Hidden tab is still never shown in the music tab

Adds tests for the default, the saved switch and the sort order.
2026-11-20 09:22:35 +03:00
FX192 38efe4d6d5 feat(library): manage the Hidden tab from Manage stores instead of the Display options 2026-11-20 09:12:45 +03:00
FX1922 3f5280412d fix(stores): show the itch.io browse grid on the default filters (#2918)
The Itch tab only showed the browse grid after a filter had been
changed. On the default filters it fell back to the old shelves page
(What's New, Deals, Free Games, Trending), so the first thing people saw
was the pre-overhaul layout.

- The Itch tab now always shows the browse grid, like Game Jolt
- On the default filters it loads itch.io/games, itch's own default
Popular page
- The first page loads as soon as the tab opens, and the filters narrow
it from there
- Searching and the other stores are unchanged
2026-11-20 09:05:47 +03:00
FX192 37cf698af2 fix(stores): show the itch.io browse grid on the default filters 2026-11-20 09:01:42 +03:00
Kurt Himebauch fccd13689c feat(ui): one screen picker replaces the D button and the Second screen tab (#2912)
* feat(ui): one screen picker replaces the D button and the Second screen tab

The bottom screen's bar showed the panel's name as plain text, a D
button opened the menu, and the menu's Second screen tab picked the
panel. Now the panel's name is a dropdown right of the X. It lists
"DroidDeck menu" first, then the panels, with a check on the one in
use, so switching panels takes two taps instead of three.

The docked menu's header shows the same dropdown, labelled
"DroidDeck menu", in place of the highlighted D button. Opened there,
focus starts on the last panel, so one press of A goes back to it.
When the menu is on the top screen, the dropdown lists None and the
panels without the menu entry.

The Second screen tab is gone. Its "Show the game on" and display
choices are a Second screen group at the end of the Display tab. The
mode list's hint and its Mode heading are removed with their strings.

Previews of the docked menu (Controller and Display) and of a panel's
bar are added to the rendered preview cases.

* feat(ui): the swap button on the Keyboard + trackpad and Terminal panels

Every bottom-screen panel now has the swap button when the game can move
to the bottom screen; it was only on Deck grips, Profile controls,
Dashboard and Desktop. The swapped top-screen view already shows both
panels.
2026-11-20 00:26:28 -05:00
Kurt Himebauch 5051fc8b32 fix(session): the bottom screen takes touch again while a game runs (#2910)
* fix(session): the bottom screen takes touch again while a game runs

Since #2763, a transparent KeepTopActivity covers every other display while a
session is on top. Its window is NOT_TOUCHABLE, but Android gives a
translucent activity alone in its task an ActivityRecordInputSink that eats
every touch on that display (ENABLE_TOUCH_OPAQUE_ACTIVITIES, on for this
target SDK). With the dual-screen panel closed, the bottom screen's launcher,
Cocoon or any other app could not be touched until the session ended, and
the guard stayed over it after Home/PiP as well.

- The guard now takes touches itself: a touch removes it from that display.
- It comes back when the session is top-resumed again, or after 5 s if the
  session kept the top spot (the user touched the bottom screen once and
  stayed in the game).
- Stopping or entering PiP removes the guards; PiP keeps the session at adj
  50 with or without them, so they protected nothing there.

A/B on a Retroid Pocket Duo (Android 16, Cocoon as bottom home): the guard
is on top in every state it was on top on main, except the 5 s after a
bottom touch and PiP. Under lmkd pressure (kills down to adj 50, bottom
home killed 14-31 times per run) neither build lost the top spot.

* test(session): A/B tool for the keep-top guard on rooted dual screens, with Duo findings

* test(session): the guard A/B tool stops on a failed session start and cleans up an interrupted pressure run
2026-11-20 00:18:50 -05:00
MaxsTechReview 4e81030fb8 fix: source builds start a session again on storage without hard links (#2908) 2026-11-20 00:00:27 -05:00
Kurt Himebauch dc9d1b81cc feat(frontend): launch from every frontend file format and store, with per-store game files (#2872) 2026-11-19 22:41:04 -05:00
Kurt Himebauch 45c31a480a Default WINESTEAMNOEXEC=0 for Black Ops II (#2892) 2026-11-19 21:27:49 -05:00
Kurt Himebauch 00557703da feat(dev): preview states for the Library and the in-game menu (#2899)
* Developer tools: preview states for the Library and the in-game menu

Settings › Developer gets a Preview states group (shown with developer
tools on):
- Library: nothing installed, signed out of every store, or sample games
  in every store (each store's storefront games passed off as owned, a
  few as installed). A pill on the Library says which preview is on and
  ends it. Nothing is installed, removed or signed out, and the preview
  is never saved, so a restart always turns it off.
- In-game menu: opens the session menu over the launcher for Steam,
  Desktop or a game, without starting a session. Its switches change only
  the preview. LB/RB switch pages and B or Back closes it, as in a session.

* Preview states: Back closes the menu preview; signed-out preview covers expired stores

The launcher's exit gesture no longer takes Back while the in-game menu
preview is open, so Back closes the preview. The signed-out Library
preview shows the sign-in card for an expired store with cached games too.

* Developer tools: a UI zoo sheet for previews; previews are read-only

The Developer tab keeps one UI zoo row instead of the preview pickers. It
opens a side sheet listing the in-game menu (Steam, Desktop, game) and the
Library states; nothing shows until one is picked, and picking one closes
the sheet. A Library preview switches to the Library on All games.

While a Library preview is on, opening a game shows a short note instead
of its page, which would act on the real install behind the preview.
Size sorting uses the size a card shows, so a real install shown as not
installed sorts by its catalog size.

* Developer tools: preview shortcuts, a Library toolbar button for preview states

An opt-in Preview shortcuts switch (off by default) puts a flask button
in the Library's toolbar that picks the real library or a preview state
in place, so a state is a tap away while using the launcher normally.
The UI zoo stays the catalog of every preview.

* Preview states: no real sign-in or sign-out from a Library preview

The toolbar's sign-out button is hidden while a Library preview is on,
and the sign-in card's button only says previews are read-only, so a
preview never signs a real account in or out.
2026-11-19 21:26:31 -05:00
Kurt Himebauch fc9ad2447d fix(agent): the setup install repairs broken package dependencies instead of stopping (#2901)
* fix(agent): the setup install repairs broken package dependencies instead of stopping

* fix(agent): retry the package refresh and fetch missing archives during the setup install
2026-11-19 21:12:50 -05:00
Kurt Himebauch d4af37937a feat(ui): Steam Deck menu icons, and Compose previews rendered to PNGs (#2900)
* Rail and second-screen icons in the Steam Deck menu's style

Solid icons throughout the rail, and Steam's glyphs where Steam has the
same place: Library is the four-square grid, Stores the price tag,
Downloads the download arrow, Settings the gear. On the second screen,
Screenshots uses Steam's Media picture and Chat its Friends people.

* Compose previews of the launcher and the in-game menu, rendered to PNGs

Debug-only previews of the launcher on each tab and the in-game menu's
pages, built from the production composables with sample state and
no-op actions, at the Duo's handheld size and in portrait.
PreviewRenderTest draws each with Robolectric's native graphics into
app/build/preview-renders/, so a UI change can be looked at without a
device, and fails on a preview that throws or draws nothing.
docs/compose-previews.md says how to run and extend them.

* Preview renders wait for store accounts before drawing

A preview case can name what the render test waits for. The Library and
Stores cases wait for store accounts, which load on a background thread,
so their PNGs never catch the loading state.

* Preview renders step the paused clock while waiting for a case to be ready
2026-11-19 19:12:10 -05:00
Kurt Himebauch df48a85a71 feat(library): Library chips and toolbar like the Stores tab, a Custom games tab, and one Manage stores sheet (#2897)
* feat(stores): one Manage stores sheet for order, visibility and accounts

Store order, which stores show, and signing in or out now live in one slide-over, the
same one Edit tabs uses, with the same sorter: drag the handle, or Y to grab and the
d-pad to move, A to show or hide.

- The Library's chip row opens it from a sliders chip at its start, in place of the
  Store accounts button at the end of the row. The Stores tab's Arrange tabs opens the
  same sheet instead of rearranging the chip row in place.
- Each store row shows its account and one action: Sign in, Sign out, Reconnect when the
  login expired, or Add key for itch.io.
- A switched-off store leaves the Library's chips too; its games stay under All. A shown
  store that is signed out keeps its chip, and picking it shows the Stores tab's sign-in
  card in the Library.
- The Stores tab, the Library's chips and the sheet share one store order.

EditTabsSheet and the new sheet share SideSheet, and the tab and store lists share
SortableRows. Sign-in from the Stores tab, the sheet and the Library goes through
startStoreSignIn.

* feat(library): Library chips match the Stores tab, cards fade in on a store change, and the sheet only arranges

The Library's chip row uses the Stores tab's chips, store-colored theme and sliding fill.
Switching store fades and lifts the visible cards in, staggered, and still when animations
are off. Sign-in now lives on each store's own tab, so Manage stores drops its account
buttons and keeps order and show or hide, with each account as a line of text.

* feat(library): chips at the top, the chosen chip's toolbar under them, and a Custom games tab

The Library drops its title row and game count. The store chips are the top row, and
under them the chosen chip's name sits beside search, display, sort, view and the game
file actions, as in the Stores tab. The add button that sat in every header becomes a
Custom games chip that is always there: empty, it opens on a card that adds a game file
or a folder of games; with games in it, its toolbar has the add button.

* feat(library): store-colored focus in the Library, an aligned All chip, and sign out from a store's toolbar

The Library's grid takes the chosen store's theme, so focus rings and accents use its
color as on the Stores tab's pages. All gets a grid mark where the other chips have a
dot, so its label lines up, and the Manage stores chip matches the chips' height. A
signed-in store's toolbar has an account button that asks before signing out, with the
Stores tab's wording.

* feat(library): drop the chosen store's name from the toolbar

The chip above already names it, so the toolbar starts with search.

* fix(library): an empty library keeps its chips, so Custom games and a store's sign-in stay reachable

With no games and no store signed in, the Library used to switch to a separate empty
page without chips. It now shows the chips and toolbar like any other library, with the
empty-library note under All games.

* fix(library): no toolbar between the chips and a sign-in or empty Custom games card

The search, display, sort and view row has nothing to act on there, so the card sits
right under the chips, as it does in the Stores tab, and Down from the chip reaches its
button.

* fix(library): sign-in and empty Custom games cards fill the space under the chips

They were a fixed 300 dp, which left the bottom of the screen empty once the toolbar
above them was gone. They now take the grid's height minus the chip row.

* fix(library): drop the Installed label and lighten the cards' left fade

The Not installed row already divides the two sections, so the Installed label above
the first games goes. The dark fade on the left of the store sign-in card and the Steam
tab's art wall is lighter, so more of the art shows while the title stays readable.

* Library: share the hero wall card and wall fade; icon handle for sign out

The Custom games splash is now built from the same card as the store
sign-in splash, with a drifting wall of the library's covers instead of a
flat gradient and no hint text. The sign-in card and the Steam tab share
one wall fade. The sign-out step shows the account icon as its handle,
like the other toolbar steps, instead of a truncated label.

* Library: sort the Custom games tab in Manage stores; keep search reachable

Opened from the Library, the Manage stores sheet lists Custom games
among the stores so it can be grabbed and moved like them. Its place is
saved as the store it follows, so hiding that store or a new store
arriving keeps it where it was. It has no switch: the tab is always there.

The Custom games splash no longer replaces the toolbar while a search is
active, so a search that matches nothing can still be cleared.

* Manage stores: sort Favorites, Steam and Custom games; hide Favorites and Custom games

Opened from the Library, the sheet lists the Library's own tabs among the
stores. Each one's place is saved as the tab it follows, so hiding a
store or a new store arriving leaves it where it was. Favorites and
Custom games have a switch; Steam can be moved but not hidden.

The sheet takes focus only in controller mode, so opening it by touch no
longer switches to controller focus and its ring. Picking up a controller
while it is open moves focus into it.

Hidden games stay off the Custom games cover wall.

* Library: keep an expired store's tab and offer sign-in when nothing is cached

An expired account no longer drops its Library tab when it has no cached
games: the tab stays and opens on the sign-in card, as on the Stores tab.
With cached games it keeps listing them.
2026-11-19 17:40:55 -05:00
Kurt Himebauch 13a6e0606a feat(library): fold not-installed games under one row, link stores' owned games, and fix card sizes and streaming progress (#2894)
* feat(library): fold not-installed games under one row, link a store's owned games, and make card sizes step

The Library shows installed games first and folds every owned-but-not-installed game
under a "Not installed · N" row that a tap or the A button opens and closes; it replaces
the installed/all-owned choice that sat in the Filter menu, which now only appears for
Xbox's access filters. Controller focus stops on the row between the two sections and
stays on it across a toggle.

A store's profile card turns its "<store> · N games" line into the link to those games
in the Library, replacing the separate text button.

Card sizes pick a column count from the pane width, one column per step, so every
Larger/Smaller step changes the grid; before, several steps landed on the same count
and only stretched the cards.

GOG streams download and install together, and each byte update and each install
update used to flip the entry's stage and reset the install count. The install count
now survives those swaps and the detail page shows both: "Downloading 9% · Installing
25%", with the download as the fill and the install as a thin bar.

The store accounts button uses an accounts icon instead of a second "+", and the
Library tab uses a game controller instead of the video library icon.

* fix(library): a store with nothing installed folds to its Not installed row instead of an empty-state button

With no installed games to show, collapsing used to swap the grid for "No installed games
match these filters" and a Browse owned games button. It now leaves only the Not installed
row, which reopens the list the same way, by tap or by A.

* feat(library): count every owned game in the header and nudge the Not installed arrow

The "N games" next to the Library title counts the games folded under Not installed
too, so a store with nothing installed reads "316 games" instead of "0 games". The
row's arrow hops twice every few seconds toward the way it opens, and at once when the
row takes controller focus; it stays still when animations are off.

* feat(rail): draw the Library tab as game cases on a shelf

Material's video library icon read as a photo or video gallery.

* feat(library): the header counts the whole library, whichever store or filter is picked

* fix(downloads): keep a streaming install's two bars until the download reaches 100%

A download at 99.95% counted as finished, so the install bar disappeared and the fill
swapped between download and install progress for the last stretch.

* fix(downloads): decide a streaming download is finished from its byte counts

A float fraction rounds 99,999,999 of 100,000,000 bytes up to 1.

* feat(downloads): show a streaming install as one bar, downloaded behind installed

Two bars that moved almost together, under a label with both percentages, read as a
glitch. The chip now shows "Installing 61%" with a light fill for what has downloaded and
a solid fill for what has installed, like a video's buffer.

* feat(downloads): the game page shows one steady bar that only fills up

The detail page's chip shows "Installing 62%" from one overall value: the download fills
the first 90% and the install the rest, also when they stream together. The fill never
steps back across stage changes, keeps one animation key per download, and the chip
keeps a minimum width with tabular digits so it does not resize as the number grows. The
Downloads tab keeps its per-stage detail.

* feat(downloads): a full-size progress button on the game page that opens Downloads

The progress chip was a 24 dp pill beside 48 dp buttons. It is now a button the size of
Pause and Cancel, filled as the job advances, with a › that opens the Downloads tab and
sends the fly-in ball to the rail's Downloads item, by touch or A.

The Library card's percent and the bottom-screen download row use the same steady value,
so every place shows one bar that only grows. The overall value keeps the install part
when the last bytes arrive while the stage still reads Download.
2026-11-19 14:57:11 -05:00
MaxsTechReview cc93ab51c5 Log the GPU ceiling and mid-session clock hold changes (#2893)
* Log the GPU ceiling, steps and mid-session clock hold changes

The clock log now records the GPU frequency steps and floor once in
its header, probes each limit file as readable or refused, and adds
the allowed GPU maximum to every sample in the CPU cur/max(of top)
style, so a vendor or thermal cap on the GPU ceiling shows up and
changes during a session are visible. Samples are unchanged when no
limit file is readable.

The limit reading is shared with the device info GPU clock range.

Turning the GPU clock hold on or off during a session now logs the
same line the session start logs.

* Ignore a zero GPU ceiling and log hold changes in order

A ceiling file that reads zero is no longer printed as a limit and is listed
as refused, matching how the step list is read. The hold state line is logged
under the same lock as the state change, so overlapping toggles cannot log
out of order.

* Find a GPU ceiling that turns readable later and probe step tables as tables

A ceiling file that read zero at session start is looked for again on each
sample until one is found, and the log notes where it came from. Step and
floor sources are probed with the same parser that reads them, so a table
with a leading zero is listed as readable.
2026-11-19 14:31:32 -05:00
MaxsTechReview de73e429cc feat(proton): list prerelease builds under Experimental and install from any archive (#2889)
* feat(proton): install prerelease builds

* fix(proton): harden prerelease archive installs

* refactor(proton): drop the superseded test build path

* fix(proton): list only current prerelease builds and label the file install

* fix(proton): hide prerelease rows that are already installed

* fix(proton): keep relative links and modes when unpacking zip and 7z builds

* fix(proton): name file installs without the archive suffix

* fix(proton): confirm a release is gone before removing its build and tighten archive handling

* Show the Experimental section without Developer tools

* Share the refresh guard, recheck sessions before removal, skip other architectures

The update check guard is shared between menu instances and held until the result is published, so a recreated screen joins the running check and results arrive in order. Automatic removal rechecks for a running session after each release lookup. Experimental assets for other CPU architectures are ignored, and in-tree links may start with the current directory.

* Keep an experimental build in place when a session starts during its removal

Removal and session start now share one lock. The tree is renamed out of the
tools folder under that lock only while no session is running, and deleted
afterwards, so a session that starts first keeps its build.
2026-11-19 13:41:57 -05:00
LunaDL 71989b4cdb Feat: Adds customizable theme and fix inner gamer theme (#2850) 2026-11-19 11:07:55 -05:00
Tushar Gandhe 8f34554516 feat(game): shape the tab bar's LB and RB keys to the bar's rounded ends (#2856) 2026-11-19 11:06:19 -05:00
Kurt Himebauch 1456c0529d feat(agent): launch and quit store games, list the library, and run Xbox and cloud save commands from droiddeckctl (#2860) 2026-11-19 11:04:34 -05:00
FryMcNugget 786166ba1a fix(lab): Fast Lab builds no longer run out of memory compiling the app (#2862) 2026-11-19 11:03:56 -05:00
FryMcNugget 674e0d6fa4 feat(agent): keep the unsent message across leaving the Agent tab (#2863) 2026-11-19 11:03:08 -05:00
Kurt Himebauch d852b1a4e5 fix(storage): let launcher prefixes and Linux system caches be removed (#2867) 2026-11-19 11:00:59 -05:00
Kurt Himebauch 2ea857a07c fix(agent): keep the closed pet chat off the app below (#2868) 2026-11-19 10:57:00 -05:00
Kurt Himebauch 697f8e73fa fix: enable Steam shader pre-caching by default (#2888) 2026-11-19 10:11:22 -05:00
kingokksa c4f4e18f87 fix: the virtual pads reach non-Steam programs, where udev is resolved through dlsym (#1593) 2026-11-19 08:37:43 -05:00
MaxsTechReview c2adf3b3dd feat(performance): switch the GPU top clock hold from the in-game menu (#2882) 2026-11-19 07:33:20 -05:00
MaxsTechReview f2d8e9e837 perf(storage): answer repeated SD library checks from the directory cache (#2881) 2026-11-19 07:33:17 -05:00
FryMcNuggetandmaxjivi05 44ade5eeee feat(proton): install experimental Proton builds from a .zip (#2864)
Components > Proton gains an Experimental builds card that installs a Proton build from a .zip, lists it as Experimental-<name> and removes it with its stored and unpacked originals and selections. Replacing a build keeps its user settings and is safe to interrupt.

Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-19 02:32:30 -05:00
Kurt Himebauch dcebdac765 fix(input): removed kit controls keep their actions in gamepad layouts 2026-11-19 00:44:41 -05:00
Kurt Himebauch cd5e824c1b fix(input): keep full insets while the kit fits, restore the library after a failed save 2026-11-19 00:19:56 -05:00
Kurt Himebauch 10b21321b7 fix(input): save per-game copies with the edit, keep failed choices visible and grips clear of the d-pad 2026-11-19 00:11:01 -05:00
Kurt Himebauch 885c4f0a44 fix(input): keep reported insets unless they crowd out the pad 2026-11-18 23:58:48 -05:00
Kurt Himebauch 968828afbd fix(input): kit scale fits the safe area and oversized insets are capped 2026-11-18 23:52:00 -05:00
Kurt Himebauch c664b6cfbf fix(input): Back shortcut label fits its button 2026-11-18 23:49:53 -05:00
Kurt Himebauch 446480aa19 feat(input): Settings Controller is the in-game page for the default, with per-game layouts, Just this game and a direct remap page 2026-11-18 23:45:46 -05:00
MaxsTechReview c35da09d1a feat(proton): offer DroidDeck-Proton test builds in Components (#2831)
Components > Proton offers a DroidDeck-Proton pre-release that is ahead of Stable through the existing channel toggle. Automatic installs and updates stay on Stable.
2026-11-18 23:26:45 -05:00
Kurt Himebauch afa696cef2 fix(input): Steam kits and PlayStation face buttons no smaller than the old gamepad; Steam layout menu opens the Controller page 2026-11-18 23:11:52 -05:00
Kurt Himebauch b87da99d21 fix(input): keep Steam's touch controller plugged while its layout is hidden 2026-11-18 23:05:03 -05:00
Kurt Himebauch f180d98da7 Ubisoft: show art for owned games the profile list leaves out (#2865)
Games Connect owns but the GraphQL game list does not name were added
with no image. Take their art from the product configuration's
background_image and thumb_image, following localisation keys, from
Ubisoft's launcher asset CDN.
2026-11-18 22:13:49 -05:00
MaxsTechReview adf13d0bdd feat(session): manage memory automatically and remove the manual memory controls (#2853)
Memory in the Steam session is kept above a floor by a monitor instead of the zRAM, RAM cap and VRAM cap settings, which are removed.
2026-11-18 21:58:57 -05:00
Kurt Himebauch 732c97831d fix(input): editor Reset keeps the D-pad direction overrides 2026-11-18 21:04:52 -05:00
Kurt Himebauch bf75dfb9c0 fix(input): saved D-pad keeps direction overrides, held directions wait for neutral and Reset regenerates an emptied gamepad 2026-11-18 21:00:31 -05:00
Kurt Himebauch 952f363b45 fix(input): D-pad keeps direction overrides, kit bindings survive layout edits and an emptied gamepad stays empty 2026-11-18 20:41:54 -05:00
Kurt Himebauch fdcb7eb3c4 fix(input): back grips fill their box as a capsule along its long side 2026-11-18 20:37:00 -05:00
Kurt Himebauch b29a5ef8aa feat(input): both sticks and both trackpads for Steam kits in portrait 2026-11-18 20:19:02 -05:00
Kurt Himebauch 0364792111 fix(input): Steam touch tint colors the D-pad and system buttons again 2026-11-18 20:11:39 -05:00
Kurt Himebauch e67c185f13 fix(input): hide on physical controller use only and refresh the kit when the virtual controller changes 2026-11-18 20:09:36 -05:00
Kurt Himebauch 318d64f3d6 fix(input): keep Steam grips on a small portrait pad and fit the bottom row 2026-11-18 20:04:00 -05:00
Kurt Himebauch 6f564caba6 fix(input): keep kit bindings, D-pad directions and Steam touch tint through the redesign 2026-11-18 20:02:37 -05:00
Kurt Himebauch 695ae21f93 feat(input): full-size portrait pad, one top row and sticks for every non-Steam kit 2026-11-18 19:40:27 -05:00
Kurt Himebauch ceb0360cd8 feat(input): drop the Deck panel tabs from the controls under the game 2026-11-18 19:17:43 -05:00
Kurt Himebauch 40665bbb1a feat(input): portrait pad under the game, kit-aware editor reset and leaner controller settings 2026-11-18 19:06:54 -05:00
Kurt Himebauch 123c431b8e feat(ea, ubisoft): cloud saves and a kept Ubisoft Denuvo token (#2824)
* feat(ubisoft): keep Denuvo game tokens per account and product until the game invalidates them

* feat(ubisoft): sync cloud saves through Ubisoft's cloud save service

* fix(xbox): turning cloud saves off passes the offline mode the game save runtime reads

* fix(ubisoft): Ubisoft games list their shared prefix, so they get a saves and cloud tab

* feat(ea): sync cloud saves through EA's cloud sync service

* fix(ea): sync at EA launch and exit, keep one rule snapshot, and check the cloud copy under the write lock

* fix(ubisoft): exact slot versions, scoped save export, and a Denuvo cache bound to its account

* fix(ea): fresh rules per sync, checksums required, backup before restore, and sign-in shown on the saves tab

* fix(ubisoft): launch-time sync on the shared prefix, saves scoped to the game, and Denuvo bound to each launch's account

* fix(ea): back up only the saves a restore replaces, refuse truncated manifests, and need a master title id

* fix(ubisoft): treat a slot whose bytes changed since the last sync as a conflict before uploading over it

* fix(ea): one resolved save folder per sync, refuse case collisions, and walk each folder once

* fix(ubisoft): sync only identified slots, keep live saves and backups safe, and tie a pending eviction to its account

* fix(cloud): a forced download fetches every saved conflict and keeps the ones it could not write

* test(ea): keep the cloud save cases in EaTest

* fix(ubisoft): report only written slots, keep drift conflicts, read whole headers, and never rename a named eviction

* fix(ea): keep real save folders in the inventory, back up any restored file, refuse duplicate or malformed cloud listings

* fix(cloud): commit Ubisoft slots one at a time and stop on a newer cloud write, name skipped and blocked slots, keep unsent conflicts

* fix(ubisoft): acknowledge an invalidation only once its marker is published and never serve a kept token after it

* fix(cloud): a cloud request the launcher cannot write still starts the game and keeps the exit upload

* fix(cloud): scope Ubisoft sync state to the account and product, compare alike slots, keep committed progress, and name partial slots

* fix(ea): ask for sign-in after a rejected refresh, upload saves reached through folder aliases

* fix(cloud): a launch that stops waiting for the cloud download claims it back, so no save is written once the game starts

* fix(ubisoft): name the account in an invalidation marker and never hold the token lock across a pipe write

* fix(ea): only invalid_grant asks for sign-in again, and case collisions count only among synced saves

* test(epic): let the launcher's ask doubles take the claim flag

* fix(ea): apply save rules in their order, match bare patterns inside the save folder, and resolve LocalLow and install folders

* fix(ubisoft): stamp a fresh identifier into a new save that has none, so it can sync

* fix(ubisoft): answer a burn ticket request as unavailable instead of leaving the game waiting

* fix(cloud): read EA manifests with the XML parser, clear conflicts whose sides match, and bound the claim and stall tests
2026-11-18 18:32:06 -05:00
Kurt Himebauch 0fba656ee2 feat(input): draw on-screen controls per virtual controller with a corner button and a simpler controller page 2026-11-18 18:08:30 -05:00
Kurt Himebauch 6ed281f78d feat(xbox): install MSIXVC2 back-compat titles from their content boxes (#2851)
* feat(xbox): install MSIXVC2 packages from their encrypted content boxes

* feat(xbox): run a package's custom install actions once per prefix

* fix(xbox): launch the program a launcher menu names instead of the menu

* fix(xbox): check free space before an MSIXVC2 install starts

* fix(xbox): keep a forwarded launch path relative when the install folder is reached through a link

* fix(xbox): rebuild the MSIXVC2 patch on the final legacy install

* fix(xbox): keep a backup whose release fails, and test an interrupted restore

* fix(xbox): verify resumed msixvc2 files, contain writes, decode install action arguments

* fix(xbox): keep one completion record per msixvc2 file, never follow a linked install state

* fix(xbox): drop a torn msixvc2 completion record before appending to it

* fix(xbox): repair a torn msixvc2 record from its tail instead of rereading it
2026-11-18 16:59:45 -05:00
Kurt Himebauch b43724e5f3 revert(hud): redraw the FPS graph every game frame outside Strip (#2857)
revert(hud): redraw the FPS graph every game frame outside Strip (#2843)
2026-11-18 16:39:07 -05:00
Kurt Himebauch 5b7409d1d5 fix(game-env): restore D3D12 12_2 and shader model 6_9 for Kingdom Come: Deliverance II (#2787)
* fix(game-env): run Kingdom Come: Deliverance II at D3D12 feature level 12_0

* fix(game-env): restore feature level 12_2 and shader model 6_9 for Kingdom Come: Deliverance II
2026-11-18 15:49:44 -05:00
Kurt Himebauch f0f7f7a116 feat(agent): permission modes for every harness, asking first by default (#2854)
* fix(agent): show the side menu's agent page whenever the tab is shown

* feat(agent): permission modes for every harness, asking first by default

* test(agent): give the drawer page tests their agent page explicitly

* fix(agent): fail turns on lost stdin writes, wait for Codex to initialize, keep approvals visible

* fix(agent): redo setup on a kept process after it failed, keep approvals in view

* fix(agent): keep full-page panels closed while an approval waits
2026-11-18 15:43:55 -05:00
24f5fa20f8 fix(session): show the recorded reason when a session fails to start (#2841)
* fix(session): show the recorded reason when a session fails to start

The ended screen now shows any recorded start-up failure message except a plain guest exit, not only PROOT_MISSING. The graphics runtime staging and game environment publish failures now record GRAPHICS_RUNTIME_FAILED and GAME_ENVIRONMENT_FAILED with their own messages instead of looking like a guest exit.

* i18n(session): translate the start failure messages

---------

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 15:10:14 -05:00
TapuukandTapuuk e4404fbb92 perf(hud): throttle FPS-graph redraws for every HUD size (#2843)
Only the Strip size limited graph redraws; Minimal, Pill, Tiles and Mega
invalidated on every display frame for the whole session. All sizes now
redraw the graph at most once per GRAPH_REDRAW_MS (66 ms).

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-18 15:09:38 -05:00
Kurt HimebauchandTimmyCraft a5d8abeab4 feat(xbox): install legacy EAppx titles through Windows Update (on main) (#2825)
* feat(xbox): install legacy EAppx titles through Windows Update

A legacy Store title does not ship as MSIXVC. It ships as an encrypted
EAppx bundle, which streaming rejects, so the store could list the game
and never install it.

Accept EAPPX and EAPPXBUNDLE beside MSIXVC, carry the format through the
catalogue, the install record and the cached library, and dispatch
legacy-install for those formats.

Two backend patches do the work:

- droiddeck-legacy-packages.patch lets the plan, license and extract
  verbs handle a legacy package, and expands a bundle in place (nesting
  bounded at three), decrypting each inner EAppx with the same keys.
- droiddeck-legacy-install.patch adds legacy-install: resolve,
  license, download, extract, hoist AppxManifest.xml to the game root.
  Resolution asks the Xbox content service first and Windows Update
  second, because some legacy products return no files from the content
  service at all. The WU endpoint needs no Xbox credential but chains to
  Microsoft's ECC Product Root CA 2018, which Android's CA bundle does
  not carry, so that one public root is pinned for those requests.

The manifest reader accepts AppxManifest.xml as well as
MicrosoftGame.config, since a legacy package carries only the former.

Running it against a real title exposed four things that only show up at
full size:

- A licence names a key by its 16-byte content id, while a bundle header
  names it as a (content id, package id) pair. Reading the 16-byte id
  yields a different pair, so a complete key file reported every key
  missing and no bundle could be opened. Keys are now aligned against
  the header's own ids before the header is judged.
- Windows Update answers with several updates whose PackageContentId
  differs from the bundle's own. Licensing used to take the first and
  fail with content-http 400; every candidate is now tried in order,
  preferring the one the container is named after.
- A container already in .xodus-container is reused rather than fetched
  again, so a failed run does not cost another download of tens of
  gigabytes. The space preflight no longer counts a container twice for
  the same reason.
- A bundle that carries add-on packages unpacks each into its own
  folder, leaving the manifest one level down. Hoisting lifts the
  largest folder that holds a manifest, so the game still lands at the
  root beside its add-ons.

Unpacking now reports bytes written, so the install bubble fills while a
package is decrypted instead of holding a single unchanging word.

* fix(xbox): unpack a legacy package across cores and report the bytes

Unpacking one title ran as a single thread on a saturated core at about
40 MB/s. Files sit at independent offsets, so each worker now opens its own
handle and takes every Nth file, with a 1 MiB read buffer in place of the
8 KiB default that turned one 64 KiB block into eight reads. Measured on the
Forza Horizon 4 bundle, writes went from 40 MB/s to about 200 MB/s.

Two things the first full-size run exposed:

- The container was deleted only after the whole nested tree was unpacked,
  so a title that holds its package as one member held the archive and the
  decrypted copy at once. On this device that runs out of space partway
  through the second stage. The container is now deleted once its members
  are on disk, which frees the archive before they are decrypted.
- A bundle member is written as a single file, so a counter that advances
  when a file finishes stays at zero for the whole of the longest stage.
  The reported figure now also follows the growth of the destination while
  that is the case, and never moves backwards when the container is freed.

Progress is exact during the per-file stage: each file's declared length is
added as it lands, instead of walking the whole destination every tick.

* docs(xbox): record the completed legacy install

The evidence section said a finished legacy install and its decrypted
contents were unverified, because the first run was still unpacking when it
was written. That install has now completed on the same device: the
85,219,173,025-byte container produced 79.3 GB at the game root with
AppxManifest.xml and the package DLLs directly beneath it, and the launcher
lists the title as installed.

It also records what unpacking costs, since that decided the change: one
thread held a core at 100% for about 40 MB/s and four reach about 200 MB/s,
and releasing each container once its members are on disk is what keeps the
peak footprint at one package rather than the archive plus its contents.

The launch is not part of this evidence, and the entry says so.

* fix(xbox): place the 64-bit framework beside a legacy title

A Windows Update framework category lists one package per architecture under
identifier-only names. The first package was unpacked, which on this device was
the x86 build, so a 64-bit title got 32-bit DLLs and every load failed with
STATUS_INVALID_IMAGE_FORMAT. Candidates are unpacked now and only the one whose
manifest declares ProcessorArchitecture="x64" is kept.

The framework folder was also never created, so a finished download failed at the
move with "no such file or directory".

unzip.rs belongs to this patch: legacy-install calls it and the recipe left it out,
so a rebuild from the pinned source could not compile.

* feat(xbox): report a UWP entry point at launch

An unpacked package can name a COM class as its entry point instead of
Windows.FullTrustApplication. That class is a UWP application, which expects the
app model to activate a view; Wine has no host for it, so the launch died inside
the loader with no explanation. The launch now reads the entry point and reports
uwp-entry-point, and full-trust packages are unaffected.

Forza Horizon 4 is such a package: its manifest names Forza.App. Its frameworks
are installed and the loader is clean before that point.

* fix(xbox): report why a launch was refused

A failed prepare replaced the backend message with a fixed sign-in hint, so a title
that was not installed or a runtime that refused all read as a bad account. The
reason is kept, with paths and URLs dropped, and written to the store log.

* fix(adb): dismiss the keyboard on Search and Go

Search and Go were terminal IME actions but were not handled, so focus stayed in
the field and the keyboard covered the results it had just fetched.

* fix(xbox): keep a cache row without a legacy format plain

Decoding added a format key with an empty value to every cached title, so a
library restored from storage no longer matched the one that was saved.

* test(ui): match the manifest message a legacy package reports

The message covers both a MicrosoftGame.config and an AppxManifest, so the
assertion follows the text the content dialog now prints.

* fix(xbox): refuse to start a title that needs the Windows app model

A legacy package that names an entry point other than
Windows.FullTrustApplication is a UWP application. Wine has no app-model
host, so starting its executable crashes inside the loader and the launch
looks like nothing happened. Read the entry point from the manifest the
installer already parses and stop the Play action with a message instead.

Forza Horizon 4 names Forza.App, so it installs and reports as installed
but cannot be started here yet.

* fix(xbox): dispatch on the container format of the chosen package

The catalogue records the format of the first installable desktop package, and
the picker only replaced the content id. An offer that lists MSIXVC and a legacy
container would then hand the legacy id to streaming, or the streamed id to
legacy-install, and the install failed after resolution had succeeded.

The choice now carries its own format and the catalogue value only fills a gap.

* fix(xbox): keep an extraction reason that the sanitizer rewrote

The extraction sanitizer replaces anything outside letters, digits, space, dot,
underscore and dash with a question mark, so a reason such as "(os error 28)"
arrived as "?os error 28?" and the allowlist dropped the line. The failure then
showed only the stage code, with no cause.

Add that replacement character to the class the allowlist accepts.

* fix(xbox): print the reason a launch was refused

The account channel sends a reason with a refusal, and the guest replaced it
with a fixed sign-in message, so a title that was never installed still read as
a bad account. The guest now shows the reason it was given, and a token holding
a path is dropped whole instead of having its slashes removed and its directory
names kept.

* build(xbox): leave RUST_TEST_THREADS unset when the host has no value

The recipe always passed the variable, empty when the host had none, and the
pinned test harness rejects an empty count. On an ARM64 host that runs cargo
test, so the default local build failed before compiling.

* fix(xbox): rebuild the backend patches from the tree that ran

The two patches in this branch were not the ones the verified install ran, and
one of them did not compile. `unzip.rs` inflates deflated entries but the
dependency that provides the inflater was never added, so `prepare.py` produced
a tree that failed at `flate2::read::DeflateDecoder`. Anything else missing fell
into the same gap: the install stage reported no bytes, so the bar held one
value for the whole unpack, and a container a stopped run had finished was
downloaded again.

Rebuilt from the patched source, and fixed the defects a review of the patch
found:

- Unpacking reports bytes again: the workers count each file's declared length,
  and for the single-file bundle member the folder's growth stands in, which is
  what the device run showed.
- A finished container is reused, so a retry after a failure past the download
  does not spend hours fetching it again. The space preflight counts it as
  reclaimable, since the retry truncates it first.
- An install over a folder that already has a manifest replaces the old files
  instead of leaving the new package nested and reporting success. A first
  install still refuses to merge into an existing target.
- The manifest search looks at the depth a nested bundle writes, not only one
  level down.
- `withdraw_libraries` removes only the DLLs `copy_libraries` recorded copying,
  so a framework replacement cannot delete a library the title owns.
- ZIP64 sizes and offsets stay `u64`; truncating them to `u32` read the wrong
  local header past 4 GiB.
- The extraction checks the blockmap length against the footer's before writing,
  which the crate only does when asked.
- The container being unpacked is never treated as a nested member, so
  `extract-eappx title.eappx .` no longer re-enters and deletes its own input.
- `flate2` is declared and the lock is updated.

`prepare.py` reproduces this from a pristine checkout and `cargo test` passes on
it.

* fix(xbox): apply the legacy install patch over the Nexus 0.2.15 backend

* fix(xbox): install only the newest x64 build of a legacy title and size the space check at its real peak

* fix(xbox): install a store package that is a plain archive instead of an XVD

* fix(xbox): refuse a package entry that ends before its recorded size

* fix(xbox): credit only complete staged containers toward the free space a legacy install needs

* fix(xbox): bound each package entry to its data and check ZIP64 decoded sizes

* fix(xbox): refuse duplicate package names and clear an unfinished download before measuring space

* fix(xbox): bound package entries by the next header and stage a plain package until it validates

* fix(xbox): hold the install folder lock through a legacy install

* fix(xbox): fall back to an older build when Microsoft refuses the newest one a license

* fix(xbox): keep the registered device across sign-out

* feat(xbox): explain device-limit and license refusals, with a link to manage devices

* fix(xbox): locate each build only once licensed, roll back a failed package swap, report the final license answer

* fix(xbox): skip trial and preorder packages, read runtime behavior, keep licensing timeouts

* fix(xbox): keep a failed package swap recoverable, size bundles up front, report key-write and framework errors cleanly

* fix(xbox): drop a pending manifest check on any newer launch, keep committed backups out of restores, match the app-model order

* fix(xbox): cancel pending launch checks on a new intent, remember entries a rollback could not remove

* fix(xbox): clear the removal list before a restore moves old files back

---------

Co-authored-by: TimmyCraft <46533729+TimmyTurner51@users.noreply.github.com>
2026-11-18 14:14:26 -05:00
DeathKhanandmaxjivi05 7680b4d771 fix(ui): fit the color picker on landscape screens (#2542)
* fix(ui): lay the color picker out side by side on wide screens

On a landscape screen the single column was taller than the screen. The wheel and swatches now sit beside the sliders and the hex field, so the whole picker is visible without scrolling.

* fix(ui): give the landscape color picker a larger wheel and one closing row

On a wide screen the picker still reached both screen edges: three sliders, the hex field and the buttons were stacked beside a small wheel. The wheel now fills the height of the sliders, and the comparison chip, the hex field, Cancel and OK share one row under them, so the dialog keeps a margin. OK is centered in both layouts.

* fix(ui): keep the column color picker in landscape windows narrower than 600 dp

The side by side layout needs 382 dp for its closing row before the hex field gets any width, so a small landscape window could squeeze the field to nothing.

* fix(ui): fit the side by side color picker on short landscape screens

On a 740 x 360 dp phone the closing row sat below the screen and had to be scrolled to. The wheel now takes its size from the screen height (up to the old 216 dp), and on a short screen the sliders get a shorter track and tighter spacing, so the whole dialog fits down to about 360 dp. Screens 468 dp tall and up, such as the Odin 3, look as before.

ColorPickerLayoutTest now also checks that OK is on screen without scrolling at 740 x 360, 800 x 384 and in portrait.

* chore: drop the added comments

---------

Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 14:05:30 -05:00
5afa8695a8 fix(session): undo start-up work when a session is stopped while starting (#2840)
* fix(session): undo start-up work when a session is stopped while starting

* style(session): drop the added comment

---------

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 13:14:49 -05:00
DeathKhanandmaxjivi05 8cfe19cd13 fix(apps): B in the folder name field saves the name and returns to the title (#2534)
* fix(apps): B in the folder name field saves the name and returns to the title

With a controller, B in the folder name field only hid the keyboard and left
focus in the field. The field now takes B as its way out: the keyboard goes,
the name is saved and focus lands on the folder title. AdbTextField gets an
optional onBack for this; fields without it behave as before.

* fix(apps): closing the bottom-screen keyboard also leaves the folder name field

With typing on the bottom screen, B is handled there and only cleared focus,
so the folder name was not saved. A field with onBack now leaves through it
on that path too.

* fix(apps): the folder sheet hands B to the name field while renaming

The sheet's own B handler sits above the name field and could take the press
first, closing the folder. While the name is being edited the sheet now treats
B as leaving the field: the keyboard goes, the name is saved and focus lands
on the title.

* chore: drop the added comments

* Return focus to the folder title once the frame settles after renaming

* Only let the active typing request close the field

---------

Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 13:13:04 -05:00
kingokksaandmaxjivi05 fc5dd7f3c5 fix(input): the layout editor shows the same placement as the session (#2783)
* fix(input): the layout editor shows the same placement as the session

Editing a layout stored for one orientation while the editor is open in
the other drew raw stored coordinates, so elements turned into flat,
overlapping bars. Route the editor through OnScreenLayout like the
on-screen controls: matched layouts are regenerated for the current
screen, everything else follows the same fit, and the dirty check
compares against what was shown when the editor opened.

* fix(input): reset and scale in the editor frame the session saves

The editor draft now carries the frame it was rebased to: the gamepad
scaler is rebuilt with the editor surface's real dimensions when edits
begin, so reset regenerates legacy controls for the display the user is
editing instead of the primary display. Stock default positions keep
their own frame aspect and are refitted into the draft frame before
being applied, so reset on a differently shaped display lands where the
editor shows and no longer marks an untouched layout as changed.

* fix(input): refit only the default positions on reset and update the test callers

---------

Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 12:57:15 -05:00
unixenon cca84f7b6b fix(setup): show the saved Mali (Venus) switch after the app restarts (#2684)
refresh() reloaded the Mali bridge switch from SessionPrefs but not
Mali (Venus), so after any process restart (an app update, or Android
reclaiming the app) Setup showed "Mali (Venus): off" while the saved
setting stayed on and sessions kept using Venus. Only opening the
Performance page (refreshCores) loaded the real value. The Vulkan
1.2 warning (venusHostVulkan) was dropped the same way.
2026-11-18 12:55:28 -05:00
MaxsTechReview d94906bd9c fix(audio): hold host restarts until an in-flight sink guard command finishes (#2821)
* fix(audio): hold host restarts until an in-flight sink guard command finishes

* fix(audio): judge sink guard commands by exit status and reap timed-out pactl

* test(audio): hold the sink guard command until the test has checked the queued restart

* test(audio): bound the stop check so a blocking stop fails instead of hanging

* test(audio): bound the exit check while the sink guard command is paused
2026-11-18 12:55:25 -05:00
801da99c11 fix(game-env): per-game DROIDDECK_GAME_TU_DEBUG reaches the game (#2781)
* fix(game-env): per-game DROIDDECK_GAME_TU_DEBUG reaches the game

game_gpu() ran on the inherited environment before apply_config() added
the entries from game-environment.json, so a DROIDDECK_GAME_TU_DEBUG
(or DROIDDECK_GAME_MESA_NO_ERROR) set for one game was passed through
unchanged and TU_DEBUG was never set. apply_config() now returns its
result through game_gpu(), so a per-game value is applied the same way
as one from the session.

* fix(game-env): a game's own TU_DEBUG still wins over a shared prefixed one

Resolve the prefixed GPU keys inside the shared entries and inside the
game's entries separately, before the game's entries are laid over the
shared ones. A game's plain TU_DEBUG (or its removal with null) now
beats a shared DROIDDECK_GAME_TU_DEBUG, and a prefixed value set for one
game still applies.

* fix(game-env): keep a plain TU_DEBUG over the prefixed key in the same profile

---------

Co-authored-by: zdennisz <15849186+zdennisz@users.noreply.github.com>
Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 12:55:22 -05:00
TapuukandTapuuk fd2f1eec8a ci: fail the checks gate when store engine tests fail (#2844)
* ci: fail the checks gate when store engine tests fail

* test(ci): expect store-tests in the checks gate

---------

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-18 12:43:31 -05:00
TapuukandTapuuk 19fa6fd8e2 fix(files): keep private app folders out of the documents provider (#2846)
The provider rooted at dataDir exposed the wireless ADB pairing identity, shared_prefs, databases, store logins and Steam's saved login to any app the user picked the DroidDeck root for. Those folders are now hidden from listings and search, refused on open, and can't be created, renamed into, or carried out by renaming, moving or deleting a parent.

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-18 12:42:37 -05:00
The412Bannerandmaxjivi05 a139d9eff4 fix(compositor): hold releases from synchronized subsurfaces until the parent commits (#2721)
* fix(compositor): hold releases from synchronized subsurfaces until the parent commits

gamescope's Wayland backend moves layers between synchronized subsurface
planes and commits the parent last. Each child commit was applied at once,
so a buffer leaving one plane could be released before the next plane took
it, and gamescope then logged "Compositor released us but we were not
acquired". A buffer attached again also dropped its queued release, and the
buffer trace records every attach.

* fix(compositor): hold a synchronized release at its sync boundary and recheck holds on set_desync

---------

Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-18 11:10:57 -05:00
FX1922 2a274623da fix(music): hide the Favorites soundtrack collection until it has a track (#2835)
The Favorites collection in the music tab was always listed, even when
no tracks had been favorited.

- Favorites is now only listed in the Collections source once it has at
least one track
- With no favorites and no other collections, the Collections tab no
longer shows
- Adding a track to Favorites brings it back
- The collection detail page still resolves Favorites by id, so an
already-open page does not close when its last track is removed

Adds a test for the empty, populated and other-collections cases.
2026-11-18 18:51:02 +03:00
MaxsTechReview bb5218746f fix(drivers): Auto gives Xclipse GPUs the old RADV pair only where that build supports them (#2337)
* fix: route unsupported Xclipse generations upstream

* fix: let Auto load upstream Xclipse pairs

* fix: clear stale auto-owned Xclipse RADV pair

* fix(drivers): clear independently owned fallback selections

* fix(drivers): keep independently chosen drivers when session start reconciles an unsupported Xclipse

* fix(drivers): name the Xclipse from Vulkan before session start picks which drivers Auto clears

* fix(drivers): keep the Vulkan query off the UI thread when session start reconciles Xclipse drivers

* test(drivers): control Xclipse GPU family in auto-driver reconciliation test

* fix(gpu): guard Xclipse auto-driver cleanup when running and handle open-driver bundles

* fix(gpu): keep active RADV-Xclipse-upstream bundle on unsupported Xclipse
2026-11-18 10:44:32 -05:00
FX192 b74d005e7f fix(library): only list the Collections source when it has something to show 2026-11-18 18:43:26 +03:00
FX192 75c19cae68 fix(library): hide the Favorites soundtrack collection until it has a track 2026-11-18 18:28:35 +03:00
Kurt Himebauch ca7b7e74ec test(session): skip the /mnt view comparison on hosts where /mnt is a symlink (#2806)
rawAndStorageMountViewsOverlapButDistinctFoldersDoNot canonicalizes
/mnt/media_rw/... with the host JVM. On SteamOS and Fedora Atomic /mnt is a
symlink to var/mnt, so the path resolves to /var/mnt/media_rw/..., which no
Android device produces, and the unit suite fails there. Skip the case when
the host's /mnt is a symlink.
2026-11-18 10:22:28 -05:00
Kurt Himebauch 0a8d6669bf ci: install the arm64 C library headers for the verified components (#2833)
* ci: install the arm64 C library headers the verified components cross-compile against

* ci: cross-compiling component recipes install the arm64 C library headers
2026-11-18 10:09:54 -05:00
Dennis Zabolotnyandzdennisz 9e05e4c00c fix(input): keep held keyboard keys when pointer capture ends (#2779)
* fix(input): keep held keyboard keys when pointer capture ends

When a game gives up its pointer lock, Android pointer capture is
released and the session dropped every held input, including keyboard
keys. In a windowed session with Relative mouse on Auto, holding W to
run and releasing the mouse button after steering stopped the
character, because the key press is never sent again.

Losing pointer capture now releases only the mouse buttons, the pen and
the mouse back-button input. Keys are still released when the window
loses focus.

* fix(input): release held keys when pointer capture ends for the session menu

Opening the session menu releases pointer capture, and the menu then
consumes key events, including the key-up. A key held at that moment
would stay pressed in the guest after the menu closed. Capture loss with
the menu open now releases keys as before; other capture loss keeps them.

* fix(input): release held keys whenever another surface takes the keyboard

Capture loss released keys only while the session menu was open. The
other places that take input from the guest (on-screen keyboard,
achievements, input settings, WoW chat, touch editor, picture in picture)
have the same problem, so keys are now kept only when the session still
owns input and the game itself dropped its pointer lock.

* fix(input): release held keys when the session menu opens

While the menu is open it takes every key event, including the key-up,
so a key held when it opened stayed pressed in the guest. The keys are
now released when the menu opens, whether or not pointer capture was
active.

---------

Co-authored-by: zdennisz <15849186+zdennisz@users.noreply.github.com>
2026-11-18 09:53:39 -05:00
The412Banner 0a167e41c2 fix(session): Steam's install-script step no longer counts as the game for return after game (#2732) 2026-11-18 09:37:50 -05:00
Kurt Himebauch 1702f2d72d fix: trust FryMcNugget for test builds (#2830) 2026-11-18 09:11:14 -05:00
FX1922 f1be935761 feat(library): add a Hidden tab synced with Steam's hidden games (#2803)
* feat(library): add a Hidden tab synced with Steam's hidden games

* fix(library): mark the hidden collection as modified so Steam uploads it

* fix(library): make the Steam hidden write atomic and refresh the hidden set on resume

* feat(library): show an error when hiding a game can't sync with Steam

* fix(library): keep the pending Steam upload list safe when it can't be read

* fix(library): report a failed Steam sync when the upload marker can't be saved

* fix(library): refresh the Steam hidden set from disk after a failed sync

* fix(library): keep the cached hidden set when Steam's file can't be read

* fix(library): handle a malformed hidden entry and a changed Steam root

* fix(library): refuse to overwrite a malformed hidden entry

* fix(library): validate the hidden collection, keep Steam saves separate from upload status and cover cloud and uninstalled games

* fix(library): accept numeric-string ids, keep uninstalled games in the Hidden tab and hide games from the Steam home list

* fix(library): keep hidden Steam games out of the home capsule wall

* fix(library): refresh home art when the hidden set changes and track the Steam account

* fix(library): clear the cached hidden set when the Steam account changes

* fix(library): ignore a previous account's art while the home scan runs

* fix(library): conceal home art for hidden added games that carry a Steam app id
2026-11-18 07:38:34 -05:00
Kurt Himebauch d89c2c1c2d Skip the inline page-out timing control when the machine is too fast for it (#2814) 2026-11-18 01:59:01 -05:00
Kurt Himebauch ecd74fce79 Save the store order only once the user arranges it (#2812)
* fix(stores): save the store order only once the user arranges it

* test(stores): exercise the tab save the hide toggle uses
2026-11-18 01:33:11 -05:00
Kurt Himebauch bf0260de61 fix(effects): keep upscaling and sharpening at panel size with frame generation on (#2728)
* fix(effects): keep upscaling and sharpening at panel size with frame generation on

* fix(effects): stub sharpening query in the terminal callers probe
2026-11-18 00:56:02 -05:00
Kurt Himebauch 2f07e11ba0 fix(build): make tools/build_local.sh work on x86_64 Linux (#2807)
Building the full APK locally on an x86_64 Linux host (rootful Docker, no
Docker Desktop) failed in the Xbox backend step and could not be rerun:

- The xodus-cli tests re-execute their own arm64 test binary, which needs an
  aarch64 binfmt handler on the host. Without one the child runs through
  /bin/sh ("Syntax error: & unexpected"). build-local.sh now checks for the
  handler up front and prints the one-line fix.
- msixvc's streaming tests give each request 40 ms. Under qemu with the whole
  suite in parallel they time out (28/30 pass in parallel, 30/30 serially),
  so they run with one test thread when emulated. Native arm64 is unchanged.
- The backend container runs as root, so with rootful Docker its outputs in
  the repo and the cache were root-owned and the next build_local.sh could not
  remove them. The container now hands them back to the calling user on exit.
- README lists the missing requirements: Go, a host C compiler, both MinGW-w64
  compilers (i686 with DWARF-2 exceptions; Homebrew's SJLJ build cannot link
  Rust's i686-pc-windows-gnu) and the arm64 binfmt handler.

Verified with a full tools/build_local.sh run on SteamOS (x86_64): all three
backend test suites pass and the APK is release-signed.
2026-11-18 00:54:33 -05:00
DantalianandDantalian bdc18bdd03 fix(ui): pin the file manager toolbar ends so the exit stays reachable (#2564)
fix(ui): pin the file manager toolbar ends so exit stays reachable

Below 600dp the whole toolbar scrolls, so on a phone the star and the
exit button sit past the right edge and need a swipe to reach. Scroll
only the middle section instead, keeping the back arrow, the drive chip
and exit in place, and move the grid list toggle into the sort menu to
give that section room. The disabled back arrow also stops being
painted primary, which made it look active at the drive root.

Co-authored-by: Dantalian <Dantalian-dev@users.noreply.github.com>
2026-11-18 00:53:45 -05:00
Kurt Himebauch c336f994e1 Library store pills follow the new default store order (#2811)
* fix(library): move an unarranged store order to the new default at startup

* fix(stores): forget an unarranged store order instead of saving the default
2026-11-18 00:47:44 -05:00
Kurt Himebauch c1cf0f3a9c feat(agent): hold to talk, slide up to lock, let go to send, with guided voice setup (#2796) 2026-11-18 00:47:42 -05:00
Kurt Himebauch 384eb78215 fix: set aside an unreadable game environment file (#2808)
fix: set aside an unreadable game environment file instead of failing every session
2026-11-18 00:47:12 -05:00
Kurt Himebauch 5e704296ed Review follow-ups for tab defaults, accounts and hero flight (#2809)
* fix: address review notes on tab defaults, accounts and hero flight

* fix: zero hero drift for cover-only pages, hide search pills from accessibility

* fix(settings): drop pill semantics while search is open
2026-11-18 00:35:45 -05:00
Kurt Himebauch 52c76ead74 chore: refresh the verified preload snapshot (#2810) 2026-11-18 00:28:49 -05:00
Kurt Himebauch 08eadf7af8 feat(agent): OpenCode takes keys for Ollama Cloud and other providers, or any OpenAI-compatible server (#2741)
* feat(agent): OpenCode takes keys for Ollama Cloud and other providers, or any OpenAI-compatible server

* fix(agent): write OpenCode config atomically, check auth first, Done hides the keyboard

* fix(agent): serialize OpenCode key saves and removals

* fix(agent): restore the OpenCode config atomically when the key write fails

* fix(agent): report a failed OpenCode config rollback

* fix(agent): delete the OpenCode config with deleteIfExists, lead with the rollback warning
2026-11-18 00:27:26 -05:00
LunaDL d40c962b37 Feat: Better SMAA, make nearest the default filter and change the default store order (#2760)
* Add SMAA screen effect option

* Atualizar o smaa_frag.h

* Atualizar o smaa.frag

* Fix SMAA endpoint and crossing-edge area weights

* Atualizar o smaa.frag

* Fix SMAA diagonal edge blending

* Regenerate SMAA fragment shader header

* Fix SMAA diagonal fallback detection

* Add anti-aliasing translations

* Fix Korean anti-aliasing label

* Change default store tab order

* Put Nearest scaling before Linear

* Make Nearest the default scaling filter

* Improve SMAA diagonal blend weighting

* Improve SMAA diagonal detection and corner protection

* Reduce false positive SMAA diagonal blending

* test: update unknown upscaler fallback expectation
2026-11-18 00:26:32 -05:00
Kurt Himebauch 8953eea9e0 fix(battlenet): keep the launch behavior a player chose in Battle.net (#2750) 2026-11-18 00:26:07 -05:00
Jan PokornýandJan Pokorny 8faaac3b89 fix(agent): force clearing focus on a tap in the Agent conversation (#2769)
A tap on the conversation while the composer held focus could crash the app:
FocusManager.clearFocus() without force walks the focused chain for a custom
exit and throws IllegalArgumentException ("ActiveParent with no focused
child") when a parent is ActiveParent with no active child. The forced path
skips that walk and treats a missing child as cleared. Nothing in the Agent UI
sets a custom focus exit, so forcing changes no behaviour.

Co-authored-by: Jan Pokorny <4580066+JanPokorny@users.noreply.github.com>
2026-11-18 00:25:36 -05:00
ZeratulloandZeratullo c7cd2b55af fix(xbox): hand Xodus a launch folder the Linux guest can see (#2751)
* fix(xbox): log and show why an Xbox launch could not be prepared

* fix(xbox): hand Xodus a launch folder the Linux guest can see

---------

Co-authored-by: Zeratullo <8460122+Zeratullo@users.noreply.github.com>
2026-11-18 00:23:00 -05:00
Kurt Himebauch c8b291b9db Tabs decide what shows: new defaults and reset, Apps and Dev Harness as tabs, animated Settings search, Library store accounts (#2798) 2026-11-17 23:56:19 -05:00
Kurt Himebauch eabcfc7b74 chore: consistent code branding (#2800)
* chore: consistent code branding

* fix: carry legacy overrides, queues and live sync rows across the rename

* fix: keep queued legacy overrides on a failed rename and separate merged queue entries
2026-11-17 23:31:26 -05:00
Kurt Himebauch ad9348879d fix: remove stray pipewire lock files from the repo root (#2805)
#2780 committed 21 empty libdroiddeck-pipewire.lock files whose names are
mangled Windows temp paths. test_pipewire_helper runs the POSIX helper
under sh; on Windows it received a C:\Users\...\Temp path, so the helper's
"$dir.lock" landed in the working directory. The helper needs a POSIX
shell, flock and Unix sockets, so skip the test on Windows.
2026-11-17 23:27:24 -05:00
Kurt Himebauch 0ce168b913 feat(settings): one home per setting, Storage/Syncthing/Downloads tabs, scoped frame limit, clearer menus (#2791) 2026-11-17 20:26:37 -05:00
MaxsTechReview 868207baf8 fix(desktop): preserve bounded Windows program diagnostics (#2695)
* fix(desktop): preserve bounded Windows program diagnostics

* fix(desktop): isolate stderr mirror failures from diagnostic file capture

* fix(desktop): continue stderr mirroring after diagnostic file limit

* fix(desktop): make diagnostic stderr messages best-effort
2026-11-17 17:37:17 -05:00
MaxsTechReview eb5aa7a536 fix: seed redist markers into new prefixes before install scripts (#2327)
* fix: initialize Proton prefix before install scripts

* game-env: start Proton first only for a new prefix

* fix: wait for new prefix wineserver before seeding

* game-env: find wineserver in either Proton layout

* fix(steam): skip redist seeding when wineserver wait fails

* fix(steam): probe new prefixes only when Proton has no template prefix

* fix(steam): check the active Proton prefix template before seeding

* fix(steam): use effective environment for redist seeding
2026-11-17 17:05:38 -05:00
MaxsTechReview cbde8b1f25 feat(quest): show the child-process command with SideQuest steps on Quest (#2306) 2026-11-17 16:20:51 -05:00
MaxsTechReview 7ce8b37824 fix(zram): back off ineffective idle compression (#2347) 2026-11-17 16:20:32 -05:00
Kurt Himebauch d7d0583c5a fix(memory): reclaim on a fast memory fall on large-RAM devices before the kill (#2754) 2026-11-17 13:37:09 -05:00
Kurt Himebauch 7909af74d6 fix(logs): say in a recovered session folder whether the device restarted (#2752) 2026-11-17 13:35:04 -05:00
Kurt Himebauch 28cf995d7b fix(agent): terminal icon for Dev Harness in the session menu (#2749) 2026-11-17 13:34:51 -05:00
Kurt Himebauch b2b2e38e67 fix(desktop): Desktop draws again and Sunshine can capture it (#2780)
* fix(desktop): keep the bundled PipeWire paths out of Plasma so the desktop draws

* fix(desktop): let the screencast portal use KWin so Sunshine can capture the desktop

* fix(proot): /proc/<pid>/root reads as the guest root so portals accept callers

* fix(nativeguest): /proc/<pid>/exe of another guest program names that program, not the loader

* fix(nativeguest): trust another process's program only when it is mapped there, and read all of its environment

* fix(nativeguest): accept versioned glibc loaders, and wait for the test program to run
2026-11-17 12:31:35 -05:00
Kurt Himebauch fa95df37d0 fix(session): keep the session the top app on dual screens under memory pressure (#2763) 2026-11-17 12:27:54 -05:00
MaxsTechReviewandKurt Himebauch b88b5f6b1d feat(steam): adopt game folders found in added libraries (#2317)
* feat: adopt game folders in added Steam libraries

* Share the appmanifest builder between steam-library and steam-games

* steam: load the shared compatibility module once per run

* Guard unreadable game folders during library adoption

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-17 11:25:04 -05:00
MaxsTechReview c31f19a9f0 fix(input): detect which axis pair is the right stick (#2333)
* fix(input): detect controller right stick axes

* fix(input): read dedicated triggers when the right stick is on RX/RY

* fix(input): stabilize mixed controller axis detection

* fix(input): normalize ranged signed triggers

* fix(input): reuse the event's device for stick and trigger detection

Pass the InputDevice captured at the start of motion handling into the
right-stick and trigger helpers instead of looking it up again, so a pad
that disappears mid-event keeps its axis layout. Write each pad-mouse
trigger only when that side has an analog source, so a held digital
trigger on the other side is not cleared.
2026-11-17 11:24:33 -05:00
MaxsTechReview 812e492302 fix(zram): page game memory out on a worker thread, not the signalled game thread (#2335)
* fix: move zram page-out off signal thread

* fix: drain pending zram requests

* Time the async and inline page-out runs on the same workload

* fix(zram): keep pageout worker responsive under load

* test(zram): synchronize signal delivery before fixture shutdown

* test(zram): compare matched single-request timings

* test(zram): correct single request timing control

* test(zram): calibrate single request timing together

* test(zram): fail the timed run when the acknowledgement never arrives
2026-11-17 11:24:05 -05:00
MaxsTechReview f84e9d5191 fix(input): the controls editor shows the layout the game uses (#2339)
* fix(input): align layout editor with game controls

* fix(input): regenerate built-in layouts for measured surfaces

* fix(input): preserve edge stick travel bounds

* Drop editor strings now translated on main

* fix(input): keep editor frame, undo state and previous edge sticks consistent

* fix(input): preserve draft controls and aspect in editor
2026-11-17 11:23:34 -05:00
MaxsTechReview 2ff890f0ec fix(dual-screen): allow game swap to external second screens (#2350)
* fix(dual-screen): allow game swap to external second screens

* fix(dual-screen): name external screens primary and secondary in the game screen choice

* Keep the selected game screen in step with display changes and session mode

* Refresh the game output when the screen is picked automatically

* Keep the game screen when controls open automatically

* Keep the external game screen across restarts and show the controls on the primary screen

* fix(dual-screen): preserve selected game display

* fix(dual-screen): retain fallback selection and keyboard access

* fix(input): clear field keyboard ownership on transitions

* fix(dual-screen): route keyboard when selected display is occupied

* fix(dual-screen): enable keyboard fallback routing

* fix(dual-screen): defer keyboard requests until focus returns

* fix(dual-screen): recheck keyboard destination on focus return and ignore stale hide events

* fix(dual-screen): end guest keyboard ownership on real dismissals
2026-11-17 11:22:33 -05:00
MaxsTechReview 913cb85c92 fix(fex): supply current Wayland libraries in the shared runtime (#2426)
* fix(fex): supply current Wayland libraries in the shared runtime

* fix(fex): provide current FreeType runtime libraries

* fix(fex): fall back when provider links are broken

* fix(fex): require ffi for provider Wayland libraries

* fix(fex): keep Wayland cursor with its provider client

* fix(fex): preserve cursor compatibility and refresh runtime cache

* fix(fex): provide current GBM runtime libraries
2026-11-17 11:22:04 -05:00
MaxsTechReviewandKurt Himebauch 7852098e63 fix(input): screen taps move the pointer without clicking while an on-screen mouse button is shown (#2465)
* fix(input): screen taps move the pointer without clicking while an on-screen mouse button is shown

* fix(input): keep tap-to-click with the stock Desktop on-screen gamepad

Only mouse buttons the user bound, not the profile base's stock bindings, make screen taps pointer-only.

* fix(input): count mouse buttons on the second-screen and foldable panels

* fix(input): keep tap clicks off on the swapped panel, copied stock panels and the scroll layer

* fix(input): move the pointer before the desktop gesture buffer when an on-screen mouse button clicks

* fix(input): the on-screen button gate leaves uninitialized gestures alone

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-17 11:21:32 -05:00
MaxsTechReview 0794f361ad fix(rockstar): serve launcher pipes named by the executables beside a protected game (#2590)
* fix(rockstar): serve launcher pipes named by the executables beside a protected game

* fix(rockstar): skip unreadable executables beside a game instead of failing the launch

* test(rockstar): exercise case-insensitive sibling pipe name dedupe

* fix(rockstar): show the launcher service log in the session log after a Rockstar game exits

* fix(store): run the store exit hook when the session ends a store game
2026-11-17 11:21:00 -05:00
MaxsTechReview 8c8cae85cf fix(session): read the compressed client back when it is in front of a running game (#2600)
* fix(session): read the compressed client back when it is in front of a running game

* fix(session): keep the client compressed while focus is unknown

A missing or unreadable focus.json no longer counts as the client in front
of the game, so the readback timer starts only on a confirmed focus change.

* fix(session): invalidate focus snapshots after collection failures

* fix(session): retry focus snapshot publication
2026-11-17 11:20:29 -05:00
MaxsTechReview 8e49dfe190 fix(fex): GL thunk passes X errors to the program instead of exiting (#2601)
* fix(fex): GL thunk passes X errors to the program instead of exiting

* fix(fex): raise forwarded X errors on the program connection without swapping its handler

* fix(fex): release the host display lock while a forwarded X error runs the program's handler

* test(fex): cover X error forwarding with real Xlib locks under Xvfb

* test(fex): verify GLX context fallback with a valid config

* test(fex): probe GLX headers before compiling harness
2026-11-17 11:19:58 -05:00
MaxsTechReview 1951bbc92a fix(desktop): expose readable removable volumes in Dolphin (#2671) 2026-11-17 11:19:29 -05:00
MaxsTechReview d7c03ba3ec revert: remove merged bot investigation docs (#2692, #2697) (#2784)
* Revert "docs(rendering): record outdoor lighting investigation (#2692)"

This reverts commit cdb8fa6f53.

* Revert "docs(rendering): record D3D10 renderer crash investigation (#2697)"

This reverts commit 663a7003bc.
2026-11-17 11:12:11 -05:00
MaxsTechReview cdb8fa6f53 docs(rendering): record outdoor lighting investigation (#2692) 2026-11-17 11:09:22 -05:00
MaxsTechReview 663a7003bc docs(rendering): record D3D10 renderer crash investigation (#2697) 2026-11-17 11:09:17 -05:00
MaxsTechReview 2be0ba58c7 fix(flatpak): expose the runtime GPU to accelerated desktop windows (#2699) 2026-11-17 11:09:12 -05:00
Kurt Himebauch 637f4b21ee fix(shortcuts): the companion no longer keeps DroidDeck running, so Cocoon stops calling it open (#2764)
* fix(shortcuts): the companion no longer keeps DroidDeck running, so Cocoon stops calling it open

* fix(shortcuts): reset the relay holder when it is installed again
2026-11-17 10:03:25 -05:00
Kurt Himebauch 51ec4a3029 chore(shortcuts): target Android 14 like DroidDeck so Play Protect does not block the companion (#2774) 2026-11-17 09:51:22 -05:00
Kurt Himebauch b1a7d9b2d0 fix(preload): leave anonymous memory alone when copying noexec image pages (#2706) 2026-11-17 08:29:32 -05:00
Kurt Himebauch 6fe7b4ec11 feat(diagnostics): record lmkd's kill records after a low-memory kill (#2758) 2026-11-16 22:53:16 -05:00
Kurt Himebauch d13458937d feat(agent): hide the Dev Harness tab by default (#2744)
* feat(agent): hide the Agent tab by default

* feat(agent): rename the Agent tab to Dev Harness with a terminal icon
2026-11-16 16:47:50 -05:00
Kurt Himebauch fde3089900 feat(hud): long press collapses or expands the HUD, locking becomes an option (#2723)
* feat(hud): long press collapses or expands the HUD, locking becomes an option

* fix(hud): keep the collapsing tab at the press point while layout runs

The layout listener could run keepOnScreen during the dock animation and replace the press-centered target with the anchored edge position, which was then saved as the tab position. The dock animation now holds the same guard the other HUD animations use until the dock is committed.
2026-11-16 15:29:17 -05:00
MaxsTechReview 8e514ada62 fix(library): persist explicitly selected executables in discovered folders (#2703)
* fix(library): persist explicitly selected executables in discovered folders

* fix(library): keep reachable executable when selecting unmapped alias
2026-11-16 15:19:10 -05:00
MaxsTechReview aba9811357 fix(ci): wait out the API rate limit in build validation (#2672)
* fix(ci): wait out the API rate limit in build validation

* fix(ci): skip rate-limit sleep retries on status POSTs

* fix(ci): detect status POSTs via --method without changing api() call signature
2026-11-16 15:00:05 -05:00
Kurt Himebauch 5fac78797f fix(display): Steam's frame limits follow the panel, not Game Mode's FPS override (#2717) 2026-11-16 14:45:38 -05:00
LunaDL d116021ff3 Feat: Add SMAA as a anti-alliasing option and the buttom for FXAA becomes a switch. (#2708)
* Add SMAA screen effect option

* Atualizar o smaa_frag.h

* Atualizar o smaa.frag

* Fix SMAA endpoint and crossing-edge area weights

* Atualizar o smaa.frag

* Fix SMAA diagonal edge blending

* Regenerate SMAA fragment shader header

* Fix SMAA diagonal fallback detection

* Add anti-aliasing translations

* Fix Korean anti-aliasing label
2026-11-16 14:36:02 -05:00
Kurt Himebauch 25cbcf0c1f feat(agent): OpenCode as a third agent, with free Zen models or a pasted Zen key (#2711)
* feat(agent): OpenCode as a third agent, with free Zen models or a pasted Zen key

* fix(agent): OpenCode's key check reads only its own entry and never overwrites an unreadable auth.json
2026-11-16 14:33:22 -05:00
Kurt Himebauch f0557302ac feat(xbox): Xbox sign-in in the same frame as the other stores (#2718)
feat(xbox): give the Xbox sign-in the same frame as the other stores and log why its helper could not start
2026-11-16 11:48:31 -05:00
LunaDL a8c1a9ff4d Feat: Add new button for integer scalling, adds tolerancy and rename (#2690)
* Add integer scaling mode

* Fix integer scaling view-space input bounds

* Improve integer scaling tolerance

* Add Fit and Auto scaling toggle to session drawer

* Translate Fit and Integer scaling labels

* Clarify integer scaling cropping hint

* Update integer scaling hint across translations

* Fix integer scaling settings and translations

* Fix controller input for integer scaling

* Complete integer scaling hint translations

* Fix integer scaling hint translations

* Restore XML declaration quote style

* Use double quotes in XML declarations

* Add missing norugeuingz translatisn

* fix: include math.h for roundf integer scaling

* fix: link math library in Vulkan caller tests

* Fix integer scaling translations

* Fix Italian integer scaling string

* Fix Italian scaling hint apostrophe
2026-11-16 11:47:04 -05:00
ASEbrahimandASEbrahim 37a816c212 Update MaliBridge to v0.5.5.4 (#2704)
Co-authored-by: ASEbrahim <264076441+ASEbrahim@users.noreply.github.com>
2026-11-16 11:34:58 -05:00
Kurt Himebauch 1ab090405e ci: reclaim root-owned workspace files before checkout on self-hosted runners (#2713) 2026-11-16 10:01:59 -05:00
Kurt Himebauch dc98b6b96a feat: target Android 14 so Play Protect installs DroidDeck without a warning (#2683)
* fix(proot): ship proot in the APK and run it from the native library directory

* fix(native): start rootfs programs through an APK-shipped exec loader where data files may not be executed

* fix(audio): start PulseAudio through the system linker where data files may not be executed

* feat: target Android 14 (SDK 34) so Play Protect installs DroidDeck without a warning

* fix: ask for all-files access on Android 11+, reject unloadable ELFs before exec, keep checking the proot pack

* fix: hand host scripts to the kernel, skip startup launch while all-files Settings is open

* fix: run proot from its add-on pack through Android's linker, so the APK carries no proot

* fix: declare high sampling rate sensors for controller gyro at target 34

* fix: offer the rootfs proot fallback only where Android lets proot exec its loader

* test: install the runtime's proot pack in GameFileSync fixtures
2026-11-16 09:35:16 -05:00
MaxsTechReview 6188c9ac0d fix(desktop): let gamescope find its reaper when /usr/games is not on PATH (#2597)
* fix(desktop): let gamescope find its reaper when /usr/games is not on PATH

* test(desktop): keep host directories off the reaper fallback test PATH
2026-11-16 09:33:31 -05:00
Kurt Himebauch 758e7983fa feat(display): black frame insertion on 100 Hz and faster screens (#2653)
* feat(display): black frame insertion on 100 Hz and faster screens

* feat(display): black frame insertion lives in Screen effects

* test(compositor): cover black frame insertion in the render-on-commit harness

* fix(display): keep HDR and pacing intact around black frame insertion

* fix(display): gate black frame insertion on the panel's refresh, not the tick rate

BFI checked the 100 Hz minimum against g_refresh_ns, an average of the time
between handled vsync ticks. BFI presents on every tick, so under load the
ticks run late, the average fell to 95-100 Hz on a 120 Hz panel, and BFI
switched off and on again many times a second (3793 times in one session on
a Retroid Pocket Duo). That showed as uneven flicker.

Use the display mode's refresh (g_output_refresh_mhz) instead, which only
changes when the mode does.

* fix(display): offer black frame insertion for the bottom screen and while it is on

* fix(display): capture a picture, not a black refresh, while black frame insertion strobes

* fix(display): hold black frame insertion off until the last capture ends

* fix(display): keep the game composed while a capture holds black frame insertion

* test(display): a picture hold presents only pictures while black frame insertion runs
2026-11-16 07:33:39 -05:00
MaxsTechReview f65e7a3d43 fix(preload): Windows games run from noexec shared storage under every Proton (#2594)
* fix(preload): Windows games run from noexec shared storage under every Proton

When mprotect(PROT_EXEC) on a private mapping is refused, libblsession
moves the pages into anonymous memory and retries, so Wine can make an
image's code sections executable on noexec mounts. FEX keeps its
existing handling.

* fix(preload): copy noexec image pages without faulting or dropping access

* fix(preload): install copied image pages with final permissions
2026-11-15 23:17:44 -05:00
MaxsTechReview 3d0c38c1d3 fix(session): default eligible Steam interfaces to GPU compositing (#2660) 2026-11-15 21:10:37 -05:00
The412Banner 81e238b92e feat(xbox): Nexus backend 0.2.15, Nexus runtime 11.0-20261102 and DLC mounting (#2696)
Nexus moved its Xodus changes from patch files in xodus-nexus into a backend
fork (domsvoboda/nexus-backend, GPL-3.0). prepare.py now fetches that fork at
backend-v0.2.15 (e7884a27, same Xodus base 53ea781d, same Rust 1.99.0) and
applies the DroidDeck patches, rebased onto it:
- droiddeck-credentials, -launch-view, -library-subscriptions: same rebase as
  Bannerlator's 0.2.15 update (identical patches before and after).
- droiddeck-credential-fallback, -credential-diagnostics: applied unchanged.
- droiddeck-cloud-token: session::prepare now also returns the account
  snapshot; the ticket checks it like upstream's profile/social commands.
- droiddeck-licensing-device-ticket: upstream 0.2.15 already formats
  delegation-compact device tickets for Store license tokens (27c335e), so only
  the content licensing path is patched. Upstream now writes compact JWE
  delegation tickets as t=, so the d= prefix check is replaced by the token
  type, the same rule as upstream's store_license.rs.
droiddeck-xbox-ticket.patch is dropped: upstream sends compact JWE delegation
tickets to Xbox Live sign-in in a form it accepts, with tests.

Runtime: domsvoboda/nexus-runtime runtime-11.0-20261102-g76c6dd13 (was
xodus-nexus runtime-11.0-20261018). Same six modules at the same path;
xgameruntime.dll is the C++ implementation (nexus-xgameruntime 455b1ba9).
Archive sha512 from the release's .sha512sum, source sha256 from its
candidate.json, module sha256 from the extracted files. The PlayFab Game Saves
proxy is a newer build at the same path and still passes droiddeck-xbox's
export checks; its license moved to share/doc/nexus-runtime/.

DLC mounting: the C++ runtime mounts downloadable content only inside a
host-managed workspace named by XODUS_MOUNT_ROOT (src/System/Package/Mount.h
returns E_NOTIMPL without it). DroidDeck starts Wine itself
(droiddeck:prepare), so droiddeck-dlc-mount.patch (ported from Bannerlator)
creates the workspace in the launch directory for the prepare session and
reports it as mountRoot; XboxRuntime passes it in the xbox-prepare reply and
droiddeck-xbox sets XODUS_MOUNT_ROOT to its Z: path. XODUS_CONTENT_ROOTS is
unchanged and still read by the runtime.

Upstream fixes since the old pins include sign-in for some accounts, offline
play, cloud-save conflict handling, DLC mounting, duplicate token requests and
per-game fixes (Ori, AoE, MSFS, Forza Motorsport).
2026-11-15 20:55:42 -05:00
MaxsTechReview a20528c62b fix(preload): 32-bit x86 programs get correct large-file stat, open, write and lock results (#2592)
The session preload is also built for i386 and preloaded into every 32-bit
x86 program under FEX. There it aliased fstat64, ftruncate64, pwrite64,
fallocate64, posix_fallocate64, open64, openat64 and fcntl64 to their 32-bit
hooks, which on i386 take a different struct layout or argument size. fstat64
returned a size with garbage high bits, so libdbus rejected a valid 33-byte
/etc/machine-id as too large and aborted the program. The aliases now exist
only where off_t is off64_t; on i386 the 64-bit calls reach their own glibc
functions, keeping the open and lock hooks.
2026-11-15 17:20:59 -05:00
Kurt Himebauch 9b5d7870a3 fix(steam): re-apply saved QAM scaling mode and filter at game start (#2681) 2026-11-15 16:41:16 -05:00
Kurt Himebauch b6391ed8c0 feat(agent): shipped rules and skills for every harness, with a user layer and tool health (#2682) 2026-11-15 16:40:45 -05:00
LunaDL c7ff93ec19 Feat: adds a interger scalling (another option) (#2620)
* Add integer scaling mode

* Add Fit and Auto options for integer scaling

* Update vk_present.c ( removed comentarios)

* Fix integer scaling view-space input bounds

* Fix integer scaling view coordinate ratios

* Fix glasses touch and effective Cardboard alignment

* Translate integer scaling settings

* Fix glasses picture bounds scaling
2026-11-15 14:51:24 -05:00
Kurt Himebauch 1cada9ad50 fix(agent): protect retained Claude background work (#2678)
* fix(agent): protect retained Claude background work

* fix(agent): address retained session review findings

* fix(agent): reset Claude cost tracking on clear
2026-11-15 13:29:38 -05:00
Kurt Himebauch 9375ed0948 fix: ship Windows executables as add-on packs and keep them out of the APK (#2676)
* fix(rockstar): ship the launcher service as an add-on pack, not inside the APK

* fix: ship the DiRT ws2_32 stand-in as an add-on pack and reject Windows executables in the APK

* fix(release): reject APK entries under a packed path even when the manifest omits them

* fix(dirt): fetch the ws2_32 stand-in pack once the Linux runtime is installed
2026-11-15 13:28:38 -05:00
Kurt Himebauch 946e9c41e0 Add per-game Steam Input overrides (#2407)
* feat: add per-game Steam Input override

* fix(steam-input): keep overrides in Steam's root apps section and keep the panel in step with the session

* fix(steam-input): reload the override after every session
2026-11-15 12:40:21 -05:00
Kurt Himebauch 259d5d184b feat(agent): keep Claude Code open between turns so background tasks can wake it (#2652) 2026-11-15 12:27:17 -05:00
Kurt Himebauch 9a93f59fbf fix(desktop): serve PipeWire in Desktop mode so screen capture works (#2446)
* fix(desktop): serve PipeWire in Desktop mode so screen capture works

* fix(desktop): preserve shared PipeWire lifecycle

* test(desktop): exercise shared PipeWire lifecycle

* fix(desktop): start PipeWire for bottom sessions

* fix(desktop): serialize shared PipeWire bundle preparation

Concurrent Steam and bottom Desktop starts unpacked the bundle into the
same staging directory and rewrote the access settings together. Hold an
exclusive lock around unpacking and access configuration, and cover the
race plus start success and failure environment handling in tests.

* fix(desktop): replace PipeWire access fragments atomically

Write each fragment to a temporary file and rename it so running daemons and clients never read a truncated file.

* fix(desktop): isolate runtime directories in concurrent PipeWire start test
2026-11-15 12:00:27 -05:00
Kurt Himebauch 03812bb3b7 feat(boot-movie): add a Shuffle switch backed by Steam's startup movie shuffle setting (#2462)
* feat(boot-movie): add a Shuffle switch backed by Steam's startup movie shuffle setting

* test(boot-movie): keep unrelated settings unchanged

* fix(boot-movie): keep the Shuffle choice across reset, unreadable configs and running sessions

* fix(boot-movie): track the Shuffle baseline per Steam home and only for values staging wrote

* fix(boot-movie): adopt a Shuffle change made in the inactive Steam home before staging overwrites it

* fix(boot-movie): keep the 60 fps note under the Installed movies row
2026-11-15 11:05:39 -05:00
kingokksaandKurt Himebauch cbcf39d7c2 feat: exit the launcher with three back presses (#1599)
Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:52:30 -05:00
91a217879f fix: surface Battle.net's own reason when it refuses a game folder (#1661)
* fix: surface Battle.net's own reason when it refuses a game folder

watch() treated any "error": <nonzero> in the Agent's status JSON as fatal. The
install form carries nested errors of its own - language.error 704 when the
requested locale is not offered, game_dir.error when the folder is unusable - so
the loop ended before the install started and agent_job reported "exit 0".

A form with a non-zero game_dir.error now fails with that reason (800 reads as
"the game folder already holds a game"); otherwise the wait continues, and only
a top-level error still ends the loop.

* fix: move the form-failure regression out of the crowded test block

Keep the driver behavior unchanged; this only relocates the new regression case so
the branch can be merged with current main without a test-file conflict.

* fix: sync the agent-error change onto current main

Bring the two touched files up to the current main versions and apply the form
failure handling on top. This keeps the PR limited to the driver and its test
without pulling workflow files into the branch.

---------

Co-authored-by: visail <visail@users.noreply.github.com>
Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:51:05 -05:00
Kurt Himebauch 605f85b4b9 fix(input): a failing BLE disconnect no longer ends the app or the unit test run (#2670) 2026-11-15 10:46:16 -05:00
Kurt Himebauch fb14b99d50 fix(session): record the guest start steps in events.jsonl (#2502)
* fix(session): record the guest start steps in events.jsonl

* fix(session): keep both start step events in the session where the step began

* fix(session): record the controller and pre-guest start steps in events.jsonl
2026-11-15 10:37:16 -05:00
Kurt Himebauch f1a0b7e2ff feat(terminal): add Clear key sending Ctrl+L to the bottom-screen key row (#2368) 2026-11-15 10:35:14 -05:00
MaxsTechReviewandKurt Himebauch cdecd09e3c fix(audio): restart host after stalled wake recovery (#2396)
* fix(audio): restart host after stalled wake recovery

* Serialize audio host restarts and make the stall counter race-free

* fix(audio): an overtaken restart leaves the socket alone and a sink guard only acts on its own host

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:31:28 -05:00
OmarAlTaki1 a8aff1c1a3 fix(input): read a USB mouse directly where Android won't capture it, as in REDMAGIC cast mode (#2298)
* fix(input): read a USB mouse directly where Android won't capture it, as in REDMAGIC cast mode

REDMAGIC's cast mode shows the session on a virtual display while its own
mirror activity keeps focus on the phone's display. Android only grants
pointer capture on the focused display, so the session got a cursor that
stopped at the screen edge and the camera stopped turning in mouse-look games.

When capture is wanted but not granted within 500 ms, the session claims the
mouse's USB HID boot interface instead, reads its reports with the layout from
its report descriptor (boot protocol if that can't be read), and sends motion,
five buttons and the wheel the way captured motion goes. The mouse goes back
to Android whenever capture is no longer wanted.

* feat(input): hold the middle button still to open the session menu while the mouse is read over USB

While the session reads the mouse over USB, Android has no cursor, so the
mouse can't reach REDMAGIC's cast-mode panel or anything else outside the
session. Holding the middle button for two seconds without moving opens the
session menu, which hands the mouse back to Android until the menu closes.
Quick middle clicks and middle-button drags still reach the game.

Relative motion sent to a locked pointer now hides the session's own cursor,
as pad pointer motion already does. A desktop keeps its grab while the menu
is open, so a click made with Android's cursor on the way back showed the
session cursor, which then stayed where the click was.

* fix(input): give a USB mouse back to Android when the app starts after being killed while reading it

A process killed while it reads the mouse, by a crash or an update, leaves
the mouse's interface with no driver, so Android has no mouse until it is
replugged. At startup, any permitted USB boot mouse that can be claimed
without force has no driver, and releasing it reattaches Android's.

* fix(input): only sessions shown off the phone's screen fall back to reading the USB mouse

Android grants pointer capture on the focused display, which the phone's own
screen is, so a session there never needs the USB mouse. Checking the display
keeps a slow capture grant from ever asking for the mouse's USB access there.

* fix(input): reject out-of-range HID report sizes and counts, and release USB buttons when the mouse is lost

A report descriptor can give any 32-bit report count or size, which drove the
field loop for billions of iterations and could overflow bit offsets into a
negative index on the reader thread. Items outside 32 bits and 4096 fields are
rejected, so such a mouse falls back to the boot protocol.

A mouse that stops responding while it is read over USB now releases the
buttons it held and cancels a pending menu hold, through a separate onLost
callback, since the session's own release path only runs while the grab is
still active.

* test(input): an oversized report count is rejected even when X and Y follow it

The earlier case had no X or Y fields, so it returned null without the count
check too. A 4097-field item before valid X and Y is now rejected, and a
4096-field one still parses.

* fix(input): Auto relative mouse sees a mouse read over USB, and re-checks when it is lost

The Auto relative-mouse decision from #2305 reads mouseAttached() on the
relative-mouse thread, which counts a mouse read over USB, so the grab's
state is now volatile. Losing that mouse re-runs the decision, as removing
an Android mouse does.

* fix(input): set up the USB mouse on its reader thread, select report protocol, and retry a failed permission request

Opening the receiver and its descriptor and protocol transfers now run on the
reader thread, so an unresponsive receiver can't stall the session for up to
two seconds. A release during setup lets the thread clean up as it already
did. A mouse that fails setup isn't tried again until it is replugged, since
releasing it re-adds Android's mouse, which would start another attempt.

A parsed report descriptor now selects report protocol first: HID 1.11
7.2.6 says a host must not assume the protocol a device is in.

A permission request that throws no longer marks the mouse as asked.

* fix(input): a cancelled or overlapping USB reader can't claim the mouse or mark it failed

A new reader waits for the previous one to let go of the interface, so a
quick release and grab, like toggling the session menu, no longer fails the
claim. A reader released before or during setup doesn't claim the interface
or keeps going. Failing to open or claim leaves the mouse with Android without
marking it failed, since nothing re-adds it to start another attempt; only a
failure after claiming, or a lost mouse, marks it, and only for the current
reader.

If SET_PROTOCOL(report) fails, setup tries boot protocol before giving up,
so the decoder always matches the protocol the mouse was set to.

* fix(input): release can't slip between the USB reader's cancellation check and its claim

The reader checked `running` and then claimed the interface, so a release in
between still let it claim and start setup. The check and claim now share a
lock with release, so the reader either never claims or claims first and sees
the release before setup.

* fix(input): hand the mouse back to Android while the WoW chat bar is on top

appUiOwnsPointer() already shows Android's pointer for the on-top chat bar,
but pointer capture, and now the USB mouse, stayed on, so that pointer
couldn't reach the bar. The bar on top now ends capture and USB reading like
the session menus do, and its changes re-run the capture decision.
2026-11-15 10:21:15 -05:00
Gerson CostaandKurt Himebauch fc0f8a8530 fix(game-env): keep DroidDeck's DLL overrides when a game sets its own (#2332)
* fix(game-env): keep DroidDeck's DLL overrides when a game sets its own

* fix(game-env): keep the game row when the merged DLL overrides pass 8192

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:17:30 -05:00
Kurt Himebauch d0398fd853 fix(dual-screen): the bottom-screen terminal keeps its shell when another app covers that screen (#2366)
* fix(dual-screen): the bottom-screen terminal keeps its shell when another app covers that screen

* fix(session): sweep the kept terminal shell's process tree when the session ends
2026-11-15 10:16:01 -05:00
MaxsTechReviewandKurt Himebauch 4e3eeea5e2 fix(graphics): fall back from unsupported auto display drivers (#2356)
* fix(graphics): fall back from unsupported auto display drivers

* refactor(graphics): drop the unused Auto recommendation lookup

* fix(graphics): repair automatic display fallback build

* test(wayland): keep Vulkan caller harness linkable

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:13:06 -05:00
MaxsTechReviewandKurt Himebauch 2e64ae7575 feat(performance): switch to turn off idle game memory compression (#2346)
* feat(performance): add idle zram compression toggle

* Gate the idle compression toggle on memory cap support and refresh counters first

* fix(zram): retain launcher reclaim when idle compression is off

* test(memory): verify launcher-only reclaim signals

* fix(performance): keep game reclaim when focus is unknown

* fix(performance): say when to turn idle compression off and that it applies on the next session

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 10:09:38 -05:00
Kurt Himebauch a62933d023 fix(fex): the x86 runtime is built from files inside it so FEX finds its libraries (#2484)
* fix(fex): the x86 runtime is built from files inside it so FEX finds its libraries

* fix(fex): the x86 runtime keeps the permissions of the directories it is built from

* fix(fex): rebuilding the x86 runtime refreshes the Steam client links and removes read-only trees

* fix(fex): rebuilding the x86 runtime removes old trees that contain unreadable directories

* fix(fex): isolate generated rootfs files
2026-11-15 10:08:31 -05:00
Kurt Himebauch ab7e17a09d fix: refresh the session loading tips (#2197)
* fix: refresh the session loading tips and drop stale translations

* fix: add tips from common support questions

* fix(session): restore translated loading tips and fix the string that broke resource merging

* fix(tips): list every store the Stores tab signs in to
2026-11-15 10:06:02 -05:00
Kurt Himebauch de5f0fe6df fix(shortcuts): move the accessibility service into an optional companion so Play Protect stops blocking the install (#2654)
* fix(shortcuts): move the accessibility service into an optional companion so Play Protect stops blocking the install

* fix(shortcuts): bind only same-signer relays, recheck enablement per call, drop timed-out keys
2026-11-15 09:55:30 -05:00
George VineandKurt Himebauch 5dd973587f Fix: Remote Play gets the Steam Deck, Steam Deck Controller, Stream Controller, and touch controls (#2033)
* fix: Remote Play gets the Steam Deck controller

Steam's Remote Play client reads the controller itself from its own
streaming_client process. The input preload only exposed the virtual
Deck controller (and the DualShock 4 / DualSense pads that share its
code) to the process named steam, so in Steam Deck controller mode
streaming_client was refused /dev/hidraw16 and the stream got no input:

  streaming_clien: deck: /dev/hidraw16 refused: not the Steam client

streaming_client now sees the same Deck, DualShock 4 and DualSense pads
as Steam. Each opener gets its own report stream from the read-only
ring, so the two processes do not compete for input. The Steam
Controller paths stay Steam-only: the paired controller's feature and
output slot is serialised only within one process.

Fixes #1860

* fix: Remote Play also gets the Steam Controller and touch controls

streaming_client now opens the Steam Controller pads (the app's
emulated one and a paired controller) and Steam's touch controller,
like the Steam Deck pad.

A paired controller's feature request and output slots, and the touch
controller's state, are shared with the app and written under a
seqlock that expects one writer. Their writers now also take a flock
on a lock file in the hook directory, so Steam and streaming_client
take turns. touch_state() was a template holding its own static mutex,
so each caller had a separate one; it now shares a single mutex.

The pad type and touch plug watchers run in streaming_client too, so
it gets the udev events for mode switches and replugs; those only reach
the process that injects them. Poking /dev watchers and moving event0
on the shared filesystem stay with Steam, so they happen once.

* fix: the shared slot lock fails safe and never waits forever

If the lock file cannot be opened or locked, ProcessSlotLock used to
carry on unlocked. Steam alone is still a single writer then, exactly
as before streaming_client could open these devices, so it carries on;
streaming_client now leaves the paired controller's feature and output
slots and the touch state alone instead (feature reads fail with EIO).
The first failure is logged.

The wait for the lock is now bounded: a session freeze can stop the
process holding it, and writers wait with controller_mutex held, so an
unbounded flock could stall all input in the other process. Feature
reads wait up to their 500 ms reply timeout, outputs 100 ms and touch
state 20 ms. When the deadline passes the lock is held by the other
process, so neither proceeds; the operation is skipped and logged.

* fix: Steam no longer turns motion off under its Remote Play client

Steam and streaming_client both set the Deck pad's IMU mode, and both
wrote the one word Android reads to decide whether to feed the gyro.
Steam keeps toggling its own mode during a stream, so it could switch
motion off while the Remote Play layout needed it, and the client never
re-sent an unchanged mode.

Each process now has its own word. Android reads motion while either
wants it, and ignores the Remote Play word once that process is gone.

* fix: Remote Play decides motion while Steam has set no mode

Until Steam published its IMU mode, Android reported the mode as unknown
without reading the Remote Play client's word, so a Remote Play request
to stop motion had no effect. The word that has been set now decides,
and the mode stays unknown only while neither process has set one.

The rule moves into ImuModes so it can be tested on the JVM.

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-15 09:55:25 -05:00
MaxsTechReview a4558c841a fix(graphics): make Auto-owned Mali fallback state explicit (#2406)
* fix(graphics): make Auto-owned Mali fallback state explicit

* fix(graphics): a route Auto stored itself is not counted as the user's choice
2026-11-15 09:39:12 -05:00
alien2003andalien2003 decab6ea90 feat(input): a pen moves the pointer while hovering, clicks with its tip and right-clicks with its side button (#2625)
* feat(compositor): pen samples drive the pointer like a mouse

Input record 13 carries the pen's state (in proximity, tip, right and
middle button) and its position in input space as 24.8 fixed point.
Hover moves the pointer, the tip holds the left button, and a record
without the in-proximity bit releases every button. Under a pointer
lock only the buttons pass. A button pressed or released mid-stroke
keeps the implicit grab on the window the stroke started in, unless
that window closed.

* feat(input): a pen moves the pointer while hovering, clicks with its tip and right-clicks with its side button

In Mouse mode (the default) a pen's hover moves the pointer, the tip
holds the left button and the side button right-clicks; Touch keeps it a
finger. The side button can send a middle click or nothing instead, and
a Bluetooth pen key counts as the side button while the pen is near.
With glasses or a program's pointer lock the pen drives the touchpad.
A hover exit followed within 50 ms by more hover or a touch keeps the
pen near, so a pen at the edge of its hover range does not flicker out,
and a hover that sends nothing for 2 s leaves proximity. On the desktop
a pen that comes near releases KWin's grab of a hardware mouse, so the
pen moves KWin's pointer. Whatever cancels touches also ends the pen,
and stylus devices no longer count as hardware mice.

* feat(input): pen mode and side button settings in the Controls tab and the session drawer

A Pen group follows the touch settings once the phone has a stylus
device or a pen event was seen, which is remembered as penSeen and kept
by a settings reset. It holds Pen (Mouse, Touch) and Side button (Right
click, Middle click, Off); Side button is hidden in Touch. Before
Android 14 a touchscreen reports the stylus source without a pen, so
there it counts only with its first pen event. The strings are
translated into all 32 languages.

* docs: describe pen input and its limits

---------

Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
2026-11-15 09:38:01 -05:00
alien2003andalien2003 de70e37f30 feat(ctl): input pen draws with a virtual pen through Android's input reader (#2639)
droiddeckctl input pen hover, tap, stroke and button register a virtual
direct pen with `adb shell uinput -` and play the gesture through it, so
Android's input reader makes the same stylus events a built-in pen does,
with pressure, tilt, distance, the eraser and both side buttons. The app
is not involved, which lets pen handling be tested without a pen.
Positions are fractions of the screen as shown, placed inside the
physical frame of the internal display viewport in dumpsys input: the
frame is smaller than the panel when `wm size` sets another aspect
ratio, and Android drops pen events outside it. The rotation and size
come from the same viewport. The values are checked before anything
runs on the device.

The script waits 1 s after registering, since uinput reads it in one go
and cannot wait for the device, and does not reset uinput's time base
after that, which would drop the first samples. Contact sends a pressure
of at least 1, because Android takes a pen at pressure 0 for a hovering
one, and a lift first moves to where it lifts, because Android's UP
repeats the last contact. A pen held still moves by one unit without
leaving the physical frame so that it keeps reporting, since the kernel
drops frames that change nothing.

Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
2026-11-15 09:37:56 -05:00
Mike Haye 33cd43237e Head tracking for the XREAL One, One Pro, One Pro+ and Aura (#2532)
* Head tracking for the XREAL One, One Pro, One Pro+ and Aura

These glasses use the same USB Ethernet link and 128-byte IMU report as the
1S. XrealModel now has one model per product: the 1S keeps its tested
display-mode control, and the others switch 2D and 3D only with GET_INPUT
(0x2821) and SET_INPUT (0x2822). Display-mode set (0x275f), brightness and
the dimmer are never sent to them. The Aura's IMU reads x right, y up, z back
(about +9.8 m/s2 on y at rest), so its axes are not flipped like the rest of
the family. Recovery-mode product ids (one below each) stay excluded.

Signed-off-by: Mike Haye <84657517+mhaye20@users.noreply.github.com>

* Describe the wider XREAL support in the glasses panel and docs

The panel's help text and docs/smart-glasses-support.md named only the 1S.
They now list the One, One Pro, One Pro+ and Aura, say what was tested on
the Aura (head tracking and 2D/3D switching), and note that these models get
2D and SBS only, without brightness, dimming or display-mode set commands.
Translations still describe the 1S only.

Signed-off-by: Mike Haye <84657517+mhaye20@users.noreply.github.com>

* Docs: XREAL support is no longer 1S only

The paragraph under the support matrix still said the One and One Pro were excluded.

Signed-off-by: Mike Haye <84657517+mhaye20@users.noreply.github.com>

---------

Signed-off-by: Mike Haye <84657517+mhaye20@users.noreply.github.com>
2026-11-15 09:37:51 -05:00
DeathKhan 253756d45f feat(theme): True black, a pure black theme with a highlight color you pick (#2541)
* feat(theme): AMOLED black, a theme with a pure black page and panels

* feat(theme): rename to True black and let the user pick its highlight color

* fix(theme): True black leaves the page unlit, with no art wash or corner glow
2026-11-15 09:37:47 -05:00
l4nr3 4759a01ef3 feat(xbox): stage the PlayFab Game Saves save-folder proxy from the Nexus runtime (#2662)
* feat(xbox): stage the PlayFab Game Saves save-folder proxy from the Nexus runtime

Xbox titles that use PlayFab Game Saves, such as Forza Horizon 6, stop with
"Initialization Failed" E:0-17 right after sign-in. The SDK's default provider
needs Gaming Runtime save APIs that xgameruntime does not have, and its
in-process provider needs a save folder the title never passes on Windows.

xodus-nexus already builds a proxy for this into the runtime archive we pin
(scripts/runtime-compat, MIT): it keeps the title's SDK as
nexus_pgs_native.dll, sets ForceUseInprocGameSaves and passes the
PersistentLocalStorage PlayFabGameSaves folder. runtime.py now takes it and
its license from the archive, checked against runtime.lock.json, and
droiddeck-xbox stages it before each launch when the game's
PlayFabGameSave.dll has exactly the SDK's 40 exports. A game update that
brings a new SDK replaces the kept copy; anything unknown is left alone.

Unlike Nexus, no DLL override is set for the two DLLs: Wine has no builtin of
either, and forcing them native-only made Forza Horizon 6 fail with E:0-0-4.

* fix(xbox): check the whole PlayFab export table and never overwrite an unknown kept SDK

The SDK and proxy checks now also require the export address table to hold
exactly 40 functions, so a DLL with the same names plus an ordinal-only export
is no longer taken for the SDK. Before copying a new SDK to
nexus_pgs_native.dll, an existing file there must itself be a regular file
holding the SDK; an unknown file or a link is left as it is.
2026-11-15 09:37:43 -05:00
MaxsTechReview 7dedf945c2 fix(xbox): send delegation-compact device tickets to licensing in the licensing wire form (#2598) 2026-11-15 09:37:38 -05:00
MaxsTechReview 4527e93118 docs(phantom): how Android counts guest processes and why detaching cannot escape it (#2584)
* docs(phantom): how Android counts guest processes and why detaching cannot escape it

* docs(phantom): clarify probe permissions and batch capture

* docs(phantom): qualify probe precondition by SDK and size the limit device-wide

* docs(phantom): keep phantom discovery on for the 12L probe and raise the limit instead

* docs(phantom): warn about the CPU kill, raise the limit before the flag and restore both after the probe

* docs(phantom): restore the monitor flag before the phantom limit after the probe

* docs(phantom): restore the flag before the limit whether each is put or deleted
2026-11-15 09:37:34 -05:00
MaxsTechReview 56fabbdbf0 fix(frontend): game file export no longer fails before the game library folder exists (#2549)
* fix(frontend): game file export no longer fails before the game library folder exists

* fix(frontend): previous automatic library check accepts a library folder not created yet
2026-11-15 09:37:30 -05:00
MaxsTechReview b424bfa353 fix(drivers): never load a KGSL-only display driver on a GPU without KGSL, and report the drivers actually in use (#2588)
* fix(drivers): never load a KGSL-only display driver on a GPU without KGSL, and report the drivers actually in use

* fix(drivers): gate KGSL-only drivers on the KGSL kernel node, not Adreno detection
2026-11-15 09:36:47 -05:00
MaxsTechReview 1570d4457c fix(gamescope): overlapping touches no longer leave the emulated click held (#2528) 2026-11-15 09:36:43 -05:00
Kurt Himebauch 75c321123d fix(ui): show dialogs on the second-screen menu without a separate platform window (#2452)
* fix(ui): show dialogs on the second-screen menu without a separate platform window

* fix(ui): track presentation alert window for controller events

* test(ui): assert presentation and platform dialog window semantics

* test(ui): target the presentation popup for outside taps

* test(ui): keep presentation popup tap tests off the auto-advancing idle loop

The outside-tap dialog tests hang in the shared unit-test JVM when the
compose clock auto-advances; step frames explicitly instead.
2026-11-15 09:36:38 -05:00
MaxsTechReview fbb705cf6f fix(epic): say which launcher installs a third-party-managed game (#2344)
* fix(epic): handle third-party managed titles

* Clear a cached third-party launcher when catalog details report none
2026-11-15 09:36:33 -05:00
MaxsTechReview 448d296a2b fix: game debug logs also reach games started by a store client (#2343)
fix: propagate store launcher debug environment
2026-11-15 09:36:27 -05:00
Jordan Y a9524ea991 fix(mesa): refresh every slot that shares a rebuilt sampler view (#2178)
zink_rebind_all_images() rebuilds a sampler view once per backing-object
change, through the rebind_count guard. A second slot bound to the same
view then skipped its descriptor refresh and kept the old VkImageView.
The Mesa patch now refreshes every slot whose cached view no longer
matches the view's current surface.

Follow-up to #2107 (CodeRabbit review). Tested on a Pixel 10 Pro Fold
(PowerVR): debug Mesa 26.0.8 with the patch, Steam web helper threaded,
8 fast Home-shelf scroll cycles, no web helper restart, thumbnails intact.
2026-11-15 09:36:23 -05:00
DeathKhan 73ccae2425 fix(apps): focus the folder when arrows follow a touch (#2545)
Opening a folder by touch and then pressing an arrow left the highlight on the page behind: focus starts outside the page, so the folder's first request was turned to the page's own entry tile. The folder now keeps asking until focus is inside it.
2026-11-15 09:35:49 -05:00
DeathKhanandJames O'Hara 6384b220fc fix(apps): closing a folder from its name field returns focus to the folder tile (#2499)
* fix(apps): closing a folder while renaming returns focus to the folder tile

* fix(apps): keep the folder tile focused while a folder closed from its name field fades out

* fix(apps): a fresh press ends the focus hold after a folder closes

---------

Co-authored-by: James O'Hara <james@jamess-Mac-Mini-317.local>
2026-11-15 09:35:45 -05:00
Dennis ZabolotnyandDennis Zabolotny e3d86c4b17 refactor(input): name the scene input types and wheel scale (#2524)
nativeSendSceneInput took bare integers (3, 4, 6, 11, 12) and the
wheel step (120) and pointer fixed-point scale (256) were repeated
inline. BottomDesktopPanel kept its own private copies of three of
them. Move them to WaylandCompositor next to the native method and
use them at every call site. No behavior change.

Co-authored-by: Dennis Zabolotny <15849186+zdennisz@users.noreply.github.com>
2026-11-15 09:35:40 -05:00
MaxsTechReview 76aa3771b7 fix(logs): app.log keeps the driver loader lines from the start of the session (#2593) 2026-11-15 09:35:36 -05:00
Shawn Montgomery 9c349e185e fix(input): Back gesture opens the menu when a controller exposes its own mouse (#2666)
The 8BitDo Ultimate Mobile registers a mouse interface next to its gamepad.
On REDMAGIC the back gesture has no virtual-hard-key flag, so with that
mouse attached it was sent to the game as a right-click. A mouse that
shares its USB id with an attached controller no longer counts.
2026-11-15 09:35:31 -05:00
SlicelessBread c2663ebee8 fix(lab): Fast Lab builds no longer run out of memory on 8 GB devices (#2667) 2026-11-15 09:35:27 -05:00
alien2003andalien2003 f15c0af34e fix(ctl): screenshots on phones with two screens take the main display (#2628)
screencap without -d prints a warning before the PNG when it finds more
than one display, so droiddeckctl screenshot failed on foldables and
dual-screen phones. Without --display, screenshot and record now use the
physical display behind logical display 0 when there is more than one.

Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
2026-11-15 09:35:23 -05:00
TapuukandTapuuk 68f1d5baa3 perf(session): boost the game's busiest threads on every Snapdragon 8 Elite (#2608)
Game thread hints only ran on the Odin 3 (CQ8725S). Phones with the SM8750 have the same core layout and power HAL, so turn them on there too.

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-15 09:35:19 -05:00
David Kubeša 293ed4fb08 fix(game-env): keep Sentry loaded for Godot games with its C# layer (#2605)
Disabling libsentry.windows.* stops Sentry.Godot.dll's module initializer, so GodotPlugins never starts and the game hangs before the menu.

Fixes #2604
2026-11-15 09:35:14 -05:00
DantalianandDantalian 52e8028609 fix(ui): leave the file manager after a drive hop instead of replaying hops (#2567)
Back replays the history stack, so a round trip between drives leaves one
entry per hop: internal storage, Linux, internal storage, then Back lands
on Linux again and leaving takes one press per hop. Two roots in a row
means the user hopped rather than descended into a folder, so Back leaves
instead. Returning to a folder from a drive root still works as before.

Co-authored-by: Dantalian <Dantalian-dev@users.noreply.github.com>
2026-11-15 09:35:10 -05:00
LunaDL 9ce6d45be8 Feat: Add per game screens effects (#2472)
* Add per-game screen effects profiles

* Fix stale screen effects callbacks

* Fix per-game screen effects profile handling

* Fix screen effects restoration on cancelled launch

* Allow nullable screen effects profile in drawer

* Fix per-game screen effects initialization

* Fix per-game screen effects tracking

* Tighten Steam process detection tests

* Fix per-game screen effects profile resolution

* Fix per-game screen effects profile selection

* Fix screen effects cleanup on game exit

* Fix Steam closing between game launches

* Update SessionService.kt comments removed

* Fix screen effects profile synchronization

* Fix saving screen effects without profile

* Prevent stale screen effects overwriting active profile

* Refresh screen effects on session resume

* Update SessionActivity.kt ( used rabbit suggested fixed )

* Fix Steam game exit detection and return

* Clear screen effects profile while awaiting Steam exit

* Preserve screen effects profile when game restarts

* Refactor screen effects sync and fix game exit handling

* Fix Steam URL game ID fallback

* Add screen effects translations for all locales

* Add per-game screen effects profiles

* Fix per-game screen effects preset persistence

* Fix screen effects profile upscaler handling

* Fix screen effects profile synchronization

* Fix screen effects focus profile synchronization

* Fix screen effects profile restoration on resume

* Fix screen effects profile switching

* Fix Steam game launch rollback target

* Fix screen effects upscaler profile inheritance

* Update SessionActivity.kt ( removed coments )

* Remove unused setup stores translations

* Guard screen effects profile rollback

* Fix per-game screen effects and queued launches

* Fix queued game state and suspend-aware startup timeout

* Fix integer scaling picture bounds

* Fix nullable automatic screen effects profile validation

* Fix integer scaling fallback for small outputs

* Revert "Fix integer scaling fallback for small outputs"

This reverts commit c667a50d58.

* Fix Steam game exit watcher for direct launches

* Fix per-game screen effects resume handling

* Fix game picture bounds scaling
2026-11-15 09:20:37 -05:00
MaxsTechReviewandxXJsonDeruloXx ae9bac225d fix(game-env): keep x64 system DLLs that only x64 code loads in ARM64 prefixes (#2647)
* fix(game-env): keep x64 system DLLs that only x64 code loads in ARM64 prefixes

The foreign-architecture repair treated every plain x64 DLL in system32 of
an ARM64 prefix as broken and swapped in the ARM64 builtin. ARM64EC games
load x64 DLLs fine, so this broke native-only DLLs such as the Khronos
vulkan-1.dll loader (vulkan-1=n leaves Wine nothing to load) and native
runtimes that games depend on.

An x64 DLL is now foreign only when Proton's own ARM64 programs import it,
found from the import tables of the Proton build's ARM64 executables.
Prefixes the old rule already repaired get their native copy back. This
replaces the Visual C++ runtime name list.

* fix(game-env): keep the old rule when Proton's programs cannot be read, restore the newest backup across gaps

* fix(game-env): number new backups above the highest one, treat truncated import tables as unreadable

* fix(game-env): treat an import directory outside every section as unreadable

* fix(game-env): treat truncated data directories and section tables as unreadable

* perf(game-env): index foreign DLL backups per directory

* fix(game-env): count only ARM64 Proton programs as roots, cover x64 component DLLs across launches

---------

Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
2026-11-15 09:20:02 -05:00
MaxsTechReview 7b4b86b0f3 perf(turnip): system-memory rendering for games and apps by default (#2338)
* fix: apply Turnip sysmem to games by default

* docs: note sysmem stays on with the Adreno 710/720 driver
2026-11-15 09:03:34 -05:00
MaxsTechReview a7032530da fix(stores): log why a GOG cloud sync failed and stage uploads in the cache folder (#2596)
* fix(stores): log why a GOG cloud sync failed and stage uploads in the cache folder

* fix(stores): strip URL credentials and bound the error body in GOG cloud failure details

* fix(stores): send Galaxy's communication-service User-Agent to GOG cloud storage

GOG cloud storage now answers every list with HTTP 400 invalid_version for the bare
"GOG Galaxy" value, so uploads and downloads failed for every game. List, HEAD, GET and
PUT now identify as GOGGalaxyCommunicationService/2.0.13.27 like gogdl and Lutris, and
PUT carries the same value as X-Object-Meta-User-Agent.

* fix(stores): bound cloud list errors and verify test requests

* fix(stores): preserve cloud error classification
2026-11-15 09:02:53 -05:00
MaxsTechReview 7254a88391 fix(game-env): turn off Proton's tabtip unless the Steam keyboard is enabled (#2595)
* fix(game-env): turn off Proton's tabtip unless the Steam keyboard is enabled

Proton's tabtip only opens Steam's keyboard with SteamDeck=1, but it always
runs UI Automation queries inside the focused game, and those calls crash
games that answer them (Godot 4.5 AccessKit). Game launches now add
tabtip.exe=d unless SteamDeck=1 or the user's overrides name tabtip.

* fix(game-env): match WINEDLLOVERRIDES modules split by spaces and tabs

* fix(game-env): count only tabtip.exe entries with a load order as the user's own setting

* fix(game-env): count *tabtip.exe and tabtip.exe.dll overrides as the user's own setting

* test(game-env): cover keyboard overrides during sync fallback
2026-11-15 02:48:50 -05:00
TapuukandTapuuk fdf3d98c36 fix(input): stop controller rumble when the game that started it is gone (#2614)
* fix(input): stop controller rumble when the game that started it is gone

A crashed game never sends the stop for a held rumble, so the keepalive re-armed it every 1.5 s until the session ended. A held effect now stops on the next keepalive once the process that sent it or the Steam game it started in has exited. The fake controller also stops its rumble when it's closed or the playing effect is erased, like the kernel does.

* test: read the test's own pid from /proc/self

* fix(input): track who plays rumble on each slot, check the game when a hold starts

The process that plays an effect now owns it, and only the handle currently playing on a slot sends the stop when it closes or erases its effect. A held effect records whether a game is running when it starts, and keeps checking that its sender still exists even when its start time couldn't be read.

* fix(input): only cache a running game, not its absence

A new hold claimed right after a no-game result reused it, so a game that started within the cache window was never watched.

* fix(input): treat a vanished sender of our own user as gone

Guest processes run as the app's user, so the app can always see them in /proc. If one is missing at the first lookup it already exited; only senders of another user (root-spawned guests) are left unchecked.

* fix(input): a stop only ends rumble the same process started

The fake controller's playing-handle tracking is per process, so another process closing or erasing its older effect still sent a slot-wide stop. The app now ignores a stop whose sender isn't the one behind the slot's current effect; stops from an unknown sender work as before.

---------

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-14 23:56:08 -05:00
Kurt Himebauch 6f7d7f827f fix(ci): no 404 window when a test build is replaced; merged PRs keep their build until Preview has it (#2635)
* fix(ci): a test build's files outlive the catalog that names them, and a merged PR's build lasts until Preview carries it

- A new push's PR release keeps the previous push's files until the catalog names the new
  ones, then five minutes more, so a download started from the old catalog still finds its APK.
  The app also reloads the catalog and retries once when a test build's download fails.
- Closing a PR without merging still deletes its test build. A merged PR's build stays, and
  stays listed, until the newest Preview build was built from a main holding the merge, or
  three days pass (docs-only merges build no Preview). Main's build, the PR cleanup and the
  sweep share one script for this.

* fix(ci): name the current push's APK in the catalog and prune nothing it still names

* fix(ci): only a Preview with every APK carries a merge or is offered

* fix(ci): publish no preview while none has every APK

* test(ci): build_catalog publishes no preview while its APKs are uploading
2026-11-14 23:40:08 -05:00
KeegantheVeganat0r 059711cfe1 fix(game-env): only patch Death Stranding's allocator for Death Stranding's app id (#2644) 2026-11-14 19:51:55 -05:00
KeegantheVeganat0r 87cd74c4bf fix: Death Stranding no longer runs out of memory on 39-bit kernels (#2641) 2026-11-14 19:28:46 -05:00
Kurt Himebauch 3087309d3c feat(agent): compact session drawer chat (model, usage and menu in the message row) (#2637) 2026-11-14 19:26:23 -05:00
Kurt Himebauch b6d77bc3d8 Dead code cleanup (#2638) 2026-11-14 18:45:03 -05:00
MaxsTechReview 99bf382ae8 fix(venus): DXVK runs on Mali GPUs without dual-source blending (#2293)
* fix(venus): DXVK runs on Mali GPUs without dual-source blending

DXVK requires dualSrcBlend for D3D11 and skips any GPU without it, so on
Mali through Venus no adapter was found. The Mali compatibility layer now
reports the feature and maxFragmentDualSrcAttachments 1, keeps it out of
the driver's device, turns fragment outputs decorated Index 1 into Private
variables (shader modules and inline stage code), and maps SRC1 blend
factors to source alpha in pipelines and vkCmdSetColorBlendEquationEXT.
Only active when the driver lacks the feature.

Adds a mock loader and driver test for the layer, and fetches the
layer's pinned headers for it in CI.

* build(venus): pin the Mali component with dual-source blending
2026-11-14 18:27:35 -05:00
Kurt Himebauch eb190f2dd7 feat(agent): Agent tab refinements: one-state composer, no snapping, notifications, choices, subagents, dictation, game frame, copy, History search (#2626)
* fix(agent): one-state composer with model and usage on top; reading back stays detached while the agent streams

- The composer no longer has a compact reading bar that a first tap expands: the editor is
  always the editor, and the model picker and context ring move to the top beside the menu.
- The pet chat drops its DeeDee title so that top bar gets the whole width.
- Scrolling back stops following new output; new entries and streamed text only scroll the
  list while it is at the bottom, and sending a message resumes following.
- When the editor slides back in or the keyboard rises, a list at the bottom keeps its last
  lines above the editor, even mid-drag.

* fix(agent): a revise while reading back shows the editor it focuses

* feat(agent): dictate a message, and attach what the running game shows

- With nothing typed, the editor's send button dictates instead, through Android's speech
  recognizer; what is heard follows the text already there. It asks for the microphone the
  first time.
- While a game session is open, a camera button attaches the game's current frame. It is
  copied from the game's own surface, as the bottom screen's screenshots are, so the chat or
  drawer over it is not in the picture.

* feat(agent): a notification when a turn ends unseen, and replies that end in choices offer them as buttons

- A turn that ends while neither the Agent page nor the pet is in view posts a notification:
  finished, failed or asking, with the reply's first line. Opening the Agent page clears it.
- Claude Code's question tool is not available in print mode, so the brief asks the agent to
  end a reply with a choices block instead. The chat shows its options as buttons, and the one
  picked is sent as the next message.

* feat(agent): a subagent's work shows under the call that started it

Claude Code tags a subagent's messages with the call that started it. Its text, thinking and
streamed deltas used to show as the main agent's reply, and its tool calls mixed into the
turn. Now only its tool calls are kept, stored with their parent, and shown inside the
parent's card: a live line with the step count and the latest call, and every call when
the card is opened. Its token counts no longer overwrite the context reading.

* feat(agent): copy a reply or a tool's text, and open a turn's changes in one place

- A turn's footer has a copy button for everything the agent said in it, and tool input and
  output boxes have one each.
- The files-changed chip opens every edit the turn made, file by file.

* feat(agent): search conversations in History

A field above the list keeps the conversations whose title, messages or replies hold the
text, ignoring case. Chat files are read off the main thread, a quarter second after the
last keystroke.

* fix(agent): sending while reading back jumps to the latest

* feat(agent): manage Claude Code's MCP servers and skills from the Agent menu

A new panel lists the MCP servers claude mcp list reports, adds one for every project from a
URL (over HTTP) or a start command (over stdio), and removes it; connectors from the
claude.ai account are listed but managed there. It also lists the skills in
~/.claude/skills with their descriptions, and deletes one after a confirming second tap.

* fix(agent): review follow-ups for the Agent tab refinements

- Choices only come from one fenced block that ends the reply.
- The Agent page counts as on screen only while its activity is started, so a turn ending
  during a game still notifies.
- Picking a choice or Go jumps to the latest like sending does.
- Dictation stops when the chat is hidden or the keyboard sends; stopping it by hand keeps
  the recognizer until its final result.
- A failed JPEG encode is not attached.
- The copied reply is read from the turn each time.
- MCP start commands keep their quoted arguments; the CLI is read beside its 90 s deadline;
  deleting a skill runs off the main thread and removes links without following them.

* fix(agent): scroll the shrinking list after layout, not during measure

* fix(agent): fence-aware choices parsing; dictation stops overwriting edited drafts

* fix(agent): ignore choices blocks nested in a code fence

* fix(agent): treat tilde fences like backtick fences when finding choices

* test(agent): cover a tilde-fenced choices block
2026-11-14 17:35:54 -05:00
MaxsTechReviewandzooluis a3be5f7ae2 fix(epic): install the Epic Games Launcher from its Linux .deb (#2281)
* fix(epic): install the Epic Games Launcher from its Linux .deb

Epic no longer serves the Linux AppImage: the installer URL answers 404
errors.com.epicgames.launcher.app_direct_url_not_found (30003), so Install
failed for everyone. Epic now ships EpicGamesLauncher-x86_64.deb
(0.113.0+g2164614).

- The installer downloads the .deb, checks its ar magic and the CDN ETag,
  and droiddeck-epic unpacks its data.tar.* member straight from the
  archive.
- The .deb links WebKitGTK 4.1, JavaScriptCoreGTK 4.1 and GTK 3, which the
  Steam Runtime 4 image does not ship. 32 Debian 13 amd64 packages, pinned
  by SHA-256 and size (60.2 MB download, 201 MB unpacked), are unpacked
  into the launcher's desktop/ folder (shared libraries only) and put on
  its LD_LIBRARY_PATH. Debian 13 matches the runtime's own base, so only
  sonames the runtime lacks are added. Each package falls back to
  snapshot.debian.org when the deb.debian.org pool has moved on.
- WebKit starts its helper processes from its built-in
  /usr/lib/x86_64-linux-gnu/webkit2gtk-4.1 path, so each launch links that
  folder in the runtime to the layer's copy.
- An installed AppImage launcher keeps starting through its AppRun; the
  next update check moves it to the .deb.

Closure checked offline: every ELF in the .deb and the layer resolves with
the runtime's own ld-linux-x86-64.so.2 inside a sandbox holding only the
runtime, the layer and libGLESv2 (0 missing, 0 version or undefined
symbol errors with LD_BIND_NOW).

Based on zooluis's research in #2268.

Co-authored-by: zooluis <150430329+zooluis@users.noreply.github.com>

* fix(epic): provide desktop GLib data paths

* fix(epic): keep archive symlinks from redirecting the desktop layer and icon

---------

Co-authored-by: zooluis <150430329+zooluis@users.noreply.github.com>
2026-11-14 16:53:43 -05:00
Kurt Himebauch 87c571f443 feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds (#2624)
* feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds

* fix(updates): address review of the Updates tab history and test-build watch

* fix(updates): notify on switch to a followed PR, keep higher-version rebuilds installable

* fix(ci): let full reruns replace every artifact, note only expired PR builds

* fix(ci): leave the rebuild note only when the PR build is too old to rerun

* fix(ci): poll unfinished PR builds together and queue version-bump runs

* fix(ci): also rebuild PR builds that were running when the versionCode changed

* fix(ci): rebuild fork and just-finished PR builds, recheck the PR head before a rerun

* fix(ci): fail the rebuild sweep when finding candidates fails

* fix(ci): time the bump from the rebuild run's creation and scan unfinished builds of any age

* fix(ci): check the latest build of every open PR instead of scanning run history

* fix(ci): count PR builds that finish between the version push and the rebuild run

* fix(ci): use the push time from the event as the rebuild boundary
2026-11-14 16:20:29 -05:00
Kurt Himebauch c847659789 feat(setup): arrange tabs in one list with drag handles, a More line and a shown switch (#2627) 2026-11-14 15:39:15 -05:00
MaxsTechReview aa3a599ec6 fix(runtime): record why a runtime install failed in the session events (#2591)
* fix(runtime): record why a runtime install failed in the session events

* fix(runtime): report empty or invalid runtime catalogs in the failure event

* fix(runtime): keep each install failure reason on its own job

* fix(runtime): name the busy reason for rejected installs and drop the owner's listener

* fix(runtime): keep each install call's failure reason on its calling thread

* fix(runtime): keep the interrupted reason when a joined install finishes during the wait
2026-11-14 14:51:29 -05:00
TapuukandTapuuk 2cb51103ac fix(game-env): the VRAM cap also caps the shared memory DXGI reports (#2607)
With a single GPU heap DXVK reports the whole heap as shared memory too, so games still saw ~8 GB as shared even with the cap on. Set dxgi.maxSharedMemory to the same value, like BattleNet already does.

Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
2026-11-14 14:50:12 -05:00
kingokksa 269d462825 feat(hud): every reading gets its own switch and a row order (#2454)
* feat: every HUD reading has its own switch and a row order

* feat: readings get a reorder dialog of their own

* refactor: drag alone moves a reading

* fix: the readings list is one column with a switch per row

* fix: one scrolling readings list, titled HUD info

* refactor: derive the readings order from the defaults instead of a second list

* fix: the readings dialog loses its doubled title and follows the saved order

* refactor: no title in the readings dialog, its actions sit beside the list

* refactor: readings dialog actions take the free side on landscape, the foot on portrait

* fix: the readings list follows the size it draws and drags with a live gap

* fix: the readings dialog fills the window and keeps scrolling under a held drag

* fix: reset restores every size's order, and the new HUD strings are translated

* refactor: one table for each size's rows and one for its text sizes

* refactor: the readings list swaps rows as the drag passes them, and the list animates the rest

* refactor: give the readings rows test tags for the local UI test

* refactor: HUD readings follow one configurable row table

* refactor: the Strip HUD draws its rows from the same table

* refactor: each size orders its rows by its own table, and the frame graph is a row

* fix: the readings dialog keeps the row order a drag leaves

* fix: each size keeps its own row order, and reset clears only the order

* refactor: the graph's size lives in one place, and the section markers are gone

* fix: a size change and the first save of a legacy config both keep the order

* chore: retrigger the build

* feat: a reading can be grabbed with Y and shuffled with the d-pad

* feat: controller hints float beside the dialog, and a moved row stays in view

* feat: Y grabs on a hold and drops on release, and a touch no longer flips the dialog

* fix: keep the key hints off the rows on narrow windows, and let Enter toggle a row
2026-11-14 14:49:47 -05:00
MaxsTechReview d8b3c66b95 fix(battlenet): a download that stops moving ends with Retry, and a killed update comes back as an update (#2602)
* fix(battlenet): a Battle.net download that stops moving ends as retryable, and a killed update comes back as an update

A job reply without a state or byte counts no longer counts as a started
download, and an Agent job that reports no change for ten minutes is
stopped with its Agent and fails with a Retry instead of waiting forever.
Updates remember their game folder in the saved queue, so one restored
after the app was closed runs agent-update on that folder instead of a
fresh install.

* fix(battlenet): a stalled job stops only the Agent it started

A game or Battle.net client running in the prefix keeps running when a
stalled Agent job is ended, and the progress test keeps the job alive
across polls with a controlled clock.

* fix(battlenet): only real progress holds off the stall timeout

The download rate and time estimate can change while no bytes move, so
the stall timer now resets only on byte counts, progress, state, phase,
pause or error.

* test(battlenet): bound the stalled-rate fake child's polls
2026-11-14 10:58:42 -05:00
MaxsTechReview 84b7295f11 fix(session): keep the session awake while a browser hand-off is pending (#2615)
* fix(session): keep the session awake while a browser hand-off is pending

When a program in the session opens a link in the Android browser, the
session view goes to the background and auto or manual suspend froze the
session within a couple of seconds. Programs that wait for the browser to
call back to a local listener (external sign-in flows) were frozen before
the callback arrived, so the sign-in never completed, and the session then
needed a tap to continue.

An open-url request now starts a browser hand-off that counts as a visible
surface until the session view comes back to the front or ten minutes pass.
Ordinary backgrounding still suspends as before.

* fix(session): hold through a display power change and only after the browser opens
2026-11-14 10:58:06 -05:00
FX1922 50fbcf8b2a feat(library): add a Favorites tab and a heart button on the game page (#2613)
* Add a Favorites tab to the Library with a heart on the game page

* Fix favorites test helper call
2026-11-14 10:08:27 -05:00
MaxsTechReview 76c4de5b5d docs: name droid-deck.dev as the official website (#2611) 2026-11-14 09:03:36 -05:00
kingokksa 2183b05573 l10n: translate the missing strings and add the input library in every locale (#2556)
* l10n: translate the strings added since the last pass

* l10n: add the input library and input strings in every locale

* l10n: keep the input hints unformatted and drop the untranslatable keys

aapt2 rejects input_axis_action_hint and input_trigger_action_hint without
formatted="false", because their translations hold two bare percent signs.
The default resource sets it, the 32 locales did not.

The 40 translatable="false" keys are left out of every locale again; lint's
ExtraTranslation check is fatal in release builds and the entries were added
here by mistake.

Also fixes wording the review caught: the Danish and Norwegian labels for
sticks and neighboring directions, the Bulgarian and Vietnamese D-pad names,
the Greek release and remap wording, the page names Hungarian, Indonesian and
Russian point users to, the Arabic log folder path, and the Finnish library
removal hint that read as deleting the folder.

* l10n: translate the strings the newer upstream commits added

* l10n: drop the two keys upstream no longer ships
2026-11-14 06:00:44 -05:00
Kurt Himebauch e816d79581 feat(session): seed Steam defaults for battery percent, byte download rates and recent sort (#2599) 2026-11-14 01:18:10 -05:00
LunaDL f502b8b3e6 feat(hud): add battery runtime estimate to DD overlay ( hud ) (#2573) 2026-11-13 21:41:44 -05:00
MaxsTechReview 30d103280b fix(session): games keep OpenGL error checks when the client skips them (#2562)
* fix(session): games keep OpenGL error checks when the client skips them

* docs(session): separate the GL error checks note from the picker paragraph
2026-11-13 20:57:42 -05:00
Kurt Himebauch f6d1794624 perf(session): keep a game that holds a steady pace off the fastest cores (#2572) 2026-11-13 20:26:08 -05:00
Kurt Himebauch e8d28c164a Make hiding Home launcher from Recents optional (#2579) 2026-11-13 20:20:44 -05:00
Kurt Himebauch 9a964ba221 feat(agent): the conversation menu moves to the chat's top right corner (#2583) 2026-11-13 20:20:16 -05:00
MaxsTechReview b3ebd54d87 Start a launcher-run game without scanning its folder and keep Play on Starting until it launches (#2586)
* Start a launcher-run game without scanning its folder and keep Play on Starting until it launches

* Create the shared added-games cache under one lock

* Read a rewritten game manifest again instead of reusing the saved ranking

* Tie a saved ranking to the declared executables that exist
2026-11-13 18:47:15 -05:00
MaxsTechReview 6d1a0d9fd0 fix(native): drive links stored as rootfs paths reach the game library mount (#2522)
* fix(native): drive links stored as rootfs paths reach the game library mount

* fix(native): relative drive links reach the game library mount

* fix(native): keep the path after a relative drive link as written

* fix(native): relative links that climb past the rootfs root stop at the guest root

Proton copies default_pfx/dosdevices/z: into each prefix with readlink and
symlink. The relinked target climbs as many folders as default_pfx is deep,
which is one more than a Steam prefix, so natively the kernel left the rootfs
and Z: pointed at the app's files folder. Proot stops ".." at the guest root;
the hook now does the same for links it resolves.

* fix(native): resolve drive links in prefixes stored in bind sources outside the rootfs

* fix(native): detect equal-length mount conversion for bound prefixes
2026-11-13 18:09:15 -05:00
MaxsTechReview bc929c08b2 fix(input): save Steam touch layout without existing config (#2580)
* fix(input): save Steam touch layout without existing config

* fix(input): preserve unreadable Steam touch config on save

* test(input): register configset in unreadable touch config fixture
2026-11-13 17:24:25 -05:00
Kurt Himebauch 0b8a3f1ee8 Add skip boot movie toggle (#2577)
* Add skip boot movie toggle

* Hide boot movie controls when skipping

* fix(session): resolve the skip movie key to its asset file
2026-11-13 16:17:03 -05:00
Kurt Himebauch 1e6aebd216 fix(agent): the pet's windows move without the system's move animation (#2582) 2026-11-13 16:02:40 -05:00
Kurt Himebauch 8a37e71e10 fix(agent): the agent's tools reach the running app's package and live adb port (#2571) 2026-11-13 13:15:55 -05:00
Kurt Himebauch 13b05656aa feat(agent): GitHub sign-in floats its device code over the browser (#2570)
* feat(agent): GitHub sign-in floats its device code over the browser

* fix(agent): the device code falls back to the browser when nothing could open

* fix(agent): dd-gh-login waits for DroidDeck to report whether the page opened
2026-11-13 13:15:24 -05:00
Kurt Himebauch 58af2e136b feat(storage): name, select and remove every prefix and store game (#2565)
* feat(storage): name, select and remove every prefix and store game

* feat(storage): bulk remove picks prefixes, shader caches or both

* fix(storage): count and clear a game's shader cache in every library

* fix(storage): guard shared prefixes, batches and active downloads

* fix(storage): count each shader cache once across games

* fix(storage): hold store uninstalls against downloads and keep every shortcut's options

* fix(stores): keep download cleanup and uninstall from overlapping

* fix(stores): wait for an installer's file discard before uninstalling

* fix(stores): a reinstall waits for the cancelled download's file cleanup

* fix(storage): fast first scan, readable 4:3 layout and every shader cache counted

* fix(storage): keep store sizes current and track discards from failing jobs

* fix(stores): uninstall waits for a cancelled update's cleanup

* test(stores): a reinstall waits for a failed job's discard
2026-11-13 12:32:24 -05:00
KeegantheVeganat0r 69b612be1f Fix Agent controls in the session drawer (#2568)
* Open full agent controls from compact composer

* Keep session drawer agent controls keyboard free

* Keep agent controls inline beside close

* Preserve Agent page Lab ABI compatibility

* Open session drawer editor with controls closed

* Consume Agent editor focus requests

* Keep session editor open during focus transition
2026-11-13 12:06:10 -05:00
rainleee 392562bfae fix(session): the Steam UI on the Mali bridge stops flickering (#2506)
* fix(session): the Steam UI on the Mali bridge stops flickering

On the Mali bridge Steam's own web helper layout makes the Deck UI footer
and overlays flicker (Mali-G78 MP14). When the browser UI is on the GPU,
default to ANGLE on Vulkan without Chromium's Vulkan compositing. Values
set by the user still win, and the software UI path is unchanged.

* fix(session): keep empty Mali bridge CEF settings as set
2026-11-13 11:47:31 -05:00
Kurt Himebauch 1b65508f56 feat(ui): reorder tabs, shelve them in More or hide them (#2569)
* feat(ui): reorder tabs, shelve them in More or hide them

* fix(ui): back from shelved tabs, startup tab and panel More count
2026-11-13 11:42:55 -05:00
K11MCH1 cd945a520a fix(dircache): Steam no longer deadlocks when a library below calls back in (#2560)
With "Run without proot" on, the Steam client hung about a second after
login and aborted three minutes later with "fatal stalled cross-thread
pipe". The directory cache holds its lock while it adds an inotify watch.
Without proot that call reaches the native userland hook, whose
inotify_add_watch creates a missing directory with mkdir() by name. That
mkdir resolves to the cache's own wrapper, which waits for the same lock
on the same thread. Steam's IPC threads then queue behind it.

The cache now counts the locks each thread holds. While a thread holds
one, calls that come back into the cache (opendir, the change wrappers,
created files, missing-name checks, closedir of a stream it did not open)
go straight to the next library. The same guard covers the hook's
remove(), which calls unlink() by name while the cache's remove wrapper
holds its operation lock.
2026-11-13 10:37:56 -05:00
FX1922 d33f4b4896 feat: Add Soundtracks tab and music player (#2389) 2026-11-13 08:49:48 -05:00
MaxsTechReview 33dbd8755f fix(agent): run the setup package install as fake root (#2539) 2026-11-13 08:48:23 -05:00
Kurt Himebauch d058bab64f fix(session): picture in picture keeps the DroidDeck front end behind the game (#2559) 2026-11-13 07:40:20 -05:00
Kurt Himebauch c57cc33125 fix(ui): the portrait bottom bar follows the sidebar labels setting (#2558) 2026-11-13 07:31:18 -05:00
Kurt Himebauch 83de0e7f8c feat(rockstar): broaden launcher protocol compatibility (#2547) 2026-11-13 06:17:12 -05:00
MaxsTechReview f33181e430 fix(proot): fchdir takes the open directory's path instead of walking it again (#2553)
* fix(proot): fchdir takes the open directory's path instead of walking it again

* fix(proot): fchdir keeps trailing-period names and rechecks the binding's parent

The descriptor path now carries the same final marker the walk produced, so a directory whose name ends with a period is not truncated. The parent of the matching binding is resolved again, so a binding whose ancestor was replaced by a symlink takes the full walk as before. The check script gains a trailing-period directory.

* fix(proot): fchdir requires the binding's parent to be a directory
2026-11-13 00:55:18 -05:00
Kurt Himebauch bb05e20d1b feat(library): pick the game resolution for games started without Steam (#2520) 2026-11-12 22:39:06 -05:00
Kurt Himebauch 1b732c1b65 Fix agent pet overlay permission and GitHub setup (#2548) 2026-11-12 22:38:22 -05:00
Kurt Himebauch 827ab2d485 fix(hud): FPS and clocks read right after sleep and wake (#2552)
* fix(hud): frame times follow the paused session's clock shift

* fix(hud): core clocks show their average over each sample
2026-11-12 22:18:39 -05:00
Kurt Himebauch d63193393d feat(ui): agent features start off and live in Setup > Developer (#2550) 2026-11-12 21:36:32 -05:00
Kurt Himebauch b841b232b4 feat(stores): add Rockstar store and classic GTA launches 2026-11-12 20:24:13 -05:00
DeathKhan 9cc37d0a12 fix(ui): header search keeps the header height and returns focus when it closes (#2543)
* fix(ui): keep the header height when search opens

The search field in the page header reserved a line for its empty label, which made the open field taller than the header row and pushed the page down.

* fix(ui): return focus to the search button when search closes

Closing the header search with Back removed the field while it held focus, so the highlight was lost. The search button takes focus once it is back on screen.
2026-11-12 20:11:34 -05:00
DeathKhan bd4bfce3af fix(apps): move straight down into a short last row (#2544)
Down from the row above a short last row landed on a tile further left, because the grid's own search only sees the tiles laid out so far. Down now goes to the tile directly below, or to the last tile when there is none below, and scrolls the next row in first when it is not laid out yet. Widgets record focus too, so the grid knows when focus is not on a tile.
2026-11-12 20:10:03 -05:00
KeegantheVeganat0r 60098d4a1b Render Agent Markdown and open web links in an external browser (#2546)
* Render Agent Markdown with clickable links in an external browser

* Preserve Markdown selection and expose table text to copy and accessibility
2026-11-12 20:08:07 -05:00
MaxsTechReview b5f6122d49 Stop walking SD card libraries on every session start and game launch (#2533)
* Stop searching whole libraries on every game launch and session start

The install script search ran over every library whenever any game's
manifest changed, and again on each launch. It now runs per game, only
when that game's build changes, and a launch that names its scripts
does no search at all.

A store game's shortcut walked its install folder on every scan instead
of reusing the ranking the scan keeps.

* Search a library for install scripts after the session has started, not before

* fix(session): keep deferred seeding off a running prefix and recheck old folder caches

* test(session): bound the held library search in the deferred seeding test

* fix(session): search a game again when its install script search failed
2026-11-12 16:03:41 -05:00
Kurt Himebauch 39a4a1b60c feat(agent): DeeDee, a floating pet that opens the agent's chat; chat-head flings for the pet and HUD (#2536)
* feat(agent): DeeDee, a pet that floats over any app and opens the agent's chat

* feat(agent): DeeDee docks and opens its chat like a chat head; throws pick their side by velocity, for the pet and the HUD

* fix(hud): the strip tucks into its fps tab with a shorter pull, and a throw toward an edge counts

* fix(hud): the HUD shows in desktop sessions again

* feat(agent): DeeDee rests tucked past the screen edge like a chat head

* fix(agent): DeeDee opens its own chat in every window, themed, and a fling across no longer tucks the HUD away

* fix(agent): the chat grows from wherever DeeDee is as it hops to its corner

* fix(agent): DeeDee hides with the PC keyboard, falls back if it cannot float, can be opened by accessibility, and settles when a drag is cancelled

* fix(agent): B and Back close DeeDee's in-window chat before the window acts on them

* fix(agent): Back closes only the chat open in that window
2026-11-12 15:07:58 -05:00
LunaDL b52ce7e4c5 Feat:Add per-game frame generation profiles (#2473) 2026-11-12 14:36:55 -05:00
measlesbagel b1b6ab7931 feat(apps): add icon packs, per-app icons and an Appearance panel (#2207)
* feat(apps): add an Appearance panel to the Apps page

A Palette button in the Apps header opens a panel for icon size, spacing and
hiding app names.

* feat(apps): support icon packs and per-app icons

The Appearance panel gains an Icon pack choice. Packs are found through the
ADW and Nova theme intents and must ship an appfilter.xml in res/xml, res/raw
or assets. Work profile apps keep their badge.

Apps a pack does not cover are drawn on its iconback, iconmask, iconupon and
scale tags when it has them, and keep their system icon otherwise. For packs
with an iconback, App color background paints that plate in each app's main
color instead of the pack's own.

With a pack selected, an app's long-press menu offers Change icon, which
opens a searchable picker listing icons that match the app first. Reset icon
removes one choice, and Reset in the panel removes them all.

Calendar apps use the pack's icon for today's date.

* feat(apps): translate the Appearance panel and icon strings

Adds the 19 new strings to all 32 languages, reusing each language's existing
wording where it has one. Icon size and spacing labels are kept short to fit
the panel's tabs.

* fix(apps): finish loading custom icons before marking them loaded

Two app list refreshes can start together on resume. The second one could
see the overrides as loaded before the first had read them, and build the
list without custom icons.
2026-11-12 12:57:12 -05:00
Kurt Himebauch dacfee64ab feat(agent): compact composer, plan go or revise, usage limits, diffs and send now (#2531)
* fix(runtime): the userland resolver survives a crash mid-write

* feat(agent): compact composer, plan go or revise, usage limits, diffs and send now
2026-11-12 12:21:36 -05:00
Kurt Himebauch 76f0c51235 feat(stores): show the pre-install size in store game details (#2438)
* feat(stores): show the download size in store game details

* test(stores): preserve other catalog sizes

* fix(stores): restart the pre-install size lookup when the item becomes accessible

* fix(stores): retry size lookups that returned no size

* fix(stores): complete shared size lookups only after a failed one is cleared

* fix(stores): complete synchronous size lookup failures without an API 31 call
2026-11-12 12:12:24 -05:00
Kurt Himebauch a1dfb96708 fix(steam): share the Steam app's prefix with shortcuts of the same install (#2463)
* fix(steam): share the Steam app's prefix with shortcuts of the same install

* fix(steam): prefer the matching install's save prefix

* fix(steam): tolerate an unreadable library when linking a shortcut prefix

A library folder that cannot be listed made the shortcut writer exit, so no added game was registered.

* fix(steam): repair a dangling shortcut prefix link and keep Steam library installs to their own prefix

* fix(steam): only change shortcut prefix links the importer created

* fix(steam): record a prefix link only when the importer created it
2026-11-12 12:11:45 -05:00
DeathKhan 52bf19ad8e feat(home): choose the page the Home button opens (#2493)
* feat(home): choose the page the Home button opens

As the Home app, DroidDeck always came back to whichever page was last
open, and a cold start landed on Steam. A new choice under Setup >
Launcher, shown while "Use as Home screen" is on, lets Home open the
Android apps page instead. The default stays Steam, which keeps the
current behaviour.

* fix(home): a Home request for the apps page closes a page open over the rail
2026-11-12 12:10:32 -05:00
DeathKhan bd022f04be fix(apps): center the folder title and rename by selecting it (#2492)
* fix(apps): center the folder title and rename by selecting it

The open folder showed its name on the left with a pencil button and a
close button. The title is now centered and is itself the rename
control: tap it, or highlight it and confirm. The close button is gone;
Back, B, or a tap outside the folder closes it as before.

* fix(apps): the folder title shows a faint chip at rest, so it reads as selectable
2026-11-12 12:10:05 -05:00
Kurt Himebauch a5712c0d20 feat(stores): EA and Ubisoft stores browse their catalogs, and EA's Get for free works in the app (#2527)
* feat(stores): EA and Ubisoft stores browse their catalogs with prices, deals and search

* feat(stores): Get for free adds EA's free games to the account in the app

* fix(stores): an owned EA game matches its store card by its full product name
2026-11-12 12:08:33 -05:00
KeegantheVeganat0r 08a8de9bc4 Fix Agent keyboard panning and collapsed landscape input (#2530)
* fix(agent): prevent Android panning the IME-aware chat

* fix(agent): reserve composer space before chat status panels
2026-11-12 11:38:31 -05:00
KeegantheVeganat0r 514f796428 Fix Agent composer keyboard spacing and scrolling (#2529)
* fix(agent): keep composer above the software keyboard

* fix(agent): place growing composer directly above keyboard
2026-11-12 11:07:39 -05:00
Kurt Himebauch 3b1366f85c feat(agent): choose the reasoning effort in the Agent tab (#2507)
* feat(agent): choose the reasoning effort in the Agent tab; agent processes survive Steam session cleanup; sdkmanager license step tolerates SIGPIPE

* docs(agent): on-device build and commit pitfalls for the agent
2026-11-12 10:23:38 -05:00
Kurt Himebauch c8dec0a8bc fix(stores): EA and Ubisoft libraries list only games the account can download (#2521)
* fix(stores): EA and Ubisoft libraries list only games the account can download

* fix(stores): keep owned games through entitlement and manifest lookup failures
2026-11-12 10:02:46 -05:00
MaxsTechReview a8237e8927 fix(memory): reclaim idle session memory under pressure (#2382) 2026-11-12 07:38:28 -05:00
Kurt Himebauch da5a36151b feat(ui): option to hide the Agent tab (#2515) 2026-11-12 02:10:34 -05:00
MaxsTechReview 01bfe8519e fix(session): preserve guest monotonic time after long pauses (#2393) 2026-11-12 01:25:21 -05:00
MaxsTechReview cd05c96d10 fix(proot): a call the filesystem does not implement no longer switches the fast path off (#2509)
Android's FUSE daemon has no symlink or link, so those calls on a storage card return ENOSYS. The fast path read any ENOSYS from its trampoline as a seccomp trap and stopped for the whole process. It now asks again with the same call number and invalid arguments: a trap answers ENOSYS again, anything else means the call reached the kernel and only that call is repeated. Folders opened for a refused call are still closed.
2026-11-12 00:13:00 -05:00
KeegantheVeganat0r b303423001 fix(lab): reuse installed add-on packs so the Agent can restart (#2512) 2026-11-12 00:02:26 -05:00
Kurt Himebauch 1882520cac fix(agent): the agent survives Steam session starts, stops and restarts (#2503)
* fix(agent): session starts and stops leave the agent's own processes running

* feat(agent): droiddeckctl ships with the app and the brief explains the Steam session
2026-11-11 23:46:48 -05:00
KeegantheVeganat0r 7da27d4ff4 feat: add build watermark toggle for Lab, test, and local builds (#2488) 2026-11-11 22:28:59 -05:00
MaxsTechReview 02a5be62da fix(input): a controller that disconnects mid-event no longer closes the app (#2369)
* fix(input): a controller that disconnects mid-event no longer closes the app

KeyEvent.getDevice() looks the device up on every call, so a controller removed while its event was handled made a later lookup return null and crashed in noteDevice. Look the device up once per event and ignore events whose device is gone.

* fix(input): retain controller layout during disconnect

* fix(input): look up the controller once per key and motion event
2026-11-11 21:57:56 -05:00
Kurt Himebauch 956f17239b fix(storage): Clean up keeps Proton EasyAntiCheat and BattlEye runtimes (#2254) 2026-11-11 20:56:30 -05:00
Kurt Himebauch 92d4959970 fix: run Final Fantasy VII Rebirth at D3D12 feature level 12_2 (#2289)
* fix: run Final Fantasy VII Rebirth at D3D12 feature level 12_2

* fix: match FF7 Rebirth by its real executables
2026-11-11 20:56:26 -05:00
MaxsTechReview 65554a544c fix(input): digital trigger keys work again on pads that also list analog axes (#2291)
Since #2205 a pad that lists an analog trigger axis had its L2/R2 keys
ignored. Handhelds whose triggers can be switched to digital keep listing
the axis but only send the keys in that mode, so the triggers stopped
responding.

A trigger key now presses its trigger when the axis is idle at that
moment and holds it until the key is released; motion events with an
idle axis keep it held. As soon as the axis reports a value it takes
over again, so pads that send both (the #2205 case) still follow their
analog axis and key repeats never change the value.
2026-11-11 20:56:19 -05:00
MaxsTechReview f4503c2eda fix(steam-x64): new store shortcuts get a compatibility tool (#2336)
fix: map new Steam shortcuts to x64 Proton
2026-11-11 20:56:15 -05:00
Kurt Himebauch 8ee50e5b38 fix(ea): retry rejected EA licence token requests (#2440)
* fix(ea): retry licence requests EA rejects for a transient token failure

* test(ea): cover bounded licence retries

* fix(ea): retry only token field rejections
2026-11-11 20:56:10 -05:00
DeathKhan afd2d91662 fix(input): B on a controller hides the on-screen keyboard before going back (#2498)
* fix(input): B on a controller hides the on-screen keyboard before going back

* fix(input): B sees the on-screen keyboard on Android 8 to 10 too
2026-11-11 20:55:56 -05:00
Kurt Himebauch 3230ccdc73 fix(steam): offer a Games folder as a Steam library when it is not already one (#2432)
* fix(steam): offer a Games folder as a Steam library when it is not already one

* test(steam): cover discovery with chosen storage

* fix(steam): compare Games folders and Steam libraries by the same storage path

The Games-folder overlap check used the raw canonical path, so a library saved under the raw card mount and the same folder under /storage were treated as different. Reuse the library canonicalisation.
2026-11-11 20:55:52 -05:00
MaxsTechReview c177b1eed1 fix(gog): installs no longer hang on Finishing for large games (#2367)
* fix(gog): list each folder once when checking install paths

The case-clash check listed a file's parent folder again for every file, so installing a game with thousands of files stayed on Finishing for a very long time after the download.

* fix(gog): check each install path prefix once instead of resolving every file
2026-11-11 20:55:48 -05:00
MaxsTechReview 8e02be2440 fix(steam-x64): skip empty runtime library folders when linking (#2334) 2026-11-11 20:55:45 -05:00
Kurt Himebauch a7bd6ed299 fix(venus): drop LIBGL_KOPPER_DISABLE without calling the guarded unsetenv (#2441) 2026-11-11 20:55:41 -05:00
Kurt Himebauch 8961d088f2 fix(desktop): run a store game's exe through its launcher so the EA environment and Origin process are set up (#2486)
* fix(desktop): run a store game's exe through its launcher so the EA environment and Origin process are set up

* fix(desktop): keep a store game's prefix and resolve its launcher through symlinks and deep folders

* fix(desktop): keep the exe's resolved compatdata folder when running its launcher and find the sidecar beside a symlinked exe
2026-11-11 20:55:37 -05:00
KeegantheVeganat0r 2953739f1e fix(lab): target the active app package and repair build setup (#2494)
* fix(lab): handle SDK licenses and cache Gradle planning

* fix(lab): target the package owning the agent session

* fix(lab): preserve package overrides across build handoff
2026-11-11 20:55:33 -05:00
MaxsTechReview ea48036811 fix(game-env): the VRAM cap also applies to D3D9 games (#2372)
* fix(game-env): the VRAM cap also applies to D3D9 games

DXVK's D3D9 frontend ignores dxgi.maxDeviceMemory, so set d3d9.maxAvailableMemory to the same cap.

* fix(vram): leave DXVK's lower per-game D3D9 limits in place above the 4096 MiB default
2026-11-11 20:55:30 -05:00
MaxsTechReview b3c61cf0bf fix: permissions set by Windows programs are kept on SD cards (#2504)
* fix: keep file permissions set by Windows programs on volumes without extended attributes

Wine's server stores a file's security descriptor in an extended attribute.
Volumes that cannot hold one dropped every descriptor, so a program that
checks and repairs its install folder's permissions repeated the repair on
every start. The descriptor is now kept inside the prefix when the volume
refuses it, and follows the file when the server renames or deletes it.

* fix: a path deleted with remove() drops its kept descriptor too
2026-11-11 20:45:23 -05:00
MaxsTechReview 3b6d13a8d7 fix: games on an SD card install faster and Battle.net can read the card's volume (#2379)
A Battle.net library on another volume is reached through its own drive letter, so the Agent's volume query succeeds. The proot fast path keeps folder handles for FUSE-backed libraries. Supersedes #2377.
2026-11-11 19:10:49 -05:00
Kurt Himebauch 1d247d212b fix(decky): run Decky's unprivileged role as root in the guest (#2481) 2026-11-11 17:39:48 -05:00
MaxsTechReview 7d5aae724c fix(ci): fetch the Venus component without spending the API quota (#2483) 2026-11-11 16:29:53 -05:00
Kurt Himebauch 263e96469f fix(agent): setup repairs a half-installed userland before installing the CLI (#2490) 2026-11-11 16:00:11 -05:00
1122 changed files with 108256 additions and 13388 deletions

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
ASEbrahim
FX192
FryMcNugget
K11MCH1
KeegantheVeganat0r
kingokksa
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
validate:
name: Validate source and build result
runs-on: ubuntu-24.04
timeout-minutes: 5
timeout-minutes: 70
steps:
- uses: actions/checkout@v4
with:
@@ -0,0 +1,35 @@
name: Build bionic runtime pack and DroidDeck-Bionic tool
on:
push:
paths:
- 'tools/bionic-runtime/**'
- 'tools/gamescope/patches/0117-wsi-cache-present-bypass-check.patch'
- 'tools/gamescope/patches/0119-wsi-default-images-under-limiter.patch'
- 'app/src/main/cpp/fakeinput_steam.cpp'
- 'tools/gpuload/**'
- '.github/workflows/build-bionic-runtime.yml'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Host tools
run: |
set -euo pipefail
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends libwayland-bin libwayland-dev libx11-dev libx11-xcb-dev \
libxcb1-dev libxcb-composite0-dev libglm-dev zstd
- name: Build
run: |
set -euo pipefail
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
export BUILD_NUMBER=${{ github.run_number }}
tools/bionic-runtime/build.sh "$RUNNER_TEMP/bionic-runtime" "$PWD/out"
- uses: actions/upload-artifact@v4
with:
name: droiddeck-bionic-runtime-${{ github.sha }}
path: out/*
+4 -1
View File
@@ -29,11 +29,14 @@ jobs:
persist-credentials: false
- name: Build in Arch Linux ARM
env:
GH_TOKEN: ${{ github.token }}
FEX_EXTRA_CXXFLAGS: ${{ inputs.cxxflags }}
FEX_THUNKS: ${{ inputs.thunks == 'true' && '1' || '0' }}
run: |
set -euo pipefail
docker run --rm -e FEX_EXTRA_CXXFLAGS="$FEX_EXTRA_CXXFLAGS" -e FEX_THUNKS="$FEX_THUNKS" -v "$PWD:/work" -w /work menci/archlinuxarm:base-devel bash tools/fex/build-in-arch.sh
FEX_VERSION=$(gh api repos/FEX-Emu/FEX/releases/latest --jq .tag_name)
echo "Building $FEX_VERSION, FEX's latest release"
docker run --rm -e FEX_VERSION="$FEX_VERSION" -e FEX_EXTRA_CXXFLAGS="$FEX_EXTRA_CXXFLAGS" -e FEX_THUNKS="$FEX_THUNKS" -v "$PWD:/work" -w /work menci/archlinuxarm:base-devel bash tools/fex/build-in-arch.sh
sudo chown -R "$(id -u):$(id -g)" .
- uses: actions/upload-artifact@v4
with:
+93 -21
View File
@@ -127,6 +127,7 @@ jobs:
name: xbox-arm64
path: app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
retention-days: 14
overwrite: true
- uses: actions/upload-artifact@v4
with:
name: xbox-corresponding-source
@@ -135,6 +136,7 @@ jobs:
app/build/xbox/runtime/*-source.tar.xz
if-no-files-found: error
retention-days: 14
overwrite: true
components-runner:
needs: source
@@ -150,6 +152,9 @@ jobs:
runs-on: ${{ fromJSON(needs.components-runner.outputs.labels) }}
timeout-minutes: 40
steps:
- name: Reclaim files a cancelled container build left owned by root
if: runner.environment == 'self-hosted'
run: sudo -n chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" || echo "::warning::could not reclaim $GITHUB_WORKSPACE"
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -190,17 +195,17 @@ jobs:
app/src/main/assets/linuxfs
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
!app/src/main/assets/linuxfs/i386/libblsession.so
!app/src/main/assets/linuxfs/i386/libddsession.so
!app/src/main/assets/linuxfs/i386/libfakeinput.so
!app/src/main/assets/linuxfs/i386/libfaultreport.so
!app/src/main/assets/linuxfs/libblaudit.so
!app/src/main/assets/linuxfs/libblfastpath.so
!app/src/main/assets/linuxfs/libddaudit.so
!app/src/main/assets/linuxfs/libddfastpath.so
!app/src/main/assets/linuxfs/libddnatv-hook.so
!app/src/main/assets/linuxfs/libblsession.so
!app/src/main/assets/linuxfs/libddsession.so
!app/src/main/assets/linuxfs/libfakeinput.so
!app/src/main/assets/linuxfs/libssbs.so
!app/src/main/assets/linuxfs/usr/local/bin/droiddeck-clipboard
!app/src/main/assets/linuxfs/x86_64/libblsession.so
!app/src/main/assets/linuxfs/x86_64/libddsession.so
!app/src/main/assets/linuxfs/x86_64/libfakeinput.so
!app/src/main/assets/linuxfs/x86_64/libfaultreport.so
!app/src/main/assets/linuxfs/x86_64/libvulkan-thunk.so
@@ -286,7 +291,7 @@ jobs:
- name: Build the non-Adreno test additions (Mali bridge client, Venus GL probe, Xclipse layer)
run: |
set -euo pipefail
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libvulkan-dev
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libc6-dev-arm64-cross libvulkan-dev
D=app/src/main/assets/linuxfs
mkdir -p "$D/usr/local/bin" "$D/usr/local/lib/droiddeck-xclipse"
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -pthread \
@@ -330,6 +335,7 @@ jobs:
if-no-files-found: error
compression-level: 0
retention-days: 14
overwrite: true
build-runner:
needs: [components]
@@ -347,6 +353,9 @@ jobs:
outputs:
variants: ${{ steps.variants.outputs.list }}
steps:
- name: Reclaim files a cancelled container build left owned by root
if: runner.environment == 'self-hosted'
run: sudo -n chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" || echo "::warning::could not reclaim $GITHUB_WORKSPACE"
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -562,6 +571,18 @@ jobs:
command -v x86_64-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-x86-64; }
bash tools/ubisoft-launcher/build.sh
- name: Rockstar launcher service (32-bit and 64-bit)
run: |
set -euo pipefail
command -v i686-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-i686; }
bash tools/rockstar-launcher/build.sh
- name: Epic Games Launcher parent stand-in (x86_64-pc-windows-gnu)
run: |
set -euo pipefail
command -v x86_64-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-x86-64; }
bash tools/epic-launcher/build.sh
- uses: actions/download-artifact@v4
with:
name: xbox-arm64
@@ -573,7 +594,7 @@ jobs:
path: |
~/.cache/droiddeck-pack-inputs
~/.cache/droiddeck-build
key: pack-inputs-v2-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env', 'tools/powervr/release.json') }}
key: pack-inputs-v2-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env', 'tools/packs/zstd/release.env', 'tools/powervr/release.json') }}
restore-keys: pack-inputs-v2-
- name: Build the add-on packs
run: |
@@ -604,25 +625,28 @@ jobs:
export NDK="$ANDROID_HOME/ndk/$NDK_VERSION"
tools/syncthing/build.sh app/src/main/jniLibs/arm64-v8a
- name: Note when the proot pack pin is behind this build
- name: Check the proot pack pin against this build
run: |
set -euo pipefail
# shellcheck disable=SC1091
source tools/packs/proot/release.env
sha=$(sha256sum app/build/packs/proot.tar.zst | cut -d' ' -f1)
if [ "$sha" != "$PROOT_PACK_SHA256" ]; then
echo "::warning::built proot pack $sha does not match tools/packs/proot/release.env ($PROOT_PACK_SHA256). This build publishes the pack it just built. Source builds keep downloading the pinned pack until release.env is updated."
size=$(stat -c %s app/build/packs/proot.tar.zst)
if [ "$sha" != "$PROOT_PACK_SHA256" ] || [ "$size" != "$PROOT_PACK_SIZE" ]; then
level=warning
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then level=error; fi
echo "::$level::built proot pack $sha ($size bytes) does not match tools/packs/proot/release.env ($PROOT_PACK_SHA256, $PROOT_PACK_SIZE bytes). Source builds download the pinned pack, so set PROOT_PACK_SHA256=$sha and PROOT_PACK_SIZE=$size in tools/packs/proot/release.env."
if [ "$level" = error ]; then exit 1; fi
fi
- name: Check out MaliBridge
run: git submodule update --init external/MaliBridge
- name: Fetch the Mali (Venus) component (tools/venus/release.env)
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
. tools/venus/release.env
gh release download "${VENUS_TAG}" -R "${VENUS_REPO}" -p venus.tzst -O venus.tzst
curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o venus.tzst \
"https://github.com/${VENUS_REPO}/releases/download/${VENUS_TAG}/venus.tzst"
echo "${VENUS_SHA256} venus.tzst" | sha256sum -c -
tar --use-compress-program=unzstd -xf venus.tzst -C app/src/main
test -f app/src/main/jniLibs/arm64-v8a/libvirgl_test_server.so
@@ -659,6 +683,7 @@ jobs:
name: stores-cargo-lock
path: app/src/main/rust/stores/Cargo.lock
if-no-files-found: ignore
overwrite: true
- name: Unit tests
id: unit-tests
@@ -682,6 +707,7 @@ jobs:
app/build/reports/tests/testReleaseUnitTest/
if-no-files-found: ignore
retention-days: 14
overwrite: true
- name: Sign with the testkey (v1 + v2 + v3)
run: |
@@ -719,6 +745,7 @@ jobs:
if-no-files-found: error
retention-days: 30
compression-level: 0
overwrite: true
- uses: actions/upload-artifact@v4
with:
@@ -727,6 +754,7 @@ jobs:
if-no-files-found: error
retention-days: 30
compression-level: 0
overwrite: true
- name: Report on the pull request
if: always() && github.event_name == 'pull_request'
@@ -747,7 +775,6 @@ jobs:
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
runs-on: ubuntu-24.04
timeout-minutes: 15
continue-on-error: true
permissions:
contents: read
actions: read
@@ -793,14 +820,16 @@ jobs:
stores-host-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.rust.outputs.rustc }}-
- name: Store engines host unit tests
timeout-minutes: 10
continue-on-error: true
run: |
set -o pipefail
cd app/src/main/rust/stores
cargo test --locked 2>&1 | tail -60
- name: Ubisoft launcher service host unit tests
- name: Windows launcher service host unit tests
timeout-minutes: 10
run: cargo test --locked --manifest-path tools/ubisoft-launcher/Cargo.toml
run: |
cargo test --locked --manifest-path tools/ubisoft-launcher/Cargo.toml
cargo test --locked --manifest-path tools/rockstar-launcher/Cargo.toml
cargo test --locked --manifest-path tools/epic-launcher/Cargo.toml
python-tests:
name: Python and native regression tests
@@ -835,7 +864,7 @@ jobs:
run: test "$(git rev-parse 'HEAD^{tree}')" = "$XBOX_SOURCE_TREE"
- name: Install Python test dependencies
timeout-minutes: 7
run: bash tools/ci/install-ubuntu-packages.sh python3-yaml gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user libvulkan-dev mesa-vulkan-drivers
run: bash tools/ci/install-ubuntu-packages.sh python3-yaml gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user libvulkan-dev mesa-vulkan-drivers spirv-tools
- name: Resolve the pinned Android NDK
run: bash tools/ci/resolve-ndk.sh
@@ -865,12 +894,22 @@ jobs:
-ldl -o /tmp/test-presenter-shutdown
timeout 10 /tmp/test-presenter-shutdown
- name: Fetch the Mali compatibility layer's headers
run: |
set -euo pipefail
sdk=$(sed -n 's/^SDK=//p' tools/venus/ci-build.sh)
bcdec=$(grep -o 'https://raw.githubusercontent.com/iOrange/bcdec/[^ ]*' tools/venus/ci-build.sh)
mkdir -p build/layer-deps/bcdec
git -c advice.detachedHead=false clone -q --depth 1 -b "$sdk" https://github.com/KhronosGroup/Vulkan-Headers.git build/layer-deps/vulkan
git -c advice.detachedHead=false clone -q --depth 1 -b "$sdk" https://github.com/KhronosGroup/SPIRV-Headers.git build/layer-deps/spirv
curl -sSfL -o build/layer-deps/bcdec/bcdec.h "$bcdec"
- name: Steam import and game environment tests
run: bash tools/ci/run-python-tests.sh
checks:
name: Compile and test APK
needs: [build, python-tests]
needs: [build, python-tests, store-tests]
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
runs-on: ubuntu-24.04
timeout-minutes: 5
@@ -879,7 +918,8 @@ jobs:
env:
BUILD_RESULT: ${{ needs.build.result }}
PYTHON_RESULT: ${{ needs.python-tests.result }}
run: test "$BUILD_RESULT" = success && test "$PYTHON_RESULT" = success
STORE_RESULT: ${{ needs.store-tests.result }}
run: test "$BUILD_RESULT" = success && test "$PYTHON_RESULT" = success && test "$STORE_RESULT" = success
sign:
needs: [build, checks]
@@ -923,7 +963,7 @@ jobs:
pull-requests: read
env:
CI_REPO: Droid-Deck/DroidDeck-CI
KEEP: 10
KEEP_DAYS: 14
steps:
- uses: actions/checkout@v4
with:
@@ -968,3 +1008,35 @@ jobs:
if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.announce.result != 'skipped' }}
uses: ./.github/workflows/update-catalog.yml
secrets: inherit
retire-tests:
needs: catalog
if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.catalog.result == 'success' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/create-github-app-token@v2
id: ci-token
with:
app-id: ${{ vars.DROIDDECK_CI_APP_ID }}
private-key: ${{ secrets.DROIDDECK_CI_APP_KEY }}
owner: Droid-Deck
repositories: DroidDeck-CI
- name: Delete the test builds this Preview build replaces
env:
SOURCE_GITHUB_TOKEN: ${{ github.token }}
CI_GITHUB_TOKEN: ${{ steps.ci-token.outputs.token }}
run: python3 tools/release/retire_test_builds.py
catalog-after-retire:
needs: retire-tests
if: ${{ always() && needs.retire-tests.result == 'success' }}
uses: ./.github/workflows/update-catalog.yml
secrets: inherit
+141
View File
@@ -0,0 +1,141 @@
name: PR Rebuild On Version Bump
run-name: rebuild test builds below versionCode on main
on:
push:
branches: [main]
paths: [app/build.gradle]
workflow_dispatch:
permissions:
actions: write
contents: read
issues: write
pull-requests: read
concurrency:
group: pr-rebuild-on-version
cancel-in-progress: false
queue: max
jobs:
rebuild:
runs-on: ubuntu-24.04
timeout-minutes: 180
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 2
persist-credentials: false
- name: Rebuild open PRs whose test build Android would refuse over main
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
PUSHED_AT: ${{ github.event.repository.pushed_at }}
run: |
set -euo pipefail
code() { sed -n 's/^[[:space:]]*versionCode[[:space:]][[:space:]]*\([0-9][0-9]*\)[[:space:]]*$/\1/p'; }
now=$(code < app/build.gradle)
[[ "$now" =~ ^[0-9]+$ ]] || { echo "::error::No numeric versionCode on main"; exit 1; }
if [ "$EVENT_NAME" = push ]; then
was=$(git show "$BEFORE:app/build.gradle" 2>/dev/null | code || true)
if [[ "$was" =~ ^[0-9]+$ ]] && [ "$was" -ge "$now" ]; then
echo "versionCode stayed at $now"
exit 0
fi
fi
# This run is created right after the push, so a PR build that started earlier may have pinned the old main.
bumped=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" --jq .created_at)
# A build can finish between the push and this run's creation; the push event carries the push time.
if [[ "${PUSHED_AT:-}" =~ ^[0-9]+$ ]]; then
pushed=$(date -u -d "@$PUSHED_AT" +%Y-%m-%dT%H:%M:%SZ)
[[ "$pushed" < "$bumped" ]] && bumped=$pushed
else
pushed=$(date -u -d "$bumped - 10 minutes" +%Y-%m-%dT%H:%M:%SZ)
fi
note() {
local number=$1
local marker="<!-- droiddeck-rebuild-$now -->"
gh api "repos/$GITHUB_REPOSITORY/issues/$number/comments?per_page=100" --jq '.[].body' | grep -qF "$marker" && return 0
gh api -X POST "repos/$GITHUB_REPOSITORY/issues/$number/comments" -f body="$marker
Main is now at versionCode $now, so this PR's test build no longer installs over current DroidDeck, and its last build is too old for GitHub to re-run. Push a commit or merge main to get a new test build." >/dev/null
}
latest() {
gh api "repos/$GITHUB_REPOSITORY/actions/workflows/build.yml/runs?event=pull_request&head_sha=$1&per_page=20" \
--jq '[.workflow_runs[] | select(.head_sha == "'"$1"'")] | sort_by(.created_at) | last // empty | [.id, .status, (.run_started_at // .created_at), .created_at, .updated_at] | @tsv'
}
consider() {
local number=$1 head=$2 built=$3 id status started created updated
IFS=$'\t' read -r id status started created updated <<<"$4"
if [[ "$started" > "$bumped" ]]; then
echo "PR #$number: build $id started after the bump"
elif ! gh api "repos/$GITHUB_REPOSITORY/pulls/$number" |
jq -e --arg head "$head" '.state == "open" and .draft == false and .base.ref == "main" and .head.sha == $head' >/dev/null; then
echo "PR #$number: moved on since the scan, its own build covers it"
elif gh run rerun "$id" -R "$GITHUB_REPOSITORY"; then
echo "PR #$number: rebuilding ${head:0:7} on main (versionCode $built -> $now)"
else
echo "::warning::PR #$number: could not rerun build $id"
# GitHub only re-runs a workflow within 30 days of its first run.
if [[ "$created" < "$(date -u -d '-30 days' +%Y-%m-%dT%H:%M:%SZ)" ]]; then
note "$number" || echo "::warning::PR #$number: could not leave a note"
fi
fi
}
pending=()
declare -A seen=()
candidates() {
gh api --paginate "repos/Droid-Deck/DroidDeck-CI/releases?per_page=100" \
--jq '.[] | select(.tag_name | test("^pr-[0-9]+$")) | [(.tag_name | ltrimstr("pr-")), ((.body // "") | capture("(?m)^VersionCode: (?<v>[0-9]+)").v // "0")] | @tsv'
# The latest build of every open PR: one that started before the bump and was still running at it
# may have pinned the old main. This also covers a PR's first build and fork builds.
gh api --paginate -X GET "repos/$GITHUB_REPOSITORY/pulls" -f state=open -f base=main -f per_page=100 \
--jq '.[] | select(.draft | not) | [(.number | tostring), .head.sha] | @tsv' |
while IFS=$'\t' read -r number sha; do
run=$(latest "$sha")
[ -n "$run" ] || continue
IFS=$'\t' read -r _ status started _ updated <<<"$run"
if [[ "$started" < "$bumped" ]] && { [ "$status" != completed ] || [[ ! "$updated" < "$pushed" ]]; }; then
printf '%s\t?\n' "$number"
fi
done
}
found=$(mktemp)
candidates > "$found"
while IFS=$'\t' read -r number built; do
[ "$built" = "?" ] || [ "$built" -lt "$now" ] || continue
[ -z "${seen[$number]:-}" ] || continue
seen[$number]=1
pr=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$number") || continue
jq -e '.state == "open" and .draft == false and .base.ref == "main"' <<<"$pr" >/dev/null || continue
head=$(jq -r .head.sha <<<"$pr")
run=$(latest "$head")
if [ -z "$run" ]; then
echo "PR #$number: no build of ${head:0:7} to rerun"
elif [ "$(cut -f2 <<<"$run")" = completed ]; then
consider "$number" "$head" "$built" "$run"
else
pending+=("$number $head $built")
fi
done < "$found"
# Builds still running are polled together so one slow build cannot hold up the rest.
deadline=$((SECONDS + 150 * 60))
while [ ${#pending[@]} -gt 0 ] && [ "$SECONDS" -lt "$deadline" ]; do
sleep 60
left=()
for item in "${pending[@]}"; do
read -r number head built <<<"$item"
run=$(latest "$head")
if [ -n "$run" ] && [ "$(cut -f2 <<<"$run")" = completed ]; then
consider "$number" "$head" "$built" "$run"
else
left+=("$item")
fi
done
pending=(${left[@]+"${left[@]}"})
done
for item in ${pending[@]+"${pending[@]}"}; do
echo "::warning::PR #${item%% *}: its build did not finish in time"
done
+8 -25
View File
@@ -40,36 +40,19 @@ jobs:
private-key: ${{ secrets.DROIDDECK_CI_APP_KEY }}
owner: Droid-Deck
repositories: DroidDeck-CI
- name: Delete the test build
if: ${{ steps.state.outputs.closed == 'true' }}
env:
GH_TOKEN: ${{ steps.ci-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
retry() {
for attempt in 1 2 3 4; do
"$@" && return 0
[ "$attempt" = 4 ] || sleep $((attempt * 20))
done
return 1
}
existing=$(retry gh api --paginate "repos/Droid-Deck/DroidDeck-CI/releases?per_page=100" --jq '.[].tag_name')
found=0
for tag in "pr-$PR_NUMBER" "pr-$PR_NUMBER.0"; do
if grep -qxF "$tag" <<<"$existing"; then
retry gh release delete "$tag" -R Droid-Deck/DroidDeck-CI --yes --cleanup-tag
echo "Deleted $tag"
found=1
fi
done
[ "$found" = 1 ] || echo "No test build for PR #$PR_NUMBER"
- uses: actions/checkout@v4
if: ${{ steps.state.outputs.closed == 'true' }}
with:
ref: main
persist-credentials: false
- name: Delete the test build unless main still needs it
if: ${{ steps.state.outputs.closed == 'true' }}
env:
SOURCE_GITHUB_TOKEN: ${{ github.token }}
CI_GITHUB_TOKEN: ${{ steps.ci-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
# A merged PR's build stays until a Preview build carries the merge; build.yml and the sweep remove it then.
run: python3 tools/release/retire_test_builds.py --pr "$PR_NUMBER"
- name: Retire the Discord PR announcement
if: ${{ steps.state.outputs.closed == 'true' }}
env:
+42 -6
View File
@@ -226,6 +226,8 @@ jobs:
publish:
needs: [authorize, sign]
runs-on: ubuntu-24.04
outputs:
keep: ${{ steps.publish.outputs.keep }}
permissions:
actions: read
contents: read
@@ -322,12 +324,8 @@ jobs:
cp pr-packs/* signed/ 2>/dev/null || true
gh release upload "$tag" signed/* -R "$repo" --clobber
gh release edit "$tag" -R "$repo" --title "PR #$PR_NUMBER" --notes "$notes" --prerelease
keep=$(cd signed && ls | jq -R . | jq -sc .)
gh api "repos/$repo/releases/tags/$tag" |
jq -r --argjson keep "$keep" '.assets[] | select(.name as $n | $keep | index($n) | not) | .id' |
while IFS= read -r id; do
gh api --method DELETE "repos/$repo/releases/assets/$id" >/dev/null
done
# The previous push's files stay until the catalog names these (the prune job), so a download started from the old catalog still finds its APK.
echo "keep=$(cd signed && ls | jq -R . | jq -sc .)" >> "$GITHUB_OUTPUT"
published=$(gh release view "$tag" -R "$repo" --json tagName,assets)
jq -e --arg tag "$tag" '.tagName == $tag and (.assets | length) > 0' <<<"$published" >/dev/null
@@ -417,3 +415,41 @@ jobs:
if: ${{ always() && needs.publish.result != 'skipped' }}
uses: ./.github/workflows/update-catalog.yml
secrets: inherit
prune:
needs: [authorize, publish, catalog]
if: ${{ always() && needs.publish.result == 'success' && needs.catalog.result == 'success' }}
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/create-github-app-token@v2
id: ci-token
with:
app-id: ${{ vars.DROIDDECK_CI_APP_ID }}
private-key: ${{ secrets.DROIDDECK_CI_APP_KEY }}
owner: Droid-Deck
repositories: DroidDeck-CI
- name: Remove the previous push's files
env:
GH_TOKEN: ${{ steps.ci-token.outputs.token }}
PR_NUMBER: ${{ needs.authorize.outputs.pr_number }}
KEEP: ${{ needs.publish.outputs.keep }}
run: |
set -euo pipefail
repo=Droid-Deck/DroidDeck-CI
tag="pr-$PR_NUMBER"
# An app that read the catalog just before it changed may still be starting that download.
sleep 300
# Delete nothing the published catalog still names.
named=$(gh api -H "Accept: application/vnd.github.raw+json" "repos/$repo/contents/catalog.json?ref=main" |
jq -c --argjson pr "$PR_NUMBER" '[.tests[] | select(.pr == $pr) | .apks[].name]')
stale=$(jq -nr --argjson named "$named" --argjson keep "$KEEP" '$named - $keep | join(" ")')
if [ -n "$stale" ]; then
echo "::warning::The catalog still names $stale; keeping every file of $tag"
exit 0
fi
gh api "repos/$repo/releases/tags/$tag" |
jq -r --argjson keep "$KEEP" '.assets[] | select(.name as $n | $keep | index($n) | not) | .id' |
while IFS= read -r id; do
gh api --method DELETE "repos/$repo/releases/assets/$id" >/dev/null
done
+14 -28
View File
@@ -26,32 +26,18 @@ jobs:
private-key: ${{ secrets.DROIDDECK_CI_APP_KEY }}
owner: Droid-Deck
repositories: DroidDeck-CI
- name: Delete test builds whose PR is no longer open
- uses: actions/checkout@v4
with:
ref: main
persist-credentials: false
- name: Delete test builds of closed PRs, and of merged PRs a Preview build carries
env:
CI_TOKEN: ${{ steps.ci-token.outputs.token }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
retry() {
for attempt in 1 2 3 4; do
"$@" && return 0
[ "$attempt" = 4 ] || sleep $((attempt * 20))
done
return 1
}
tags=$(GH_TOKEN="$CI_TOKEN" retry gh api --paginate "repos/Droid-Deck/DroidDeck-CI/releases?per_page=100" --jq '.[].tag_name' |
grep -E '^pr-[0-9]+(\.0)?$' || true)
failed=0
for tag in $tags; do
number=${tag#pr-}
number=${number%.0}
state=$(retry gh api "repos/$GITHUB_REPOSITORY/pulls/$number" --jq .state) || { failed=1; continue; }
if [ "$state" != open ]; then
if GH_TOKEN="$CI_TOKEN" retry gh release delete "$tag" -R Droid-Deck/DroidDeck-CI --yes --cleanup-tag; then
echo "Deleted $tag (PR #$number is $state)"
else
failed=1
fi
fi
done
exit "$failed"
SOURCE_GITHUB_TOKEN: ${{ github.token }}
CI_GITHUB_TOKEN: ${{ steps.ci-token.outputs.token }}
run: python3 tools/release/retire_test_builds.py
catalog:
needs: sweep
if: ${{ always() }}
uses: ./.github/workflows/update-catalog.yml
secrets: inherit
+1 -1
View File
@@ -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; do
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt epic; 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)
+2
View File
@@ -36,3 +36,5 @@ __pycache__/
app/src/main/assets/directaudio/
app/src/main/assets/hybris/
/tools/vr/out/
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar/
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-epic/
+10
View File
@@ -1,3 +1,13 @@
# Rules
- Comments should be rare, factual, and explain only non-obvious external constraints or business invariants.
# Working on the device
- `dd-lab-build` builds only committed work. Check `git status` and `gh api user` for the identity before committing; if `git config user.name` is empty, use the `gh` login's name and noreply email for this repo, never a guess.
- Do not commit or start a build in the same step: a build started next to a failed commit fails too. Commit first, check it, then build.
- Uncommitted changes in the tree may not be yours. Read `git diff` before committing them and tell the user what they do.
- If `dd-lab-build` says "could not read DroidDeck's state", loopback adb is down and `$ADB_SERIAL` is stale. Run `adb devices`; the port changes whenever wireless debugging is toggled. Ask the user to turn it on rather than retrying.
- A build that "did not start" can be adb, not the app. Read `~/.cache/dd-lab-build.json` and `.log` for the real reason; they can be stale from an earlier build, so compare their times with `date`.
- Run `dd-lab-build` with `run_in_background` and read its output file. A foreground `sleep` is blocked; wait with Monitor and an until-loop.
- The build restarts DroidDeck and ends your process. A turn that ends this way is not a failure.
+13 -9
View File
@@ -25,7 +25,7 @@ DroidDeck brings the SteamOS experience to Android: Steam Gaming Mode, full Linu
<p align="center"><img src="docs/media/steam-to-desktop.gif" width="100%" alt="On a Retroid Pocket Duo: Play Steam from the DroidDeck launcher, open Pac-Man in Steam Big Picture and play it, exit the game, then Switch to Desktop from the Power menu"></p>
> DroidDeck has no website. Only download it from this repository's [Releases](https://github.com/Droid-Deck/DroidDeck/releases).
> The official website is [droid-deck.dev](https://droid-deck.dev). Only download DroidDeck from this repository's [Releases](https://github.com/Droid-Deck/DroidDeck/releases).
<p align="center">
<img src="docs/releases/media/0.6.7/library.gif" width="49%" alt="The Library switching source chips, changing the card size and opening the Filter menu">
@@ -47,7 +47,7 @@ Help, Preview builds and device reports are on [Discord](https://discord.gg/JRGA
## Build
Needs Docker, Java 17, the Android SDK and NDK, Rust via rustup, GitHub CLI, Python 3 and `zstd`.
Needs Docker, Java 17, the Android SDK and NDK, Rust via rustup, Go, a host C compiler, the x86_64 and i686 MinGW-w64 compilers (i686 with DWARF-2 exceptions, as Debian and Ubuntu ship it; SJLJ builds such as Homebrew's cannot link Rust's `i686-pc-windows-gnu`), GitHub CLI, Python 3 and `zstd`. On x86_64 Linux, Docker also needs an arm64 binfmt handler (`docker run --privileged --rm tonistiigi/binfmt --install arm64`).
```bash
tools/build_local.sh
@@ -70,17 +70,18 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
- Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05.
- mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)).
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT). FEX's code disk cache was checked in its source.
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source.
- x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence.
- x86 programs linking OpenSSL 3 use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt). x86 Linux games get the `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes.
- `WriteProcessMemory` hooks fall back to `/proc/<pid>/mem` the way [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` did before Wine 11.
- Wine write watches use userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later). libblsession supplies the arm64 syscall number and answers `PAGEMAP_SCAN` from `/proc/self/pagemap`.
- libblsession runs Wine's arm64 `SIGUSR2` context handler (`dlls/ntdll/unix/signal_arm64.c`, LGPL-2.1-or-later) in place on a frame laid out like [Linux](https://github.com/torvalds/linux)'s `arch/arm64/kernel/signal.c`, and serves `fill_vm_counters` in `dlls/ntdll/unix/process.c` the kernel's own `/proc/<pid>/status`.
- Windows programs on noexec storage get executable copies of their image pages, following [@yujikaido](https://github.com/yujikaido)'s finding in [droiddeck-rp4pro](https://github.com/yujikaido/droiddeck-rp4pro) that Wine's own processes need the noexec shim.
- Wine write watches use userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later). libddsession supplies the arm64 syscall number and answers `PAGEMAP_SCAN` from `/proc/self/pagemap`.
- libddsession runs Wine's arm64 `SIGUSR2` context handler (`dlls/ntdll/unix/signal_arm64.c`, LGPL-2.1-or-later) in place on a frame laid out like [Linux](https://github.com/torvalds/linux)'s `arch/arm64/kernel/signal.c`, and serves `fill_vm_counters` in `dlls/ntdll/unix/process.c` the kernel's own `/proc/<pid>/status`.
- droiddeck-ntsync follows the [Linux](https://github.com/torvalds/linux) ntsync semantics in `Documentation/userspace-api/ntsync.rst` (GPL-2.0).
- The proot fast path orders bindings like [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later).
- DiRT 3 and DiRT Showdown keep their telemetry socket the way RoccoC's DiRTTelemetryErrorFix (MIT) does, based on the fix by Carsten Gottschling.
- Zink on PowerVR keeps colour textures in colour with Icenowy Zheng's upstream [Mesa](https://gitlab.freedesktop.org/mesa/mesa) fix d55418dae7 (MIT), carried as a runtime patch.
- Games and AppImage, Flatpak and Snap programs such as emulators use [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's per render pass memory choice. The Steam client and Chromium-based apps keep `TU_DEBUG=sysmem`.
- Games and AppImage, Flatpak and Snap programs such as emulators use `TU_DEBUG=sysmem` by default, as does the Steam client. Turnip sysmem rendering can be turned off in Performance settings, except with the Adreno 710/720 driver, which always uses it.
- Black Ops III and Dark Souls Remastered start without [umu-protonfixes](https://github.com/Open-Wine-Components/umu-protonfixes) (BSD-2-Clause), whose `311210.py` and `570940.py` fail under ARM64 Proton.
- [ReSkate](https://github.com/Dingo-Shenanigans/ReSkate) (GPL-3.0) by Dingo Shenanigans uses the launch option from its README and D3D12 feature level 12_1.
- The arm64 client's sign in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest).
@@ -90,14 +91,16 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
<details>
<summary><b>Stores</b></summary>
- Epic Games and GOG build on [Phobos](https://github.com/phobos665)'s adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl). GOG install script registry entries are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) (GPL-3.0) reads them.
- Epic Games and GOG build on [Phobos](https://github.com/phobos665)'s adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl). GOG install script registry entries are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) (GPL-3.0) reads them. GOG cloud storage requests send the Galaxy communication-service User-Agent that gogdl and [Lutris](https://github.com/lutris/lutris) (GPL-3.0) send.
- Epic's official Linux launcher preview runs through FEX. That setup is outside Epic's listed Linux support.
- The launcher's .deb gets the WebKitGTK and GTK 3 libraries it needs from unmodified [Debian](https://www.debian.org) 13 packages, following [@zooluis](https://github.com/zooluis)'s research in [#2268](https://github.com/Droid-Deck/DroidDeck/pull/2268).
- Battle.net is by [@kayakyakr](https://github.com/kayakyakr). It runs Blizzard's own client in Proton (downloaded from Blizzard, not included) and shows key art from the [Battle.net Shop](https://shop.battle.net). Without Steam, its games see the pad as an Xbox 360 controller via `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`.
- The EA store follows the EA app's protocols as documented by [ArmchairDevelopers](https://github.com/ArmchairDevelopers)' [Maxima](https://github.com/ArmchairDevelopers/Maxima) (GPL-3.0): sign-in, the GraphQL queries (included verbatim, since EA matches them by hash), build archives, online activation licences and the LSX game endpoint. The code is DroidDeck's own.
- Battle.net installs drive Blizzard's Agent the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) does, with requests from [wowdev.wiki](https://wowdev.wiki/Agent). Read without taking code: [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader.
- The Rockstar launcher service looks for launcher pipe names in the executables beside the game, since [CitizenFX](https://github.com/citizenfx/fivem)'s `ros-patches-five` shows GTA V opening `GTAVLauncher_Pipe` and [@pingod](https://github.com/pingod)'s [rdr2-linux-launcher](https://github.com/pingod/rdr2-linux-launcher) notes that Rockstar's protected executables resolve such strings only at run time. Read without taking code.
- World of Warcraft addon imports replace an addon's folder from a temporary copy, as [WowUp](https://github.com/WowUp/WowUp) does, and read flavour folders the way [WoWDeck](https://github.com/sigboe/wowdeck) does. No code from either is used.
- The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. [CurseForge](https://www.curseforge.com/wow) opens in the user's browser, with no API and no key.
- Xbox games load [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) modules (LGPL-2.1-or-later), including `wintypes.dll`. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT).
- The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. Installed addons show their `.toc` version and `X-WoWI-ID`, and are checked against that list for updates, as [WowUp](https://github.com/WowUp/WowUp) does. The Addons tab installs the official [CurseForge](https://www.curseforge.com/download/app) Linux app from CurseForge's own update feed (downloaded at install time and checked against its SHA-512, not included), which keeps its own sign-in.
- The Xbox store runs [@domsvoboda](https://github.com/domsvoboda)'s [nexus-backend](https://github.com/domsvoboda/nexus-backend) 0.2.15 (GPL-3.0, a fork of [Xodus](https://github.com/xodus-gaming/xodus)), and Xbox games load the Windows modules of his [nexus-runtime](https://github.com/domsvoboda/nexus-runtime) (LGPL-2.1-or-later), including the C++ [nexus-xgameruntime](https://github.com/domsvoboda/nexus-xgameruntime) and `wintypes.dll`. Content licensing sends delegation-compact device tickets in the licensing wire form, as nexus-backend's Store license path (commit `27c335e`) does. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT).
- The Xbox Cloud Gaming player uses the WebRTC client of [@unknownskl](https://github.com/unknownskl)'s [Greenlight](https://github.com/unknownskl/greenlight) (MIT), and its offer tweaks and sharpening follow [@redphx](https://github.com/redphx)'s [Better xCloud](https://github.com/redphx/better-xcloud) (MIT). See `tools/xcloud-player/NOTICE.md`.
- The itch.io butler pack ships butler's `7z.so`, itch.io's build of [7-Zip](https://www.7-zip.org) by Igor Pavlov (LGPL-2.1, unRAR restriction on RAR code), unmodified. Other archives use Apache Commons Compress and the runtime's bsdtar (libarchive).
- The Store uses [Flatpak](https://github.com/flatpak/flatpak) (LGPL-2.1) through DroidDeck's own bubblewrap shim. Chromium and Electron apps start directly, since [zypak](https://github.com/refi64/zypak) by [@refi64](https://github.com/refi64) (BSD-3-Clause) always uses Flatpak's spawn portal.
@@ -112,6 +115,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
- The DroidDeck HUD is [@The412Banner](https://github.com/The412Banner)'s [FusionHUD](https://github.com/The412Banner/FusionHUD) (GPL-3.0 with an attribution term). Its readings match Valve's [MangoHud](https://github.com/flightlessmango/MangoHud) build (MIT), with frame times from gamescope patch 0125.
- The HUD's CPU, GPU load, thermal and battery readers come from [@xXJSONDeruloXx](https://github.com/xXJSONDeruloXx)'s work.
- LSFG frame generation comes from Camille LaVey and the [Eden](https://eden-emu.dev) project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported by [@maxjivi05](https://github.com/maxjivi05). It needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders.
- Black frame insertion follows the design of [@artzox](https://github.com/artzox)'s [BFI Presenter](https://github.com/artzox/BFI-Presenter) (GPL-3.0): the strobe runs on the display's refresh clock and the game is paced to the lit refresh. Both build on [Blur Busters](https://blurbusters.com)' research on MPRT and motion blur. No BFI Presenter code is used.
- Remote Play decodes through Android's MediaCodec or the [FFmpeg](https://ffmpeg.org) (LGPL-2.1-or-later) in Steam's runtime. Qualcomm low latency settings follow [Moonlight](https://github.com/moonlight-stream/moonlight-android) (GPL-3.0).
- [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) sockets use the settings in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions.
+29 -8
View File
@@ -93,7 +93,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'].collectEntries { name ->
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
def pack = file("build/packs/${name}.tar.zst")
if (!pack.isFile()) {
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
@@ -130,7 +130,7 @@ android {
defaultConfig {
applicationId "com.droiddeck.launcher"
minSdkVersion 26
targetSdkVersion 28
targetSdkVersion 34
versionCode 19
versionName "0.7.1"
buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\""
@@ -141,6 +141,7 @@ android {
buildConfigField "boolean", "CI_BUILD", "${ciBuild}"
buildConfigField "String", "RELEASE_SIGNER", "\"${releaseSigner}\""
buildConfigField "long", "COMMIT_TIME", "${commitTime}L * 1000L"
buildConfigField "String", "UPDATE_CATALOG_BRANCH", "\"${(System.getenv("DROIDDECK_UPDATE_CATALOG_BRANCH") ?: "main").with { it ==~ /[A-Za-z0-9._-]+/ ? it : "main" }}\""
buildConfigField "String", "VARIANT_SUFFIXES", "\"${variantSuffixes}\""
buildConfigField "String", "SGDB_API_KEY", "\"${System.getenv("SGDB_API_KEY") ?: project.findProperty("sgdbApiKey") ?: ""}\""
buildConfigField "String", "DESKTOP_KDE_TAG", "\"${desktopKde.DESKTOP_KDE_TAG}\""
@@ -200,12 +201,8 @@ android {
}
}
lint {
disable 'ExpiredTargetSdkVersion'
}
androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<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>directaudio:<dir>hybris'
}
packagingOptions {
@@ -215,7 +212,7 @@ android {
jniLibs {
useLegacyPackaging = true
pickFirsts += ['**/libtermux.so']
excludes += ['**/libproot.so', '**/libproot-loader.so', '**/libopencv_java4.so', '**/libmediapipe_tasks_jni.so']
excludes += ['**/libproot.so', '**/libopencv_java4.so', '**/libmediapipe_tasks_jni.so']
}
}
@@ -277,6 +274,10 @@ def stageRuntimeAssets = tasks.register('stageRuntimeAssets', Sync) {
dependsOn(stageSessionScripts)
from(layout.projectDirectory.dir('src/main/assets')) { exclude 'pulseaudio.tzst' }
from(rootProject.file('tools/linuxfs/innoextract'))
from(rootProject.file('tools')) { include 'droiddeckctl', 'droiddeck-scenario', 'adb_device.py', 'proot_profile.py'; into('agent/ctl') }
from(rootProject.file('tools/agent/AGENTS.md')) { into('agent/ctl') }
from(rootProject.file('docs/agent-control.md')) { into('agent/ctl') }
from(rootProject.file('tools/agent/skills')) { into('agent/skills') }
from(layout.buildDirectory.dir('prepared-assets'))
into(runtimeAssetsDir)
}
@@ -292,6 +293,16 @@ if (uvcDir) {
}
tasks.named('preBuild').configure { dependsOn(stageRuntimeAssets) }
android.sourceSets.main.java.srcDir(rootProject.file('shortcuts/src/protocol/java'))
def stageShortcuts = tasks.register('stageShortcuts', Copy) {
dependsOn(':shortcuts:assembleRelease')
from(project(':shortcuts').layout.buildDirectory.file('outputs/apk/release/shortcuts-release.apk'))
into(layout.buildDirectory.dir('shortcutsAssets'))
rename { 'shortcuts.apk' }
}
android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('shortcutsAssets'))
tasks.named('preBuild').configure { dependsOn(stageShortcuts) }
def stageGogNotices = tasks.register('stageGogNotices', Copy) {
from(layout.projectDirectory.dir('src/main/rust/stores/vendor/xdelta3')) { include 'LICENSE', 'README.droiddeck.md' }
into(layout.buildDirectory.dir('gogNotices/licenses/xdelta3'))
@@ -377,9 +388,16 @@ dependencies {
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'
// Declares the ComponentActivity that createComposeRule launches, for PreviewRenderTest.
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.compose.material:material-icons-extended'
implementation 'io.coil-kt:coil-compose:2.6.0'
implementation 'io.noties.markwon:core:4.6.2'
implementation 'io.noties.markwon:ext-strikethrough:4.6.2'
implementation 'io.noties.markwon:ext-tables:4.6.2'
implementation 'io.noties.markwon:ext-tasklist:4.6.2'
implementation 'com.atlassian.commonmark:commonmark-ext-autolink:0.13.0'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'com.flyfishxu:kadb-android:1.2.1'
@@ -387,11 +405,14 @@ dependencies {
implementation 'androidx.camera:camera-camera2:1.4.2'
implementation 'androidx.camera:camera-lifecycle:1.4.2'
implementation 'androidx.webkit:webkit:1.12.1'
implementation 'androidx.palette:palette:1.0.0'
implementation 'io.github.webrtc-sdk:android:125.6422.07'
implementation("com.google.mediapipe:tasks-vision:${trackingPack.MEDIAPIPE_VERSION}") {
exclude group: 'com.google.auto.value', module: 'auto-value'
}
implementation 'com.google.zxing:core:3.5.3'
implementation 'androidx.media3:media3-exoplayer:1.3.1'
implementation 'androidx.media3:media3-session:1.3.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.16.1'
@@ -0,0 +1,79 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.droiddeck.launcher.R
import com.droiddeck.launcher.input.SecondScreenMode
/** The launcher as a whole: rail and page, opened on each tab through FrontEndState.navigate. */
@Composable
private fun Launcher(tab: String, games: List<com.droiddeck.launcher.frontend.Library.SteamGame> = sampleGames, ready: Boolean = true) =
PreviewHost { FrontEndScreen(sampleState(games = games, navigate = tab, ready = ready), sampleActions) }
@DroidDeckPreviews @Composable private fun SteamTabPreview() = Launcher("steam")
@DroidDeckPreviews @Composable private fun LibraryPreview() = Launcher("games")
@DroidDeckPreviews @Composable private fun LibraryEmptyPreview() = Launcher("games", games = emptyList())
@DroidDeckPreviews @Composable private fun StoresPreview() = Launcher("stores")
@DroidDeckPreviews @Composable private fun DownloadsPreview() = Launcher("downloads")
@DroidDeckPreviews @Composable private fun SettingsPreview() = Launcher("setup")
@DroidDeckPreviews @Composable private fun RuntimeMissingPreview() = Launcher("setup", ready = false)
/** The in-game menu on one page, as a session shows it. */
@Composable
private fun SessionMenu(page: SessionDrawerPage, steam: Boolean = true, desktop: Boolean = false) = PreviewHost {
SessionDrawer(true, page, controllerActive = true, onPageChange = {}, a = sampleDrawerActions(steam, desktop))
}
@DroidDeckPreviews @Composable private fun SessionMenuControllerPreview() = SessionMenu(SessionDrawerPage.CONTROLLER)
@DroidDeckPreviews @Composable private fun SessionMenuDisplayPreview() = SessionMenu(SessionDrawerPage.DISPLAY)
@DroidDeckPreviews @Composable private fun SessionMenuHudPreview() = SessionMenu(SessionDrawerPage.HUD)
@DroidDeckPreviews @Composable private fun SessionMenuSessionPreview() = SessionMenu(SessionDrawerPage.SESSION)
@DroidDeckPreviews @Composable private fun SessionMenuDesktopPreview() = SessionMenu(SessionDrawerPage.CONTROLLER, steam = false, desktop = true)
/** The in-game menu docked on the bottom screen, with the screen picker in its header. */
@Composable
private fun DockedMenu(page: SessionDrawerPage) = PreviewHost {
SessionDrawer(true, page, controllerActive = false, onPageChange = {},
a = sampleDrawerActions(secondScreen = SecondScreenMode.KEYBOARD_TRACKPAD), docked = true)
}
/** The bottom screen's bar on a panel: the panel's name is the screen picker. */
@Composable
private fun BottomPanelBar() = PreviewHost {
val modes = secondScreenModes(false, deckPad = false, dashboard = true, desktop = false)
Column(Modifier.fillMaxSize().background(Color.Black)) {
BottomScreenBar(BottomBarModel("Keyboard + trackpad", {}, {}, {}, {},
listOf(BarExtra("Keyboard", icon = R.drawable.ic_bottom_keyboard) {}),
picker = ScreenPicker(modes, SecondScreenMode.KEYBOARD_TRACKPAD, {}, onMenu = {})))
}
}
@DroidDeckPreviews @Composable private fun SessionMenuDockedPreview() = DockedMenu(SessionDrawerPage.CONTROLLER)
@DroidDeckPreviews @Composable private fun SessionMenuDockedDisplayPreview() = DockedMenu(SessionDrawerPage.DISPLAY)
@DroidDeckPreviews @Composable private fun BottomPanelBarPreview() = BottomPanelBar()
/** The Library and Stores tabs read store accounts, which load on a background thread. */
private val storesLoaded = { com.droiddeck.launcher.stores.StoresState.accountsLoaded }
/** Every preview above, for the render test. Add a case when adding a preview. */
internal val previewCases: List<PreviewCase> = listOf(
PreviewCase("steam-tab") { Launcher("steam") },
PreviewCase("library", storesLoaded) { Launcher("games") },
PreviewCase("library-empty", storesLoaded) { Launcher("games", games = emptyList()) },
PreviewCase("stores", storesLoaded) { Launcher("stores") },
PreviewCase("downloads") { Launcher("downloads") },
PreviewCase("settings") { Launcher("setup") },
PreviewCase("runtime-missing") { Launcher("setup", ready = false) },
PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) },
PreviewCase("session-menu-display") { SessionMenu(SessionDrawerPage.DISPLAY) },
PreviewCase("session-menu-hud") { SessionMenu(SessionDrawerPage.HUD) },
PreviewCase("session-menu-session") { SessionMenu(SessionDrawerPage.SESSION) },
PreviewCase("session-menu-desktop") { SessionMenu(SessionDrawerPage.CONTROLLER, steam = false, desktop = true) },
PreviewCase("session-menu-docked") { DockedMenu(SessionDrawerPage.CONTROLLER) },
PreviewCase("session-menu-docked-display") { DockedMenu(SessionDrawerPage.DISPLAY) },
PreviewCase("bottom-panel-bar") { BottomPanelBar() },
)
@@ -0,0 +1,88 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.gpu.FrameGen
import com.droiddeck.launcher.gpu.Lossless
import com.droiddeck.launcher.input.SecondScreenDisplay
import com.droiddeck.launcher.input.SecondScreenMode
import com.droiddeck.launcher.session.SessionPrefs
/**
* Debug-only support for Compose previews: the production theme around a screen, and sample state and no-op actions so
* production composables render without a device, a runtime or a network. See docs/compose-previews.md.
*/
/** The sizes the previews come in. The Duo's top screen is 1920x1080 at xhdpi, i.e. 960x540 dp. */
@Preview(name = "Handheld", widthDp = 960, heightDp = 540, device = "spec:width=960dp,height=540dp,dpi=320,orientation=landscape")
@Preview(name = "Portrait", widthDp = 540, heightDp = 960, device = "spec:width=540dp,height=960dp,dpi=320")
internal annotation class DroidDeckPreviews
@Composable
internal fun PreviewHost(content: @Composable () -> Unit) {
DroidDeckTheme {
Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) { content() }
}
}
/**
* A case the render test draws: a name for its PNG and the preview's content. [ready] is what the test waits for before
* drawing, for a screen that loads something off the main thread first.
*/
internal class PreviewCase(val name: String, val ready: () -> Boolean = { true }, val content: @Composable () -> Unit) {
override fun toString() = name
}
internal val sampleGames: List<Library.SteamGame> = listOf(
"Portal 2" to 620, "Hades" to 1145360, "Celeste" to 504230, "Stardew Valley" to 413150, "Hollow Knight" to 367520,
"Balatro" to 2379780, "Dead Cells" to 588650, "Terraria" to 105600, "Vampire Survivors" to 1794680, "Slay the Spire" to 646570,
).mapIndexed { i, (name, appId) ->
Library.SteamGame(appId, name, art = null, library = "steam", lastPlayed = 1_700_000_000_000L - i * 86_400_000L)
}
internal fun sampleState(
games: List<Library.SteamGame> = sampleGames,
navigate: String? = null,
ready: Boolean = true,
): FrontEndState = FrontEndState(
installed = "ubuntu-r1", ready = ready, available = "ubuntu-r1", busy = false, stage = "", percent = 0,
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "Off", romsDir = null, logsEnabled = true,
steamGames = games, emulators = emptyList(), running = null, navigate = navigate,
)
internal val sampleActions: FrontEndActions = FrontEndActions(
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {},
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {},
onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {},
onFiles = {}, onLogs = {}, onOffline = {},
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> }, onSetPhantomProcessLimit = { _, _ -> },
)
/** The in-game menu's actions with settled sample values; its switches do nothing. */
internal fun sampleDrawerActions(
steam: Boolean = true, desktop: Boolean = false, secondScreen: SecondScreenMode? = null,
): DrawerActions = DrawerActions(
steam = steam, desktop = desktop, title = if (!steam && !desktop) "Hades" else null,
isHomeApp = false, androidApps = emptyList(),
hudOn = true, onHud = {},
frameGen = FrameGen.Mode.OFF, onFrameGenPick = {},
lossless = Lossless.State.NONE,
oscMode = SessionPrefs.OSC_AUTO, onOsc = {},
suspendPolicy = SessionPrefs.SUSPEND_MANUAL, onSuspendPolicy = {},
backActionsInverted = false, onBackActionsInverted = {},
touchMode = SessionPrefs.TOUCH_AUTO, onTouch = {}, touchAuto = "Auto (direct)",
fexPreset = "", onFexPreset = {},
secondScreenMode = secondScreen ?: SecondScreenMode.NONE, onSecondScreenMode = {}, secondScreenNone = secondScreen == null,
secondScreenDisplays = listOfNotNull(secondScreen?.let { SecondScreenDisplay(2, "Built-in · 1240×1080") }),
selectedSecondScreenDisplay = if (secondScreen != null) 2 else -1, onSecondScreenDisplay = {},
gameSwapAvailable = secondScreen != null, dashboardAvailable = secondScreen != null,
onImportLossless = {}, onKeyboard = {}, onHardwareKeyboard = {},
onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null,
onLaunchAndroidApp = { _, _ -> }, onBackground = {}, onShareLogs = {}, onStop = {}, onClose = {},
)
+62 -17
View File
@@ -4,6 +4,9 @@
<queries>
<package android:name="cn.nubia.gamelauncher" />
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
<intent>
<action android:name="android.content.pm.action.CONFIRM_INSTALL" />
</intent>
@@ -18,8 +21,15 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SECONDARY_HOME" />
</intent>
<intent>
<action android:name="org.adw.launcher.THEMES" />
</intent>
<intent>
<action android:name="com.novalauncher.THEME" />
</intent>
</queries>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
@@ -29,7 +39,12 @@
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@@ -41,7 +56,8 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x401000" android:required="true" />
@@ -63,6 +79,7 @@
android:hardwareAccelerated="true"
android:largeHeap="true"
android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true"
android:appCategory="game"
android:isGame="true">
@@ -82,21 +99,11 @@
android:label="@string/steam_wall_label"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="true" />
<service android:name=".input.HomeButtonService"
android:label="@string/integration_shortcuts_service"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="true">
<service android:name=".input.ShortcutsRelay" android:exported="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
<action android:name="com.droiddeck.shortcuts.RELAY" />
</intent-filter>
<meta-data android:name="android.accessibilityservice" android:resource="@xml/home_button_service" />
</service>
<receiver android:name=".core.ShortcutsListingReceiver" android:exported="false"
android:process=":shortcuts_sync">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest2|quest3|quest3s" />
<activity android:name=".QuestXrActivity" android:exported="true" android:launchMode="singleTask"
android:permission="android.permission.DUMP"
@@ -111,6 +118,17 @@
</intent-filter>
</activity>
<activity
android:name=".DeviceCodeActivity"
android:exported="false"
android:launchMode="singleTask"
android:taskAffinity="${applicationId}.devicecode"
android:excludeFromRecents="true"
android:supportsPictureInPicture="true"
android:resizeableActivity="true"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density|keyboard|keyboardHidden|navigation"
android:theme="@style/AppTheme" />
<activity
android:name=".PairingGuideActivity"
android:exported="false"
@@ -134,6 +152,8 @@
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.CAR_LAUNCHER" />
<data android:scheme="droiddeck" android:host="game" />
<data android:scheme="droiddeck" android:host="soundtrack" />
<data android:scheme="droiddeck" android:host="settings" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
@@ -303,11 +323,23 @@
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode|density"
android:theme="@style/SessionTheme" />
<service android:name=".agent.AgentHostService" android:exported="false" />
<service android:name=".agent.AgentHostService" android:exported="false"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Keeps the user's on-device assistant running between screens" />
</service>
<service
android:name=".update.UpdateWatch"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" />
<service
android:name=".session.SessionService"
android:exported="false"
android:stopWithTask="false" />
android:stopWithTask="false"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Runs the user's Linux gaming session while its window is in the background" />
</service>
<!-- The compositor's native state is one per process, so the bottom-screen desktop's compositor runs in its own. -->
<service
android:name=".wayland.BottomDesktopCompositorService"
@@ -315,10 +347,15 @@
android:exported="false" />
<service
android:name=".runtime.RuntimeInstallService"
android:exported="false" />
android:exported="false"
android:foregroundServiceType="dataSync" />
<service
android:name=".core.WirelessAdbPairingService"
android:exported="false" />
android:exported="false"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Waits for the wireless debugging pairing code the user enters" />
</service>
<service
android:name=".stores.download.StoreDownloadService"
android:exported="false"
@@ -327,6 +364,14 @@
android:name=".sync.SyncthingService"
android:exported="false"
android:foregroundServiceType="dataSync" />
<service
android:name=".playback.SoundtrackService"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
</intent-filter>
</service>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.logs"
+44 -19
View File
@@ -1,27 +1,52 @@
#!/bin/bash
# GitHub sign-in through Android's browser, with the one-time code typed in for the person.
serial=${ADB_SERIAL:-127.0.0.1:5555}
display=${DD_BROWSER_DISPLAY:-0}
adb connect "$serial" >/dev/null 2>&1
# Starts GitHub's device login, floats its code over Android's browser and opens the approval page.
url=https://github.com/login/device
inbox=${DD_AGENT_INBOX:-}
# DroidDeck takes $inbox/device-code within a few seconds when it can float the code.
float_code() {
[ -n "$inbox" ] && [ -d "$inbox" ] || return 1
rm -f "$inbox/device-code.result"
printf '%s %s\n' "$1" "$url" > "$inbox/device-code.part" && mv -f "$inbox/device-code.part" "$inbox/device-code" || return 1
i=0
while [ $i -lt 40 ] && [ -e "$inbox/device-code" ]; do
sleep 0.2
i=$((i + 1))
done
if [ -e "$inbox/device-code" ]; then
rm -f "$inbox/device-code"
return 1
fi
# DroidDeck writes "ok" or "failed" once it has tried to open the page; no answer counts as failed.
i=0
while [ $i -lt 50 ] && [ ! -e "$inbox/device-code.result" ]; do
sleep 0.2
i=$((i + 1))
done
result=$(cat "$inbox/device-code.result" 2>/dev/null)
rm -f "$inbox/device-code.result"
[ "$result" = ok ]
}
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
# bash drops GH and GH_PID once gh exits, which can be before the loop reads its last line.
ghpid=$GH_PID
gh_pid=$GH_PID
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
typed=
shown=
while IFS= read -r line <&"$ghout"; do
printf '%s\n' "$line"
code=$(grep -oE '[A-Z0-9]{4}-[A-Z0-9]{4}' <<<"$line" | head -1)
if [ -n "$code" ] && [ -z "$typed" ]; then
typed=1
# gh's own prompts would push the code out of the one line the setup card shows.
case "$line" in
*"one-time code"* | *"Press Enter"* | *"Open this URL"*) ;;
*) printf '%s\n' "$line" ;;
esac
if [ -n "$code" ] && [ -z "$shown" ]; then
shown=1
echo >&"$ghin"
adb -s "$serial" shell "am start --display $display -a android.intent.action.VIEW -d https://github.com/login/device" >/dev/null 2>&1
# Chrome drops characters from `input text` and from fast key events on this page.
keys=
for ((i = 0; i < ${#code}; i++)); do
c=${code:i:1}
[ "$c" = - ] || keys+="input -d $display keyevent KEYCODE_$c; sleep 0.4; "
done
(sleep 7; adb -s "$serial" shell "$keys" >/dev/null 2>&1) &
printf 'GitHub device code: %s · github.com/login/device\n' "$code"
float_code "$code" || android-open "$url"
fi
done
wait "$ghpid"
wait "$gh_pid"
status=$?
[ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code"
exit $status
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exec python3 /root/.local/share/droiddeck/ctl/droiddeck-scenario "$@"
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exec python3 /root/.local/share/droiddeck/ctl/droiddeckctl "$@"
Binary file not shown.
+6
View File
@@ -40,6 +40,12 @@ add_library(gpuclock SHARED gpuclock/kgsl_clock.c gpuclock/kgsl_busy.c)
add_library(termux SHARED termux/termux.c)
# An executable packaged as a library: the only place a targetSdk 29+ app may execute files from.
add_library(ddexec SHARED ddexec/ddexec.c)
target_compile_options(ddexec PRIVATE -O2 -ffreestanding -fno-builtin -fno-stack-protector -fno-asynchronous-unwind-tables)
target_link_options(ddexec PRIVATE -nostdlib -Wl,-e,_start -Wl,-z,noexecstack -Wl,--no-undefined -Wl,-Bsymbolic
-Wl,-z,max-page-size=16384)
add_library(ddvenc SHARED venc/venc_server.cpp)
target_compile_features(ddvenc PRIVATE cxx_std_17)
target_link_libraries(ddvenc mediandk log)
+274
View File
@@ -0,0 +1,274 @@
// libddexec.so: starts an ELF program from the app's data directory.
//
// usage: libddexec.so <file> <argv0> [args...]
//
// From targetSdk 29, Android refuses execve() of app data files, but still lets the app map them
// executable, and executes the APK's extracted libraries. This executable is one of those libraries:
// it maps <file> (and its PT_INTERP, if it names one) the way the kernel's ELF loader would, builds the
// stack the kernel would have built for "<argv0> [args...]", and jumps to the entry point.
// It is freestanding: no libc, no relocations, so the kernel can run it as a static PIE.
#include <elf.h>
#include <stddef.h>
#include <stdint.h>
#define SYS_faccessat 48
#define SYS_openat 56
#define SYS_close 57
#define SYS_pread64 67
#define SYS_write 64
#define SYS_exit_group 94
#define SYS_munmap 215
#define SYS_mmap 222
#define SYS_mprotect 226
#define AT_FDCWD_ (-100)
#define O_RDONLY_ 0
#define O_CLOEXEC_ 02000000
#define PROT_READ_ 1
#define PROT_WRITE_ 2
#define PROT_EXEC_ 4
#define MAP_PRIVATE_ 0x02
#define MAP_FIXED_ 0x10
#define MAP_ANONYMOUS_ 0x20
#define MAX_PHDRS 64
#define STACK_GAP 65536
static long sys6(long n, long a, long b, long c, long d, long e, long f) {
register long x8 __asm__("x8") = n;
register long x0 __asm__("x0") = a;
register long x1 __asm__("x1") = b;
register long x2 __asm__("x2") = c;
register long x3 __asm__("x3") = d;
register long x4 __asm__("x4") = e;
register long x5 __asm__("x5") = f;
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5) : "memory", "cc");
return x0;
}
static size_t slen(const char *s) {
size_t n = 0;
while (s[n]) n++;
return n;
}
static void out(const char *s) { sys6(SYS_write, 2, (long)s, (long)slen(s), 0, 0, 0); }
static void out_num(long v) {
char buf[24];
int i = (int)sizeof(buf) - 1;
buf[i] = 0;
unsigned long u = v < 0 ? (unsigned long)-v : (unsigned long)v;
do {
buf[--i] = (char)('0' + u % 10);
u /= 10;
} while (u && i > 1);
if (v < 0) buf[--i] = '-';
out(buf + i);
}
__attribute__((noreturn)) static void die(const char *what, const char *path, long err) {
out("libddexec: ");
if (path) {
out(path);
out(": ");
}
out(what);
if (err) {
out(" (");
out_num(err);
out(")");
}
out("\n");
sys6(SYS_exit_group, 127, 0, 0, 0, 0, 0);
__builtin_unreachable();
}
static long xpread(int fd, void *buf, size_t len, long off) {
size_t done = 0;
while (done < len) {
long n = sys6(SYS_pread64, fd, (long)((char *)buf + done), (long)(len - done), off + (long)done, 0, 0);
if (n <= 0) return n < 0 ? n : -1;
done += (size_t)n;
}
return (long)done;
}
struct image {
uintptr_t base;
uintptr_t phdr;
uintptr_t entry;
unsigned long phnum;
unsigned long phent;
char interp[256];
};
static uintptr_t trunc_page(uintptr_t v, uintptr_t page) { return v & ~(page - 1); }
static uintptr_t round_page(uintptr_t v, uintptr_t page) { return (v + page - 1) & ~(page - 1); }
static int prot_of(uint32_t flags) {
return ((flags & PF_R) ? PROT_READ_ : 0) | ((flags & PF_W) ? PROT_WRITE_ : 0) | ((flags & PF_X) ? PROT_EXEC_ : 0);
}
static void map_failed(const char *path, long r) { die("cannot map a segment", path, r); }
static void load(const char *path, struct image *im, uintptr_t page) {
int fd = (int)sys6(SYS_openat, AT_FDCWD_, (long)path, O_RDONLY_ | O_CLOEXEC_, 0, 0, 0);
if (fd < 0) die("cannot open", path, fd);
Elf64_Ehdr eh;
if (xpread(fd, &eh, sizeof(eh), 0) != (long)sizeof(eh)) die("not an ELF file", path, 0);
if (eh.e_ident[EI_MAG0] != ELFMAG0 || eh.e_ident[EI_MAG1] != ELFMAG1 || eh.e_ident[EI_MAG2] != ELFMAG2 ||
eh.e_ident[EI_MAG3] != ELFMAG3 || eh.e_ident[EI_CLASS] != ELFCLASS64 || eh.e_machine != EM_AARCH64 ||
(eh.e_type != ET_EXEC && eh.e_type != ET_DYN) || eh.e_phentsize != sizeof(Elf64_Phdr) ||
eh.e_phnum == 0 || eh.e_phnum > MAX_PHDRS)
die("not a 64-bit ARM ELF program", path, 0);
Elf64_Phdr ph[MAX_PHDRS];
long size = (long)eh.e_phnum * (long)sizeof(Elf64_Phdr);
if (xpread(fd, ph, (size_t)size, (long)eh.e_phoff) != size) die("truncated program headers", path, 0);
uintptr_t lo = UINTPTR_MAX, hi = 0;
for (int i = 0; i < eh.e_phnum; i++) {
if (ph[i].p_type != PT_LOAD) continue;
uintptr_t s = trunc_page(ph[i].p_vaddr, page), e = round_page(ph[i].p_vaddr + ph[i].p_memsz, page);
if (s < lo) lo = s;
if (e > hi) hi = e;
}
if (lo >= hi) die("no loadable segments", path, 0);
uintptr_t bias = 0;
if (eh.e_type == ET_DYN) {
long r = sys6(SYS_mmap, 0, (long)(hi - lo), 0, MAP_PRIVATE_ | MAP_ANONYMOUS_, -1, 0);
if (r < 0 && r > -4096) map_failed(path, r);
bias = (uintptr_t)r - lo;
}
for (int i = 0; i < eh.e_phnum; i++) {
Elf64_Phdr *p = &ph[i];
if (p->p_type != PT_LOAD || p->p_memsz == 0) continue;
int prot = prot_of(p->p_flags);
uintptr_t seg = bias + p->p_vaddr;
uintptr_t start = trunc_page(seg, page);
uintptr_t file_end = seg + p->p_filesz;
uintptr_t mem_end = round_page(seg + p->p_memsz, page);
int zero_tail = p->p_memsz > p->p_filesz && (file_end & (page - 1)) != 0;
if (p->p_filesz > 0) {
uintptr_t len = round_page(file_end, page) - start;
long r = sys6(SYS_mmap, (long)start, (long)len, prot | (zero_tail ? PROT_WRITE_ : 0),
MAP_PRIVATE_ | MAP_FIXED_, fd, (long)trunc_page(p->p_offset, page));
if (r < 0 && r > -4096) map_failed(path, r);
if (zero_tail) {
for (volatile char *z = (volatile char *)file_end; (uintptr_t)z < round_page(file_end, page); z++) *z = 0;
if (!(prot & PROT_WRITE_)) sys6(SYS_mprotect, (long)trunc_page(file_end, page), (long)page, prot, 0, 0, 0);
}
}
uintptr_t anon = p->p_filesz > 0 ? round_page(file_end, page) : start;
if (mem_end > anon) {
long r = sys6(SYS_mmap, (long)anon, (long)(mem_end - anon), prot, MAP_PRIVATE_ | MAP_FIXED_ | MAP_ANONYMOUS_, -1, 0);
if (r < 0 && r > -4096) map_failed(path, r);
}
}
im->base = bias;
im->entry = bias + eh.e_entry;
im->phnum = eh.e_phnum;
im->phent = eh.e_phentsize;
im->phdr = 0;
im->interp[0] = 0;
for (int i = 0; i < eh.e_phnum; i++) {
if (ph[i].p_type == PT_PHDR) im->phdr = bias + ph[i].p_vaddr;
if (ph[i].p_type == PT_INTERP) {
if (ph[i].p_filesz == 0 || ph[i].p_filesz >= sizeof(im->interp)) die("bad PT_INTERP", path, 0);
if (xpread(fd, im->interp, ph[i].p_filesz, (long)ph[i].p_offset) != (long)ph[i].p_filesz)
die("truncated PT_INTERP", path, 0);
im->interp[ph[i].p_filesz] = 0;
}
}
if (!im->phdr) {
for (int i = 0; i < eh.e_phnum; i++) {
Elf64_Phdr *p = &ph[i];
if (p->p_type == PT_LOAD && eh.e_phoff >= p->p_offset && eh.e_phoff < p->p_offset + p->p_filesz) {
im->phdr = bias + p->p_vaddr + (eh.e_phoff - p->p_offset);
break;
}
}
}
if (!im->phdr) die("program headers are not in a loaded segment", path, 0);
sys6(SYS_close, fd, 0, 0, 0, 0, 0);
}
static unsigned long auxv_get(const uintptr_t *auxv, unsigned long type, unsigned long fallback) {
for (; auxv[0] != AT_NULL; auxv += 2)
if (auxv[0] == type) return auxv[1];
return fallback;
}
__attribute__((used, noreturn)) void ddexec_main(uintptr_t *sp) {
long argc = (long)sp[0];
char **argv = (char **)(sp + 1);
char **envp = argv + argc + 1;
long nenv = 0;
while (envp[nenv]) nenv++;
uintptr_t *auxv = (uintptr_t *)(envp + nenv + 1);
long naux = 0;
while (auxv[naux * 2] != AT_NULL) naux++;
if (argc < 3) die("usage: libddexec.so <file> <argv0> [args...]", 0, 0);
uintptr_t page = auxv_get(auxv, AT_PAGESZ, 4096);
const char *path = argv[1];
struct image prog, interp;
load(path, &prog, page);
int has_interp = prog.interp[0] != 0;
if (has_interp) load(prog.interp, &interp, page);
// The new stack: argc, argv, envp and auxv as the kernel lays them out, below the current one.
// The strings stay where the kernel put them.
static const unsigned long replaced[] = {AT_PHDR, AT_PHENT, AT_PHNUM, AT_BASE, AT_ENTRY, AT_EXECFN};
long nreplaced = (long)(sizeof(replaced) / sizeof(replaced[0]));
long new_argc = argc - 2;
long words = 1 + (new_argc + 1) + (nenv + 1) + (naux + nreplaced + 1) * 2;
uintptr_t *nsp = (uintptr_t *)(((uintptr_t)sp - STACK_GAP - (uintptr_t)words * sizeof(uintptr_t)) & ~(uintptr_t)15);
uintptr_t *w = nsp;
*w++ = (uintptr_t)new_argc;
for (long i = 0; i < new_argc; i++) *w++ = (uintptr_t)argv[i + 2];
*w++ = 0;
for (long i = 0; i < nenv; i++) *w++ = (uintptr_t)envp[i];
*w++ = 0;
for (long i = 0; i < naux; i++) {
unsigned long type = auxv[i * 2];
int skip = 0;
for (long r = 0; r < nreplaced; r++)
if (type == replaced[r]) skip = 1;
if (skip) continue;
*w++ = type;
*w++ = auxv[i * 2 + 1];
}
*w++ = AT_PHDR;
*w++ = prog.phdr;
*w++ = AT_PHENT;
*w++ = prog.phent;
*w++ = AT_PHNUM;
*w++ = prog.phnum;
*w++ = AT_BASE;
*w++ = has_interp ? interp.base : 0;
*w++ = AT_ENTRY;
*w++ = prog.entry;
*w++ = AT_EXECFN;
*w++ = (uintptr_t)path;
*w++ = AT_NULL;
*w++ = 0;
uintptr_t entry = has_interp ? interp.entry : prog.entry;
__asm__ volatile("mov sp, %0\n"
"mov x0, #0\n"
"br %1\n"
:
: "r"(nsp), "r"(entry)
: "memory");
__builtin_unreachable();
}
__attribute__((naked, noreturn)) void _start(void) {
__asm__ volatile("mov x0, sp\n"
"and sp, x0, #~15\n"
"bl ddexec_main\n");
}
+197 -37
View File
@@ -37,6 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/eventfd.h>
#include <sys/file.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -157,6 +158,8 @@ struct FakeController {
bool closed = false;
bool needs_keyframe = true;
bool mouse = false;
int playing_ff = -1;
pid_t owner = getpid();
~FakeController() {
if (ring) munmap(ring, mapping_size);
@@ -195,12 +198,18 @@ static constexpr size_t kSnapshotButtonCount =
namespace Logger {
void init();
void log(const char *message, ...);
}
static void controller_fork_prepare();
static void controller_fork_parent();
static void controller_fork_child();
// bionic: libc's own start-up calls hooked functions (access) before environ is set. Settings read
// then would be empty and cached for good, so until environ exists hooks see defaults, uncached.
extern "C" char **environ;
static bool env_ready() { return environ != nullptr; }
struct FakeConfig {
const char *hook_dir;
const char *udev_data_dir;
@@ -214,6 +223,10 @@ struct FakeConfig {
// would throw a recursive-init error there, so the fields are filled without allocating, and a
// reentry on the initializing thread gets them while other threads wait for the fork handlers.
static FakeConfig &config() {
if (!env_ready()) {
static FakeConfig early = {"/data/data/com.termux/files/home/fake-input", nullptr, false, false, false};
return early;
}
static FakeConfig cfg;
static std::atomic<int> state{0};
static __thread bool initializing __attribute__((tls_model("initial-exec")));
@@ -286,6 +299,68 @@ static bool fake_vibration_enabled() { return config().vibration_enabled; }
static bool fake_xbox360_identity() { return config().xbox360_identity; }
static bool fake_uinput_enabled() { return config().uinput_enabled; }
static bool process_is_steam_client();
// Steam and its Remote Play client write the same shared slots; the caller's mutex serialises its own threads.
// Without the lock Steam stays the only writer, as before streaming_client could open these devices. The wait
// is bounded because a session freeze can stop the holder, and callers wait with controller_mutex held.
class ProcessSlotLock {
public:
ProcessSlotLock(int &fd, const char *name, int timeout_ms) : fd_(fd) {
int saved_errno = errno;
if (fd_ < 0) {
std::string path = std::string(fake_hook_dir()) + "/." + name + ".lock";
fd_ = fd = static_cast<int>(syscall(SYS_openat, AT_FDCWD, path.c_str(), O_CREAT | O_RDWR | O_CLOEXEC, 0600));
}
int error = fd_ < 0 ? errno : 0;
if (fd_ >= 0) {
struct timespec start, now, pause = {0, 1000 * 1000};
clock_gettime(CLOCK_MONOTONIC, &start);
for (;;) {
if (flock(fd_, LOCK_EX | LOCK_NB) == 0) {
locked_ = true;
break;
}
if (errno == EINTR) continue;
if (errno != EWOULDBLOCK) {
error = errno;
break;
}
clock_gettime(CLOCK_MONOTONIC, &now);
if ((now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - start.tv_nsec) / 1000000 >= timeout_ms) {
busy_ = true;
break;
}
nanosleep(&pause, nullptr);
}
}
if (busy_) {
static std::atomic<unsigned> waits;
unsigned n = ++waits;
if ((n & (n - 1)) == 0) Logger::log("lock: %s still held after %d ms, skipped (x%u)\n", name, timeout_ms, n);
} else if (!locked_) {
static std::atomic<bool> noted{false};
if (!noted.exchange(true))
Logger::log("lock: %s not taken (%s)%s\n", name, strerror(error),
process_is_steam_client() ? "" : "; this process leaves the shared slots alone");
}
errno = saved_errno;
}
~ProcessSlotLock() {
int saved_errno = errno;
if (locked_) flock(fd_, LOCK_UN);
errno = saved_errno;
}
bool may_write() const { return locked_ || (!busy_ && process_is_steam_client()); }
ProcessSlotLock(const ProcessSlotLock &) = delete;
ProcessSlotLock &operator=(const ProcessSlotLock &) = delete;
private:
int fd_;
bool locked_ = false;
bool busy_ = false;
};
static bool ring_paths_loaded = false;
static int next_ff_id = 0;
@@ -411,22 +486,49 @@ __attribute__((visibility("hidden"))) static void send_ff_effect(const struct ff
send_vibration(effect.u.periodic.magnitude, effect.u.periodic.magnitude, duration, slot);
}
static std::unordered_map<int, const FakeController *> &ff_players() {
static auto *players = new std::unordered_map<int, const FakeController *>();
return *players;
}
__attribute__((visibility("hidden"))) static void ff_played(FakeController &controller, int id) {
controller.playing_ff = id;
controller.owner = getpid();
ff_players()[controller.slot] = &controller;
}
__attribute__((visibility("hidden"))) static bool ff_release(FakeController &controller) {
auto player = ff_players().find(controller.slot);
bool current = player != ff_players().end() && player->second == &controller;
if (current) ff_players().erase(player);
controller.playing_ff = -1;
return current;
}
__attribute__((visibility("hidden"))) static void
check_ff_event(const struct input_event *ev, uint16_t slot) {
check_ff_event(const struct input_event *ev, FakeController &controller) {
if (ev->type != EV_FF)
return;
uint16_t slot = static_cast<uint16_t>(controller.slot);
int id = ev->code;
if (ev->value > 0) {
auto it = ff_effects().find(id);
if (it == ff_effects().end())
return;
send_ff_effect(it->second, slot);
ff_played(controller, id);
} else {
send_vibration(0, 0, 0, slot);
ff_release(controller);
}
}
__attribute__((visibility("hidden"))) static void stop_ff(FakeController &controller) {
bool playing = controller.playing_ff >= 0 && controller.owner == getpid();
if (ff_release(controller) && playing) send_vibration(0, 0, 0, static_cast<uint16_t>(controller.slot));
}
__attribute__((visibility("hidden"))) char *
from_real_to_fake_path(const char *pathname) {
const char *event = strrchr(pathname, '/') + 1;
@@ -494,7 +596,7 @@ get_fake_input_rdev(const char *event) {
__attribute__((visibility("hidden"))) static void load_ring_paths() {
std::lock_guard<std::recursive_mutex> guard(controller_mutex());
if (ring_paths_loaded)
if (ring_paths_loaded || !env_ready())
return;
const char *spec = getenv("FAKE_EVDEV_MEMFD_PATHS");
@@ -714,12 +816,25 @@ __attribute__((visibility("hidden"))) static bool is_steam_client() {
__attribute__((visibility("hidden"))) static bool presents_steam_virtual() {
static int known;
if (known == 0) {
if (!env_ready()) return false;
const char *enabled = getenv("FAKE_EVDEV_STEAM_VIRTUAL");
known = enabled && atoi(enabled) && !is_steam_client() ? 1 : -1;
}
return known == 1;
}
// The bionic Proton layer's winebus has no udev bus, and its SDL bus skips 28de:11ff (Proton reads Steam's virtual
// pad through udev/evdev), so with FAKE_EVDEV_STEAM_PAD_AS_X360=1 other processes see that pad as a plain Xbox 360 pad.
__attribute__((visibility("hidden"))) static bool steam_pad_as_x360() {
static int known;
if (known == 0) {
if (!env_ready()) return false;
const char *v = getenv("FAKE_EVDEV_STEAM_PAD_AS_X360");
known = v && atoi(v) && !is_steam_client() ? 1 : -1;
}
return known == 1;
}
__attribute__((visibility("hidden"))) static bool
presents_xbox_triggers(const FakeController &fake) {
return fake.uinput || !is_steam_client();
@@ -1185,10 +1300,13 @@ struct DeckImu {
uint32_t controls;
uint32_t pad_type;
uint32_t latency;
uint32_t remote_imu_mode;
uint32_t remote_imu_pid;
};
static_assert(offsetof(DeckImu, pad_type) == FAKE_INPUT_RING_PAD_TYPE_OFFSET,
"DeckImu::pad_type matches FakeInputWriter and the ring reader");
static_assert(offsetof(DeckImu, latency) == 48, "DeckImu::latency matches FakeInputWriter");
static_assert(offsetof(DeckImu, remote_imu_mode) == 52, "DeckImu::remote_imu_mode matches FakeInputWriter");
static constexpr uint32_t LATENCY_CONTROLLER = 1, LATENCY_TOUCH = 2;
static constexpr int LOW_LATENCY_REPORT_INTERVAL_US = 1000;
static constexpr uint32_t DECK_EXTRA_L4 = 1, DECK_EXTRA_R4 = 2, DECK_EXTRA_L5 = 4,
@@ -1295,6 +1413,7 @@ static std::unordered_map<int, std::shared_ptr<DeckHidraw>> &deck_map() {
static bool fake_deck_enabled() {
static int enabled = -1;
if (enabled < 0 && !env_ready()) return false;
if (enabled < 0) enabled = getenv("FAKE_EVDEV_DECK") && atoi(getenv("FAKE_EVDEV_DECK")) ? 1 : 0;
return enabled == 1;
}
@@ -1302,6 +1421,7 @@ static bool fake_deck_enabled() {
__attribute__((visibility("hidden"))) static uint32_t session_pad_type() {
static int type = -1;
if (type < 0) {
if (!env_ready()) return PAD_TYPE_DECK;
const char *env = getenv("FAKE_EVDEV_PAD_TYPE");
type = env && !strcmp(env, "steamcontroller") ? PAD_TYPE_STEAM
: env && !strcmp(env, "xbox360") ? PAD_TYPE_XBOX
@@ -1374,6 +1494,7 @@ __attribute__((visibility("hidden"))) static uint64_t monotonic_us() {
static bool fake_triton_enabled() {
static int enabled = -1;
if (enabled < 0 && !env_ready()) return false;
if (enabled < 0)
enabled = fake_deck_enabled() && getenv("FAKE_EVDEV_TRITON") && atoi(getenv("FAKE_EVDEV_TRITON")) ? 1 : 0;
return enabled == 1;
@@ -1395,6 +1516,25 @@ __attribute__((visibility("hidden"))) static bool process_is_steam_client() {
return known == 1;
}
// Steam's Remote Play client reads the controller itself, in its own streaming_client process.
__attribute__((visibility("hidden"))) static bool process_reads_pads() {
static int known;
if (known == 0) {
bool reader = process_is_steam_client();
if (!reader) {
char exe[PATH_MAX];
ssize_t length = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
if (length > 0) {
exe[length] = '\0';
const char *name = strrchr(exe, '/');
reader = !strcmp(name ? name + 1 : exe, "streaming_client");
}
}
known = reader ? 1 : -1;
}
return known == 1;
}
__attribute__((constructor)) static void log_client_start() {
config();
if (process_is_steam_client())
@@ -1439,7 +1579,7 @@ __attribute__((visibility("hidden"))) static bool is_withdrawn_pad_path(const ch
free(fake);
return !exposed;
}
return number == 0 || !process_is_steam_client();
return number == 0 || !process_reads_pads();
}
static bool fake_pad_withdrawn(const FakeController &fake) {
@@ -1654,7 +1794,7 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg)
__attribute__((visibility("hidden"))) static int open_deck_hidraw(int flags, uint8_t sony = 0) {
const char *path = sony == 4 ? DS4_HIDRAW_PATH : sony == 5 ? DUALSENSE_HIDRAW_PATH : DECK_HIDRAW_PATH;
static auto my_open = reinterpret_cast<int (*)(const char *, int, ...)>(dlsym(RTLD_NEXT, "open"));
if (!process_is_steam_client()) {
if (!process_reads_pads()) {
Logger::log("deck: %s refused: not the Steam client\n", path);
errno = ENOENT;
return -1;
@@ -1863,7 +2003,7 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg)
__attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags, bool emulated) {
static auto my_open = reinterpret_cast<int (*)(const char *, int, ...)>(dlsym(RTLD_NEXT, "open"));
if (!process_is_steam_client()) {
if (!process_reads_pads()) {
errno = ENOENT;
return -1;
}
@@ -1976,6 +2116,7 @@ static_assert(sizeof(TouchRingFile) <= TOUCH_RING_SIZE, "TouchRingFile layout");
__attribute__((visibility("hidden"))) static TouchRingFile *touch_ring() {
static TouchRingFile *ring = nullptr;
if (!env_ready()) return nullptr;
static std::once_flag once;
std::call_once(once, [] {
const char *path = getenv("FAKE_TOUCHCTL_RING");
@@ -2004,15 +2145,19 @@ __attribute__((visibility("hidden"))) static bool touch_plugged() {
}
__attribute__((visibility("hidden"))) static bool is_touch_hidraw_path(const char *pathname) {
return pathname && !strcmp(pathname, TOUCH_HIDRAW_PATH) && process_is_steam_client() && touch_ring();
return pathname && !strcmp(pathname, TOUCH_HIDRAW_PATH) && process_reads_pads() && touch_ring();
}
static std::mutex touch_state_mutex;
static int touch_state_lock_fd = -1;
template <typename F>
__attribute__((visibility("hidden"))) static void touch_state(F &&write) {
TouchRingFile *ring = touch_ring();
if (!ring) return;
static std::mutex mutex;
std::lock_guard<std::mutex> guard(mutex);
std::lock_guard<std::mutex> guard(touch_state_mutex);
ProcessSlotLock slot(touch_state_lock_fd, "touch-state", 20);
if (!slot.may_write()) return;
__atomic_fetch_add(&ring->state_seq, 1, __ATOMIC_ACQ_REL);
write(*ring);
__atomic_fetch_add(&ring->state_seq, 1, __ATOMIC_ACQ_REL);
@@ -2193,7 +2338,7 @@ __attribute__((visibility("hidden"))) static int inject_uevent(const char *actio
const char *subsystem, const char *devname,
unsigned major, unsigned minor) {
using inject_fn = int (*)(const char *, const char *, const char *, const char *, unsigned, unsigned);
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "bl_udevmon_inject"));
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "dd_udevmon_inject"));
return inject ? inject(action, devpath, subsystem, devname, major, minor) : -1;
}
@@ -2264,9 +2409,10 @@ __attribute__((visibility("hidden"))) static void *pad_type_thread(void *) {
struct timespec settle = {0, 300 * 1000 * 1000};
nanosleep(&settle, nullptr);
int added = pad_type_uevent(now, "add");
if (was != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(was));
if (now != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(now));
if (was == PAD_TYPE_XBOX || now == PAD_TYPE_XBOX) {
bool shared = process_is_steam_client();
if (shared && was != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(was));
if (shared && now != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(now));
if (shared && (was == PAD_TYPE_XBOX || now == PAD_TYPE_XBOX)) {
std::string node = std::string(fake_hook_dir()) + "/event0";
std::string aside = std::string(fake_hook_dir()) + "/.event0-switching";
if (rename(node.c_str(), aside.c_str()) == 0) {
@@ -2285,7 +2431,7 @@ __attribute__((visibility("hidden"))) static void *pad_type_thread(void *) {
__attribute__((constructor)) static void start_pad_type_watch() {
config();
if (!process_is_steam_client() || !fake_deck_enabled()) return;
if (!process_reads_pads() || !fake_deck_enabled()) return;
pthread_t thread;
if (pthread_create(&thread, nullptr, pad_type_thread, nullptr) == 0) pthread_detach(thread);
}
@@ -2306,7 +2452,7 @@ __attribute__((visibility("hidden"))) static void *touch_plug_thread(void *) {
__attribute__((constructor)) static void start_touch_controller() {
config();
if (!process_is_steam_client() || !touch_ring()) return;
if (!process_reads_pads() || !touch_ring()) return;
pthread_t thread;
if (pthread_create(&thread, nullptr, touch_plug_thread, nullptr) == 0) pthread_detach(thread);
}
@@ -2314,6 +2460,7 @@ __attribute__((constructor)) static void start_touch_controller() {
static constexpr long SYSFS_FS_MAGIC = 0x62656572;
__attribute__((visibility("hidden"))) static const char *deck_listing_dir() {
if (!env_ready()) return nullptr;
static const char *dir = getenv("FAKE_DECK_SYSFS_LISTING");
return dir && *dir ? dir : nullptr;
}
@@ -2413,8 +2560,13 @@ __attribute__((visibility("hidden"))) static void publish_imu_mode(const DeckHid
std::string path = get_ring_path_for_slot(0);
int fd = path.empty() ? -1 : my_open(path.c_str(), O_WRONLY | O_CLOEXEC);
if (fd < 0) return;
uint32_t value = 0x80000000u | static_cast<uint32_t>(mode);
if (pwrite(fd, &value, sizeof(value), FAKE_INPUT_RING_SIZE + offsetof(DeckImu, imu_mode)) != sizeof(value))
// Steam and its Remote Play client each keep their own word, so one turning motion off does not starve the
// other; Android reads motion while either wants it. The pid lets it ignore a Remote Play client that has gone.
uint32_t value[2] = {0x80000000u | static_cast<uint32_t>(mode), static_cast<uint32_t>(getpid())};
bool steam = process_is_steam_client();
size_t length = steam ? sizeof(value[0]) : sizeof(value);
off_t offset = FAKE_INPUT_RING_SIZE + (steam ? offsetof(DeckImu, imu_mode) : offsetof(DeckImu, remote_imu_mode));
if (pwrite(fd, value, length, offset) != static_cast<ssize_t>(length))
Logger::log("deck: imu mode not published (%s)\n", strerror(errno));
syscall(SYS_close, fd);
}
@@ -2619,7 +2771,10 @@ __attribute__((visibility("hidden"))) static void triton_queue_output(DeckHidraw
auto *shared = reinterpret_cast<TritonSharedData *>(reinterpret_cast<uint8_t *>(triton.ring) + TRITON_SHARED_OFFSET);
if (__atomic_load_n(&shared->magic, __ATOMIC_ACQUIRE) != TRITON_SHARED_MAGIC) return;
static std::mutex one_at_a_time;
static int lock_fd = -1;
std::lock_guard<std::mutex> guard(one_at_a_time);
ProcessSlotLock slot(lock_fd, "triton-output", TRITON_OUTPUT_TIMEOUT_MS * 2);
if (!slot.may_write()) return;
for (int waited = 0;
static_cast<uint32_t>(__atomic_load_n(&shared->output_seq, __ATOMIC_ACQUIRE)) !=
__atomic_load_n(&shared->output_ack, __ATOMIC_ACQUIRE) &&
@@ -2651,7 +2806,13 @@ __attribute__((visibility("hidden"))) static int triton_get_feature(DeckHidraw &
}
auto *shared = reinterpret_cast<TritonSharedData *>(reinterpret_cast<uint8_t *>(triton.ring) + TRITON_SHARED_OFFSET);
static std::mutex one_at_a_time;
static int lock_fd = -1;
std::lock_guard<std::mutex> guard(one_at_a_time);
ProcessSlotLock slot(lock_fd, "triton-feature", TRITON_FEATURE_TIMEOUT_MS);
if (!slot.may_write()) {
errno = EIO;
return -1;
}
uint8_t report_id = report[0];
__atomic_store_n(&shared->get_report_id, report_id, __ATOMIC_RELAXED);
uint64_t request = __atomic_add_fetch(&shared->get_request, 1, __ATOMIC_RELEASE);
@@ -2839,7 +3000,7 @@ __attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton
__attribute__((visibility("hidden"))) static std::string note_sys_failure(int dirfd, const char *pathname) {
int saved_errno = errno;
std::string path;
if (saved_errno == ENOENT || !pathname || !process_is_steam_client()) {
if (saved_errno == ENOENT || !pathname || !process_reads_pads()) {
errno = saved_errno;
return path;
}
@@ -2878,7 +3039,7 @@ __attribute__((visibility("hidden"))) static std::string note_sys_failure(int di
__attribute__((visibility("hidden"))) static std::string deck_listing_for(const char *path) {
const char *listing = deck_listing_dir();
if (!path || !listing || errno != EACCES || !fake_deck_enabled() || !process_is_steam_client()) return {};
if (!path || !listing || errno != EACCES || !fake_deck_enabled() || !process_reads_pads()) return {};
std::string p(path);
while (p.size() > 1 && p.back() == '/') p.pop_back();
int which = p == "/sys" ? 0 : p == "/sys/class" ? 1 : p == "/sys/bus" ? 2 : -1;
@@ -2947,7 +3108,7 @@ EXPORT int statx(int dirfd, const char *path, int flags, unsigned mask, struct s
constexpr unsigned unique_mount_id = 0x4000;
if (result == 0 && (mask & STATX_MNT_ID) &&
!(buf->stx_mask & (STATX_MNT_ID | unique_mount_id)) && fake_deck_enabled() &&
process_is_steam_client() && deck_device_library(__builtin_return_address(0))) {
process_reads_pads() && deck_device_library(__builtin_return_address(0))) {
bool recovered = deck_mount_id_from_fdinfo(dirfd, path, flags, buf);
static std::atomic<bool> noted_success{false}, noted_failure{false};
if (!(recovered ? noted_success : noted_failure).exchange(true))
@@ -3136,7 +3297,7 @@ template <typename S, typename Real>
static int fake_stat_path(const char *pathname, S *statbuf, Real real) {
if (is_withdrawn_pad_path(pathname) ||
((is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) ||
sony_pad_path(pathname)) && !process_is_steam_client())) {
sony_pad_path(pathname)) && !process_reads_pads())) {
errno = ENOENT;
return -1;
}
@@ -3261,9 +3422,9 @@ EXPORT int fstat(int fd, struct stat *buf) {
EXPORT int access(const char *pathname, int mode) {
static auto my_access = reinterpret_cast<decltype(&::access)>(dlsym(RTLD_NEXT, "access"));
if (fake_uinput_enabled() && is_uinput_path(pathname)) return 0;
if (is_deck_hidraw_path(pathname) && process_is_steam_client()) return 0;
if (is_deck_hidraw_path(pathname) && process_reads_pads()) return 0;
if ((is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) || sony_pad_path(pathname)) &&
process_is_steam_client())
process_reads_pads())
return 0;
if (is_touch_hidraw_path(pathname)) return 0;
if (is_withdrawn_pad_path(pathname) || is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) ||
@@ -3302,9 +3463,9 @@ EXPORT int access(const char *pathname, int mode) {
EXPORT int faccessat(int dirfd, const char *pathname, int mode, int flags) {
static auto my_faccessat = reinterpret_cast<decltype(&::faccessat)>(dlsym(RTLD_NEXT, "faccessat"));
if (fake_uinput_enabled() && is_uinput_path(pathname)) return 0;
if (is_deck_hidraw_path(pathname) && process_is_steam_client()) return 0;
if (is_deck_hidraw_path(pathname) && process_reads_pads()) return 0;
if ((is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) || sony_pad_path(pathname)) &&
process_is_steam_client())
process_reads_pads())
return 0;
if (is_touch_hidraw_path(pathname)) return 0;
if (is_withdrawn_pad_path(pathname) || is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) ||
@@ -3371,7 +3532,7 @@ EXPORT int inotify_add_watch(int fd, const char *pathname, uint32_t mask) {
pathname = fake_path;
} else if (!strcmp(pathname, "/dev/input")) {
pathname = fake_hook_dir();
} else if (!strcmp(pathname, "/dev") && fake_deck_enabled() && process_is_steam_client()) {
} else if (!strcmp(pathname, "/dev") && fake_deck_enabled() && process_reads_pads()) {
std::string events = hidraw_event_dir();
mkdir(events.c_str(), 0700);
my_inotify_add_watch(fd, events.c_str(), mask);
@@ -3555,6 +3716,10 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
id.bustype = 0x03;
if (made) {
id = made->id;
if (steam_pad_as_x360() && id.vendor == STEAM_VIRTUAL_VENDOR_ID && id.product == STEAM_VIRTUAL_PRODUCT_ID) {
id.vendor = X360_VENDOR_ID;
id.product = X360_PRODUCT_ID;
}
} else if (presents_steam_virtual()) {
id.vendor = STEAM_VIRTUAL_VENDOR_ID;
id.product = STEAM_VIRTUAL_PRODUCT_ID;
@@ -3657,10 +3822,12 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
effect->id = next_ff_id++;
ff_effects()[effect->id] = *effect;
send_ff_effect(*effect, static_cast<uint16_t>(event_number));
ff_played(*controller->second, effect->id);
return 0;
} else if (type == 0x45 && number == 0x81) {
int id = (intptr_t)argp;
ff_effects().erase(id);
if (controller->second->playing_ff == id) stop_ff(*controller->second);
return 0;
} else if (type == 0x45 && number == 0x84) {
int max_effects = 16;
@@ -3740,6 +3907,7 @@ EXPORT int close(int fd) {
if (controller != controller_map().end()) {
Logger::log("Removing controller, fd %d event %s\n", controller->first,
controller->second->event ? controller->second->event : "(unknown)");
stop_ff(*controller->second);
controller->second->closed = true;
controller_map().erase(fd);
}
@@ -3937,12 +4105,8 @@ EXPORT ssize_t write(int fd, const void *buf, size_t count) {
return -1;
}
const struct input_event *ev = nullptr;
uint16_t slot = static_cast<uint16_t>(controller->second->slot);
if (count == sizeof(struct input_event)) {
ev = static_cast<const struct input_event *>(buf);
check_ff_event(ev, slot);
}
if (count == sizeof(struct input_event))
check_ff_event(static_cast<const struct input_event *>(buf), *controller->second);
return static_cast<ssize_t>(count);
}
@@ -3982,14 +4146,10 @@ EXPORT ssize_t writev(int fd, const struct iovec *iov, int iovcnt) {
return -1;
}
uint16_t slot = static_cast<uint16_t>(controller->second->slot);
ssize_t total = 0;
for (int i = 0; i < iovcnt; i++) {
if (iov[i].iov_len == sizeof(struct input_event)) {
const struct input_event *ev =
static_cast<const struct input_event *>(iov[i].iov_base);
check_ff_event(ev, slot);
}
if (iov[i].iov_len == sizeof(struct input_event))
check_ff_event(static_cast<const struct input_event *>(iov[i].iov_base), *controller->second);
total += static_cast<ssize_t>(iov[i].iov_len);
}
return total;
+106
View File
@@ -0,0 +1,106 @@
#pragma once
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_android.h>
struct VkTable {
PFN_vkCreateInstance CreateInstance;
PFN_vkDestroyInstance DestroyInstance;
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
PFN_vkGetPhysicalDeviceFeatures2 GetPhysicalDeviceFeatures2;
PFN_vkCreateDevice CreateDevice;
PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyDevice DestroyDevice;
PFN_vkGetDeviceQueue GetDeviceQueue;
PFN_vkDeviceWaitIdle DeviceWaitIdle;
PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
PFN_vkQueuePresentKHR QueuePresentKHR;
PFN_vkQueueSubmit QueueSubmit;
PFN_vkCreateQueryPool CreateQueryPool;
PFN_vkDestroyQueryPool DestroyQueryPool;
PFN_vkCmdResetQueryPool CmdResetQueryPool;
PFN_vkCmdWriteTimestamp CmdWriteTimestamp;
PFN_vkGetQueryPoolResults GetQueryPoolResults;
PFN_vkCreateRenderPass CreateRenderPass;
PFN_vkDestroyRenderPass DestroyRenderPass;
PFN_vkCreateFramebuffer CreateFramebuffer;
PFN_vkDestroyFramebuffer DestroyFramebuffer;
PFN_vkCreateImageView CreateImageView;
PFN_vkDestroyImageView DestroyImageView;
PFN_vkCreateImage CreateImage;
PFN_vkDestroyImage DestroyImage;
PFN_vkCreateBuffer CreateBuffer;
PFN_vkDestroyBuffer DestroyBuffer;
PFN_vkAllocateMemory AllocateMemory;
PFN_vkFreeMemory FreeMemory;
PFN_vkMapMemory MapMemory;
PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges;
PFN_vkBindBufferMemory BindBufferMemory;
PFN_vkBindImageMemory BindImageMemory;
PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements;
PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout;
PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout;
PFN_vkCreateDescriptorPool CreateDescriptorPool;
PFN_vkDestroyDescriptorPool DestroyDescriptorPool;
PFN_vkAllocateDescriptorSets AllocateDescriptorSets;
PFN_vkFreeDescriptorSets FreeDescriptorSets;
PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
PFN_vkCreatePipelineLayout CreatePipelineLayout;
PFN_vkDestroyPipelineLayout DestroyPipelineLayout;
PFN_vkCreateShaderModule CreateShaderModule;
PFN_vkDestroyShaderModule DestroyShaderModule;
PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines;
PFN_vkDestroyPipeline DestroyPipeline;
PFN_vkCreateCommandPool CreateCommandPool;
PFN_vkDestroyCommandPool DestroyCommandPool;
PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
PFN_vkFreeCommandBuffers FreeCommandBuffers;
PFN_vkBeginCommandBuffer BeginCommandBuffer;
PFN_vkEndCommandBuffer EndCommandBuffer;
PFN_vkResetCommandBuffer ResetCommandBuffer;
PFN_vkCmdBeginRenderPass CmdBeginRenderPass;
PFN_vkCmdEndRenderPass CmdEndRenderPass;
PFN_vkCmdBindPipeline CmdBindPipeline;
PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
PFN_vkCmdDraw CmdDraw;
PFN_vkCmdPushConstants CmdPushConstants;
PFN_vkCmdSetViewport CmdSetViewport;
PFN_vkCmdSetScissor CmdSetScissor;
PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
PFN_vkCmdCopyImage CmdCopyImage;
PFN_vkCmdBlitImage CmdBlitImage;
PFN_vkCmdDispatch CmdDispatch;
PFN_vkCreateComputePipelines CreateComputePipelines;
PFN_vkUnmapMemory UnmapMemory;
PFN_vkCmdClearColorImage CmdClearColorImage;
PFN_vkResetDescriptorPool ResetDescriptorPool;
PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage;
PFN_vkCreateSampler CreateSampler;
PFN_vkDestroySampler DestroySampler;
PFN_vkCreateSemaphore CreateSemaphore;
PFN_vkDestroySemaphore DestroySemaphore;
PFN_vkCreateFence CreateFence;
PFN_vkDestroyFence DestroyFence;
PFN_vkWaitForFences WaitForFences;
PFN_vkResetFences ResetFences;
PFN_vkGetFenceStatus GetFenceStatus;
PFN_vkGetAndroidHardwareBufferPropertiesANDROID GetAndroidHardwareBufferPropertiesANDROID;
};
@@ -1,680 +0,0 @@
#pragma once
#include <vulkan/vulkan.h>
#include <list>
#include <vulkan/vulkan_android.h>
struct VkTable {
PFN_vkCreateInstance CreateInstance;
PFN_vkDestroyInstance DestroyInstance;
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
PFN_vkGetPhysicalDeviceFeatures2 GetPhysicalDeviceFeatures2;
PFN_vkCreateDevice CreateDevice;
PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyDevice DestroyDevice;
PFN_vkGetDeviceQueue GetDeviceQueue;
PFN_vkDeviceWaitIdle DeviceWaitIdle;
PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
PFN_vkQueuePresentKHR QueuePresentKHR;
PFN_vkQueueSubmit QueueSubmit;
PFN_vkCreateQueryPool CreateQueryPool;
PFN_vkDestroyQueryPool DestroyQueryPool;
PFN_vkCmdResetQueryPool CmdResetQueryPool;
PFN_vkCmdWriteTimestamp CmdWriteTimestamp;
PFN_vkGetQueryPoolResults GetQueryPoolResults;
PFN_vkCreateRenderPass CreateRenderPass;
PFN_vkDestroyRenderPass DestroyRenderPass;
PFN_vkCreateFramebuffer CreateFramebuffer;
PFN_vkDestroyFramebuffer DestroyFramebuffer;
PFN_vkCreateImageView CreateImageView;
PFN_vkDestroyImageView DestroyImageView;
PFN_vkCreateImage CreateImage;
PFN_vkDestroyImage DestroyImage;
PFN_vkCreateBuffer CreateBuffer;
PFN_vkDestroyBuffer DestroyBuffer;
PFN_vkAllocateMemory AllocateMemory;
PFN_vkFreeMemory FreeMemory;
PFN_vkMapMemory MapMemory;
PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges;
PFN_vkBindBufferMemory BindBufferMemory;
PFN_vkBindImageMemory BindImageMemory;
PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements;
PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout;
PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout;
PFN_vkCreateDescriptorPool CreateDescriptorPool;
PFN_vkDestroyDescriptorPool DestroyDescriptorPool;
PFN_vkAllocateDescriptorSets AllocateDescriptorSets;
PFN_vkFreeDescriptorSets FreeDescriptorSets;
PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
PFN_vkCreatePipelineLayout CreatePipelineLayout;
PFN_vkDestroyPipelineLayout DestroyPipelineLayout;
PFN_vkCreateShaderModule CreateShaderModule;
PFN_vkDestroyShaderModule DestroyShaderModule;
PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines;
PFN_vkDestroyPipeline DestroyPipeline;
PFN_vkCreateCommandPool CreateCommandPool;
PFN_vkDestroyCommandPool DestroyCommandPool;
PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
PFN_vkFreeCommandBuffers FreeCommandBuffers;
PFN_vkBeginCommandBuffer BeginCommandBuffer;
PFN_vkEndCommandBuffer EndCommandBuffer;
PFN_vkResetCommandBuffer ResetCommandBuffer;
PFN_vkCmdBeginRenderPass CmdBeginRenderPass;
PFN_vkCmdEndRenderPass CmdEndRenderPass;
PFN_vkCmdBindPipeline CmdBindPipeline;
PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
PFN_vkCmdDraw CmdDraw;
PFN_vkCmdPushConstants CmdPushConstants;
PFN_vkCmdSetViewport CmdSetViewport;
PFN_vkCmdSetScissor CmdSetScissor;
PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
PFN_vkCmdCopyImage CmdCopyImage;
PFN_vkCmdBlitImage CmdBlitImage;
PFN_vkCmdDispatch CmdDispatch;
PFN_vkCreateComputePipelines CreateComputePipelines;
PFN_vkUnmapMemory UnmapMemory;
PFN_vkCmdClearColorImage CmdClearColorImage;
PFN_vkResetDescriptorPool ResetDescriptorPool;
PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage;
PFN_vkCreateSampler CreateSampler;
PFN_vkDestroySampler DestroySampler;
PFN_vkCreateSemaphore CreateSemaphore;
PFN_vkDestroySemaphore DestroySemaphore;
PFN_vkCreateFence CreateFence;
PFN_vkDestroyFence DestroyFence;
PFN_vkWaitForFences WaitForFences;
PFN_vkResetFences ResetFences;
PFN_vkGetFenceStatus GetFenceStatus;
PFN_vkGetAndroidHardwareBufferPropertiesANDROID GetAndroidHardwareBufferPropertiesANDROID;
};
#include <android/log.h>
#include <string>
#define WLOG_TAG "DroidDeck_Renderer"
#define RLOG(...) if(verboseLog) __android_log_print(ANDROID_LOG_DEBUG,WLOG_TAG,__VA_ARGS__)
#define RLOG_E(...) __android_log_print(ANDROID_LOG_ERROR,WLOG_TAG,__VA_ARGS__)
#define SCANOUT_LOG(...) __android_log_print(ANDROID_LOG_DEBUG,"DroidDeck_Scanout",__VA_ARGS__)
#include <vulkan/vulkan_android.h>
#include <android/hardware_buffer.h>
#include <android/native_window.h>
#include <vector>
#include <unordered_map>
#include <thread>
#include <atomic>
#include <mutex>
#include <shared_mutex>
#include <condition_variable>
#include <chrono>
#include "../scanout/ScanoutContext.h"
#include "lsfg/lsfg_probe.h"
#include <memory>
#include <string>
namespace lsfg { class Engine; }
namespace ddfg { class Engine; }
static constexpr uint32_t MAX_FRAMES_IN_FLIGHT = 2;
struct SgsrPushConstants {
float ndc[4];
float viewportInfo[4];
float edgeSharpness;
};
struct NisPushConstants {
float ndc[4];
float viewportInfo[4];
float sharpness;
};
struct EasuPushConstants {
float ndc[4];
uint32_t con0[4], con1[4], con2[4], con3[4];
float outW, outH;
};
struct RcasPushConstants {
float ndc[4];
uint32_t con[4];
float outW, outH;
};
struct CasPushConstants {
float ndc[4];
float resolution[2];
float sharpness;
float _pad;
};
struct HdrPushConstants {
float ndc[4];
float resolution[2];
};
struct FxaaPushConstants {
float ndc[4];
float resolution[2];
};
struct ToonPushConstants {
float ndc[4];
float resolution[2];
};
struct ColorPushConstants {
float ndc[4];
float brightness;
float contrast;
float gamma;
float saturation;
};
struct NtscPushConstants {
float ndc[4];
float resolution[2];
float frameCount;
};
struct CrtPushConstants {
float ndc[4];
float resolution[2];
};
struct DebandPushConstants {
float ndc[4];
float resolution[2];
float strength;
};
class VulkanRendererContext {
public:
VulkanRendererContext(ANativeWindow* window, int cWidth, int cHeight, void* adrenotoolsHandle = nullptr,
bool lsfgVk11Compat = false);
~VulkanRendererContext();
void onSurfaceResized(int width, int height);
void setTransform(float ox, float oy, float sx, float sy);
void setClipRegion(int x, int y, int w, int h);
void updatePointerPosition(short x, short y);
void updateWindowContent(int64_t id, void* pixels, short w, short h, short stride, int x, int y);
void updateWindowContentAHB(int64_t id, AHardwareBuffer* ahb, short w, short h, int x, int y);
void updateCursorImage(void* pixels, short w, short h, short hotX, short hotY);
void setCursorVisible(bool visible);
void setRenderList(const int64_t* ids, const int* xs, const int* ys, int count);
void removeWindow(int64_t id);
void clearBackbuffer() {}
void beginBatch() {}
void endBatch() {}
void initScanout();
void destroyScanout();
void applyScanoutBuffer();
void initScanoutFromWindows(ANativeWindow* gameWin, ANativeWindow* cursorWin);
void scanoutSetDst(int x, int y, int w, int h);
void scanoutSetBuffer(AHardwareBuffer* ahb, int x, int y, int w, int h, int fenceFd = -1);
void scanoutSetCursorImage(void* pixels, short w, short h, short stride);
void scanoutSetCursorPos(short x, short y, short hotX, short hotY);
ScanoutContext scanout;
std::atomic<bool>& scanoutActive = scanout.scanoutActive;
std::atomic<bool>& gameFrameDelivered = scanout.gameFrameDelivered;
std::atomic<bool> surfaceDetached{false};
void detachSurface();
bool reattachSurface(ANativeWindow* newWindow);
bool verboseLog = true;
void setVerboseLog(bool v) { verboseLog = v; scanout.setVerboseLog(v); }
void dumpRendererInfo();
std::string adrenoDriverPath;
std::string adrenoDriverName;
std::string adrenoNativeLibDir;
void* vulkanHandle = nullptr;
std::atomic<bool> scanoutBlackFrameDone{false};
PFN_vkGetInstanceProcAddr gipa = nullptr;
VkTable vk_ = {};
void loadCustomDriver();
void loadInstanceDispatch();
void loadDeviceDispatch();
void setFilterMode(int mode);
void setUpscaler(int mode);
void setHqDownscale(bool enabled);
void setCas(bool enabled, int sharpness);
void setHdr(bool enabled);
void setDeband(bool enabled, int strength);
void setUpscaleSharpness(int sharpness);
void setFxaa(bool enabled);
void setToon(bool enabled);
void setCrt(bool enabled);
void setNtsc(bool enabled);
void setColorGrade(float brightness, float contrast, float gamma, float saturation);
void setSwapRB(bool enabled);
void setPresentMode(VkPresentModeKHR mode);
std::vector<int> getSupportedPresentModes() const;
const lsfg::Caps& lsfgCaps() const { return lsfgCaps_; }
void setFrameGenArmed(bool armed, int multiplier);
bool frameGenArmed() const { return fgArmed_.load(std::memory_order_relaxed); }
void frameGenStats(float out[6]) const;
int frameGenProblem() const;
void setLsfgCachePath(const char* path);
static constexpr int32_t kFgCaptureGame = -1;
void setFrameGenTuning(float flowScale, float refreshHz, int32_t captureHeight = 0);
void setFrameGenEngine(int kind);
void setDdFgTuning(int model, int perfPreset);
private:
struct WinTex {
VkImage img = VK_NULL_HANDLE;
VkDeviceMemory mem = VK_NULL_HANDLE;
VkImageView view = VK_NULL_HANDLE;
VkDescriptorSet ds = VK_NULL_HANDLE;
VkBuffer stg = VK_NULL_HANDLE;
VkDeviceMemory stgMem = VK_NULL_HANDLE;
void* mapped = nullptr;
VkDeviceSize cap = 0;
int w = 0;
int h = 0;
bool dirty = false;
bool isAHB = false;
bool needsTransition = false;
AHardwareBuffer* ahb = nullptr;
};
struct RenderEntry { int64_t id; int x, y; };
struct DrawEntry {
VkImage img = VK_NULL_HANDLE;
VkDescriptorSet ds = VK_NULL_HANDLE;
VkBuffer upload = VK_NULL_HANDLE;
int x=0, y=0, w=0, h=0;
bool needsTransition = false;
bool isAHB = false;
};
ANativeWindow* window;
int surfaceWidth, surfaceHeight, containerWidth, containerHeight;
std::atomic<int> clipRegionX{0}, clipRegionY{0}, clipRegionW{0}, clipRegionH{0};
void* adrenotoolsHandle = nullptr;
bool lsfgVk11Compat_ = false;
int filterMode = 0;
bool swapRB = false;
float maxAnisotropy = 1.0f;
bool cubicSupported = false;
VkPhysicalDeviceMemoryProperties memProperties{};
VkPresentModeKHR requestedPresentMode = VK_PRESENT_MODE_FIFO_KHR;
uint32_t graphicsQueueFamilyIndex = 0;
std::vector<VkPresentModeKHR> availablePresentModes;
std::unordered_map<int64_t, WinTex> texMap;
std::unordered_map<AHardwareBuffer*, WinTex> ahbImportCache;
std::unordered_map<int64_t, std::vector<AHardwareBuffer*>> windowAhbs;
std::vector<WinTex> deleteQueue;
std::vector<RenderEntry> renderList;
std::vector<DrawEntry> frameDraws;
std::vector<VkImageMemoryBarrier> frameAhbTransitions;
std::vector<VkImageMemoryBarrier> framePreUpload;
std::vector<VkImageMemoryBarrier> framePostUpload;
std::atomic<int> pointerX{0}, pointerY{0};
float sceneOffsetX=0.f, sceneOffsetY=0.f, sceneScaleX=1.f, sceneScaleY=1.f;
std::atomic<bool> cursorVisible{false};
short cursorHotX=0, cursorHotY=0, cursorTexW=0, cursorTexH=0;
std::vector<uint32_t> cursorPixels;
std::atomic<bool> isCursorImageDirty{false};
std::atomic<bool> cursorMoved{false};
VkImage cursorImg = VK_NULL_HANDLE;
VkDeviceMemory cursorMem = VK_NULL_HANDLE;
VkImageView cursorView = VK_NULL_HANDLE;
VkDescriptorSet cursorDS = VK_NULL_HANDLE;
VkBuffer cursorStg = VK_NULL_HANDLE;
VkDeviceMemory cursorStgM = VK_NULL_HANDLE;
void* cursorStgP = nullptr;
VkDeviceSize cursorStgC = 0;
VkDeviceSize cursorUploadSize = 0;
VkInstance instance;
VkSurfaceKHR surface;
VkPhysicalDevice physicalDevice;
VkDevice device;
VkQueue graphicsQueue;
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
VkFormat swapchainFmt;
VkExtent2D swapchainExt;
std::vector<VkImage> swapchainImages;
std::vector<VkImageView> swapchainViews;
std::vector<VkFramebuffer> swapchainFBs;
VkRenderPass renderPass = VK_NULL_HANDLE;
VkDescriptorSetLayout dsLayout = VK_NULL_HANDLE;
VkPipelineLayout pipeLayout = VK_NULL_HANDLE;
VkPipeline pipeline = VK_NULL_HANDLE;
int upscalerMode = 0;
bool hqDownscale = false;
bool casEnabled = false;
int casSharpness = 60;
bool hdrEnabled = false;
float upscaleSharpness01 = 0.75f;
bool debandEnabled = false;
int debandStrength = 100;
bool fxaaEnabled = false;
bool toonEnabled = false;
bool crtEnabled = false;
bool ntscEnabled = false;
bool colorEnabled = false;
float colorBrightness = 0.0f;
float colorContrast = 0.0f;
float colorGamma = 1.0f;
float colorSaturation = 1.0f;
uint32_t ntscFrameCounter = 0;
VkSampler upscaleSampler = VK_NULL_HANDLE;
struct CompositeTarget {
VkImage img = VK_NULL_HANDLE;
VkDeviceMemory mem = VK_NULL_HANDLE;
VkImageView view = VK_NULL_HANDLE;
VkImageView storageView = VK_NULL_HANDLE;
VkFramebuffer fb = VK_NULL_HANDLE;
VkDescriptorSet ds = VK_NULL_HANDLE;
};
static constexpr uint32_t kMaxCompositeTargets = 7;
std::vector<CompositeTarget> compositeTargets;
VkRenderPass compositeRenderPass = VK_NULL_HANDLE;
uint32_t compositeW = 0, compositeH = 0;
uint32_t compositeIndex = 0;
bool compositeArmed = false;
bool swapchainTransferDst = false;
std::atomic<bool> fgArmed_{false};
std::atomic<int> fgMultiplier_{0};
std::atomic<float> fgFlowScale_{1.0f};
std::atomic<float> fgRefreshHz_{0.0f};
std::atomic<bool> fgConfigDirty_{true};
std::atomic<int32_t> fgCaptureHeight_{0};
void compositeExtentFor(uint32_t& w, uint32_t& h) const;
VkExtent2D renderExtent() const {
if (compositeActive() && (compositeW != swapchainExt.width || compositeH != swapchainExt.height))
return VkExtent2D{compositeW, compositeH};
return swapchainExt;
}
void recordCompositeToSwapchainTransfer(VkCommandBuffer cb, VkImage src, uint32_t imgIdx);
bool createCompositeRenderPass();
bool ensureCompositeTargets(uint32_t w, uint32_t h, uint32_t count);
void destroyCompositeTargets();
bool compositeActive() const;
VkRenderPass targetRenderPass() const;
VkFramebuffer targetFramebuffer(uint32_t imgIdx) const;
void copyCompositeToSwapchain(VkCommandBuffer cb, uint32_t imgIdx);
VkRenderPass cursorOverlayRenderPass = VK_NULL_HANDLE;
struct CursorOverlay {
bool draw = false;
float ox = 0, oy = 0, sx = 0, sy = 0, cw = 0, ch = 0;
short ptrX = 0, ptrY = 0, hotX = 0, hotY = 0, w = 0, h = 0;
};
CursorOverlay cursorOverlay_{};
bool createCursorOverlayRenderPass();
void recordCursorOverlay(VkCommandBuffer cb, uint32_t imgIdx);
bool cursorDrawnPerPresent() const;
static constexpr uint32_t kMaxPresentsPerFrame = 4;
struct FrameGenPlan {
uint32_t generations = 0;
uint32_t presents = 1;
uint32_t imgIdx[kMaxPresentsPerFrame] = {};
};
FrameGenPlan fgPlan_{};
std::unique_ptr<lsfg::Engine> lsfgEngine_;
uint64_t fgSourceFrames_ = 0;
std::string lsfgCachePath_;
bool lsfgEngineTried_ = false;
std::unique_ptr<ddfg::Engine> ddfgEngine_;
bool ddfgEngineTried_ = false;
std::atomic<int> fgEngineKind_{0};
std::atomic<int> fgModel_{4};
std::atomic<int> fgPerfPreset_{1};
bool ensureDdFgEngine();
bool fgCapsOk() const;
uint32_t syncSlot(uint32_t k) const { return currentFrame * kMaxPresentsPerFrame + k; }
void recreateSyncObjects();
uint32_t fgAcquireFailLog_ = 0;
float fgPresentedRate_ = 0.0f;
float fgSourceRate_ = 0.0f;
uint32_t fgSourceAccum_ = 0;
uint32_t fgPresentAccum_ = 0;
std::chrono::steady_clock::time_point fgRateWindowStart_{};
bool fgRateWindowOpen_ = false;
void trackPresentedRate(uint32_t presents);
bool ensureLsfgEngine();
uint32_t cmdSlot(uint32_t k) const { return currentFrame * kMaxPresentsPerFrame + k; }
void recordFrameGenProcess(VkCommandBuffer cb);
void recordFrameGenGeneration(VkCommandBuffer cb, uint32_t g);
VkQueryPool fgQueryPool_ = VK_NULL_HANDLE;
bool fgTimestampsOk_ = false;
float fgTimestampPeriodNs_ = 0.0f;
bool fgQueryPending_[MAX_FRAMES_IN_FLIGHT] = {};
uint32_t fgQueryGens_[MAX_FRAMES_IN_FLIGHT] = {};
float fgChainMsPerGen_ = -1.0f;
uint32_t fgChainLogCount_ = 0;
void ensureFgQueryPool();
void destroyFgQueryPool();
void readFgQueryResult();
VkFormat offscreenFmt = VK_FORMAT_R8G8B8A8_UNORM;
VkRenderPass offscreenRenderPass = VK_NULL_HANDLE;
VkPipelineLayout postPipeLayout = VK_NULL_HANDLE;
VkPipeline sgsrPipeline = VK_NULL_HANDLE;
VkPipeline nisPipeline = VK_NULL_HANDLE;
VkPipeline sgsrQualityPipeline = VK_NULL_HANDLE;
VkPipeline easuPipeline = VK_NULL_HANDLE;
VkPipeline rcasPipeline = VK_NULL_HANDLE;
VkPipeline downscalePipeline = VK_NULL_HANDLE;
VkPipeline casPipelineOff = VK_NULL_HANDLE;
VkPipeline casPipelineSwap = VK_NULL_HANDLE;
VkPipeline hdrPipelineOff = VK_NULL_HANDLE;
VkPipeline hdrPipelineSwap = VK_NULL_HANDLE;
VkPipeline fxaaPipelineOff = VK_NULL_HANDLE;
VkPipeline fxaaPipelineSwap = VK_NULL_HANDLE;
VkPipeline toonPipelineOff = VK_NULL_HANDLE;
VkPipeline toonPipelineSwap = VK_NULL_HANDLE;
VkPipeline colorPipelineOff = VK_NULL_HANDLE;
VkPipeline colorPipelineSwap = VK_NULL_HANDLE;
VkPipeline ntscPipelineOff = VK_NULL_HANDLE;
VkPipeline ntscPipelineSwap = VK_NULL_HANDLE;
VkPipeline crtPipelineOff = VK_NULL_HANDLE;
VkPipeline crtPipelineSwap = VK_NULL_HANDLE;
VkPipeline debandPipelineSwap = VK_NULL_HANDLE;
VkImage offscreenImg = VK_NULL_HANDLE;
VkDeviceMemory offscreenMem = VK_NULL_HANDLE;
VkImageView offscreenView = VK_NULL_HANDLE;
VkFramebuffer offscreenFB = VK_NULL_HANDLE;
VkDescriptorSet offscreenDS = VK_NULL_HANDLE;
int offscreenW = 0, offscreenH = 0;
VkImage midImg = VK_NULL_HANDLE;
VkDeviceMemory midMem = VK_NULL_HANDLE;
VkImageView midView = VK_NULL_HANDLE;
VkFramebuffer midFB = VK_NULL_HANDLE;
VkDescriptorSet midDS = VK_NULL_HANDLE;
int midW = 0, midH = 0;
VkImage fx1Img = VK_NULL_HANDLE;
VkDeviceMemory fx1Mem = VK_NULL_HANDLE;
VkImageView fx1View = VK_NULL_HANDLE;
VkFramebuffer fx1FB = VK_NULL_HANDLE;
VkDescriptorSet fx1DS = VK_NULL_HANDLE;
int fx1W = 0, fx1H = 0;
VkImage fx2Img = VK_NULL_HANDLE;
VkDeviceMemory fx2Mem = VK_NULL_HANDLE;
VkImageView fx2View = VK_NULL_HANDLE;
VkFramebuffer fx2FB = VK_NULL_HANDLE;
VkDescriptorSet fx2DS = VK_NULL_HANDLE;
int fx2W = 0, fx2H = 0;
struct UpscaleFrame {
bool active = false;
int mode = 0;
int outX = 0, outY = 0, outW = 0, outH = 0;
bool cas = false;
bool hdr = false;
bool fxaa = false;
bool toon = false;
bool color = false;
bool ntsc = false;
bool crt = false;
bool deband = false;
SgsrPushConstants sgsrPC{};
NisPushConstants nisPC{};
EasuPushConstants easuPC{};
RcasPushConstants rcasPC{};
CasPushConstants casPC{};
HdrPushConstants hdrPC{};
FxaaPushConstants fxaaPC{};
ToonPushConstants toonPC{};
ColorPushConstants colorPC{};
NtscPushConstants ntscPC{};
CrtPushConstants crtPC{};
DebandPushConstants debandPC{};
} upFrame;
VkCommandPool cmdPool = VK_NULL_HANDLE;
std::vector<VkCommandBuffer> cmdBufs;
std::vector<VkSemaphore> imgAvailSems;
std::vector<VkSemaphore> renderDoneSems;
std::vector<VkFence> inFlightFences;
std::vector<VkFence> imgInFlight;
uint32_t currentFrame = 0;
VkSampler sampler = VK_NULL_HANDLE;
VkDescriptorPool winTexPool = VK_NULL_HANDLE;
std::atomic<bool> needsRender{false};
std::thread renderThread;
std::atomic<bool> isRunning{false};
std::atomic<bool> fbResized{false};
std::mutex renderMutex;
std::mutex dirtyMutex;
std::condition_variable dirtyCV;
std::shared_mutex frameMutex;
void createInstance();
void createSurface();
void pickPhysicalDevice();
lsfg::Caps lsfgCaps_{};
void createLogicalDevice();
void createSwapchain();
void createRenderPass();
void createDSLayout();
void createPipeline(bool blend, VkPipeline& out);
void createFramebuffers();
void createCmdPool();
void createSampler();
void createUpscaleSampler();
void createOffscreenRenderPass();
void createPostPipelines();
VkPipeline createPostPipeline(const uint32_t* fragCode, size_t fragSz, VkRenderPass rp);
bool createColorTarget(int w, int h, VkImage& img, VkDeviceMemory& mem,
VkImageView& view, VkFramebuffer& fb, VkDescriptorSet& ds);
void destroyColorTarget(VkImage& img, VkDeviceMemory& mem, VkImageView& view,
VkFramebuffer& fb, VkDescriptorSet& ds);
bool ensureOffscreen(int w, int h);
bool ensureMid(int w, int h);
bool ensureFx1(int w, int h);
bool ensureFx2(int w, int h);
void recordUpscalePasses(VkCommandBuffer cb, uint32_t imgIdx,
const std::vector<DrawEntry>& draws, bool cursorDrawn,
short ptrX, short ptrY, short curHotX, short curHotY,
short curW, short curH,
float ox, float oy, float sx, float sy,
float cw, float ch);
void planUpscaleFrame();
void createWinTexPool();
void createCursorPipeline();
void createCursorDS();
void createCmdBufs();
void createSyncObjects();
void cleanupSwapchain();
bool createWinTexResources(WinTex& wt, int w, int h);
bool importAHBToWinTex(WinTex& wt, AHardwareBuffer* ahb);
void cleanupAllAHBCache();
void flushDeleteQueue();
void destroyWinTex(WinTex& wt);
void ensureCursorTex(short w, short h);
void cleanupCursorTex();
void ensureCursorStaging(VkDeviceSize sz);
void recordCmdBuf(VkCommandBuffer cb, uint32_t imgIdx,
const std::vector<DrawEntry>& draws,
std::vector<VkImageMemoryBarrier>& ahbTransitions,
std::vector<VkImageMemoryBarrier>& preUpload,
std::vector<VkImageMemoryBarrier>& postUpload,
VkBuffer cursorUpload, bool hasCursorUpload,
float ox, float oy, float sx, float sy, float cw, float ch,
short ptrX, short ptrY, short curHotX, short curHotY,
short curW, short curH, bool curVis);
void renderLoop();
void renderFrame();
uint32_t findMemType(uint32_t filter, VkMemoryPropertyFlags props);
void createBuffer(VkDeviceSize sz, VkBufferUsageFlags usage,
VkMemoryPropertyFlags props, VkBuffer& buf, VkDeviceMemory& mem);
VkCommandBuffer beginOneTime();
void endOneTime(VkCommandBuffer cmd);
void transition(VkCommandBuffer cmd, VkImage img,
VkImageLayout oldL, VkImageLayout newL,
VkAccessFlags srcA, VkAccessFlags dstA,
VkPipelineStageFlags srcS, VkPipelineStageFlags dstS);
VkShaderModule makeShader(const uint32_t* code, size_t sz);
};
+1 -1
View File
@@ -1,5 +1,5 @@
#include "ddfg_vkd.h"
#include "../VulkanRendererContext.h"
#include "../VkDispatchTable.h"
#include <android/log.h>
bool ddfgVkdInit(const VkTable& table, ddfg::DeviceDispatch& dd, ddfg::InstanceDispatch& id) {
@@ -1,6 +1,6 @@
#include "lsfg_probe.h"
#include "../VulkanRendererContext.h"
#include "../VkDispatchTable.h"
#include <cstdio>
#include <cstring>
+1 -1
View File
@@ -1,6 +1,6 @@
#include "lsfg_vkd.h"
#include "../VulkanRendererContext.h"
#include "../VkDispatchTable.h"
#include <android/log.h>
-82
View File
@@ -1,82 +0,0 @@
#pragma once
#include <android/hardware_buffer.h>
#include <android/native_window.h>
#include <android/rect.h>
#include <android/log.h>
#include <atomic>
#include <mutex>
#include <cstdint>
#ifndef SCANOUT_LOG
#define SCANOUT_LOG(...) __android_log_print(ANDROID_LOG_DEBUG,"DroidDeck_Scanout",__VA_ARGS__)
#endif
class ScanoutContext {
public:
bool loadApi();
void initFromWindow(ANativeWindow* win = nullptr);
void initFromWindows(ANativeWindow* gameWin, ANativeWindow* cursorWin);
void destroy();
void setBuffer(AHardwareBuffer* ahb, int x, int y, int w, int h, int fenceFd = -1);
bool setCursorImage(void* pixels, short w, short h, short stride);
bool setCursorPos(short x, short y, short hotX, short hotY);
void applyPendingCursor();
void setDst(int x, int y, int w, int h);
void setContainerSize(int w, int h) { containerWidth = w; containerHeight = h; }
void setSurfaceSize(int w, int h) { surfaceWidth = w; surfaceHeight = h; }
void setFallbackWindow(ANativeWindow* win) { window = win; }
void setVerboseLog(bool v) { verboseLog = v; }
bool isActive() const { return scanoutActive.load(); }
bool isGameFrameDelivered() const {
return gameFrameDelivered.load(std::memory_order_acquire);
}
void* debugGameSC() const { return scanoutGameSC; }
std::atomic<bool> scanoutActive{false};
std::atomic<bool> gameFrameDelivered{false};
private:
ANativeWindow* window = nullptr;
bool verboseLog = true;
int surfaceWidth = 0, surfaceHeight = 0, containerWidth = 0, containerHeight = 0;
void* scanoutGameSC = nullptr;
void* scanoutCursorSC = nullptr;
void* scanoutCursorBuf = nullptr;
int32_t scanoutCursorBufW = 0;
int32_t scanoutCursorBufH = 0;
void* scanoutTx = nullptr;
void* scanoutGameTx = nullptr;
ARect scanoutLastSrc{}, scanoutLastDst{};
bool scanoutGeoDirty = true;
bool scanoutVisShown = false;
bool scanoutApiLoaded = false;
void* fnSCCreateFromWin = nullptr;
void* fnSCRelease = nullptr;
void* fnSTCreate = nullptr;
void* fnSTDelete = nullptr;
void* fnSTApply = nullptr;
void* fnSTSetBuffer = nullptr;
void* fnSTSetZOrder = nullptr;
void* fnSTSetVisibility = nullptr;
void* fnSTSetGeometry = nullptr;
int32_t scanoutDstX = 0, scanoutDstY = 0, scanoutDstW = 0, scanoutDstH = 0;
bool gameScVisible = false;
std::mutex scanoutMutex;
short pendingCursorX = 0, pendingCursorY = 0, pendingCursorHotX = 0, pendingCursorHotY = 0;
bool cursorPosDirty = false;
bool cursorImageDirty = false;
};
+100
View File
@@ -0,0 +1,100 @@
#version 450
layout(location = 0) in vec2 fragTexCoord;
layout(location = 0) out vec4 outColor;
layout(set = 0, binding = 0) uniform sampler2D InputTexture;
layout(push_constant) uniform Constants {
vec4 ndc;
vec2 resolution;
float extra;
float pad;
} pc;
float luma(vec3 c) {
return dot(c, vec3(0.2126, 0.7152, 0.0722));
}
float edgeVertical(vec2 uv, vec2 px) {
float a = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb);
float b = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb);
return abs(a - b);
}
float edgeHorizontal(vec2 uv, vec2 px) {
float a = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb);
float b = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb);
return abs(a - b);
}
void main() {
vec2 px = 1.0 / max(pc.resolution, vec2(1.0));
vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5);
vec4 center = texture(InputTexture, uv);
float lc = luma(center.rgb);
float ll = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb);
float lr = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb);
float lu = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb);
float ld = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb);
float dL = abs(lc - ll);
float dR = abs(lc - lr);
float dU = abs(lc - lu);
float dD = abs(lc - ld);
float localMin = min(lc, min(min(ll, lr), min(lu, ld)));
float localMax = max(lc, max(max(ll, lr), max(lu, ld)));
float localContrast = localMax - localMin;
float threshold = max(0.045, localContrast * 0.08);
float vertical = max(dL, dR);
float horizontal = max(dU, dD);
float strongest = max(vertical, horizontal);
if (strongest <= threshold) {
outColor = center;
return;
}
bool verticalEdge = vertical >= horizontal;
vec2 tangent = verticalEdge ? vec2(0.0, px.y) : vec2(px.x, 0.0);
vec2 normal = verticalEdge
? vec2(dL >= dR ? -1.0 : 1.0, 0.0)
: vec2(0.0, dU >= dD ? -1.0 : 1.0);
float negativeRun = 0.0;
float positiveRun = 0.0;
for (int i = 1; i <= 6; ++i) {
vec2 offset = tangent * float(i);
float edgeN = verticalEdge ? edgeVertical(uv - offset, px) : edgeHorizontal(uv - offset, px);
float edgeP = verticalEdge ? edgeVertical(uv + offset, px) : edgeHorizontal(uv + offset, px);
if (negativeRun == float(i - 1) && edgeN > threshold * 0.65) negativeRun = float(i);
if (positiveRun == float(i - 1) && edgeP > threshold * 0.65) positiveRun = float(i);
}
float span = negativeRun + positiveRun;
float edgeConfidence = smoothstep(threshold, threshold * 2.5, strongest);
float nw = luma(texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb);
float ne = luma(texture(InputTexture, uv + vec2(px.x, -px.y)).rgb);
float sw = luma(texture(InputTexture, uv + vec2(-px.x, px.y)).rgb);
float se = luma(texture(InputTexture, uv + vec2(px.x, px.y)).rgb);
float endpointPattern = clamp(abs(negativeRun - positiveRun) / max(span, 1.0), 0.0, 1.0);
float endpointArea = endpointPattern / (1.0 + span * 0.055);
float crossingA = verticalEdge ? abs(nw - ne) : abs(nw - sw);
float crossingB = verticalEdge ? abs(sw - se) : abs(ne - se);
float crossingContrast = abs(crossingA - crossingB);
float crossingPattern = smoothstep(threshold, threshold * 2.5, crossingContrast);
float areaWeight = 0.38 * crossingPattern * clamp(span / 4.0, 0.0, 1.0);
float diagonalContrast = max(abs(nw - se), abs(ne - sw));
float cornerFactor = 1.0 - 0.35 * smoothstep(threshold, threshold * 3.0, diagonalContrast);
float baseWeight = areaWeight * endpointArea * edgeConfidence * cornerFactor;
float diagonalStrength = min(vertical, horizontal);
float diagonalPattern = smoothstep(threshold, threshold * 2.5, diagonalStrength);
float diagonalContinuity = smoothstep(1.0, 3.0, span);
float diagonalFallback = 0.16 * diagonalPattern * edgeConfidence
* cornerFactor * diagonalContinuity * crossingPattern;
float weight = clamp(max(baseWeight, diagonalFallback), 0.0, 0.42);
vec3 across = texture(InputTexture, uv + normal * px).rgb;
outColor = vec4(mix(center.rgb, across, weight), center.a);
}
+443
View File
@@ -0,0 +1,443 @@
#pragma once
#include <stdint.h>
static const uint32_t smaa_code[] = {
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000251u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x0007000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000072u, 0x000000f6u, 0x00030010u,
0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u, 0x6e69616du,
0x00000000u, 0x00050005u, 0x0000000bu, 0x616d756cu, 0x33667628u, 0x0000003bu, 0x00030005u, 0x0000000au,
0x00000063u, 0x00080005u, 0x00000012u, 0x65676465u, 0x74726556u, 0x6c616369u, 0x32667628u, 0x3266763bu,
0x0000003bu, 0x00030005u, 0x00000010u, 0x00007675u, 0x00030005u, 0x00000011u, 0x00007870u, 0x00080005u,
0x00000016u, 0x65676465u, 0x69726f48u, 0x746e6f7au, 0x76286c61u, 0x763b3266u, 0x003b3266u, 0x00030005u,
0x00000014u, 0x00007675u, 0x00030005u, 0x00000015u, 0x00007870u, 0x00030005u, 0x00000021u, 0x00000061u,
0x00060005u, 0x00000025u, 0x75706e49u, 0x78655474u, 0x65727574u, 0x00000000u, 0x00040005u, 0x00000031u,
0x61726170u, 0x0000006du, 0x00030005u, 0x00000034u, 0x00000062u, 0x00040005u, 0x0000003cu, 0x61726170u,
0x0000006du, 0x00030005u, 0x00000045u, 0x00000061u, 0x00040005u, 0x0000004eu, 0x61726170u, 0x0000006du,
0x00030005u, 0x00000051u, 0x00000062u, 0x00040005u, 0x00000059u, 0x61726170u, 0x0000006du, 0x00030005u,
0x00000062u, 0x00007870u, 0x00050005u, 0x00000064u, 0x736e6f43u, 0x746e6174u, 0x00000073u, 0x00040006u,
0x00000064u, 0x00000000u, 0x0063646eu, 0x00060006u, 0x00000064u, 0x00000001u, 0x6f736572u, 0x6974756cu,
0x00006e6fu, 0x00050006u, 0x00000064u, 0x00000002u, 0x72747865u, 0x00000061u, 0x00040006u, 0x00000064u,
0x00000003u, 0x00646170u, 0x00030005u, 0x00000066u, 0x00006370u, 0x00030005u, 0x00000070u, 0x00007675u,
0x00060005u, 0x00000072u, 0x67617266u, 0x43786554u, 0x64726f6fu, 0x00000000u, 0x00040005u, 0x0000007cu,
0x746e6563u, 0x00007265u, 0x00030005u, 0x00000080u, 0x0000636cu, 0x00040005u, 0x00000081u, 0x61726170u,
0x0000006du, 0x00030005u, 0x00000085u, 0x00006c6cu, 0x00040005u, 0x0000008du, 0x61726170u, 0x0000006du,
0x00030005u, 0x00000090u, 0x0000726cu, 0x00040005u, 0x00000098u, 0x61726170u, 0x0000006du, 0x00030005u,
0x0000009bu, 0x0000756cu, 0x00040005u, 0x000000a3u, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000a6u,
0x0000646cu, 0x00040005u, 0x000000aeu, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000b1u, 0x00004c64u,
0x00030005u, 0x000000b6u, 0x00005264u, 0x00030005u, 0x000000bbu, 0x00005564u, 0x00030005u, 0x000000c0u,
0x00004464u, 0x00050005u, 0x000000c5u, 0x61636f6cu, 0x6e694d6cu, 0x00000000u, 0x00050005u, 0x000000cfu,
0x61636f6cu, 0x78614d6cu, 0x00000000u, 0x00060005u, 0x000000d9u, 0x61636f6cu, 0x6e6f436cu, 0x73617274u,
0x00000074u, 0x00050005u, 0x000000ddu, 0x65726874u, 0x6c6f6873u, 0x00000064u, 0x00050005u, 0x000000e3u,
0x74726576u, 0x6c616369u, 0x00000000u, 0x00050005u, 0x000000e7u, 0x69726f68u, 0x746e6f7au, 0x00006c61u,
0x00050005u, 0x000000ebu, 0x6f727473u, 0x7365676eu, 0x00000074u, 0x00050005u, 0x000000f6u, 0x4374756fu,
0x726f6c6fu, 0x00000000u, 0x00060005u, 0x000000fau, 0x74726576u, 0x6c616369u, 0x65676445u, 0x00000000u,
0x00040005u, 0x000000feu, 0x676e6174u, 0x00746e65u, 0x00040005u, 0x0000010bu, 0x6d726f6eu, 0x00006c61u,
0x00050005u, 0x0000011du, 0x6167656eu, 0x65766974u, 0x006e7552u, 0x00050005u, 0x0000011eu, 0x69736f70u,
0x65766974u, 0x006e7552u, 0x00030005u, 0x00000120u, 0x00000069u, 0x00040005u, 0x00000129u, 0x7366666fu,
0x00007465u, 0x00040005u, 0x0000012eu, 0x65676465u, 0x0000004eu, 0x00040005u, 0x00000136u, 0x61726170u,
0x0000006du, 0x00040005u, 0x00000137u, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000013eu, 0x61726170u,
0x0000006du, 0x00040005u, 0x0000013fu, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000143u, 0x65676465u,
0x00000050u, 0x00040005u, 0x0000014bu, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000014cu, 0x61726170u,
0x0000006du, 0x00040005u, 0x00000153u, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000154u, 0x61726170u,
0x0000006du, 0x00040005u, 0x0000017bu, 0x6e617073u, 0x00000000u, 0x00060005u, 0x0000017fu, 0x65676465u,
0x666e6f43u, 0x6e656469u, 0x00006563u, 0x00030005u, 0x00000186u, 0x0000776eu, 0x00040005u, 0x00000192u,
0x61726170u, 0x0000006du, 0x00030005u, 0x00000195u, 0x0000656eu, 0x00040005u, 0x000001a0u, 0x61726170u,
0x0000006du, 0x00030005u, 0x000001a3u, 0x00007773u, 0x00040005u, 0x000001aeu, 0x61726170u, 0x0000006du,
0x00030005u, 0x000001b1u, 0x00006573u, 0x00040005u, 0x000001bbu, 0x61726170u, 0x0000006du, 0x00060005u,
0x000001beu, 0x70646e65u, 0x746e696fu, 0x74746150u, 0x006e7265u, 0x00060005u, 0x000001c7u, 0x70646e65u,
0x746e696fu, 0x61657241u, 0x00000000u, 0x00050005u, 0x000001ceu, 0x736f7263u, 0x676e6973u, 0x00000041u,
0x00050005u, 0x000001ddu, 0x736f7263u, 0x676e6973u, 0x00000042u, 0x00070005u, 0x000001ecu, 0x736f7263u,
0x676e6973u, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x000001f1u, 0x736f7263u, 0x676e6973u,
0x74746150u, 0x006e7265u, 0x00050005u, 0x000001f7u, 0x61657261u, 0x67696557u, 0x00007468u, 0x00070005u,
0x00000200u, 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x0000020au,
0x6e726f63u, 0x61467265u, 0x726f7463u, 0x00000000u, 0x00050005u, 0x00000214u, 0x65736162u, 0x67696557u,
0x00007468u, 0x00070005u, 0x0000021cu, 0x67616964u, 0x6c616e6fu, 0x65727453u, 0x6874676eu, 0x00000000u,
0x00060005u, 0x00000220u, 0x67616964u, 0x6c616e6fu, 0x74746150u, 0x006e7265u, 0x00070005u, 0x00000226u,
0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x69756e69u, 0x00007974u, 0x00070005u, 0x00000229u, 0x67616964u,
0x6c616e6fu, 0x6c6c6146u, 0x6b636162u, 0x00000000u, 0x00040005u, 0x00000235u, 0x67696577u, 0x00007468u,
0x00040005u, 0x0000023bu, 0x6f726361u, 0x00007373u, 0x00040047u, 0x00000025u, 0x00000021u, 0x00000000u,
0x00040047u, 0x00000025u, 0x00000022u, 0x00000000u, 0x00030047u, 0x00000064u, 0x00000002u, 0x00050048u,
0x00000064u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000064u, 0x00000001u, 0x00000023u,
0x00000010u, 0x00050048u, 0x00000064u, 0x00000002u, 0x00000023u, 0x00000018u, 0x00050048u, 0x00000064u,
0x00000003u, 0x00000023u, 0x0000001cu, 0x00040047u, 0x00000072u, 0x0000001eu, 0x00000000u, 0x00040047u,
0x000000f6u, 0x0000001eu, 0x00000000u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u,
0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u, 0x00000003u, 0x00040020u,
0x00000008u, 0x00000007u, 0x00000007u, 0x00040021u, 0x00000009u, 0x00000006u, 0x00000008u, 0x00040017u,
0x0000000du, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000eu, 0x00000007u, 0x0000000du, 0x00050021u,
0x0000000fu, 0x00000006u, 0x0000000eu, 0x0000000eu, 0x0004002bu, 0x00000006u, 0x00000019u, 0x3e59b3d0u,
0x0004002bu, 0x00000006u, 0x0000001au, 0x3f371759u, 0x0004002bu, 0x00000006u, 0x0000001bu, 0x3d93dd98u,
0x0006002cu, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001au, 0x0000001bu, 0x00040020u, 0x00000020u,
0x00000007u, 0x00000006u, 0x00090019u, 0x00000022u, 0x00000006u, 0x00000001u, 0x00000000u, 0x00000000u,
0x00000000u, 0x00000001u, 0x00000000u, 0x0003001bu, 0x00000023u, 0x00000022u, 0x00040020u, 0x00000024u,
0x00000000u, 0x00000023u, 0x0004003bu, 0x00000024u, 0x00000025u, 0x00000000u, 0x00040015u, 0x00000028u,
0x00000020u, 0x00000000u, 0x0004002bu, 0x00000028u, 0x00000029u, 0x00000000u, 0x0004002bu, 0x00000006u,
0x0000002cu, 0x00000000u, 0x00040017u, 0x0000002fu, 0x00000006u, 0x00000004u, 0x0004002bu, 0x00000028u,
0x00000048u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000063u, 0x3f800000u, 0x0006001eu, 0x00000064u,
0x0000002fu, 0x0000000du, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000065u, 0x00000009u, 0x00000064u,
0x0004003bu, 0x00000065u, 0x00000066u, 0x00000009u, 0x00040015u, 0x00000067u, 0x00000020u, 0x00000001u,
0x0004002bu, 0x00000067u, 0x00000068u, 0x00000001u, 0x00040020u, 0x00000069u, 0x00000009u, 0x0000000du,
0x0005002cu, 0x0000000du, 0x0000006cu, 0x00000063u, 0x00000063u, 0x00040020u, 0x00000071u, 0x00000001u,
0x0000000du, 0x0004003bu, 0x00000071u, 0x00000072u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000075u,
0x3f000000u, 0x00040020u, 0x0000007bu, 0x00000007u, 0x0000002fu, 0x0004002bu, 0x00000006u, 0x000000deu,
0x3d3851ecu, 0x0004002bu, 0x00000006u, 0x000000e0u, 0x3da3d70au, 0x00020014u, 0x000000f1u, 0x00040020u,
0x000000f5u, 0x00000003u, 0x0000002fu, 0x0004003bu, 0x000000f5u, 0x000000f6u, 0x00000003u, 0x00040020u,
0x000000f9u, 0x00000007u, 0x000000f1u, 0x0004002bu, 0x00000006u, 0x00000113u, 0xbf800000u, 0x00040020u,
0x0000011fu, 0x00000007u, 0x00000067u, 0x0004002bu, 0x00000067u, 0x00000127u, 0x00000006u, 0x0004002bu,
0x00000006u, 0x00000161u, 0x3f266666u, 0x0004002bu, 0x00000006u, 0x00000182u, 0x40200000u, 0x0004002bu,
0x00000006u, 0x000001cau, 0x3d6147aeu, 0x0004002bu, 0x00000006u, 0x000001f8u, 0x3ec28f5cu, 0x0004002bu,
0x00000006u, 0x000001fcu, 0x40800000u, 0x0004002bu, 0x00000006u, 0x0000020bu, 0x3eb33333u, 0x0004002bu,
0x00000006u, 0x0000020eu, 0x40400000u, 0x0004002bu, 0x00000006u, 0x0000022au, 0x3e23d70au, 0x0004002bu,
0x00000006u, 0x00000239u, 0x3ed70a3du, 0x0004002bu, 0x00000028u, 0x0000024au, 0x00000003u, 0x00050036u,
0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu, 0x0000000eu,
0x00000062u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000070u, 0x00000007u, 0x0004003bu, 0x0000007bu,
0x0000007cu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000080u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x00000081u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000085u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x0000008du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000090u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x00000098u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000009bu, 0x00000007u, 0x0004003bu, 0x00000008u,
0x000000a3u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000a6u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x000000aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000b1u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000000b6u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000bbu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000000c0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000c5u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000000cfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000d9u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000000ddu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000e3u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000000e7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000ebu, 0x00000007u, 0x0004003bu, 0x000000f9u,
0x000000fau, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x000000feu, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x00000100u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000010bu, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x0000010du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000011du, 0x00000007u, 0x0004003bu, 0x00000020u,
0x0000011eu, 0x00000007u, 0x0004003bu, 0x0000011fu, 0x00000120u, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x00000129u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000012eu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000130u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000136u, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x00000137u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000013eu, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x0000013fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000143u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000145u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000014bu, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x0000014cu, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000153u, 0x00000007u, 0x0004003bu, 0x0000000eu,
0x00000154u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000017bu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x0000017fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000186u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x00000192u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000195u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x000001a0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001a3u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x000001aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001b1u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x000001bbu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001beu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000001c7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ceu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000001d0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ddu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000001dfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ecu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x000001f1u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001f7u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000200u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000020au, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000214u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000021cu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000220u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000226u, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000229u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000235u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x0000023bu, 0x00000007u, 0x00050041u, 0x00000069u, 0x0000006au, 0x00000066u, 0x00000068u, 0x0004003du,
0x0000000du, 0x0000006bu, 0x0000006au, 0x0007000cu, 0x0000000du, 0x0000006du, 0x00000001u, 0x00000028u,
0x0000006bu, 0x0000006cu, 0x00050050u, 0x0000000du, 0x0000006eu, 0x00000063u, 0x00000063u, 0x00050088u,
0x0000000du, 0x0000006fu, 0x0000006eu, 0x0000006du, 0x0003003eu, 0x00000062u, 0x0000006fu, 0x0004003du,
0x0000000du, 0x00000073u, 0x00000072u, 0x0004003du, 0x0000000du, 0x00000074u, 0x00000062u, 0x0005008eu,
0x0000000du, 0x00000076u, 0x00000074u, 0x00000075u, 0x0004003du, 0x0000000du, 0x00000077u, 0x00000062u,
0x0005008eu, 0x0000000du, 0x00000078u, 0x00000077u, 0x00000075u, 0x00050083u, 0x0000000du, 0x00000079u,
0x0000006cu, 0x00000078u, 0x0008000cu, 0x0000000du, 0x0000007au, 0x00000001u, 0x0000002bu, 0x00000073u,
0x00000076u, 0x00000079u, 0x0003003eu, 0x00000070u, 0x0000007au, 0x0004003du, 0x00000023u, 0x0000007du,
0x00000025u, 0x0004003du, 0x0000000du, 0x0000007eu, 0x00000070u, 0x00050057u, 0x0000002fu, 0x0000007fu,
0x0000007du, 0x0000007eu, 0x0003003eu, 0x0000007cu, 0x0000007fu, 0x0004003du, 0x0000002fu, 0x00000082u,
0x0000007cu, 0x0008004fu, 0x00000007u, 0x00000083u, 0x00000082u, 0x00000082u, 0x00000000u, 0x00000001u,
0x00000002u, 0x0003003eu, 0x00000081u, 0x00000083u, 0x00050039u, 0x00000006u, 0x00000084u, 0x0000000bu,
0x00000081u, 0x0003003eu, 0x00000080u, 0x00000084u, 0x0004003du, 0x00000023u, 0x00000086u, 0x00000025u,
0x0004003du, 0x0000000du, 0x00000087u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000088u, 0x00000062u,
0x00000029u, 0x0004003du, 0x00000006u, 0x00000089u, 0x00000088u, 0x00050050u, 0x0000000du, 0x0000008au,
0x00000089u, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000008bu, 0x00000087u, 0x0000008au, 0x00050057u,
0x0000002fu, 0x0000008cu, 0x00000086u, 0x0000008bu, 0x0008004fu, 0x00000007u, 0x0000008eu, 0x0000008cu,
0x0000008cu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000008du, 0x0000008eu, 0x00050039u,
0x00000006u, 0x0000008fu, 0x0000000bu, 0x0000008du, 0x0003003eu, 0x00000085u, 0x0000008fu, 0x0004003du,
0x00000023u, 0x00000091u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000092u, 0x00000070u, 0x00050041u,
0x00000020u, 0x00000093u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000094u, 0x00000093u,
0x00050050u, 0x0000000du, 0x00000095u, 0x00000094u, 0x0000002cu, 0x00050081u, 0x0000000du, 0x00000096u,
0x00000092u, 0x00000095u, 0x00050057u, 0x0000002fu, 0x00000097u, 0x00000091u, 0x00000096u, 0x0008004fu,
0x00000007u, 0x00000099u, 0x00000097u, 0x00000097u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu,
0x00000098u, 0x00000099u, 0x00050039u, 0x00000006u, 0x0000009au, 0x0000000bu, 0x00000098u, 0x0003003eu,
0x00000090u, 0x0000009au, 0x0004003du, 0x00000023u, 0x0000009cu, 0x00000025u, 0x0004003du, 0x0000000du,
0x0000009du, 0x00000070u, 0x00050041u, 0x00000020u, 0x0000009eu, 0x00000062u, 0x00000048u, 0x0004003du,
0x00000006u, 0x0000009fu, 0x0000009eu, 0x00050050u, 0x0000000du, 0x000000a0u, 0x0000002cu, 0x0000009fu,
0x00050083u, 0x0000000du, 0x000000a1u, 0x0000009du, 0x000000a0u, 0x00050057u, 0x0000002fu, 0x000000a2u,
0x0000009cu, 0x000000a1u, 0x0008004fu, 0x00000007u, 0x000000a4u, 0x000000a2u, 0x000000a2u, 0x00000000u,
0x00000001u, 0x00000002u, 0x0003003eu, 0x000000a3u, 0x000000a4u, 0x00050039u, 0x00000006u, 0x000000a5u,
0x0000000bu, 0x000000a3u, 0x0003003eu, 0x0000009bu, 0x000000a5u, 0x0004003du, 0x00000023u, 0x000000a7u,
0x00000025u, 0x0004003du, 0x0000000du, 0x000000a8u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000000a9u,
0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000000aau, 0x000000a9u, 0x00050050u, 0x0000000du,
0x000000abu, 0x0000002cu, 0x000000aau, 0x00050081u, 0x0000000du, 0x000000acu, 0x000000a8u, 0x000000abu,
0x00050057u, 0x0000002fu, 0x000000adu, 0x000000a7u, 0x000000acu, 0x0008004fu, 0x00000007u, 0x000000afu,
0x000000adu, 0x000000adu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000aeu, 0x000000afu,
0x00050039u, 0x00000006u, 0x000000b0u, 0x0000000bu, 0x000000aeu, 0x0003003eu, 0x000000a6u, 0x000000b0u,
0x0004003du, 0x00000006u, 0x000000b2u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b3u, 0x00000085u,
0x00050083u, 0x00000006u, 0x000000b4u, 0x000000b2u, 0x000000b3u, 0x0006000cu, 0x00000006u, 0x000000b5u,
0x00000001u, 0x00000004u, 0x000000b4u, 0x0003003eu, 0x000000b1u, 0x000000b5u, 0x0004003du, 0x00000006u,
0x000000b7u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b8u, 0x00000090u, 0x00050083u, 0x00000006u,
0x000000b9u, 0x000000b7u, 0x000000b8u, 0x0006000cu, 0x00000006u, 0x000000bau, 0x00000001u, 0x00000004u,
0x000000b9u, 0x0003003eu, 0x000000b6u, 0x000000bau, 0x0004003du, 0x00000006u, 0x000000bcu, 0x00000080u,
0x0004003du, 0x00000006u, 0x000000bdu, 0x0000009bu, 0x00050083u, 0x00000006u, 0x000000beu, 0x000000bcu,
0x000000bdu, 0x0006000cu, 0x00000006u, 0x000000bfu, 0x00000001u, 0x00000004u, 0x000000beu, 0x0003003eu,
0x000000bbu, 0x000000bfu, 0x0004003du, 0x00000006u, 0x000000c1u, 0x00000080u, 0x0004003du, 0x00000006u,
0x000000c2u, 0x000000a6u, 0x00050083u, 0x00000006u, 0x000000c3u, 0x000000c1u, 0x000000c2u, 0x0006000cu,
0x00000006u, 0x000000c4u, 0x00000001u, 0x00000004u, 0x000000c3u, 0x0003003eu, 0x000000c0u, 0x000000c4u,
0x0004003du, 0x00000006u, 0x000000c6u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000c7u, 0x00000085u,
0x0004003du, 0x00000006u, 0x000000c8u, 0x00000090u, 0x0007000cu, 0x00000006u, 0x000000c9u, 0x00000001u,
0x00000025u, 0x000000c7u, 0x000000c8u, 0x0004003du, 0x00000006u, 0x000000cau, 0x0000009bu, 0x0004003du,
0x00000006u, 0x000000cbu, 0x000000a6u, 0x0007000cu, 0x00000006u, 0x000000ccu, 0x00000001u, 0x00000025u,
0x000000cau, 0x000000cbu, 0x0007000cu, 0x00000006u, 0x000000cdu, 0x00000001u, 0x00000025u, 0x000000c9u,
0x000000ccu, 0x0007000cu, 0x00000006u, 0x000000ceu, 0x00000001u, 0x00000025u, 0x000000c6u, 0x000000cdu,
0x0003003eu, 0x000000c5u, 0x000000ceu, 0x0004003du, 0x00000006u, 0x000000d0u, 0x00000080u, 0x0004003du,
0x00000006u, 0x000000d1u, 0x00000085u, 0x0004003du, 0x00000006u, 0x000000d2u, 0x00000090u, 0x0007000cu,
0x00000006u, 0x000000d3u, 0x00000001u, 0x00000028u, 0x000000d1u, 0x000000d2u, 0x0004003du, 0x00000006u,
0x000000d4u, 0x0000009bu, 0x0004003du, 0x00000006u, 0x000000d5u, 0x000000a6u, 0x0007000cu, 0x00000006u,
0x000000d6u, 0x00000001u, 0x00000028u, 0x000000d4u, 0x000000d5u, 0x0007000cu, 0x00000006u, 0x000000d7u,
0x00000001u, 0x00000028u, 0x000000d3u, 0x000000d6u, 0x0007000cu, 0x00000006u, 0x000000d8u, 0x00000001u,
0x00000028u, 0x000000d0u, 0x000000d7u, 0x0003003eu, 0x000000cfu, 0x000000d8u, 0x0004003du, 0x00000006u,
0x000000dau, 0x000000cfu, 0x0004003du, 0x00000006u, 0x000000dbu, 0x000000c5u, 0x00050083u, 0x00000006u,
0x000000dcu, 0x000000dau, 0x000000dbu, 0x0003003eu, 0x000000d9u, 0x000000dcu, 0x0004003du, 0x00000006u,
0x000000dfu, 0x000000d9u, 0x00050085u, 0x00000006u, 0x000000e1u, 0x000000dfu, 0x000000e0u, 0x0007000cu,
0x00000006u, 0x000000e2u, 0x00000001u, 0x00000028u, 0x000000deu, 0x000000e1u, 0x0003003eu, 0x000000ddu,
0x000000e2u, 0x0004003du, 0x00000006u, 0x000000e4u, 0x000000b1u, 0x0004003du, 0x00000006u, 0x000000e5u,
0x000000b6u, 0x0007000cu, 0x00000006u, 0x000000e6u, 0x00000001u, 0x00000028u, 0x000000e4u, 0x000000e5u,
0x0003003eu, 0x000000e3u, 0x000000e6u, 0x0004003du, 0x00000006u, 0x000000e8u, 0x000000bbu, 0x0004003du,
0x00000006u, 0x000000e9u, 0x000000c0u, 0x0007000cu, 0x00000006u, 0x000000eau, 0x00000001u, 0x00000028u,
0x000000e8u, 0x000000e9u, 0x0003003eu, 0x000000e7u, 0x000000eau, 0x0004003du, 0x00000006u, 0x000000ecu,
0x000000e3u, 0x0004003du, 0x00000006u, 0x000000edu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x000000eeu,
0x00000001u, 0x00000028u, 0x000000ecu, 0x000000edu, 0x0003003eu, 0x000000ebu, 0x000000eeu, 0x0004003du,
0x00000006u, 0x000000efu, 0x000000ebu, 0x0004003du, 0x00000006u, 0x000000f0u, 0x000000ddu, 0x000500bcu,
0x000000f1u, 0x000000f2u, 0x000000efu, 0x000000f0u, 0x000300f7u, 0x000000f4u, 0x00000000u, 0x000400fau,
0x000000f2u, 0x000000f3u, 0x000000f4u, 0x000200f8u, 0x000000f3u, 0x0004003du, 0x0000002fu, 0x000000f7u,
0x0000007cu, 0x0003003eu, 0x000000f6u, 0x000000f7u, 0x000100fdu, 0x000200f8u, 0x000000f4u, 0x0004003du,
0x00000006u, 0x000000fbu, 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000fcu, 0x000000e7u, 0x000500beu,
0x000000f1u, 0x000000fdu, 0x000000fbu, 0x000000fcu, 0x0003003eu, 0x000000fau, 0x000000fdu, 0x0004003du,
0x000000f1u, 0x000000ffu, 0x000000fau, 0x000300f7u, 0x00000102u, 0x00000000u, 0x000400fau, 0x000000ffu,
0x00000101u, 0x00000106u, 0x000200f8u, 0x00000101u, 0x00050041u, 0x00000020u, 0x00000103u, 0x00000062u,
0x00000048u, 0x0004003du, 0x00000006u, 0x00000104u, 0x00000103u, 0x00050050u, 0x0000000du, 0x00000105u,
0x0000002cu, 0x00000104u, 0x0003003eu, 0x00000100u, 0x00000105u, 0x000200f9u, 0x00000102u, 0x000200f8u,
0x00000106u, 0x00050041u, 0x00000020u, 0x00000107u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u,
0x00000108u, 0x00000107u, 0x00050050u, 0x0000000du, 0x00000109u, 0x00000108u, 0x0000002cu, 0x0003003eu,
0x00000100u, 0x00000109u, 0x000200f9u, 0x00000102u, 0x000200f8u, 0x00000102u, 0x0004003du, 0x0000000du,
0x0000010au, 0x00000100u, 0x0003003eu, 0x000000feu, 0x0000010au, 0x0004003du, 0x000000f1u, 0x0000010cu,
0x000000fau, 0x000300f7u, 0x0000010fu, 0x00000000u, 0x000400fau, 0x0000010cu, 0x0000010eu, 0x00000116u,
0x000200f8u, 0x0000010eu, 0x0004003du, 0x00000006u, 0x00000110u, 0x000000b1u, 0x0004003du, 0x00000006u,
0x00000111u, 0x000000b6u, 0x000500beu, 0x000000f1u, 0x00000112u, 0x00000110u, 0x00000111u, 0x000600a9u,
0x00000006u, 0x00000114u, 0x00000112u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x00000115u,
0x00000114u, 0x0000002cu, 0x0003003eu, 0x0000010du, 0x00000115u, 0x000200f9u, 0x0000010fu, 0x000200f8u,
0x00000116u, 0x0004003du, 0x00000006u, 0x00000117u, 0x000000bbu, 0x0004003du, 0x00000006u, 0x00000118u,
0x000000c0u, 0x000500beu, 0x000000f1u, 0x00000119u, 0x00000117u, 0x00000118u, 0x000600a9u, 0x00000006u,
0x0000011au, 0x00000119u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x0000011bu, 0x0000002cu,
0x0000011au, 0x0003003eu, 0x0000010du, 0x0000011bu, 0x000200f9u, 0x0000010fu, 0x000200f8u, 0x0000010fu,
0x0004003du, 0x0000000du, 0x0000011cu, 0x0000010du, 0x0003003eu, 0x0000010bu, 0x0000011cu, 0x0003003eu,
0x0000011du, 0x0000002cu, 0x0003003eu, 0x0000011eu, 0x0000002cu, 0x0003003eu, 0x00000120u, 0x00000068u,
0x000200f9u, 0x00000121u, 0x000200f8u, 0x00000121u, 0x000400f6u, 0x00000123u, 0x00000124u, 0x00000000u,
0x000200f9u, 0x00000125u, 0x000200f8u, 0x00000125u, 0x0004003du, 0x00000067u, 0x00000126u, 0x00000120u,
0x000500b3u, 0x000000f1u, 0x00000128u, 0x00000126u, 0x00000127u, 0x000400fau, 0x00000128u, 0x00000122u,
0x00000123u, 0x000200f8u, 0x00000122u, 0x0004003du, 0x0000000du, 0x0000012au, 0x000000feu, 0x0004003du,
0x00000067u, 0x0000012bu, 0x00000120u, 0x0004006fu, 0x00000006u, 0x0000012cu, 0x0000012bu, 0x0005008eu,
0x0000000du, 0x0000012du, 0x0000012au, 0x0000012cu, 0x0003003eu, 0x00000129u, 0x0000012du, 0x0004003du,
0x000000f1u, 0x0000012fu, 0x000000fau, 0x000300f7u, 0x00000132u, 0x00000000u, 0x000400fau, 0x0000012fu,
0x00000131u, 0x0000013au, 0x000200f8u, 0x00000131u, 0x0004003du, 0x0000000du, 0x00000133u, 0x00000070u,
0x0004003du, 0x0000000du, 0x00000134u, 0x00000129u, 0x00050083u, 0x0000000du, 0x00000135u, 0x00000133u,
0x00000134u, 0x0003003eu, 0x00000136u, 0x00000135u, 0x0004003du, 0x0000000du, 0x00000138u, 0x00000062u,
0x0003003eu, 0x00000137u, 0x00000138u, 0x00060039u, 0x00000006u, 0x00000139u, 0x00000012u, 0x00000136u,
0x00000137u, 0x0003003eu, 0x00000130u, 0x00000139u, 0x000200f9u, 0x00000132u, 0x000200f8u, 0x0000013au,
0x0004003du, 0x0000000du, 0x0000013bu, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000013cu, 0x00000129u,
0x00050083u, 0x0000000du, 0x0000013du, 0x0000013bu, 0x0000013cu, 0x0003003eu, 0x0000013eu, 0x0000013du,
0x0004003du, 0x0000000du, 0x00000140u, 0x00000062u, 0x0003003eu, 0x0000013fu, 0x00000140u, 0x00060039u,
0x00000006u, 0x00000141u, 0x00000016u, 0x0000013eu, 0x0000013fu, 0x0003003eu, 0x00000130u, 0x00000141u,
0x000200f9u, 0x00000132u, 0x000200f8u, 0x00000132u, 0x0004003du, 0x00000006u, 0x00000142u, 0x00000130u,
0x0003003eu, 0x0000012eu, 0x00000142u, 0x0004003du, 0x000000f1u, 0x00000144u, 0x000000fau, 0x000300f7u,
0x00000147u, 0x00000000u, 0x000400fau, 0x00000144u, 0x00000146u, 0x0000014fu, 0x000200f8u, 0x00000146u,
0x0004003du, 0x0000000du, 0x00000148u, 0x00000070u, 0x0004003du, 0x0000000du, 0x00000149u, 0x00000129u,
0x00050081u, 0x0000000du, 0x0000014au, 0x00000148u, 0x00000149u, 0x0003003eu, 0x0000014bu, 0x0000014au,
0x0004003du, 0x0000000du, 0x0000014du, 0x00000062u, 0x0003003eu, 0x0000014cu, 0x0000014du, 0x00060039u,
0x00000006u, 0x0000014eu, 0x00000012u, 0x0000014bu, 0x0000014cu, 0x0003003eu, 0x00000145u, 0x0000014eu,
0x000200f9u, 0x00000147u, 0x000200f8u, 0x0000014fu, 0x0004003du, 0x0000000du, 0x00000150u, 0x00000070u,
0x0004003du, 0x0000000du, 0x00000151u, 0x00000129u, 0x00050081u, 0x0000000du, 0x00000152u, 0x00000150u,
0x00000151u, 0x0003003eu, 0x00000153u, 0x00000152u, 0x0004003du, 0x0000000du, 0x00000155u, 0x00000062u,
0x0003003eu, 0x00000154u, 0x00000155u, 0x00060039u, 0x00000006u, 0x00000156u, 0x00000016u, 0x00000153u,
0x00000154u, 0x0003003eu, 0x00000145u, 0x00000156u, 0x000200f9u, 0x00000147u, 0x000200f8u, 0x00000147u,
0x0004003du, 0x00000006u, 0x00000157u, 0x00000145u, 0x0003003eu, 0x00000143u, 0x00000157u, 0x0004003du,
0x00000006u, 0x00000158u, 0x0000011du, 0x0004003du, 0x00000067u, 0x00000159u, 0x00000120u, 0x00050082u,
0x00000067u, 0x0000015au, 0x00000159u, 0x00000068u, 0x0004006fu, 0x00000006u, 0x0000015bu, 0x0000015au,
0x000500b4u, 0x000000f1u, 0x0000015cu, 0x00000158u, 0x0000015bu, 0x000300f7u, 0x0000015eu, 0x00000000u,
0x000400fau, 0x0000015cu, 0x0000015du, 0x0000015eu, 0x000200f8u, 0x0000015du, 0x0004003du, 0x00000006u,
0x0000015fu, 0x0000012eu, 0x0004003du, 0x00000006u, 0x00000160u, 0x000000ddu, 0x00050085u, 0x00000006u,
0x00000162u, 0x00000160u, 0x00000161u, 0x000500bau, 0x000000f1u, 0x00000163u, 0x0000015fu, 0x00000162u,
0x000200f9u, 0x0000015eu, 0x000200f8u, 0x0000015eu, 0x000700f5u, 0x000000f1u, 0x00000164u, 0x0000015cu,
0x00000147u, 0x00000163u, 0x0000015du, 0x000300f7u, 0x00000166u, 0x00000000u, 0x000400fau, 0x00000164u,
0x00000165u, 0x00000166u, 0x000200f8u, 0x00000165u, 0x0004003du, 0x00000067u, 0x00000167u, 0x00000120u,
0x0004006fu, 0x00000006u, 0x00000168u, 0x00000167u, 0x0003003eu, 0x0000011du, 0x00000168u, 0x000200f9u,
0x00000166u, 0x000200f8u, 0x00000166u, 0x0004003du, 0x00000006u, 0x00000169u, 0x0000011eu, 0x0004003du,
0x00000067u, 0x0000016au, 0x00000120u, 0x00050082u, 0x00000067u, 0x0000016bu, 0x0000016au, 0x00000068u,
0x0004006fu, 0x00000006u, 0x0000016cu, 0x0000016bu, 0x000500b4u, 0x000000f1u, 0x0000016du, 0x00000169u,
0x0000016cu, 0x000300f7u, 0x0000016fu, 0x00000000u, 0x000400fau, 0x0000016du, 0x0000016eu, 0x0000016fu,
0x000200f8u, 0x0000016eu, 0x0004003du, 0x00000006u, 0x00000170u, 0x00000143u, 0x0004003du, 0x00000006u,
0x00000171u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000172u, 0x00000171u, 0x00000161u, 0x000500bau,
0x000000f1u, 0x00000173u, 0x00000170u, 0x00000172u, 0x000200f9u, 0x0000016fu, 0x000200f8u, 0x0000016fu,
0x000700f5u, 0x000000f1u, 0x00000174u, 0x0000016du, 0x00000166u, 0x00000173u, 0x0000016eu, 0x000300f7u,
0x00000176u, 0x00000000u, 0x000400fau, 0x00000174u, 0x00000175u, 0x00000176u, 0x000200f8u, 0x00000175u,
0x0004003du, 0x00000067u, 0x00000177u, 0x00000120u, 0x0004006fu, 0x00000006u, 0x00000178u, 0x00000177u,
0x0003003eu, 0x0000011eu, 0x00000178u, 0x000200f9u, 0x00000176u, 0x000200f8u, 0x00000176u, 0x000200f9u,
0x00000124u, 0x000200f8u, 0x00000124u, 0x0004003du, 0x00000067u, 0x00000179u, 0x00000120u, 0x00050080u,
0x00000067u, 0x0000017au, 0x00000179u, 0x00000068u, 0x0003003eu, 0x00000120u, 0x0000017au, 0x000200f9u,
0x00000121u, 0x000200f8u, 0x00000123u, 0x0004003du, 0x00000006u, 0x0000017cu, 0x0000011du, 0x0004003du,
0x00000006u, 0x0000017du, 0x0000011eu, 0x00050081u, 0x00000006u, 0x0000017eu, 0x0000017cu, 0x0000017du,
0x0003003eu, 0x0000017bu, 0x0000017eu, 0x0004003du, 0x00000006u, 0x00000180u, 0x000000ddu, 0x0004003du,
0x00000006u, 0x00000181u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000183u, 0x00000181u, 0x00000182u,
0x0004003du, 0x00000006u, 0x00000184u, 0x000000ebu, 0x0008000cu, 0x00000006u, 0x00000185u, 0x00000001u,
0x00000031u, 0x00000180u, 0x00000183u, 0x00000184u, 0x0003003eu, 0x0000017fu, 0x00000185u, 0x0004003du,
0x00000023u, 0x00000187u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000188u, 0x00000070u, 0x00050041u,
0x00000020u, 0x00000189u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000018au, 0x00000189u,
0x0004007fu, 0x00000006u, 0x0000018bu, 0x0000018au, 0x00050041u, 0x00000020u, 0x0000018cu, 0x00000062u,
0x00000048u, 0x0004003du, 0x00000006u, 0x0000018du, 0x0000018cu, 0x0004007fu, 0x00000006u, 0x0000018eu,
0x0000018du, 0x00050050u, 0x0000000du, 0x0000018fu, 0x0000018bu, 0x0000018eu, 0x00050081u, 0x0000000du,
0x00000190u, 0x00000188u, 0x0000018fu, 0x00050057u, 0x0000002fu, 0x00000191u, 0x00000187u, 0x00000190u,
0x0008004fu, 0x00000007u, 0x00000193u, 0x00000191u, 0x00000191u, 0x00000000u, 0x00000001u, 0x00000002u,
0x0003003eu, 0x00000192u, 0x00000193u, 0x00050039u, 0x00000006u, 0x00000194u, 0x0000000bu, 0x00000192u,
0x0003003eu, 0x00000186u, 0x00000194u, 0x0004003du, 0x00000023u, 0x00000196u, 0x00000025u, 0x0004003du,
0x0000000du, 0x00000197u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000198u, 0x00000062u, 0x00000029u,
0x0004003du, 0x00000006u, 0x00000199u, 0x00000198u, 0x00050041u, 0x00000020u, 0x0000019au, 0x00000062u,
0x00000048u, 0x0004003du, 0x00000006u, 0x0000019bu, 0x0000019au, 0x0004007fu, 0x00000006u, 0x0000019cu,
0x0000019bu, 0x00050050u, 0x0000000du, 0x0000019du, 0x00000199u, 0x0000019cu, 0x00050081u, 0x0000000du,
0x0000019eu, 0x00000197u, 0x0000019du, 0x00050057u, 0x0000002fu, 0x0000019fu, 0x00000196u, 0x0000019eu,
0x0008004fu, 0x00000007u, 0x000001a1u, 0x0000019fu, 0x0000019fu, 0x00000000u, 0x00000001u, 0x00000002u,
0x0003003eu, 0x000001a0u, 0x000001a1u, 0x00050039u, 0x00000006u, 0x000001a2u, 0x0000000bu, 0x000001a0u,
0x0003003eu, 0x00000195u, 0x000001a2u, 0x0004003du, 0x00000023u, 0x000001a4u, 0x00000025u, 0x0004003du,
0x0000000du, 0x000001a5u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001a6u, 0x00000062u, 0x00000029u,
0x0004003du, 0x00000006u, 0x000001a7u, 0x000001a6u, 0x0004007fu, 0x00000006u, 0x000001a8u, 0x000001a7u,
0x00050041u, 0x00000020u, 0x000001a9u, 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000001aau,
0x000001a9u, 0x00050050u, 0x0000000du, 0x000001abu, 0x000001a8u, 0x000001aau, 0x00050081u, 0x0000000du,
0x000001acu, 0x000001a5u, 0x000001abu, 0x00050057u, 0x0000002fu, 0x000001adu, 0x000001a4u, 0x000001acu,
0x0008004fu, 0x00000007u, 0x000001afu, 0x000001adu, 0x000001adu, 0x00000000u, 0x00000001u, 0x00000002u,
0x0003003eu, 0x000001aeu, 0x000001afu, 0x00050039u, 0x00000006u, 0x000001b0u, 0x0000000bu, 0x000001aeu,
0x0003003eu, 0x000001a3u, 0x000001b0u, 0x0004003du, 0x00000023u, 0x000001b2u, 0x00000025u, 0x0004003du,
0x0000000du, 0x000001b3u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001b4u, 0x00000062u, 0x00000029u,
0x0004003du, 0x00000006u, 0x000001b5u, 0x000001b4u, 0x00050041u, 0x00000020u, 0x000001b6u, 0x00000062u,
0x00000048u, 0x0004003du, 0x00000006u, 0x000001b7u, 0x000001b6u, 0x00050050u, 0x0000000du, 0x000001b8u,
0x000001b5u, 0x000001b7u, 0x00050081u, 0x0000000du, 0x000001b9u, 0x000001b3u, 0x000001b8u, 0x00050057u,
0x0000002fu, 0x000001bau, 0x000001b2u, 0x000001b9u, 0x0008004fu, 0x00000007u, 0x000001bcu, 0x000001bau,
0x000001bau, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000001bbu, 0x000001bcu, 0x00050039u,
0x00000006u, 0x000001bdu, 0x0000000bu, 0x000001bbu, 0x0003003eu, 0x000001b1u, 0x000001bdu, 0x0004003du,
0x00000006u, 0x000001bfu, 0x0000011du, 0x0004003du, 0x00000006u, 0x000001c0u, 0x0000011eu, 0x00050083u,
0x00000006u, 0x000001c1u, 0x000001bfu, 0x000001c0u, 0x0006000cu, 0x00000006u, 0x000001c2u, 0x00000001u,
0x00000004u, 0x000001c1u, 0x0004003du, 0x00000006u, 0x000001c3u, 0x0000017bu, 0x0007000cu, 0x00000006u,
0x000001c4u, 0x00000001u, 0x00000028u, 0x000001c3u, 0x00000063u, 0x00050088u, 0x00000006u, 0x000001c5u,
0x000001c2u, 0x000001c4u, 0x0008000cu, 0x00000006u, 0x000001c6u, 0x00000001u, 0x0000002bu, 0x000001c5u,
0x0000002cu, 0x00000063u, 0x0003003eu, 0x000001beu, 0x000001c6u, 0x0004003du, 0x00000006u, 0x000001c8u,
0x000001beu, 0x0004003du, 0x00000006u, 0x000001c9u, 0x0000017bu, 0x00050085u, 0x00000006u, 0x000001cbu,
0x000001c9u, 0x000001cau, 0x00050081u, 0x00000006u, 0x000001ccu, 0x00000063u, 0x000001cbu, 0x00050088u,
0x00000006u, 0x000001cdu, 0x000001c8u, 0x000001ccu, 0x0003003eu, 0x000001c7u, 0x000001cdu, 0x0004003du,
0x000000f1u, 0x000001cfu, 0x000000fau, 0x000300f7u, 0x000001d2u, 0x00000000u, 0x000400fau, 0x000001cfu,
0x000001d1u, 0x000001d7u, 0x000200f8u, 0x000001d1u, 0x0004003du, 0x00000006u, 0x000001d3u, 0x00000186u,
0x0004003du, 0x00000006u, 0x000001d4u, 0x00000195u, 0x00050083u, 0x00000006u, 0x000001d5u, 0x000001d3u,
0x000001d4u, 0x0006000cu, 0x00000006u, 0x000001d6u, 0x00000001u, 0x00000004u, 0x000001d5u, 0x0003003eu,
0x000001d0u, 0x000001d6u, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d7u, 0x0004003du, 0x00000006u,
0x000001d8u, 0x00000186u, 0x0004003du, 0x00000006u, 0x000001d9u, 0x000001a3u, 0x00050083u, 0x00000006u,
0x000001dau, 0x000001d8u, 0x000001d9u, 0x0006000cu, 0x00000006u, 0x000001dbu, 0x00000001u, 0x00000004u,
0x000001dau, 0x0003003eu, 0x000001d0u, 0x000001dbu, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d2u,
0x0004003du, 0x00000006u, 0x000001dcu, 0x000001d0u, 0x0003003eu, 0x000001ceu, 0x000001dcu, 0x0004003du,
0x000000f1u, 0x000001deu, 0x000000fau, 0x000300f7u, 0x000001e1u, 0x00000000u, 0x000400fau, 0x000001deu,
0x000001e0u, 0x000001e6u, 0x000200f8u, 0x000001e0u, 0x0004003du, 0x00000006u, 0x000001e2u, 0x000001a3u,
0x0004003du, 0x00000006u, 0x000001e3u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x000001e4u, 0x000001e2u,
0x000001e3u, 0x0006000cu, 0x00000006u, 0x000001e5u, 0x00000001u, 0x00000004u, 0x000001e4u, 0x0003003eu,
0x000001dfu, 0x000001e5u, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e6u, 0x0004003du, 0x00000006u,
0x000001e7u, 0x00000195u, 0x0004003du, 0x00000006u, 0x000001e8u, 0x000001b1u, 0x00050083u, 0x00000006u,
0x000001e9u, 0x000001e7u, 0x000001e8u, 0x0006000cu, 0x00000006u, 0x000001eau, 0x00000001u, 0x00000004u,
0x000001e9u, 0x0003003eu, 0x000001dfu, 0x000001eau, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e1u,
0x0004003du, 0x00000006u, 0x000001ebu, 0x000001dfu, 0x0003003eu, 0x000001ddu, 0x000001ebu, 0x0004003du,
0x00000006u, 0x000001edu, 0x000001ceu, 0x0004003du, 0x00000006u, 0x000001eeu, 0x000001ddu, 0x00050083u,
0x00000006u, 0x000001efu, 0x000001edu, 0x000001eeu, 0x0006000cu, 0x00000006u, 0x000001f0u, 0x00000001u,
0x00000004u, 0x000001efu, 0x0003003eu, 0x000001ecu, 0x000001f0u, 0x0004003du, 0x00000006u, 0x000001f2u,
0x000000ddu, 0x0004003du, 0x00000006u, 0x000001f3u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x000001f4u,
0x000001f3u, 0x00000182u, 0x0004003du, 0x00000006u, 0x000001f5u, 0x000001ecu, 0x0008000cu, 0x00000006u,
0x000001f6u, 0x00000001u, 0x00000031u, 0x000001f2u, 0x000001f4u, 0x000001f5u, 0x0003003eu, 0x000001f1u,
0x000001f6u, 0x0004003du, 0x00000006u, 0x000001f9u, 0x000001f1u, 0x00050085u, 0x00000006u, 0x000001fau,
0x000001f8u, 0x000001f9u, 0x0004003du, 0x00000006u, 0x000001fbu, 0x0000017bu, 0x00050088u, 0x00000006u,
0x000001fdu, 0x000001fbu, 0x000001fcu, 0x0008000cu, 0x00000006u, 0x000001feu, 0x00000001u, 0x0000002bu,
0x000001fdu, 0x0000002cu, 0x00000063u, 0x00050085u, 0x00000006u, 0x000001ffu, 0x000001fau, 0x000001feu,
0x0003003eu, 0x000001f7u, 0x000001ffu, 0x0004003du, 0x00000006u, 0x00000201u, 0x00000186u, 0x0004003du,
0x00000006u, 0x00000202u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x00000203u, 0x00000201u, 0x00000202u,
0x0006000cu, 0x00000006u, 0x00000204u, 0x00000001u, 0x00000004u, 0x00000203u, 0x0004003du, 0x00000006u,
0x00000205u, 0x00000195u, 0x0004003du, 0x00000006u, 0x00000206u, 0x000001a3u, 0x00050083u, 0x00000006u,
0x00000207u, 0x00000205u, 0x00000206u, 0x0006000cu, 0x00000006u, 0x00000208u, 0x00000001u, 0x00000004u,
0x00000207u, 0x0007000cu, 0x00000006u, 0x00000209u, 0x00000001u, 0x00000028u, 0x00000204u, 0x00000208u,
0x0003003eu, 0x00000200u, 0x00000209u, 0x0004003du, 0x00000006u, 0x0000020cu, 0x000000ddu, 0x0004003du,
0x00000006u, 0x0000020du, 0x000000ddu, 0x00050085u, 0x00000006u, 0x0000020fu, 0x0000020du, 0x0000020eu,
0x0004003du, 0x00000006u, 0x00000210u, 0x00000200u, 0x0008000cu, 0x00000006u, 0x00000211u, 0x00000001u,
0x00000031u, 0x0000020cu, 0x0000020fu, 0x00000210u, 0x00050085u, 0x00000006u, 0x00000212u, 0x0000020bu,
0x00000211u, 0x00050083u, 0x00000006u, 0x00000213u, 0x00000063u, 0x00000212u, 0x0003003eu, 0x0000020au,
0x00000213u, 0x0004003du, 0x00000006u, 0x00000215u, 0x000001f7u, 0x0004003du, 0x00000006u, 0x00000216u,
0x000001c7u, 0x00050085u, 0x00000006u, 0x00000217u, 0x00000215u, 0x00000216u, 0x0004003du, 0x00000006u,
0x00000218u, 0x0000017fu, 0x00050085u, 0x00000006u, 0x00000219u, 0x00000217u, 0x00000218u, 0x0004003du,
0x00000006u, 0x0000021au, 0x0000020au, 0x00050085u, 0x00000006u, 0x0000021bu, 0x00000219u, 0x0000021au,
0x0003003eu, 0x00000214u, 0x0000021bu, 0x0004003du, 0x00000006u, 0x0000021du, 0x000000e3u, 0x0004003du,
0x00000006u, 0x0000021eu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x0000021fu, 0x00000001u, 0x00000025u,
0x0000021du, 0x0000021eu, 0x0003003eu, 0x0000021cu, 0x0000021fu, 0x0004003du, 0x00000006u, 0x00000221u,
0x000000ddu, 0x0004003du, 0x00000006u, 0x00000222u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000223u,
0x00000222u, 0x00000182u, 0x0004003du, 0x00000006u, 0x00000224u, 0x0000021cu, 0x0008000cu, 0x00000006u,
0x00000225u, 0x00000001u, 0x00000031u, 0x00000221u, 0x00000223u, 0x00000224u, 0x0003003eu, 0x00000220u,
0x00000225u, 0x0004003du, 0x00000006u, 0x00000227u, 0x0000017bu, 0x0008000cu, 0x00000006u, 0x00000228u,
0x00000001u, 0x00000031u, 0x00000063u, 0x0000020eu, 0x00000227u, 0x0003003eu, 0x00000226u, 0x00000228u,
0x0004003du, 0x00000006u, 0x0000022bu, 0x00000220u, 0x00050085u, 0x00000006u, 0x0000022cu, 0x0000022au,
0x0000022bu, 0x0004003du, 0x00000006u, 0x0000022du, 0x0000017fu, 0x00050085u, 0x00000006u, 0x0000022eu,
0x0000022cu, 0x0000022du, 0x0004003du, 0x00000006u, 0x0000022fu, 0x0000020au, 0x00050085u, 0x00000006u,
0x00000230u, 0x0000022eu, 0x0000022fu, 0x0004003du, 0x00000006u, 0x00000231u, 0x00000226u, 0x00050085u,
0x00000006u, 0x00000232u, 0x00000230u, 0x00000231u, 0x0004003du, 0x00000006u, 0x00000233u, 0x000001f1u,
0x00050085u, 0x00000006u, 0x00000234u, 0x00000232u, 0x00000233u, 0x0003003eu, 0x00000229u, 0x00000234u,
0x0004003du, 0x00000006u, 0x00000236u, 0x00000214u, 0x0004003du, 0x00000006u, 0x00000237u, 0x00000229u,
0x0007000cu, 0x00000006u, 0x00000238u, 0x00000001u, 0x00000028u, 0x00000236u, 0x00000237u, 0x0008000cu,
0x00000006u, 0x0000023au, 0x00000001u, 0x0000002bu, 0x00000238u, 0x0000002cu, 0x00000239u, 0x0003003eu,
0x00000235u, 0x0000023au, 0x0004003du, 0x00000023u, 0x0000023cu, 0x00000025u, 0x0004003du, 0x0000000du,
0x0000023du, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000023eu, 0x0000010bu, 0x0004003du, 0x0000000du,
0x0000023fu, 0x00000062u, 0x00050085u, 0x0000000du, 0x00000240u, 0x0000023eu, 0x0000023fu, 0x00050081u,
0x0000000du, 0x00000241u, 0x0000023du, 0x00000240u, 0x00050057u, 0x0000002fu, 0x00000242u, 0x0000023cu,
0x00000241u, 0x0008004fu, 0x00000007u, 0x00000243u, 0x00000242u, 0x00000242u, 0x00000000u, 0x00000001u,
0x00000002u, 0x0003003eu, 0x0000023bu, 0x00000243u, 0x0004003du, 0x0000002fu, 0x00000244u, 0x0000007cu,
0x0008004fu, 0x00000007u, 0x00000245u, 0x00000244u, 0x00000244u, 0x00000000u, 0x00000001u, 0x00000002u,
0x0004003du, 0x00000007u, 0x00000246u, 0x0000023bu, 0x0004003du, 0x00000006u, 0x00000247u, 0x00000235u,
0x00060050u, 0x00000007u, 0x00000248u, 0x00000247u, 0x00000247u, 0x00000247u, 0x0008000cu, 0x00000007u,
0x00000249u, 0x00000001u, 0x0000002eu, 0x00000245u, 0x00000246u, 0x00000248u, 0x00050041u, 0x00000020u,
0x0000024bu, 0x0000007cu, 0x0000024au, 0x0004003du, 0x00000006u, 0x0000024cu, 0x0000024bu, 0x00050051u,
0x00000006u, 0x0000024du, 0x00000249u, 0x00000000u, 0x00050051u, 0x00000006u, 0x0000024eu, 0x00000249u,
0x00000001u, 0x00050051u, 0x00000006u, 0x0000024fu, 0x00000249u, 0x00000002u, 0x00070050u, 0x0000002fu,
0x00000250u, 0x0000024du, 0x0000024eu, 0x0000024fu, 0x0000024cu, 0x0003003eu, 0x000000f6u, 0x00000250u,
0x000100fdu, 0x00010038u, 0x00050036u, 0x00000006u, 0x0000000bu, 0x00000000u, 0x00000009u, 0x00030037u,
0x00000008u, 0x0000000au, 0x000200f8u, 0x0000000cu, 0x0004003du, 0x00000007u, 0x00000018u, 0x0000000au,
0x00050094u, 0x00000006u, 0x0000001du, 0x00000018u, 0x0000001cu, 0x000200feu, 0x0000001du, 0x00010038u,
0x00050036u, 0x00000006u, 0x00000012u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, 0x00000010u,
0x00030037u, 0x0000000eu, 0x00000011u, 0x000200f8u, 0x00000013u, 0x0004003bu, 0x00000020u, 0x00000021u,
0x00000007u, 0x0004003bu, 0x00000008u, 0x00000031u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000034u,
0x00000007u, 0x0004003bu, 0x00000008u, 0x0000003cu, 0x00000007u, 0x0004003du, 0x00000023u, 0x00000026u,
0x00000025u, 0x0004003du, 0x0000000du, 0x00000027u, 0x00000010u, 0x00050041u, 0x00000020u, 0x0000002au,
0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000002bu, 0x0000002au, 0x00050050u, 0x0000000du,
0x0000002du, 0x0000002bu, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000002eu, 0x00000027u, 0x0000002du,
0x00050057u, 0x0000002fu, 0x00000030u, 0x00000026u, 0x0000002eu, 0x0008004fu, 0x00000007u, 0x00000032u,
0x00000030u, 0x00000030u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x00000031u, 0x00000032u,
0x00050039u, 0x00000006u, 0x00000033u, 0x0000000bu, 0x00000031u, 0x0003003eu, 0x00000021u, 0x00000033u,
0x0004003du, 0x00000023u, 0x00000035u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000036u, 0x00000010u,
0x00050041u, 0x00000020u, 0x00000037u, 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000038u,
0x00000037u, 0x00050050u, 0x0000000du, 0x00000039u, 0x00000038u, 0x0000002cu, 0x00050081u, 0x0000000du,
0x0000003au, 0x00000036u, 0x00000039u, 0x00050057u, 0x0000002fu, 0x0000003bu, 0x00000035u, 0x0000003au,
0x0008004fu, 0x00000007u, 0x0000003du, 0x0000003bu, 0x0000003bu, 0x00000000u, 0x00000001u, 0x00000002u,
0x0003003eu, 0x0000003cu, 0x0000003du, 0x00050039u, 0x00000006u, 0x0000003eu, 0x0000000bu, 0x0000003cu,
0x0003003eu, 0x00000034u, 0x0000003eu, 0x0004003du, 0x00000006u, 0x0000003fu, 0x00000021u, 0x0004003du,
0x00000006u, 0x00000040u, 0x00000034u, 0x00050083u, 0x00000006u, 0x00000041u, 0x0000003fu, 0x00000040u,
0x0006000cu, 0x00000006u, 0x00000042u, 0x00000001u, 0x00000004u, 0x00000041u, 0x000200feu, 0x00000042u,
0x00010038u, 0x00050036u, 0x00000006u, 0x00000016u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu,
0x00000014u, 0x00030037u, 0x0000000eu, 0x00000015u, 0x000200f8u, 0x00000017u, 0x0004003bu, 0x00000020u,
0x00000045u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000004eu, 0x00000007u, 0x0004003bu, 0x00000020u,
0x00000051u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000059u, 0x00000007u, 0x0004003du, 0x00000023u,
0x00000046u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000047u, 0x00000014u, 0x00050041u, 0x00000020u,
0x00000049u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, 0x0000004au, 0x00000049u, 0x00050050u,
0x0000000du, 0x0000004bu, 0x0000002cu, 0x0000004au, 0x00050083u, 0x0000000du, 0x0000004cu, 0x00000047u,
0x0000004bu, 0x00050057u, 0x0000002fu, 0x0000004du, 0x00000046u, 0x0000004cu, 0x0008004fu, 0x00000007u,
0x0000004fu, 0x0000004du, 0x0000004du, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000004eu,
0x0000004fu, 0x00050039u, 0x00000006u, 0x00000050u, 0x0000000bu, 0x0000004eu, 0x0003003eu, 0x00000045u,
0x00000050u, 0x0004003du, 0x00000023u, 0x00000052u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000053u,
0x00000014u, 0x00050041u, 0x00000020u, 0x00000054u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u,
0x00000055u, 0x00000054u, 0x00050050u, 0x0000000du, 0x00000056u, 0x0000002cu, 0x00000055u, 0x00050081u,
0x0000000du, 0x00000057u, 0x00000053u, 0x00000056u, 0x00050057u, 0x0000002fu, 0x00000058u, 0x00000052u,
0x00000057u, 0x0008004fu, 0x00000007u, 0x0000005au, 0x00000058u, 0x00000058u, 0x00000000u, 0x00000001u,
0x00000002u, 0x0003003eu, 0x00000059u, 0x0000005au, 0x00050039u, 0x00000006u, 0x0000005bu, 0x0000000bu,
0x00000059u, 0x0003003eu, 0x00000051u, 0x0000005bu, 0x0004003du, 0x00000006u, 0x0000005cu, 0x00000045u,
0x0004003du, 0x00000006u, 0x0000005du, 0x00000051u, 0x00050083u, 0x00000006u, 0x0000005eu, 0x0000005cu,
0x0000005du, 0x0006000cu, 0x00000006u, 0x0000005fu, 0x00000001u, 0x00000004u, 0x0000005eu, 0x000200feu,
0x0000005fu, 0x00010038u,
};
+5 -2
View File
@@ -1,5 +1,6 @@
add_library(droiddeckwayland SHARED
src/compositor.c
src/clock_domain.c
src/vk_present.c
src/effects_chain.c
src/cardboard.c
@@ -7,6 +8,7 @@ add_library(droiddeckwayland SHARED
src/vk_loader.c
src/sc_layer.c
src/ahb_swapchain.c
src/display_buffers.c
src/waylandcomp_jni.c
src/gpu_clock_pin.c
src/droiddeck_ext.c
@@ -25,7 +27,7 @@ add_library(droiddeckwayland SHARED
generated/linux-dmabuf-v1-protocol.c
generated/wayland-android-protocol.c
generated/viewporter-protocol.c
generated/banner-desktop-v1-protocol.c
generated/droiddeck-desktop-v1-protocol.c
generated/presentation-time-protocol.c
generated/pointer-constraints-unstable-v1-protocol.c
generated/relative-pointer-unstable-v1-protocol.c
@@ -33,7 +35,8 @@ add_library(droiddeckwayland SHARED
generated/text-input-unstable-v3-protocol.c
generated/xdg-toplevel-icon-v1-protocol.c
generated/single-pixel-buffer-v1-protocol.c
generated/banner-ahb-v1-protocol.c
generated/droiddeck-ahb-v1-protocol.c
generated/droiddeck-refresh-v1-protocol.c
src/framegen_bridge.c
src/framegen_jni.c
src/hudframes.c
@@ -19,8 +19,8 @@ exactly how Turnip already imports every gralloc buffer on Android (`vk_android.
in play already have every extension needed; nothing is missing in the drivers. What is missing is
a **WSI hook**: Mesa's Wayland WSI always allocates its own dma-bufs and has no way to receive or
allocate compositor-visible buffers, so **option (a) or (c) each need a ~300-line patch to
`wsi_common_wayland.c` in our own Wayland Turnip build** (banners-turnip-wayland
`build_turnip_wayland_wsi.sh`, Mesa `7cda7850`) plus a small private Wayland protocol. Nothing in
`wsi_common_wayland.c` in our own Wayland Turnip build**
(`build_turnip_wayland_wsi.sh`, Mesa `7cda7850`) plus a small private Wayland protocol. Nothing in
the app can remove the copy on its own. Recommended: **option (a′) - the game's WSI allocates its
swapchain images as `AHardwareBuffer`s (gralloc-native, UBWC), imports them through the AHB path
Turnip already has, and hands the compositor the AHB over a Unix socket (`AHardwareBuffer_send/
@@ -77,7 +77,7 @@ Mesa's Wayland WSI creates every native swapchain image with `wsi_create_native_
(the Android-WSI import path, `tu_image.cc:880-925`) is only reachable from the Android swapchain.
The patch (in our Wayland Turnip build): a new `create_mem` for the Wayland chain, selected when the
compositor advertises a private global `banner_layer_buffer_v1`:
compositor advertises a private global `droiddeck_layer_buffer_v1`:
1. `AHardwareBuffer_allocate(w, h, R8G8B8A8, GPU_COLOR_OUTPUT | GPU_SAMPLED_IMAGE)`;
`vkGetAndroidHardwareBufferPropertiesANDROID` → `vkAllocateMemory` with
`VkImportAndroidHardwareBufferInfoANDROID` (Turnip: `tu_device.cc:3828`), bind - the image was
@@ -85,7 +85,7 @@ compositor advertises a private global `banner_layer_buffer_v1`:
2. `wsi_image.dma_buf_fd = dup(native_handle->data[0])`, `drm_modifier` / `row_pitches[0]` from
the same layout → the existing `zwp_linux_dmabuf_v1` path stays untouched: the compositor keeps
importing a dma-buf and can keep the blit path as the fallback.
3. `banner_layer_buffer_v1.attach(wl_buffer, socket_fd)`: the WSI creates a `socketpair`, sends one
3. `droiddeck_layer_buffer_v1.attach(wl_buffer, socket_fd)`: the WSI creates a `socketpair`, sends one
end in the request, and calls `AHardwareBuffer_sendHandleToUnixSocket(ahb, other_end)`; the
compositor's request handler does `AHardwareBuffer_recvHandleFromUnixSocket` and stores the AHB
on `struct dmabuf_buffer`. Per swapchain image, once - not per frame.
@@ -262,7 +262,7 @@ D3D12 tabs) as the workload, session log in `Download/Wayland-logs/`.
since the blit only changed its destination) and `dumpsys gfxinfo`/battery for 5 min each. This
is the baseline the WSI patch is measured against.
4. **Fence probe outcome → choose the acquire-fence design** (§3) before starting the WSI patch.
5. **WSI patch (option a) in banners-turnip-wayland**, wcp rebuild, then the same steps 1–3 with
5. **WSI patch (option a) in the Wayland Turnip build**, wcp rebuild, then the same steps 1–3 with
the AHB arriving from the guest: log line to add on the compositor side `layer: buffer N of
"<window>" received from the game (AHardwareBuffer WxH, UBWC)` and the fps delta vs X11.
@@ -296,7 +296,7 @@ unchanged. Off by default: with the variable unset no new code runs.
Not zero-copy yet - it is the receive side. The copy disappears when step 5 lands and
`sc_layer_present` is handed the game's own `AHardwareBuffer` instead of a pool slot.
## 7. Step 5 implemented (feat/wayland-zero-copy-wsi + banners-turnip-wayland `banner_ahb_wsi.py`)
## 7. Step 5 implemented (feat/wayland-zero-copy-wsi + the Wayland Turnip build `droiddeck_ahb_wsi.py`)
Option (a′) as recommended, with one deviation forced by the build: the Wayland Turnip is a
`platforms=wayland` build with Android detection off, so `VK_ANDROID_external_memory_android_hardware_buffer`
@@ -38,7 +38,7 @@
extern const struct wl_interface wl_buffer_interface;
static const struct wl_interface *banner_ahb_v1_types[] = {
static const struct wl_interface *droiddeck_ahb_v1_types[] = {
NULL,
&wl_buffer_interface,
NULL,
@@ -50,18 +50,18 @@ static const struct wl_interface *banner_ahb_v1_types[] = {
NULL,
};
static const struct wl_message banner_ahb_v1_requests[] = {
{ "destroy", "", banner_ahb_v1_types + 0 },
{ "attach", "ohuuuuuu", banner_ahb_v1_types + 1 },
static const struct wl_message droiddeck_ahb_v1_requests[] = {
{ "destroy", "", droiddeck_ahb_v1_types + 0 },
{ "attach", "ohuuuuuu", droiddeck_ahb_v1_types + 1 },
};
static const struct wl_message banner_ahb_v1_events[] = {
{ "mode", "2u", banner_ahb_v1_types + 0 },
static const struct wl_message droiddeck_ahb_v1_events[] = {
{ "mode", "2u", droiddeck_ahb_v1_types + 0 },
};
WL_PRIVATE const struct wl_interface banner_ahb_v1_interface = {
"banner_ahb_v1", 2,
2, banner_ahb_v1_requests,
1, banner_ahb_v1_events,
WL_PRIVATE const struct wl_interface droiddeck_ahb_v1_interface = {
"droiddeck_ahb_v1", 2,
2, droiddeck_ahb_v1_requests,
1, droiddeck_ahb_v1_events,
};
@@ -1,6 +1,6 @@
#ifndef BANNER_AHB_V1_SERVER_PROTOCOL_H
#define BANNER_AHB_V1_SERVER_PROTOCOL_H
#ifndef DROIDDECK_AHB_V1_SERVER_PROTOCOL_H
#define DROIDDECK_AHB_V1_SERVER_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
@@ -14,7 +14,7 @@ struct wl_client;
struct wl_resource;
/*
* @section page_copyright_banner_ahb_v1 Copyright
* @section page_copyright_droiddeck_ahb_v1 Copyright
*
* Copyright 2026 The412Banner
*
@@ -42,15 +42,15 @@ struct wl_resource;
struct banner_ahb_v1;
struct droiddeck_ahb_v1;
struct wl_buffer;
#ifndef BANNER_AHB_V1_INTERFACE
#define BANNER_AHB_V1_INTERFACE
extern const struct wl_interface banner_ahb_v1_interface;
#ifndef DROIDDECK_AHB_V1_INTERFACE
#define DROIDDECK_AHB_V1_INTERFACE
extern const struct wl_interface droiddeck_ahb_v1_interface;
#endif
struct banner_ahb_v1_interface {
struct droiddeck_ahb_v1_interface {
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
void (*attach)(struct wl_client *client,
@@ -65,17 +65,17 @@ struct banner_ahb_v1_interface {
uint32_t image_count);
};
#define BANNER_AHB_V1_MODE 0
#define DROIDDECK_AHB_V1_MODE 0
#define BANNER_AHB_V1_MODE_SINCE_VERSION 2
#define DROIDDECK_AHB_V1_MODE_SINCE_VERSION 2
#define BANNER_AHB_V1_DESTROY_SINCE_VERSION 1
#define BANNER_AHB_V1_ATTACH_SINCE_VERSION 1
#define DROIDDECK_AHB_V1_DESTROY_SINCE_VERSION 1
#define DROIDDECK_AHB_V1_ATTACH_SINCE_VERSION 1
static inline void
banner_ahb_v1_send_mode(struct wl_resource *resource_, uint32_t enabled)
droiddeck_ahb_v1_send_mode(struct wl_resource *resource_, uint32_t enabled)
{
wl_resource_post_event(resource_, BANNER_AHB_V1_MODE, enabled);
wl_resource_post_event(resource_, DROIDDECK_AHB_V1_MODE, enabled);
}
#ifdef __cplusplus
@@ -38,7 +38,7 @@
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *banner_desktop_v1_types[] = {
static const struct wl_interface *droiddeck_desktop_v1_types[] = {
NULL,
&wl_surface_interface,
&wl_surface_interface,
@@ -47,16 +47,16 @@ static const struct wl_interface *banner_desktop_v1_types[] = {
NULL,
};
static const struct wl_message banner_desktop_v1_requests[] = {
{ "destroy", "", banner_desktop_v1_types + 0 },
{ "set_desktop", "o", banner_desktop_v1_types + 1 },
{ "set_window", "ouii", banner_desktop_v1_types + 2 },
{ "set_zorder", "a", banner_desktop_v1_types + 0 },
static const struct wl_message droiddeck_desktop_v1_requests[] = {
{ "destroy", "", droiddeck_desktop_v1_types + 0 },
{ "set_desktop", "o", droiddeck_desktop_v1_types + 1 },
{ "set_window", "ouii", droiddeck_desktop_v1_types + 2 },
{ "set_zorder", "a", droiddeck_desktop_v1_types + 0 },
};
WL_PRIVATE const struct wl_interface banner_desktop_v1_interface = {
"banner_desktop_v1", 1,
4, banner_desktop_v1_requests,
WL_PRIVATE const struct wl_interface droiddeck_desktop_v1_interface = {
"droiddeck_desktop_v1", 1,
4, droiddeck_desktop_v1_requests,
0, NULL,
};
@@ -1,6 +1,6 @@
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#ifndef DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#define DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
@@ -14,7 +14,7 @@ struct wl_client;
struct wl_resource;
/*
* @section page_copyright_banner_desktop_v1 Copyright
* @section page_copyright_droiddeck_desktop_v1 Copyright
*
* Copyright 2026 The412Banner
*
@@ -42,15 +42,15 @@ struct wl_resource;
struct banner_desktop_v1;
struct droiddeck_desktop_v1;
struct wl_surface;
#ifndef BANNER_DESKTOP_V1_INTERFACE
#define BANNER_DESKTOP_V1_INTERFACE
extern const struct wl_interface banner_desktop_v1_interface;
#ifndef DROIDDECK_DESKTOP_V1_INTERFACE
#define DROIDDECK_DESKTOP_V1_INTERFACE
extern const struct wl_interface droiddeck_desktop_v1_interface;
#endif
struct banner_desktop_v1_interface {
struct droiddeck_desktop_v1_interface {
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
void (*set_desktop)(struct wl_client *client,
@@ -68,10 +68,10 @@ struct banner_desktop_v1_interface {
};
#define BANNER_DESKTOP_V1_DESTROY_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_DESTROY_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
#ifdef __cplusplus
}
@@ -0,0 +1,59 @@
/*
* Copyright 2026 DroidDeck contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
static const struct wl_interface *droiddeck_refresh_v1_types[] = {
NULL,
NULL,
};
static const struct wl_message droiddeck_refresh_v1_requests[] = {
{ "destroy", "", droiddeck_refresh_v1_types + 0 },
{ "set_target", "uu", droiddeck_refresh_v1_types + 0 },
};
static const struct wl_message droiddeck_refresh_v1_events[] = {
{ "rate", "u", droiddeck_refresh_v1_types + 0 },
{ "done", "", droiddeck_refresh_v1_types + 0 },
};
WL_PRIVATE const struct wl_interface droiddeck_refresh_v1_interface = {
"droiddeck_refresh_v1", 1,
2, droiddeck_refresh_v1_requests,
2, droiddeck_refresh_v1_events,
};
@@ -0,0 +1,175 @@
#ifndef DROIDDECK_REFRESH_V1_SERVER_PROTOCOL_H
#define DROIDDECK_REFRESH_V1_SERVER_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
#include "wayland-server.h"
#ifdef __cplusplus
extern "C" {
#endif
struct wl_client;
struct wl_resource;
/**
* @page page_droiddeck_refresh_v1 The droiddeck_refresh_v1 protocol
* @section page_ifaces_droiddeck_refresh_v1 Interfaces
* - @subpage page_iface_droiddeck_refresh_v1 - panel refresh rates a nested compositor may ask for
* @section page_copyright_droiddeck_refresh_v1 Copyright
* <pre>
*
* Copyright 2026 DroidDeck contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* </pre>
*/
struct droiddeck_refresh_v1;
#ifndef DROIDDECK_REFRESH_V1_INTERFACE
#define DROIDDECK_REFRESH_V1_INTERFACE
/**
* @page page_iface_droiddeck_refresh_v1 droiddeck_refresh_v1
* @section page_iface_droiddeck_refresh_v1_desc Description
*
* A nested compositor paces its clients against the refresh rate of the
* panel it is shown on. When its clients are held to a frame rate the
* panel's current rate does not divide evenly, frames are shown for an
* uneven number of refreshes. This interface lets the nested compositor
* see every refresh rate the panel can run at its current size and ask
* for the one that suits the frame rate it is pacing to.
*
* On bind the compositor sends one rate event per refresh rate, lowest
* first, followed by done. The list is sent again, in full, whenever it
* changes (a different panel, or a limit the user placed on the panel's
* rate). The rate the panel is running at is still reported the standard
* way, through wl_output.mode.
*
* A request is a preference, not a guarantee: the user, the platform or
* another output mirroring the panel may hold the panel at another rate.
* The client reads the result from wl_output.mode.
* @section page_iface_droiddeck_refresh_v1_api API
* See @ref iface_droiddeck_refresh_v1.
*/
/**
* @defgroup iface_droiddeck_refresh_v1 The droiddeck_refresh_v1 interface
*
* A nested compositor paces its clients against the refresh rate of the
* panel it is shown on. When its clients are held to a frame rate the
* panel's current rate does not divide evenly, frames are shown for an
* uneven number of refreshes. This interface lets the nested compositor
* see every refresh rate the panel can run at its current size and ask
* for the one that suits the frame rate it is pacing to.
*
* On bind the compositor sends one rate event per refresh rate, lowest
* first, followed by done. The list is sent again, in full, whenever it
* changes (a different panel, or a limit the user placed on the panel's
* rate). The rate the panel is running at is still reported the standard
* way, through wl_output.mode.
*
* A request is a preference, not a guarantee: the user, the platform or
* another output mirroring the panel may hold the panel at another rate.
* The client reads the result from wl_output.mode.
*/
extern const struct wl_interface droiddeck_refresh_v1_interface;
#endif
/**
* @ingroup iface_droiddeck_refresh_v1
* @struct droiddeck_refresh_v1_interface
*/
struct droiddeck_refresh_v1_interface {
/**
* destroy the object
*
* The preference set through this object is dropped.
*/
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
/**
* ask for a refresh rate
*
* refresh is the panel rate the client would like, in Hz, taken
* from the advertised list; 0 withdraws the preference. frame_rate
* is the frame rate the client holds its content to, in frames per
* second, or 0 when the content is not held to a rate. The
* compositor may multiply the content's frame rate itself
* (generated frames); when it does, it picks the advertised rate
* that the multiplied frame rate divides evenly instead of the
* requested one.
* @param refresh wanted panel refresh rate in Hz, 0 for none
* @param frame_rate content frame rate in frames per second, 0 for unpaced
*/
void (*set_target)(struct wl_client *client,
struct wl_resource *resource,
uint32_t refresh,
uint32_t frame_rate);
};
#define DROIDDECK_REFRESH_V1_RATE 0
#define DROIDDECK_REFRESH_V1_DONE 1
/**
* @ingroup iface_droiddeck_refresh_v1
*/
#define DROIDDECK_REFRESH_V1_RATE_SINCE_VERSION 1
/**
* @ingroup iface_droiddeck_refresh_v1
*/
#define DROIDDECK_REFRESH_V1_DONE_SINCE_VERSION 1
/**
* @ingroup iface_droiddeck_refresh_v1
*/
#define DROIDDECK_REFRESH_V1_DESTROY_SINCE_VERSION 1
/**
* @ingroup iface_droiddeck_refresh_v1
*/
#define DROIDDECK_REFRESH_V1_SET_TARGET_SINCE_VERSION 1
/**
* @ingroup iface_droiddeck_refresh_v1
* Sends an rate event to the client owning the resource.
* @param resource_ The client's resource
* @param refresh panel refresh rate in Hz
*/
static inline void
droiddeck_refresh_v1_send_rate(struct wl_resource *resource_, uint32_t refresh)
{
wl_resource_post_event(resource_, DROIDDECK_REFRESH_V1_RATE, refresh);
}
/**
* @ingroup iface_droiddeck_refresh_v1
* Sends an done event to the client owning the resource.
* @param resource_ The client's resource
*/
static inline void
droiddeck_refresh_v1_send_done(struct wl_resource *resource_)
{
wl_resource_post_event(resource_, DROIDDECK_REFRESH_V1_DONE);
}
#ifdef __cplusplus
}
#endif
#endif
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="banner_ahb_v1">
<protocol name="droiddeck_ahb_v1">
<copyright>
Copyright 2026 The412Banner
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="banner_ahb_v1" version="2">
<interface name="droiddeck_ahb_v1" version="2">
<description summary="Android gralloc buffers behind dma-buf wl_buffers">
Zero-copy window layers on Android. A Vulkan swapchain image that the
client allocated as an Android AHardwareBuffer (gralloc) is still shared
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="banner_desktop_v1">
<protocol name="droiddeck_desktop_v1">
<copyright>
Copyright 2026 The412Banner
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="banner_desktop_v1" version="1">
<interface name="droiddeck_desktop_v1" version="1">
<description summary="Windows virtual desktop layout">
Each Wine process is a separate Wayland client, so a Windows virtual
desktop can't be built from subsurfaces. Instead the process that owns
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="droiddeck_refresh_v1">
<copyright>
Copyright 2026 DroidDeck contributors
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="droiddeck_refresh_v1" version="1">
<description summary="panel refresh rates a nested compositor may ask for">
A nested compositor paces its clients against the refresh rate of the
panel it is shown on. When its clients are held to a frame rate the
panel's current rate does not divide evenly, frames are shown for an
uneven number of refreshes. This interface lets the nested compositor
see every refresh rate the panel can run at its current size and ask
for the one that suits the frame rate it is pacing to.
On bind the compositor sends one rate event per refresh rate, lowest
first, followed by done. The list is sent again, in full, whenever it
changes (a different panel, or a limit the user placed on the panel's
rate). The rate the panel is running at is still reported the standard
way, through wl_output.mode.
A request is a preference, not a guarantee: the user, the platform or
another output mirroring the panel may hold the panel at another rate.
The client reads the result from wl_output.mode.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the object">
The preference set through this object is dropped.
</description>
</request>
<request name="set_target">
<description summary="ask for a refresh rate">
refresh is the panel rate the client would like, in Hz, taken from
the advertised list; 0 withdraws the preference. frame_rate is the
frame rate the client holds its content to, in frames per second, or
0 when the content is not held to a rate. The compositor may multiply
the content's frame rate itself (generated frames); when it does, it
picks the advertised rate that the multiplied frame rate divides
evenly instead of the requested one.
</description>
<arg name="refresh" type="uint" summary="wanted panel refresh rate in Hz, 0 for none"/>
<arg name="frame_rate" type="uint" summary="content frame rate in frames per second, 0 for unpaced"/>
</request>
<event name="rate">
<description summary="a refresh rate the panel can run">
Sent once per rate, lowest first, in Hz rounded to the nearest whole
number.
</description>
<arg name="refresh" type="uint" summary="panel refresh rate in Hz"/>
</event>
<event name="done">
<description summary="the list of rates is complete">
Ends a list of rate events. The rates received since the previous
done replace the earlier list.
</description>
</event>
</interface>
</protocol>
@@ -4,7 +4,7 @@
#include "droiddeck_ext.h"
#include "sc_layer.h"
#include "vk_present.h"
#include "banner-ahb-v1-server-protocol.h"
#include "droiddeck-ahb-v1-server-protocol.h"
#include <android/hardware_buffer.h>
#include <errno.h>
#include <fcntl.h>
@@ -25,6 +25,7 @@ struct droiddeck_dma_buf_sync_file { uint32_t flags; int32_t fd; };
#define DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW('b', 3, struct droiddeck_dma_buf_sync_file)
extern volatile int g_zero_copy;
void droiddeck_dmabuf_formats_stale(void);
struct ahb_buf {
uint64_t id;
@@ -37,6 +38,7 @@ struct ahb_buf {
struct wl_client *client;
struct wl_resource *resource;
struct wl_listener resource_destroy;
int display;
int on_layer;
int release_pending;
int64_t deferred_ns;
@@ -131,10 +133,10 @@ static void handle_released(uint64_t id, int fd) {
if (fd >= 0) {
struct droiddeck_dma_buf_sync_file imp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = fd};
int dmabuf_fd = droiddeck_dmabuf_fd(ab->b);
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) {
if (!ab->display && dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) {
close(fd);
} else {
if (!g_import_failed_logged) {
if (!ab->display && !g_import_failed_logged) {
g_import_failed_logged = 1;
droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_IMPORT_SYNC_FILE failed (%s): releases wait for the display's fence here instead",
strerror(errno));
@@ -187,7 +189,7 @@ int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b) {
return b && *droiddeck_dmabuf_ahb_slot((struct dmabuf_buffer *)b) != NULL;
}
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h) {
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h, const struct vkp_draw *draw) {
struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot(b) : NULL;
if (!ab) return -1;
int dmabuf_fd = droiddeck_dmabuf_fd(b);
@@ -205,7 +207,7 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
int r;
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
}
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h,
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h, draw,
s ? droiddeck_surface_color(s) : NULL, ab->format);
if (r < 0) return -1;
if (r == 1) return 0;
@@ -259,6 +261,58 @@ uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) {
}
static int adopt(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b, AHardwareBuffer *ahb,
uint32_t stride, uint32_t image_count, uint64_t modifier) {
AHardwareBuffer_Desc d;
AHardwareBuffer_describe(ahb, &d);
int bw, bh;
droiddeck_dmabuf_size(b, &bw, &bh);
struct ahb_buf *ab = calloc(1, sizeof(*ab));
if (!ab) return -1;
ab->id = g_next_id++;
ab->b = b;
droiddeck_dmabuf_ref(b);
ab->ahb = ahb;
ab->w = bw; ab->h = bh;
ab->stride = d.stride ? d.stride : stride;
ab->image_count = image_count;
ab->format = d.format;
ab->modifier = modifier;
ab->client = c;
ab->resource = buffer;
ab->resource_destroy.notify = on_buffer_resource_destroyed;
wl_resource_add_destroy_listener(buffer, &ab->resource_destroy);
ab->fence_fd = -1;
wl_list_insert(g_bufs.prev, &ab->link);
*droiddeck_dmabuf_ahb_slot(b) = ab;
if (g_last_chain.client != c || g_last_chain.w != bw || g_last_chain.h != bh ||
g_last_chain.image_count != image_count || g_last_chain.modifier != modifier || g_last_chain.format != d.format) {
char count[32] = "";
if (image_count) snprintf(count, sizeof(count), "%u images, ", image_count);
g_last_chain = (struct chain_seen){c, bw, bh, image_count, modifier, d.format};
droiddeck_log("layer", "zero-copy: %s from %s (%s%dx%d, %s, %s, stride %u px)",
image_count ? "AHB swapchain" : "display buffers", droiddeck_client_name(c), count, bw, bh,
droiddeck_ahb_format_name(d.format), modifier == MOD_QCOM_COMPRESSED ? "UBWC (QCOM_COMPRESSED)"
: modifier == 0 ? "linear" : "unknown modifier", ab->stride);
}
return 0;
}
int ahb_swapchain_adopt(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b, AHardwareBuffer *ahb,
uint64_t modifier) {
if (!g_advertised || *droiddeck_dmabuf_ahb_slot(b)) return -1;
AHardwareBuffer_acquire(ahb);
if (adopt(c, buffer, b, ahb, 0, 0, modifier) != 0) { AHardwareBuffer_release(ahb); return -1; }
((struct ahb_buf *)*droiddeck_dmabuf_ahb_slot(b))->display = 1;
return 0;
}
AHardwareBuffer *ahb_swapchain_display_buffer(const struct dmabuf_buffer *b) {
struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot((struct dmabuf_buffer *)b) : NULL;
return ab && ab->display ? ab->ahb : NULL;
}
static void ahb_destroy(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
static void ahb_attach(struct wl_client *c, struct wl_resource *r, struct wl_resource *buffer, int32_t sock,
@@ -295,36 +349,13 @@ static void ahb_attach(struct wl_client *c, struct wl_resource *r, struct wl_res
AHardwareBuffer_release(ahb);
return;
}
struct ahb_buf *ab = calloc(1, sizeof(*ab));
if (!ab) { AHardwareBuffer_release(ahb); wl_client_post_no_memory(c); return; }
ab->id = g_next_id++;
ab->b = b;
droiddeck_dmabuf_ref(b);
ab->ahb = ahb;
ab->w = bw; ab->h = bh;
ab->stride = d.stride ? d.stride : stride;
ab->image_count = image_count;
ab->format = d.format;
ab->modifier = modifier;
ab->client = c;
ab->resource = buffer;
ab->resource_destroy.notify = on_buffer_resource_destroyed;
wl_resource_add_destroy_listener(buffer, &ab->resource_destroy);
ab->fence_fd = -1;
wl_list_insert(g_bufs.prev, &ab->link);
*slot = ab;
if (g_last_chain.client != c || g_last_chain.w != bw || g_last_chain.h != bh ||
g_last_chain.image_count != image_count || g_last_chain.modifier != modifier || g_last_chain.format != d.format) {
g_last_chain = (struct chain_seen){c, bw, bh, image_count, modifier, d.format};
droiddeck_log("layer", "zero-copy: AHB swapchain from %s (%u images, %dx%d, %s, %s, stride %u px)", droiddeck_client_name(c),
image_count, bw, bh, droiddeck_ahb_format_name(d.format), modifier == MOD_QCOM_COMPRESSED ? "UBWC (QCOM_COMPRESSED)"
: modifier == 0 ? "linear" : "unknown modifier", ab->stride);
if (adopt(c, buffer, b, ahb, stride, image_count, modifier) != 0) {
AHardwareBuffer_release(ahb);
wl_client_post_no_memory(c);
}
}
static const struct banner_ahb_v1_interface ahb_impl = {
static const struct droiddeck_ahb_v1_interface ahb_impl = {
.destroy = ahb_destroy,
.attach = ahb_attach,
};
@@ -336,20 +367,21 @@ static void on_client_resource_destroyed(struct wl_resource *r) {
static void bind_ahb(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
static struct wl_client *last_named;
if (ver > 2) ver = 2;
struct wl_resource *r = wl_resource_create(c, &banner_ahb_v1_interface, (int)ver, id);
struct wl_resource *r = wl_resource_create(c, &droiddeck_ahb_v1_interface, (int)ver, id);
if (!r) { wl_client_post_no_memory(c); return; }
wl_resource_set_implementation(r, &ahb_impl, NULL, on_client_resource_destroyed);
wl_list_insert(&g_clients, wl_resource_get_link(r));
if (ver >= BANNER_AHB_V1_MODE_SINCE_VERSION) banner_ahb_v1_send_mode(r, g_zero_copy ? 1u : 0u);
if (ver >= DROIDDECK_AHB_V1_MODE_SINCE_VERSION) droiddeck_ahb_v1_send_mode(r, g_zero_copy ? 1u : 0u);
if (last_named != c) {
last_named = c;
droiddeck_log("layer", "zero-copy: %s bound banner_ahb_v1 version %u (%s)", droiddeck_client_name(c), ver,
droiddeck_log("layer", "zero-copy: %s bound droiddeck_ahb_v1 version %u (%s)", droiddeck_client_name(c), ver,
ver >= 2 ? "follows the live switch" : "version 1: decides from its launch environment only");
}
}
void ahb_swapchain_set_mode(int on, int live) {
on = on ? 1 : 0;
if (g_zero_copy != on) droiddeck_dmabuf_formats_stale();
g_zero_copy = on;
if (!g_advertised) {
if (live) droiddeck_log("layer", "zero-copy switched %s from the drawer, but no display layer is available on this device: no change",
@@ -361,8 +393,8 @@ void ahb_swapchain_set_mode(int on, int live) {
int told = 0;
struct wl_resource *r;
wl_resource_for_each(r, &g_clients) {
if (wl_resource_get_version(r) >= BANNER_AHB_V1_MODE_SINCE_VERSION) {
banner_ahb_v1_send_mode(r, (uint32_t)on);
if (wl_resource_get_version(r) >= DROIDDECK_AHB_V1_MODE_SINCE_VERSION) {
droiddeck_ahb_v1_send_mode(r, (uint32_t)on);
told++;
}
}
@@ -385,7 +417,7 @@ void ahb_swapchain_init(struct wl_display *display) {
wl_list_init(&g_bufs);
wl_list_init(&g_clients);
if (!sc_layer_available()) {
droiddeck_log("layer", "zero-copy: no display layer on this device (see the line above): banner_ahb_v1 not advertised");
droiddeck_log("layer", "zero-copy: no display layer on this device (see the line above): droiddeck_ahb_v1 not advertised");
return;
}
g_loop = wl_display_get_event_loop(display);
@@ -395,11 +427,11 @@ void ahb_swapchain_init(struct wl_display *display) {
return;
}
wl_event_loop_add_fd(g_loop, g_rel_pipe[0], WL_EVENT_READABLE, on_release_pipe, NULL);
if (!wl_global_create(display, &banner_ahb_v1_interface, 2, NULL, bind_ahb)) {
droiddeck_log("error", "zero-copy: banner_ahb_v1 global creation failed");
if (!wl_global_create(display, &droiddeck_ahb_v1_interface, 2, NULL, bind_ahb)) {
droiddeck_log("error", "zero-copy: droiddeck_ahb_v1 global creation failed");
return;
}
g_advertised = 1;
droiddeck_log("layer", "zero-copy: banner_ahb_v1 version 2 advertised (games built for it present their own gralloc buffers while the switch is on)");
droiddeck_log("layer", "zero-copy: droiddeck_ahb_v1 version 2 advertised (games built for it present their own gralloc buffers while the switch is on)");
ahb_swapchain_set_mode(g_zero_copy, 0);
}
@@ -2,16 +2,21 @@
#define AHB_SWAPCHAIN_H
#include <stddef.h>
#include <stdint.h>
#include <android/hardware_buffer.h>
#include <wayland-server.h>
struct dmabuf_buffer;
struct surface;
struct vkp_draw;
void ahb_swapchain_init(struct wl_display *display);
void ahb_swapchain_set_mode(int on, int live);
int ahb_swapchain_last_frame_age_ms(void);
int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b);
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h);
int ahb_swapchain_adopt(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b, AHardwareBuffer *ahb,
uint64_t modifier);
AHardwareBuffer *ahb_swapchain_display_buffer(const struct dmabuf_buffer *b);
int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_w, int scene_h, const struct vkp_draw *draw);
int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced);
void ahb_swapchain_surface_gone(struct surface *s);
unsigned ahb_swapchain_stats_take(void);
@@ -0,0 +1,72 @@
#define _GNU_SOURCE
#include "clock_domain.h"
#include <fcntl.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
static const int64_t *g_shift;
static pthread_mutex_t g_control_lock = PTHREAD_MUTEX_INITIALIZER;
static dev_t g_device;
static ino_t g_inode;
void droiddeck_clock_domain_set_control(const char *path) {
int fd;
struct stat st;
pthread_mutex_lock(&g_control_lock);
if (!path || !*path) {
const int64_t *previous = g_shift;
g_shift = NULL;
if (previous) munmap((void *)previous, sizeof(*previous));
pthread_mutex_unlock(&g_control_lock);
return;
}
fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0 || fstat(fd, &st) != 0 || st.st_size < (off_t)sizeof(int64_t)) {
if (fd >= 0) close(fd);
pthread_mutex_unlock(&g_control_lock);
return;
}
if (g_shift && st.st_dev == g_device && st.st_ino == g_inode) {
close(fd);
pthread_mutex_unlock(&g_control_lock);
return;
}
const int64_t *shift = mmap(NULL, sizeof(*shift), PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if (shift != MAP_FAILED) {
g_device = st.st_dev;
g_inode = st.st_ino;
const int64_t *previous = g_shift;
g_shift = shift;
if (previous) munmap((void *)previous, sizeof(*previous));
}
pthread_mutex_unlock(&g_control_lock);
}
static int64_t shift_ns(void) {
pthread_mutex_lock(&g_control_lock);
const int64_t *mapping = g_shift;
int64_t shift = mapping ? __atomic_load_n(mapping, __ATOMIC_RELAXED) : 0;
pthread_mutex_unlock(&g_control_lock);
return shift > 0 ? shift : 0;
}
int64_t droiddeck_clock_domain_adjust_ns(int64_t value) {
int64_t shift = shift_ns();
return value > shift ? value - shift : 0;
}
int64_t droiddeck_clock_domain_now_ns(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return droiddeck_clock_domain_adjust_ns((int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec);
}
uint32_t droiddeck_clock_domain_now_ms(void) {
return (uint32_t)(droiddeck_clock_domain_now_ns() / 1000000LL);
}
@@ -0,0 +1,11 @@
#ifndef DROIDDECK_CLOCK_DOMAIN_H
#define DROIDDECK_CLOCK_DOMAIN_H
#include <stdint.h>
void droiddeck_clock_domain_set_control(const char *path);
int64_t droiddeck_clock_domain_now_ns(void);
uint32_t droiddeck_clock_domain_now_ms(void);
int64_t droiddeck_clock_domain_adjust_ns(int64_t value);
#endif
File diff suppressed because it is too large. Load diff
@@ -20,6 +20,7 @@
#define DRM_XBGR8888 FOURCC('X', 'B', '2', '4')
#define MOD_LINEAR VKP_MOD_LINEAR
#define MOD_INVALID VKP_MOD_INVALID
#define MOD_QCOM_COMPRESSED VKP_MOD_QCOM_COMPRESSED
#define MAX_PLANES 4
struct dmabuf_params {
@@ -0,0 +1,343 @@
#define _GNU_SOURCE
#include "display_buffers.h"
#include "ahb_swapchain.h"
#include "compositor_internal.h"
#include "droiddeck_color.h"
#include "droiddeck_ext.h"
#include "sc_layer.h"
#include <android/hardware_buffer.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
#define DISPLAY_BUFFERS_SOCKET "droiddeck-display-buffers"
#define DISPLAY_BUFFERS_MAGIC 0x42444444u
#define DISPLAY_BUFFERS_VERSION 1u
#define DISPLAY_BUFFERS_ALLOC 1u
#define DISPLAY_BUFFERS_FREE 2u
#define DISPLAY_BUFFERS_MAX_SIDE 16384u
#define DISPLAY_BUFFERS_MAX_PER_CLIENT 256
#define DISPLAY_BUFFERS_PROBE_W 1280u
#define DISPLAY_BUFFERS_PROBE_H 720u
#define ALIGN_UP(v, a) (((v) + (a) - 1) / (a) * (a))
extern volatile int g_zero_copy;
volatile int g_display_buffer_driver;
struct display_buffers_request {
uint32_t magic, version, op, width, height, format, stride, offset;
uint64_t size, id, modifier;
};
struct display_buffers_reply {
uint32_t magic, status;
uint64_t id, size;
};
struct peer {
int fd;
pid_t pid;
int count;
int logged_w, logged_h;
uint32_t logged_format;
struct wl_event_source *src;
};
struct entry {
uint64_t id;
dev_t dev;
ino_t ino;
AHardwareBuffer *ahb;
uint32_t format, stride, width, height;
uint64_t modifier;
struct peer *peer;
struct wl_list link;
};
static struct wl_list g_entries;
static struct wl_event_loop *g_loop;
static uint64_t g_next_id = 1;
static int g_refused_logged;
static int g_ubwc_promised;
static int g_ubwc_probed[2];
static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) {
switch (drm) {
case DRM_ABGR8888: case DRM_XBGR8888: return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
case DRM_ARGB8888: case DRM_XRGB8888: return modifier == MOD_QCOM_COMPRESSED ? AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM : 0;
case FOURCC('A', 'B', '3', '0'): case FOURCC('X', 'B', '3', '0'): return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
default: return 0;
}
}
static uint64_t ubwc_meta_size(uint32_t w, uint32_t h) {
return ALIGN_UP((uint64_t)ALIGN_UP((w + 15) / 16, 64) * ALIGN_UP((h + 3) / 4, 16), 4096);
}
static uint64_t ubwc_size(uint32_t w, uint32_t h, uint32_t stride) {
return ubwc_meta_size(w, h) + ALIGN_UP((uint64_t)stride * ALIGN_UP(h, 16), 4096);
}
static void entry_free(struct entry *e) {
wl_list_remove(&e->link);
e->peer->count--;
AHardwareBuffer_release(e->ahb);
free(e);
}
static AHardwareBuffer *allocate_ubwc(uint32_t w, uint32_t h, uint32_t format, uint32_t stride, int *fd, uint64_t *size) {
const uint64_t tiers[2] = {SC_LAYER_AHB_USAGE_VENDOR_UBWC, 0};
for (int i = 0; i < 2; i++) {
AHardwareBuffer_Desc d = {
.width = w, .height = h, .layers = 1, .format = format,
.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY | tiers[i]};
AHardwareBuffer *ahb = NULL;
if (AHardwareBuffer_allocate(&d, &ahb) != 0 || !ahb) continue;
AHardwareBuffer_Desc got;
AHardwareBuffer_describe(ahb, &got);
const uint64_t need = ubwc_size(w, h, got.stride * 4);
*fd = !stride || (uint64_t)got.stride * 4 == stride ? sc_layer_ahb_fd(ahb, need) : -1;
if (*fd >= 0 && (uint64_t)lseek(*fd, 0, SEEK_END) == need) { *size = need; return ahb; }
*fd = -1;
AHardwareBuffer_release(ahb);
}
return NULL;
}
static uint64_t gralloc_bytes(uint32_t format, uint64_t usage, uint32_t *stride) {
AHardwareBuffer_Desc d = {
.width = DISPLAY_BUFFERS_PROBE_W, .height = DISPLAY_BUFFERS_PROBE_H, .layers = 1, .format = format,
.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY | usage};
AHardwareBuffer *ahb = NULL;
if (AHardwareBuffer_allocate(&d, &ahb) != 0 || !ahb) return 0;
AHardwareBuffer_describe(ahb, &d);
const int fd = sc_layer_ahb_fd(ahb, 1);
const off_t bytes = fd >= 0 ? lseek(fd, 0, SEEK_END) : 0;
if (fd >= 0) lseek(fd, 0, SEEK_SET);
AHardwareBuffer_release(ahb);
*stride = d.stride;
return bytes > 0 ? (uint64_t)bytes : 0;
}
static int ubwc_probe(uint32_t format) {
int *state = &g_ubwc_probed[format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM ? 0 : 1];
if (*state) return *state > 0;
uint32_t stride = 0, linear_stride = 0;
const uint64_t flagged = gralloc_bytes(format, SC_LAYER_AHB_USAGE_VENDOR_UBWC, &stride);
const uint64_t plain = gralloc_bytes(format, 0, &stride);
const uint64_t linear = gralloc_bytes(format, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, &linear_stride);
const uint64_t need = ubwc_size(DISPLAY_BUFFERS_PROBE_W, DISPLAY_BUFFERS_PROBE_H, stride * 4);
*state = stride && linear != need && (flagged == need || plain == need) ? 1 : -1;
droiddeck_log("layer", "display buffers: gralloc %s buffers %s (%ux%u: the layout takes %llu bytes; gralloc gives %llu "
"asked for UBWC, %llu unasked, %llu linear)", droiddeck_ahb_format_name(format),
*state > 0 ? "use the UBWC layout the drivers render to: compressed frames can go on the display layer"
: "do not match the UBWC layout the drivers render to: compressed frames are not offered",
DISPLAY_BUFFERS_PROBE_W, DISPLAY_BUFFERS_PROBE_H, (unsigned long long)need, (unsigned long long)flagged,
(unsigned long long)plain, (unsigned long long)linear);
return *state > 0;
}
int display_buffers_offer_ubwc(uint32_t drm) {
const uint32_t format = ahb_format_of(drm, MOD_QCOM_COMPRESSED);
if (!g_loop || !g_zero_copy || !g_ubwc || !g_display_buffer_driver || !format || !ubwc_probe(format)) return 0;
g_ubwc_promised = 1;
return 1;
}
void display_buffers_withdraw_ubwc(void) { g_ubwc_promised = 0; }
static AHardwareBuffer *allocate(const struct display_buffers_request *q, uint32_t format, int *fd) {
const uint32_t rows = (uint32_t)((q->size + q->stride - 1) / q->stride);
const uint32_t dims[2][2] = {{q->width, q->height}, {q->stride / 4, rows}};
for (int i = 0; i < 2; i++) {
AHardwareBuffer_Desc d = {
.width = dims[i][0], .height = dims[i][1], .layers = 1, .format = format,
.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY};
AHardwareBuffer *ahb = NULL;
if (i && dims[1][0] == dims[0][0] && dims[1][1] == dims[0][1]) break;
if (AHardwareBuffer_allocate(&d, &ahb) != 0 || !ahb) continue;
AHardwareBuffer_Desc got;
AHardwareBuffer_describe(ahb, &got);
*fd = (uint64_t)got.stride * 4 == q->stride ? sc_layer_ahb_fd(ahb, q->size) : -1;
if (*fd >= 0) return ahb;
AHardwareBuffer_release(ahb);
}
return NULL;
}
static int reply(struct peer *p, const struct display_buffers_reply *r, int fd) {
char control[CMSG_SPACE(sizeof(int))] = {0};
struct iovec iov = {.iov_base = (void *)r, .iov_len = sizeof(*r)};
struct msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
if (fd >= 0) {
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
struct cmsghdr *c = CMSG_FIRSTHDR(&msg);
c->cmsg_level = SOL_SOCKET;
c->cmsg_type = SCM_RIGHTS;
c->cmsg_len = CMSG_LEN(sizeof(int));
memcpy(CMSG_DATA(c), &fd, sizeof(int));
}
ssize_t n;
do { n = sendmsg(p->fd, &msg, MSG_NOSIGNAL); } while (n < 0 && errno == EINTR);
return n == (ssize_t)sizeof(*r) ? 0 : -1;
}
static void handle_alloc(struct peer *p, const struct display_buffers_request *q) {
struct display_buffers_reply r = {.magic = DISPLAY_BUFFERS_MAGIC, .status = 1};
const int compressed = q->modifier == MOD_QCOM_COMPRESSED;
const uint32_t format = compressed || q->modifier == MOD_LINEAR ? ahb_format_of(q->format, q->modifier) : 0;
struct entry *e = NULL;
AHardwareBuffer *ahb = NULL;
struct stat st;
uint64_t need = 0;
int fd = -1;
const int sized = format && q->width && q->height && q->width <= DISPLAY_BUFFERS_MAX_SIDE &&
q->height <= DISPLAY_BUFFERS_MAX_SIDE && q->stride % 4 == 0 && q->stride / 4 >= q->width &&
q->stride / 4 <= DISPLAY_BUFFERS_MAX_SIDE;
const int sane = !sized ? 0
: compressed ? q->offset == ubwc_meta_size(q->width, q->height) &&
q->size == ubwc_size(q->width, q->height, q->stride)
: q->offset == 0 && q->size >= (uint64_t)q->stride * q->height &&
q->size <= (uint64_t)q->stride * DISPLAY_BUFFERS_MAX_SIDE;
const int wanted = compressed ? g_ubwc_promised : g_zero_copy;
if (sane && wanted && ahb_swapchain_advertised() && p->count < DISPLAY_BUFFERS_MAX_PER_CLIENT)
ahb = compressed ? allocate_ubwc(q->width, q->height, format, q->stride, &fd, &need) : allocate(q, format, &fd);
if (ahb && fstat(fd, &st) == 0) e = calloc(1, sizeof(*e));
if (e) {
e->id = r.id = g_next_id++;
e->dev = st.st_dev; e->ino = st.st_ino;
e->ahb = ahb;
e->format = format; e->stride = q->stride;
e->width = q->width; e->height = q->height;
e->modifier = q->modifier;
e->peer = p;
p->count++;
wl_list_insert(&g_entries, &e->link);
r.status = 0;
r.size = (uint64_t)lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
if (p->logged_w != (int)q->width || p->logged_h != (int)q->height || p->logged_format != q->format) {
AHardwareBuffer_Desc got;
AHardwareBuffer_describe(ahb, &got);
p->logged_w = (int)q->width; p->logged_h = (int)q->height; p->logged_format = q->format;
droiddeck_log("layer", "display buffers: pid %d renders %ux%u %c%c%c%c %s straight into gralloc buffers "
"(%s %ux%u, stride %u px, %llu bytes for the %llu it asked for)", (int)p->pid, q->width, q->height,
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
compressed ? "UBWC" : "linear", droiddeck_ahb_format_name(format), got.width, got.height,
got.stride, (unsigned long long)r.size, (unsigned long long)q->size);
}
} else {
if (ahb) AHardwareBuffer_release(ahb);
fd = -1;
if (sized && wanted && (compressed || !g_refused_logged)) {
g_refused_logged = 1;
droiddeck_log(compressed ? "error" : "layer", "display buffers: no gralloc buffer matches pid %d's %ux%u "
"%c%c%c%c %s layout (stride %u bytes, pixels at %u, %llu bytes; gralloc's layout has pixels at "
"%llu, %llu bytes): %s", (int)p->pid, q->width, q->height,
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
compressed ? "UBWC" : "linear", q->stride, q->offset, (unsigned long long)q->size,
(unsigned long long)(compressed ? ubwc_meta_size(q->width, q->height) : 0),
(unsigned long long)(compressed ? ubwc_size(q->width, q->height, q->stride) : q->size),
compressed ? "its compressed frames cannot be shown" : "its frames keep the copy path");
}
}
if (reply(p, &r, fd) != 0 && e) entry_free(e);
}
static void peer_gone(struct peer *p) {
struct entry *e, *tmp;
wl_list_for_each_safe(e, tmp, &g_entries, link)
if (e->peer == p) entry_free(e);
wl_event_source_remove(p->src);
close(p->fd);
free(p);
}
static int on_peer(int fd, uint32_t mask, void *data) {
struct peer *p = data;
for (;;) {
struct display_buffers_request q;
ssize_t n = recv(fd, &q, sizeof(q), MSG_DONTWAIT);
if (n < 0 && errno == EINTR) continue;
if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return 0;
if (n != (ssize_t)sizeof(q) || q.magic != DISPLAY_BUFFERS_MAGIC || q.version != DISPLAY_BUFFERS_VERSION) break;
if (q.op == DISPLAY_BUFFERS_ALLOC) {
handle_alloc(p, &q);
} else if (q.op == DISPLAY_BUFFERS_FREE) {
struct entry *e, *tmp;
wl_list_for_each_safe(e, tmp, &g_entries, link)
if (e->peer == p && e->id == q.id) entry_free(e);
} else {
break;
}
}
peer_gone(p);
return 0;
}
static int on_listen(int fd, uint32_t mask, void *data) {
int c = accept4(fd, NULL, NULL, SOCK_CLOEXEC | SOCK_NONBLOCK);
if (c < 0) return 0;
struct peer *p = calloc(1, sizeof(*p));
if (!p) { close(c); return 0; }
struct ucred cred = {0};
socklen_t len = sizeof(cred);
if (getsockopt(c, SOL_SOCKET, SO_PEERCRED, &cred, &len) == 0) p->pid = cred.pid;
p->fd = c;
p->src = wl_event_loop_add_fd(g_loop, c, WL_EVENT_READABLE, on_peer, p);
if (!p->src) { close(c); free(p); }
return 0;
}
void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) {
struct stat st;
struct entry *e;
if (!g_loop || wl_list_empty(&g_entries) || b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) return;
wl_list_for_each(e, &g_entries, link) {
if (e->dev != st.st_dev || e->ino != st.st_ino) continue;
AHardwareBuffer_Desc d;
AHardwareBuffer_describe(e->ahb, &d);
const int compressed = e->modifier == MOD_QCOM_COMPRESSED;
const int laid_out = compressed ? b->modifier == MOD_QCOM_COMPRESSED && (uint32_t)b->width == e->width &&
(uint32_t)b->height == e->height
: (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) &&
e->stride == b->stride[0];
if (laid_out && e->format == ahb_format_of(b->format, e->modifier) && b->width > 0 && b->height > 0 &&
(uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height)
ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier);
return;
}
}
void display_buffers_init(struct wl_display *display) {
wl_list_init(&g_entries);
const char *dir = getenv("XDG_RUNTIME_DIR");
struct sockaddr_un addr = {.sun_family = AF_UNIX};
if (!ahb_swapchain_advertised() || !dir) return;
if (snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/" DISPLAY_BUFFERS_SOCKET, dir) >= (int)sizeof(addr.sun_path)) {
droiddeck_log("layer", "display buffers: %s is too long for a socket path, not offered", dir);
return;
}
int fd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (fd < 0) return;
unlink(addr.sun_path);
struct wl_event_loop *loop = wl_display_get_event_loop(display);
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) != 0 || listen(fd, 16) != 0 ||
!wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, on_listen, NULL)) {
droiddeck_log("layer", "display buffers: socket %s failed (%s), not offered", addr.sun_path, strerror(errno));
close(fd);
return;
}
g_loop = loop;
droiddeck_log("layer", "display buffers: offered on %s (programs whose driver asks render into gralloc buffers while "
"zero-copy is on)", addr.sun_path);
}
@@ -0,0 +1,12 @@
#ifndef DISPLAY_BUFFERS_H
#define DISPLAY_BUFFERS_H
#include <wayland-server.h>
struct dmabuf_buffer;
void display_buffers_init(struct wl_display *display);
int display_buffers_offer_ubwc(uint32_t drm);
void display_buffers_withdraw_ubwc(void);
void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b);
#endif
@@ -16,6 +16,9 @@ struct droiddeck_color {
float max_lum, min_lum;
int has_cta861;
float max_cll, max_fall;
int convert;
float to2020[9];
float gain;
char text[256];
};
@@ -17,6 +17,7 @@
#include "cas_frag.h"
#include "color_frag.h"
#include "fxaa_frag.h"
#include "smaa_frag.h"
#include "toon_frag.h"
#include "hdr_frag.h"
#include "ntsc_frag.h"
@@ -41,7 +42,7 @@ struct fx_settings {
int color_on;
float brightness, contrast, gamma, saturation;
float b_raw, c_raw, s_raw;
int fxaa, toon, crt, ntsc;
int aa_mode, toon, crt, ntsc;
char look[48];
};
@@ -78,7 +79,7 @@ void vkp_effects_set_deband(int enabled, int pct) {
}
static float clampf(float v, float lo, float hi) { return v < lo ? lo : v > hi ? hi : v; }
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
int fxaa, int toon, int crt, int ntsc) {
int aa_mode, int toon, int crt, int ntsc) {
int on = !(brightness == 0.0f && contrast == 0.0f && gamma == 1.0f && saturation == 100.0f);
set_begin();
g_set.color_on = on;
@@ -87,7 +88,8 @@ void vkp_effects_set_screen(float brightness, float contrast, float gamma, float
g_set.contrast = clampf(contrast / 100.0f, 0.0f, 2.0f);
g_set.saturation = clampf(saturation / 100.0f, 0.0f, 2.0f);
g_set.gamma = clampf(gamma, 0.1f, 5.0f);
g_set.fxaa = fxaa ? 1 : 0; g_set.toon = toon ? 1 : 0; g_set.crt = crt ? 1 : 0; g_set.ntsc = ntsc ? 1 : 0;
g_set.aa_mode = (aa_mode >= 0 && aa_mode <= 2) ? aa_mode : 0;
g_set.toon = toon ? 1 : 0; g_set.crt = crt ? 1 : 0; g_set.ntsc = ntsc ? 1 : 0;
set_end();
}
void vkp_effects_set_look(const char *name) {
@@ -103,7 +105,7 @@ static const char *scaling_name(int m) {
static int spatial_mode(int m) { return m >= 3 && m <= 8; }
static int cas_active(const struct fx_settings *s) { return s->cas_on && s->cas_pct > 0; }
static int effect_count(const struct fx_settings *s) {
return s->fxaa + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
}
static void log_settings(const struct fx_settings *s) {
@@ -121,7 +123,8 @@ static void log_settings(const struct fx_settings *s) {
if (s->color_on)
n += snprintf(line + n, sizeof(line) - n, ", colour b=%+.0f c=%+.0f g=%.2f s=%.0f%%",
s->b_raw, s->c_raw, s->gamma, s->s_raw);
if (s->fxaa) n += snprintf(line + n, sizeof(line) - n, ", FXAA on");
if (s->aa_mode == 1) n += snprintf(line + n, sizeof(line) - n, ", FXAA on");
else if (s->aa_mode == 2) n += snprintf(line + n, sizeof(line) - n, ", SMAA on");
if (s->toon) n += snprintf(line + n, sizeof(line) - n, ", Toon on");
if (s->hdr_on) n += snprintf(line + n, sizeof(line) - n, ", HDR on");
if (s->ntsc) n += snprintf(line + n, sizeof(line) - n, ", NTSC on");
@@ -152,6 +155,10 @@ int vkp_effects_upscaling(void) {
return spatial_mode(g_cur.scaling) && g_cur.scaling != 6;
}
int vkp_effects_sharpening(void) {
return vkp_effects_upscaling() || cas_active(&g_cur);
}
int vkp_effects_postprocessing(void) {
vkp_effects_sync();
return effect_count(&g_cur) > 0;
@@ -202,7 +209,7 @@ static VkDescriptorSetLayout g_dsl;
static VkPipelineLayout g_pl;
static VkDescriptorPool g_dpool;
static VkSampler g_sampler;
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT };
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_SMAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT };
static VkPipeline g_pipe[P_COUNT];
static struct fx_target g_t[2], g_mid;
@@ -438,6 +445,7 @@ static int objects_ensure(void) {
MK(P_CAS, cas_code, "cas");
MK(P_COLOR, color_code, "color");
MK(P_FXAA, fxaa_code, "fxaa");
MK(P_SMAA, smaa_code, "smaa");
MK(P_TOON, toon_code, "toon");
MK(P_HDR, hdr_code, "hdr");
MK(P_NTSC, ntsc_code, "ntsc");
@@ -446,7 +454,7 @@ static int objects_ensure(void) {
#undef MK
g_vk.DestroyShaderModule(g_dev, vert, NULL);
g_ready = 1;
droiddeck_log("effects", "chain ready: 13 passes (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name());
droiddeck_log("effects", "chain ready: 14 pipelines (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, SMAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name());
return 0;
fail:
objects_destroy();
@@ -567,9 +575,10 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
cur = NULL; cur_ds = g_scene.ds;
}
enum { FX_FXAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
enum { FX_FXAA, FX_SMAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
int order[8], n = 0;
if (s->fxaa) order[n++] = FX_FXAA;
if (s->aa_mode == 1) order[n++] = FX_FXAA;
else if (s->aa_mode == 2) order[n++] = FX_SMAA;
if (s->toon) order[n++] = FX_TOON;
if (s->color_on) order[n++] = FX_COLOR;
if (cas_active(s)) order[n++] = FX_CAS;
@@ -584,6 +593,7 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
pr.res[0] = (float)cw; pr.res[1] = (float)ch;
switch (order[i]) {
case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break;
case FX_SMAA: pass(cmd, g_pipe[P_SMAA], dst, cur_ds, &pr, sizeof(pr)); break;
case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
case FX_COLOR: {
struct pc_color pc = {0};
@@ -11,6 +11,7 @@ int vkp_effects_sync(void);
int vkp_effects_active(void);
int vkp_effects_upscaling(void);
int vkp_effects_sharpening(void);
int vkp_effects_postprocessing(void);
VkFilter vkp_effects_blit_filter(void);
@@ -30,7 +31,7 @@ void vkp_effects_set_cas(int enabled, int pct);
void vkp_effects_set_hdr(int enabled);
void vkp_effects_set_deband(int enabled, int pct);
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
int fxaa, int toon, int crt, int ntsc);
int aa_mode, int toon, int crt, int ntsc);
void vkp_effects_set_look(const char *name);
#endif
@@ -33,7 +33,9 @@ static PFN_vkGetInstanceProcAddr g_gipa;
static VkPhysicalDevice g_pd;
static VkQueue g_queue;
static uint32_t g_qfam;
static int g_dev_ready, g_dev_lost, g_features_enabled;
static _Atomic int g_dev_ready, g_dev_lost;
static int g_features_enabled;
static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok;
static VkPhysicalDeviceMemoryProperties g_memprops;
static struct {
PFN_vkCreateImage CreateImage;
@@ -141,9 +143,12 @@ static void mark_failed(int kind) {
}
int vkp_framegen_problem(void) {
if (!g_dev_ready) return -1;
if (!atomic_load(&g_dev_ready)) return -1;
int kind = atomic_load(&g_kind);
if (!fge_caps_ok(kind)) return 1;
int caps_ok = kind == VKP_FG_ENGINE_DDFG
? atomic_load(&g_caps_ddfg_ok)
: atomic_load(&g_caps_lsfg_ok);
if (!caps_ok) return 1;
if (start_failed_for(kind)) return 2;
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
return 0;
@@ -179,13 +184,17 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
#undef R
g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops);
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
g_dev_ready = vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier;
atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG));
atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
atomic_store(&g_dev_lost, 0);
atomic_store(&g_dev_ready,
vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s",
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(),
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable");
}
void vkp_framegen_device_lost(void) { g_dev_lost = 1; }
void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); }
static void destroy_ring(void) {
@@ -244,7 +253,12 @@ static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) {
static int engine_usable(void) {
int kind = atomic_load(&g_kind);
return g_dev_ready && !g_dev_lost && fge_caps_ok(kind) && !start_failed_for(kind);
int ready = atomic_load(&g_dev_ready);
int lost = atomic_load(&g_dev_lost);
int caps_ok = kind == VKP_FG_ENGINE_DDFG
? atomic_load(&g_caps_ddfg_ok)
: atomic_load(&g_caps_lsfg_ok);
return ready && !lost && caps_ok && !start_failed_for(kind);
}
int vkp_framegen_format_ok(VkFormat fmt) {
@@ -8,7 +8,7 @@
#include <android/log.h>
#include "VulkanRendererContext.h"
#include "VkDispatchTable.h"
#include "lsfg/lsfg_engine.h"
#include "lsfg/lsfg_probe.h"
#include "lsfg/lsfg_vkd.h"
@@ -50,6 +50,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenCapsReason(J
return (*env)->NewStringUTF(env, r ? r : "");
}
JNIEXPORT jboolean JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenActive(JNIEnv *env, jclass clazz) {
(void)env; (void)clazz;
return vkp_framegen_active() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jfloatArray JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenStats(JNIEnv *env, jclass clazz) {
(void)clazz;
+11 -2
View File
@@ -12,7 +12,7 @@
#define MIXED_FORMAT VK_FORMAT_A2B10G10R10_UNORM_PACK32
struct pc_encode { float ndc[4]; float params[4]; float rects[HDRC_MAX_RECTS][4]; };
struct pc_encode { float ndc[4]; float params[4]; uint32_t rects[HDRC_MAX_RECTS][2]; float conv[3][4]; };
static VkDevice g_dev;
static int g_ready;
@@ -266,7 +266,16 @@ int hdrc_encode(VkCommandBuffer cmd, VkImage mixed, VkImage out, VkFormat out_fm
pc.params[1] = p->peak_nits > 0.0f ? p->peak_nits : 1000.0f;
pc.params[2] = p->mode == HDRC_OUT_SDR ? 1.0f : 0.0f;
pc.params[3] = (float)count + 16.0f * (float)mask;
for (int i = 0; i < count; i++) memcpy(pc.rects[i], p->rects[i], sizeof(pc.rects[i]));
for (int i = 0; i < count; i++) {
uint32_t v[4];
for (int k = 0; k < 4; k++) v[k] = p->rects[i][k] <= 0.0f ? 0u : p->rects[i][k] >= 65535.0f ? 65535u : (uint32_t)p->rects[i][k];
pc.rects[i][0] = v[0] | v[1] << 16;
pc.rects[i][1] = v[2] | v[3] << 16;
}
for (int k = 0; k < 3; k++) memcpy(pc.conv[k], &p->conv[3 * k], 3 * sizeof(float));
pc.conv[0][3] = (float)(p->conv_mask & mask);
pc.conv[1][3] = p->conv_linear ? 1.0f : 0.0f;
pc.conv[2][3] = p->conv_gain;
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_out[slot].rp,
.framebuffer = fb, .renderArea = {{0, 0}, {(uint32_t)w, (uint32_t)h}}};
@@ -14,6 +14,10 @@ struct hdrc_params {
int count;
unsigned hdr_mask;
float rects[HDRC_MAX_RECTS][4];
unsigned conv_mask;
int conv_linear;
float conv_gain;
float conv[9];
};
void hdrc_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops);
@@ -6,7 +6,8 @@ layout(binding = 0) uniform sampler2D Mixed;
layout(push_constant) uniform PC {
vec4 ndc;
vec4 params;
vec4 rects[6];
uvec2 rects[6];
vec4 conv[3];
} pc;
layout(location = 0) in vec2 fragTexCoord;
@@ -55,28 +56,38 @@ float toneCurve(float x, float peak) {
return knee + (1.0 - knee) * (1.0 - exp(-(x - knee) / rate));
}
bool isHdrPixel(vec2 p) {
float packed = pc.params.w;
float count = mod(packed, 16.0);
float mask = floor(packed / 16.0);
int rectAt(vec2 p) {
float count = mod(pc.params.w, 16.0);
for (int i = 0; i < 6; i++) {
if (float(i) >= count - 0.5) break;
vec4 r = pc.rects[i];
if (p.x >= r.x && p.y >= r.y && p.x < r.z && p.y < r.w) {
float bit = mod(floor(mask / exp2(float(i))), 2.0);
return bit > 0.5;
}
uvec2 r = pc.rects[i];
vec2 lo = vec2(float(r.x & 0xFFFFu), float(r.x >> 16));
vec2 hi = vec2(float(r.y & 0xFFFFu), float(r.y >> 16));
if (p.x >= lo.x && p.y >= lo.y && p.x < hi.x && p.y < hi.y) return i;
}
return false;
return -1;
}
bool bitOf(float mask, int i) {
return i >= 0 && mod(floor(mask / exp2(float(i))), 2.0) > 0.5;
}
vec3 convertedNits(vec3 c) {
vec3 lin = pc.conv[1].w > 0.5 ? c : pqToLinear(c);
return vec3(dot(pc.conv[0].xyz, lin), dot(pc.conv[1].xyz, lin), dot(pc.conv[2].xyz, lin)) * pc.conv[2].w;
}
void main() {
vec3 c = texelFetch(Mixed, ivec2(gl_FragCoord.xy), 0).rgb;
bool hdr = isHdrPixel(gl_FragCoord.xy);
int at = rectAt(gl_FragCoord.xy);
bool hdr = bitOf(floor(pc.params.w / 16.0), at);
bool conv = hdr && bitOf(pc.conv[0].w, at);
float sdrWhite = max(pc.params.x, 1.0);
vec3 outc;
if (pc.params.z < 0.5) {
if (hdr) {
if (conv) {
outc = linearToPq(max(convertedNits(c), 0.0) / 10000.0);
} else if (hdr) {
outc = c;
} else {
vec3 nits = (BT709_TO_BT2020 * srgbToLinear(c)) * sdrWhite;
@@ -86,7 +97,8 @@ void main() {
if (!hdr) {
outc = c;
} else {
vec3 rel = max(BT2020_TO_BT709 * (pqToLinear(c) * 10000.0), 0.0) / sdrWhite;
vec3 nits = conv ? convertedNits(c) : pqToLinear(c) * 10000.0;
vec3 rel = max(BT2020_TO_BT709 * nits, 0.0) / sdrWhite;
float m = max(max(rel.r, rel.g), rel.b);
if (m > 1e-6) rel *= toneCurve(m, max(pc.params.y, sdrWhite) / sdrWhite) / m;
outc = linearToSrgb(clamp(rel, 0.0, 1.0));
+346 -264
View File
@@ -1,8 +1,8 @@
#pragma once
const uint32_t hdr_encode_code[] = {
0x07230203,0x00010000,0x0008000b,0x0000018e,0x00000000,0x00020011,0x00000001,0x0006000b,
0x07230203,0x00010000,0x0008000b,0x000001ff,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000010d,0x00000186,0x0000018d,
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000151,0x000001f7,0x000001fe,
0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,
0x6e69616d,0x00000000,0x00070005,0x0000000b,0x62677273,0x694c6f54,0x7261656e,0x33667628,
0x0000003b,0x00030005,0x0000000a,0x00000063,0x00070005,0x0000000e,0x656e696c,0x6f547261,
@@ -10,272 +10,354 @@ const uint32_t hdr_encode_code[] = {
0x6f547170,0x656e694c,0x76287261,0x003b3366,0x00030005,0x00000010,0x00000065,0x00060005,
0x00000014,0x656e696c,0x6f547261,0x76287150,0x003b3366,0x00030005,0x00000013,0x00000079,
0x00070005,0x0000001a,0x656e6f74,0x76727543,0x31662865,0x3b31663b,0x00000000,0x00030005,
0x00000018,0x00000078,0x00040005,0x00000019,0x6b616570,0x00000000,0x00060005,0x00000021,
0x64487369,0x78695072,0x76286c65,0x003b3266,0x00030005,0x00000020,0x00000070,0x00030005,
0x00000023,0x00006f6c,0x00030005,0x00000028,0x00006968,0x00030005,0x0000003c,0x00006f6c,
0x00030005,0x0000003f,0x00006968,0x00030005,0x00000050,0x00000070,0x00030005,0x0000006f,
0x00000070,0x00040005,0x0000008c,0x6e617073,0x00000000,0x00040005,0x00000091,0x65746172,
0x00000000,0x00040005,0x000000a2,0x6b636170,0x00006465,0x00030005,0x000000a7,0x00004350,
0x00040006,0x000000a7,0x00000000,0x0063646e,0x00050006,0x000000a7,0x00000001,0x61726170,
0x0000736d,0x00050006,0x000000a7,0x00000002,0x74636572,0x00000073,0x00030005,0x000000a9,
0x00006370,0x00040005,0x000000b0,0x6e756f63,0x00000074,0x00040005,0x000000b4,0x6b73616d,
0x00000000,0x00030005,0x000000b9,0x00000069,0x00030005,0x000000cd,0x00000072,0x00030005,
0x000000f5,0x00746962,0x00030005,0x00000106,0x00000063,0x00040005,0x0000010a,0x6578694d,
0x00000064,0x00060005,0x0000010d,0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00030005,
0x00000116,0x00726468,0x00040005,0x00000117,0x61726170,0x0000006d,0x00050005,0x0000011b,
0x57726473,0x65746968,0x00000000,0x00040005,0x00000127,0x6374756f,0x00000000,0x00040005,
0x0000012a,0x7374696e,0x00000000,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,
0x00000143,0x61726170,0x0000006d,0x00030005,0x0000014c,0x006c6572,0x00040005,0x0000015a,
0x61726170,0x0000006d,0x00030005,0x00000164,0x0000006d,0x00040005,0x00000177,0x61726170,
0x0000006d,0x00040005,0x00000179,0x61726170,0x0000006d,0x00040005,0x00000183,0x61726170,
0x0000006d,0x00050005,0x00000186,0x4374756f,0x726f6c6f,0x00000000,0x00060005,0x0000018d,
0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040047,0x000000a6,0x00000006,0x00000010,
0x00030047,0x000000a7,0x00000002,0x00050048,0x000000a7,0x00000000,0x00000023,0x00000000,
0x00050048,0x000000a7,0x00000001,0x00000023,0x00000010,0x00050048,0x000000a7,0x00000002,
0x00000023,0x00000020,0x00040047,0x0000010a,0x00000021,0x00000000,0x00040047,0x0000010a,
0x00000022,0x00000000,0x00040047,0x0000010d,0x0000000b,0x0000000f,0x00040047,0x00000186,
0x0000001e,0x00000000,0x00040047,0x0000018d,0x0000001e,0x00000000,0x00020013,0x00000002,
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007,0x00040021,0x00000009,
0x00000007,0x00000008,0x00040020,0x00000016,0x00000007,0x00000006,0x00050021,0x00000017,
0x00000006,0x00000016,0x00000016,0x00040017,0x0000001c,0x00000006,0x00000002,0x00040020,
0x0000001d,0x00000007,0x0000001c,0x00020014,0x0000001e,0x00040021,0x0000001f,0x0000001e,
0x0000001d,0x0004002b,0x00000006,0x00000025,0x414eb852,0x0004002b,0x00000006,0x0000002a,
0x3d6147ae,0x0004002b,0x00000006,0x0000002d,0x3f870a3d,0x0004002b,0x00000006,0x00000030,
0x4019999a,0x0006002c,0x00000007,0x00000031,0x00000030,0x00000030,0x00000030,0x0004002b,
0x00000006,0x00000035,0x3d25aee6,0x0006002c,0x00000007,0x00000036,0x00000035,0x00000035,
0x00000035,0x0004002b,0x00000006,0x00000041,0x3ed55555,0x0006002c,0x00000007,0x00000042,
0x00000041,0x00000041,0x00000041,0x0004002b,0x00000006,0x00000049,0x3b4d2e1c,0x0006002c,
0x00000007,0x0000004a,0x00000049,0x00000049,0x00000049,0x0004002b,0x00000006,0x00000052,
0x00000000,0x0004002b,0x00000006,0x00000053,0x3f800000,0x0004002b,0x00000006,0x00000057,
0x3c4fcdac,0x0006002c,0x00000007,0x00000058,0x00000057,0x00000057,0x00000057,0x0004002b,
0x00000006,0x0000005b,0x3f560000,0x0004002b,0x00000006,0x00000060,0x4196d000,0x0004002b,
0x00000006,0x00000061,0x41958000,0x0004002b,0x00000006,0x00000066,0x358637bd,0x0004002b,
0x00000006,0x0000006a,0x40c8e06b,0x0006002c,0x00000007,0x0000006b,0x0000006a,0x0000006a,
0x0000006a,0x0004002b,0x00000006,0x00000074,0x3e232000,0x0006002c,0x00000007,0x00000075,
0x00000074,0x00000074,0x00000074,0x0004002b,0x00000006,0x00000080,0x429db000,0x0006002c,
0x00000007,0x00000081,0x00000080,0x00000080,0x00000080,0x0004002b,0x00000006,0x00000086,
0x3f4ccccd,0x0004002b,0x00000006,0x0000008f,0x3d4ccccd,0x0004002b,0x00000006,0x00000093,
0x407a5e35,0x0004002b,0x00000006,0x00000095,0x3e4ccccd,0x00040017,0x000000a3,0x00000006,
0x00000004,0x00040015,0x000000a4,0x00000020,0x00000000,0x0004002b,0x000000a4,0x000000a5,
0x00000006,0x0004001c,0x000000a6,0x000000a3,0x000000a5,0x0005001e,0x000000a7,0x000000a3,
0x000000a3,0x000000a6,0x00040020,0x000000a8,0x00000009,0x000000a7,0x0004003b,0x000000a8,
0x000000a9,0x00000009,0x00040015,0x000000aa,0x00000020,0x00000001,0x0004002b,0x000000aa,
0x000000ab,0x00000001,0x0004002b,0x000000a4,0x000000ac,0x00000003,0x00040020,0x000000ad,
0x00000009,0x00000006,0x0004002b,0x00000006,0x000000b2,0x41800000,0x00040020,0x000000b8,
0x00000007,0x000000aa,0x0004002b,0x000000aa,0x000000ba,0x00000000,0x0004002b,0x000000aa,
0x000000c1,0x00000006,0x0004002b,0x00000006,0x000000c6,0x3f000000,0x00040020,0x000000cc,
0x00000007,0x000000a3,0x0004002b,0x000000aa,0x000000ce,0x00000002,0x00040020,0x000000d0,
0x00000009,0x000000a3,0x0004002b,0x000000a4,0x000000d3,0x00000000,0x0004002b,0x000000a4,
0x000000db,0x00000001,0x0004002b,0x000000a4,0x000000e6,0x00000002,0x0004002b,0x00000006,
0x000000fc,0x40000000,0x0003002a,0x0000001e,0x00000103,0x00090019,0x00000107,0x00000006,
0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000108,
0x00000107,0x00040020,0x00000109,0x00000000,0x00000108,0x0004003b,0x00000109,0x0000010a,
0x00000000,0x00040020,0x0000010c,0x00000001,0x000000a3,0x0004003b,0x0000010c,0x0000010d,
0x00000001,0x00040017,0x00000110,0x000000aa,0x00000002,0x00040020,0x00000115,0x00000007,
0x0000001e,0x00040018,0x0000012b,0x00000007,0x00000003,0x0004002b,0x00000006,0x0000012c,
0x3f209d49,0x0004002b,0x00000006,0x0000012d,0x3d8d844d,0x0004002b,0x00000006,0x0000012e,
0x3c86594b,0x0006002c,0x00000007,0x0000012f,0x0000012c,0x0000012d,0x0000012e,0x0004002b,
0x00000006,0x00000130,0x3ea89a02,0x0004002b,0x00000006,0x00000131,0x3f6b645a,0x0004002b,
0x00000006,0x00000132,0x3db43958,0x0006002c,0x00000007,0x00000133,0x00000130,0x00000131,
0x00000132,0x0004002b,0x00000006,0x00000134,0x3d315b57,0x0004002b,0x00000006,0x00000135,
0x3c3ac711,0x0004002b,0x00000006,0x00000136,0x3f65460b,0x0006002c,0x00000007,0x00000137,
0x00000134,0x00000135,0x00000136,0x0006002c,0x0000012b,0x00000138,0x0000012f,0x00000133,
0x00000137,0x0004002b,0x00000006,0x00000140,0x461c4000,0x0004002b,0x00000006,0x0000014d,
0x3fd48b44,0x0004002b,0x00000006,0x0000014e,0xbdff2e49,0x0004002b,0x00000006,0x0000014f,
0xbc95182b,0x0006002c,0x00000007,0x00000150,0x0000014d,0x0000014e,0x0000014f,0x0004002b,
0x00000006,0x00000151,0xbf166cf4,0x0004002b,0x00000006,0x00000152,0x3f9102de,0x0004002b,
0x00000006,0x00000153,0xbdce075f,0x0006002c,0x00000007,0x00000154,0x00000151,0x00000152,
0x00000153,0x0004002b,0x00000006,0x00000155,0xbd95182b,0x0004002b,0x00000006,0x00000156,
0xbc07fcb9,0x0004002b,0x00000006,0x00000157,0x3f8f3190,0x0006002c,0x00000007,0x00000158,
0x00000155,0x00000156,0x00000157,0x0006002c,0x0000012b,0x00000159,0x00000150,0x00000154,
0x00000158,0x00040020,0x00000185,0x00000003,0x000000a3,0x0004003b,0x00000185,0x00000186,
0x00000003,0x00040020,0x0000018c,0x00000001,0x0000001c,0x0004003b,0x0000018c,0x0000018d,
0x00000018,0x00000078,0x00040005,0x00000019,0x6b616570,0x00000000,0x00050005,0x00000021,
0x74636572,0x76287441,0x003b3266,0x00030005,0x00000020,0x00000070,0x00060005,0x00000028,
0x4f746962,0x31662866,0x3b31693b,0x00000000,0x00040005,0x00000026,0x6b73616d,0x00000000,
0x00030005,0x00000027,0x00000069,0x00070005,0x0000002b,0x766e6f63,0x65747265,0x74694e64,
0x66762873,0x00003b33,0x00030005,0x0000002a,0x00000063,0x00030005,0x0000002d,0x00006f6c,
0x00030005,0x00000032,0x00006968,0x00030005,0x00000046,0x00006f6c,0x00030005,0x00000049,
0x00006968,0x00030005,0x0000005a,0x00000070,0x00030005,0x00000079,0x00000070,0x00040005,
0x00000096,0x6e617073,0x00000000,0x00040005,0x0000009b,0x65746172,0x00000000,0x00040005,
0x000000ac,0x6e756f63,0x00000074,0x00030005,0x000000b4,0x00004350,0x00040006,0x000000b4,
0x00000000,0x0063646e,0x00050006,0x000000b4,0x00000001,0x61726170,0x0000736d,0x00050006,
0x000000b4,0x00000002,0x74636572,0x00000073,0x00050006,0x000000b4,0x00000003,0x766e6f63,
0x00000000,0x00030005,0x000000b6,0x00006370,0x00030005,0x000000bd,0x00000069,0x00030005,
0x000000d1,0x00000072,0x00030005,0x000000d7,0x00006f6c,0x00030005,0x000000e5,0x00006968,
0x00030005,0x00000126,0x006e696c,0x00040005,0x00000130,0x61726170,0x0000006d,0x00030005,
0x0000014a,0x00000063,0x00040005,0x0000014e,0x6578694d,0x00000064,0x00060005,0x00000151,
0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00030005,0x00000159,0x00007461,0x00040005,
0x0000015a,0x61726170,0x0000006d,0x00030005,0x0000015f,0x00726468,0x00040005,0x00000164,
0x61726170,0x0000006d,0x00040005,0x00000165,0x61726170,0x0000006d,0x00040005,0x00000168,
0x766e6f63,0x00000000,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x0000016f,
0x61726170,0x0000006d,0x00050005,0x00000173,0x57726473,0x65746968,0x00000000,0x00040005,
0x00000180,0x6374756f,0x00000000,0x00040005,0x00000181,0x61726170,0x0000006d,0x00040005,
0x00000189,0x61726170,0x0000006d,0x00040005,0x00000191,0x7374696e,0x00000000,0x00040005,
0x000001a0,0x61726170,0x0000006d,0x00040005,0x000001a9,0x61726170,0x0000006d,0x00040005,
0x000001b2,0x7374696e,0x00000000,0x00040005,0x000001b7,0x61726170,0x0000006d,0x00040005,
0x000001bb,0x61726170,0x0000006d,0x00030005,0x000001c0,0x006c6572,0x00030005,0x000001d5,
0x0000006d,0x00040005,0x000001e8,0x61726170,0x0000006d,0x00040005,0x000001ea,0x61726170,
0x0000006d,0x00040005,0x000001f4,0x61726170,0x0000006d,0x00050005,0x000001f7,0x4374756f,
0x726f6c6f,0x00000000,0x00060005,0x000001fe,0x67617266,0x43786554,0x64726f6f,0x00000000,
0x00040047,0x000000b1,0x00000006,0x00000008,0x00040047,0x000000b3,0x00000006,0x00000010,
0x00030047,0x000000b4,0x00000002,0x00050048,0x000000b4,0x00000000,0x00000023,0x00000000,
0x00050048,0x000000b4,0x00000001,0x00000023,0x00000010,0x00050048,0x000000b4,0x00000002,
0x00000023,0x00000020,0x00050048,0x000000b4,0x00000003,0x00000023,0x00000050,0x00040047,
0x0000014e,0x00000021,0x00000000,0x00040047,0x0000014e,0x00000022,0x00000000,0x00040047,
0x00000151,0x0000000b,0x0000000f,0x00040047,0x000001f7,0x0000001e,0x00000000,0x00040047,
0x000001fe,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,
0x00000008,0x00000007,0x00000007,0x00040021,0x00000009,0x00000007,0x00000008,0x00040020,
0x00000016,0x00000007,0x00000006,0x00050021,0x00000017,0x00000006,0x00000016,0x00000016,
0x00040017,0x0000001c,0x00000006,0x00000002,0x00040020,0x0000001d,0x00000007,0x0000001c,
0x00040015,0x0000001e,0x00000020,0x00000001,0x00040021,0x0000001f,0x0000001e,0x0000001d,
0x00040020,0x00000023,0x00000007,0x0000001e,0x00020014,0x00000024,0x00050021,0x00000025,
0x00000024,0x00000016,0x00000023,0x0004002b,0x00000006,0x0000002f,0x414eb852,0x0004002b,
0x00000006,0x00000034,0x3d6147ae,0x0004002b,0x00000006,0x00000037,0x3f870a3d,0x0004002b,
0x00000006,0x0000003a,0x4019999a,0x0006002c,0x00000007,0x0000003b,0x0000003a,0x0000003a,
0x0000003a,0x0004002b,0x00000006,0x0000003f,0x3d25aee6,0x0006002c,0x00000007,0x00000040,
0x0000003f,0x0000003f,0x0000003f,0x0004002b,0x00000006,0x0000004b,0x3ed55555,0x0006002c,
0x00000007,0x0000004c,0x0000004b,0x0000004b,0x0000004b,0x0004002b,0x00000006,0x00000053,
0x3b4d2e1c,0x0006002c,0x00000007,0x00000054,0x00000053,0x00000053,0x00000053,0x0004002b,
0x00000006,0x0000005c,0x00000000,0x0004002b,0x00000006,0x0000005d,0x3f800000,0x0004002b,
0x00000006,0x00000061,0x3c4fcdac,0x0006002c,0x00000007,0x00000062,0x00000061,0x00000061,
0x00000061,0x0004002b,0x00000006,0x00000065,0x3f560000,0x0004002b,0x00000006,0x0000006a,
0x4196d000,0x0004002b,0x00000006,0x0000006b,0x41958000,0x0004002b,0x00000006,0x00000070,
0x358637bd,0x0004002b,0x00000006,0x00000074,0x40c8e06b,0x0006002c,0x00000007,0x00000075,
0x00000074,0x00000074,0x00000074,0x0004002b,0x00000006,0x0000007e,0x3e232000,0x0006002c,
0x00000007,0x0000007f,0x0000007e,0x0000007e,0x0000007e,0x0004002b,0x00000006,0x0000008a,
0x429db000,0x0006002c,0x00000007,0x0000008b,0x0000008a,0x0000008a,0x0000008a,0x0004002b,
0x00000006,0x00000090,0x3f4ccccd,0x0004002b,0x00000006,0x00000099,0x3d4ccccd,0x0004002b,
0x00000006,0x0000009d,0x407a5e35,0x0004002b,0x00000006,0x0000009f,0x3e4ccccd,0x00040017,
0x000000ad,0x00000006,0x00000004,0x00040015,0x000000ae,0x00000020,0x00000000,0x00040017,
0x000000af,0x000000ae,0x00000002,0x0004002b,0x000000ae,0x000000b0,0x00000006,0x0004001c,
0x000000b1,0x000000af,0x000000b0,0x0004002b,0x000000ae,0x000000b2,0x00000003,0x0004001c,
0x000000b3,0x000000ad,0x000000b2,0x0006001e,0x000000b4,0x000000ad,0x000000ad,0x000000b1,
0x000000b3,0x00040020,0x000000b5,0x00000009,0x000000b4,0x0004003b,0x000000b5,0x000000b6,
0x00000009,0x0004002b,0x0000001e,0x000000b7,0x00000001,0x00040020,0x000000b8,0x00000009,
0x00000006,0x0004002b,0x00000006,0x000000bb,0x41800000,0x0004002b,0x0000001e,0x000000be,
0x00000000,0x0004002b,0x0000001e,0x000000c5,0x00000006,0x0004002b,0x00000006,0x000000ca,
0x3f000000,0x00040020,0x000000d0,0x00000007,0x000000af,0x0004002b,0x0000001e,0x000000d2,
0x00000002,0x00040020,0x000000d4,0x00000009,0x000000af,0x0004002b,0x000000ae,0x000000d8,
0x00000000,0x00040020,0x000000d9,0x00000007,0x000000ae,0x0004002b,0x000000ae,0x000000dc,
0x0000ffff,0x0004002b,0x0000001e,0x000000e1,0x00000010,0x0004002b,0x000000ae,0x000000e6,
0x00000001,0x0004002b,0x0000001e,0x00000113,0xffffffff,0x0004002b,0x00000006,0x00000120,
0x40000000,0x0004002b,0x0000001e,0x00000127,0x00000003,0x00040020,0x00000134,0x00000009,
0x000000ad,0x00090019,0x0000014b,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
0x00000001,0x00000000,0x0003001b,0x0000014c,0x0000014b,0x00040020,0x0000014d,0x00000000,
0x0000014c,0x0004003b,0x0000014d,0x0000014e,0x00000000,0x00040020,0x00000150,0x00000001,
0x000000ad,0x0004003b,0x00000150,0x00000151,0x00000001,0x00040017,0x00000154,0x0000001e,
0x00000002,0x00040020,0x0000015e,0x00000007,0x00000024,0x0004002b,0x000000ae,0x00000177,
0x00000002,0x0004002b,0x00000006,0x00000186,0x461c4000,0x00040018,0x00000192,0x00000007,
0x00000003,0x0004002b,0x00000006,0x00000193,0x3f209d49,0x0004002b,0x00000006,0x00000194,
0x3d8d844d,0x0004002b,0x00000006,0x00000195,0x3c86594b,0x0006002c,0x00000007,0x00000196,
0x00000193,0x00000194,0x00000195,0x0004002b,0x00000006,0x00000197,0x3ea89a02,0x0004002b,
0x00000006,0x00000198,0x3f6b645a,0x0004002b,0x00000006,0x00000199,0x3db43958,0x0006002c,
0x00000007,0x0000019a,0x00000197,0x00000198,0x00000199,0x0004002b,0x00000006,0x0000019b,
0x3d315b57,0x0004002b,0x00000006,0x0000019c,0x3c3ac711,0x0004002b,0x00000006,0x0000019d,
0x3f65460b,0x0006002c,0x00000007,0x0000019e,0x0000019b,0x0000019c,0x0000019d,0x0006002c,
0x00000192,0x0000019f,0x00000196,0x0000019a,0x0000019e,0x0004002b,0x00000006,0x000001c1,
0x3fd48b44,0x0004002b,0x00000006,0x000001c2,0xbdff2e49,0x0004002b,0x00000006,0x000001c3,
0xbc95182b,0x0006002c,0x00000007,0x000001c4,0x000001c1,0x000001c2,0x000001c3,0x0004002b,
0x00000006,0x000001c5,0xbf166cf4,0x0004002b,0x00000006,0x000001c6,0x3f9102de,0x0004002b,
0x00000006,0x000001c7,0xbdce075f,0x0006002c,0x00000007,0x000001c8,0x000001c5,0x000001c6,
0x000001c7,0x0004002b,0x00000006,0x000001c9,0xbd95182b,0x0004002b,0x00000006,0x000001ca,
0xbc07fcb9,0x0004002b,0x00000006,0x000001cb,0x3f8f3190,0x0006002c,0x00000007,0x000001cc,
0x000001c9,0x000001ca,0x000001cb,0x0006002c,0x00000192,0x000001cd,0x000001c4,0x000001c8,
0x000001cc,0x00040020,0x000001f6,0x00000003,0x000000ad,0x0004003b,0x000001f6,0x000001f7,
0x00000003,0x00040020,0x000001fd,0x00000001,0x0000001c,0x0004003b,0x000001fd,0x000001fe,
0x00000001,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
0x0004003b,0x00000008,0x00000106,0x00000007,0x0004003b,0x00000115,0x00000116,0x00000007,
0x0004003b,0x0000001d,0x00000117,0x00000007,0x0004003b,0x00000016,0x0000011b,0x00000007,
0x0004003b,0x00000008,0x00000127,0x00000007,0x0004003b,0x00000008,0x0000012a,0x00000007,
0x0004003b,0x00000008,0x00000139,0x00000007,0x0004003b,0x00000008,0x00000143,0x00000007,
0x0004003b,0x00000008,0x0000014c,0x00000007,0x0004003b,0x00000008,0x0000015a,0x00000007,
0x0004003b,0x00000016,0x00000164,0x00000007,0x0004003b,0x00000016,0x00000177,0x00000007,
0x0004003b,0x00000016,0x00000179,0x00000007,0x0004003b,0x00000008,0x00000183,0x00000007,
0x0004003d,0x00000108,0x0000010b,0x0000010a,0x0004003d,0x000000a3,0x0000010e,0x0000010d,
0x0007004f,0x0000001c,0x0000010f,0x0000010e,0x0000010e,0x00000000,0x00000001,0x0004006e,
0x00000110,0x00000111,0x0000010f,0x00040064,0x00000107,0x00000112,0x0000010b,0x0007005f,
0x000000a3,0x00000113,0x00000112,0x00000111,0x00000002,0x000000ba,0x0008004f,0x00000007,
0x00000114,0x00000113,0x00000113,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000106,
0x00000114,0x0004003d,0x000000a3,0x00000118,0x0000010d,0x0007004f,0x0000001c,0x00000119,
0x00000118,0x00000118,0x00000000,0x00000001,0x0003003e,0x00000117,0x00000119,0x00050039,
0x0000001e,0x0000011a,0x00000021,0x00000117,0x0003003e,0x00000116,0x0000011a,0x00060041,
0x000000ad,0x0000011c,0x000000a9,0x000000ab,0x000000d3,0x0004003d,0x00000006,0x0000011d,
0x0000011c,0x0007000c,0x00000006,0x0000011e,0x00000001,0x00000028,0x0000011d,0x00000053,
0x0003003e,0x0000011b,0x0000011e,0x00060041,0x000000ad,0x0000011f,0x000000a9,0x000000ab,
0x000000e6,0x0004003d,0x00000006,0x00000120,0x0000011f,0x000500b8,0x0000001e,0x00000121,
0x00000120,0x000000c6,0x000300f7,0x00000123,0x00000000,0x000400fa,0x00000121,0x00000122,
0x00000145,0x000200f8,0x00000122,0x0004003d,0x0000001e,0x00000124,0x00000116,0x000300f7,
0x00000126,0x00000000,0x000400fa,0x00000124,0x00000125,0x00000129,0x000200f8,0x00000125,
0x0004003d,0x00000007,0x00000128,0x00000106,0x0003003e,0x00000127,0x00000128,0x000200f9,
0x00000126,0x000200f8,0x00000129,0x0004003d,0x00000007,0x0000013a,0x00000106,0x0003003e,
0x00000139,0x0000013a,0x00050039,0x00000007,0x0000013b,0x0000000b,0x00000139,0x00050091,
0x00000007,0x0000013c,0x00000138,0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000011b,
0x0005008e,0x00000007,0x0000013e,0x0000013c,0x0000013d,0x0003003e,0x0000012a,0x0000013e,
0x0004003d,0x00000007,0x0000013f,0x0000012a,0x00060050,0x00000007,0x00000141,0x00000140,
0x00000140,0x00000140,0x00050088,0x00000007,0x00000142,0x0000013f,0x00000141,0x0003003e,
0x00000143,0x00000142,0x00050039,0x00000007,0x00000144,0x00000014,0x00000143,0x0003003e,
0x00000127,0x00000144,0x000200f9,0x00000126,0x000200f8,0x00000126,0x000200f9,0x00000123,
0x000200f8,0x00000145,0x0004003d,0x0000001e,0x00000146,0x00000116,0x000400a8,0x0000001e,
0x00000147,0x00000146,0x000300f7,0x00000149,0x00000000,0x000400fa,0x00000147,0x00000148,
0x0000014b,0x000200f8,0x00000148,0x0004003d,0x00000007,0x0000014a,0x00000106,0x0003003e,
0x00000127,0x0000014a,0x000200f9,0x00000149,0x000200f8,0x0000014b,0x0004003d,0x00000007,
0x0000015b,0x00000106,0x0003003e,0x0000015a,0x0000015b,0x00050039,0x00000007,0x0000015c,
0x00000011,0x0000015a,0x0005008e,0x00000007,0x0000015d,0x0000015c,0x00000140,0x00050091,
0x00000007,0x0000015e,0x00000159,0x0000015d,0x00060050,0x00000007,0x0000015f,0x00000052,
0x00000052,0x00000052,0x0007000c,0x00000007,0x00000160,0x00000001,0x00000028,0x0000015e,
0x0000015f,0x0004003d,0x00000006,0x00000161,0x0000011b,0x00060050,0x00000007,0x00000162,
0x00000161,0x00000161,0x00000161,0x00050088,0x00000007,0x00000163,0x00000160,0x00000162,
0x0003003e,0x0000014c,0x00000163,0x00050041,0x00000016,0x00000165,0x0000014c,0x000000d3,
0x0004003d,0x00000006,0x00000166,0x00000165,0x00050041,0x00000016,0x00000167,0x0000014c,
0x000000db,0x0004003d,0x00000006,0x00000168,0x00000167,0x0007000c,0x00000006,0x00000169,
0x00000001,0x00000028,0x00000166,0x00000168,0x00050041,0x00000016,0x0000016a,0x0000014c,
0x000000e6,0x0004003d,0x00000006,0x0000016b,0x0000016a,0x0007000c,0x00000006,0x0000016c,
0x00000001,0x00000028,0x00000169,0x0000016b,0x0003003e,0x00000164,0x0000016c,0x0004003d,
0x00000006,0x0000016d,0x00000164,0x000500ba,0x0000001e,0x0000016e,0x0000016d,0x00000066,
0x000300f7,0x00000170,0x00000000,0x000400fa,0x0000016e,0x0000016f,0x00000170,0x000200f8,
0x0000016f,0x00060041,0x000000ad,0x00000171,0x000000a9,0x000000ab,0x000000db,0x0004003d,
0x00000006,0x00000172,0x00000171,0x0004003d,0x00000006,0x00000173,0x0000011b,0x0007000c,
0x00000006,0x00000174,0x00000001,0x00000028,0x00000172,0x00000173,0x0004003d,0x00000006,
0x00000175,0x0000011b,0x00050088,0x00000006,0x00000176,0x00000174,0x00000175,0x0004003d,
0x00000006,0x00000178,0x00000164,0x0003003e,0x00000177,0x00000178,0x0003003e,0x00000179,
0x00000176,0x00060039,0x00000006,0x0000017a,0x0000001a,0x00000177,0x00000179,0x0004003d,
0x00000006,0x0000017b,0x00000164,0x00050088,0x00000006,0x0000017c,0x0000017a,0x0000017b,
0x0004003d,0x00000007,0x0000017d,0x0000014c,0x0005008e,0x00000007,0x0000017e,0x0000017d,
0x0000017c,0x0003003e,0x0000014c,0x0000017e,0x000200f9,0x00000170,0x000200f8,0x00000170,
0x0004003d,0x00000007,0x0000017f,0x0000014c,0x00060050,0x00000007,0x00000180,0x00000052,
0x00000052,0x00000052,0x00060050,0x00000007,0x00000181,0x00000053,0x00000053,0x00000053,
0x0008000c,0x00000007,0x00000182,0x00000001,0x0000002b,0x0000017f,0x00000180,0x00000181,
0x0003003e,0x00000183,0x00000182,0x00050039,0x00000007,0x00000184,0x0000000e,0x00000183,
0x0003003e,0x00000127,0x00000184,0x000200f9,0x00000149,0x000200f8,0x00000149,0x000200f9,
0x00000123,0x000200f8,0x00000123,0x0004003d,0x00000007,0x00000187,0x00000127,0x00050051,
0x00000006,0x00000188,0x00000187,0x00000000,0x00050051,0x00000006,0x00000189,0x00000187,
0x00000001,0x00050051,0x00000006,0x0000018a,0x00000187,0x00000002,0x00070050,0x000000a3,
0x0000018b,0x00000188,0x00000189,0x0000018a,0x00000053,0x0003003e,0x00000186,0x0000018b,
0x0004003b,0x00000008,0x0000014a,0x00000007,0x0004003b,0x00000023,0x00000159,0x00000007,
0x0004003b,0x0000001d,0x0000015a,0x00000007,0x0004003b,0x0000015e,0x0000015f,0x00000007,
0x0004003b,0x00000016,0x00000164,0x00000007,0x0004003b,0x00000023,0x00000165,0x00000007,
0x0004003b,0x0000015e,0x00000168,0x00000007,0x0004003b,0x00000016,0x0000016c,0x00000007,
0x0004003b,0x00000023,0x0000016f,0x00000007,0x0004003b,0x00000016,0x00000173,0x00000007,
0x0004003b,0x00000008,0x00000180,0x00000007,0x0004003b,0x00000008,0x00000181,0x00000007,
0x0004003b,0x00000008,0x00000189,0x00000007,0x0004003b,0x00000008,0x00000191,0x00000007,
0x0004003b,0x00000008,0x000001a0,0x00000007,0x0004003b,0x00000008,0x000001a9,0x00000007,
0x0004003b,0x00000008,0x000001b2,0x00000007,0x0004003b,0x00000008,0x000001b4,0x00000007,
0x0004003b,0x00000008,0x000001b7,0x00000007,0x0004003b,0x00000008,0x000001bb,0x00000007,
0x0004003b,0x00000008,0x000001c0,0x00000007,0x0004003b,0x00000016,0x000001d5,0x00000007,
0x0004003b,0x00000016,0x000001e8,0x00000007,0x0004003b,0x00000016,0x000001ea,0x00000007,
0x0004003b,0x00000008,0x000001f4,0x00000007,0x0004003d,0x0000014c,0x0000014f,0x0000014e,
0x0004003d,0x000000ad,0x00000152,0x00000151,0x0007004f,0x0000001c,0x00000153,0x00000152,
0x00000152,0x00000000,0x00000001,0x0004006e,0x00000154,0x00000155,0x00000153,0x00040064,
0x0000014b,0x00000156,0x0000014f,0x0007005f,0x000000ad,0x00000157,0x00000156,0x00000155,
0x00000002,0x000000be,0x0008004f,0x00000007,0x00000158,0x00000157,0x00000157,0x00000000,
0x00000001,0x00000002,0x0003003e,0x0000014a,0x00000158,0x0004003d,0x000000ad,0x0000015b,
0x00000151,0x0007004f,0x0000001c,0x0000015c,0x0000015b,0x0000015b,0x00000000,0x00000001,
0x0003003e,0x0000015a,0x0000015c,0x00050039,0x0000001e,0x0000015d,0x00000021,0x0000015a,
0x0003003e,0x00000159,0x0000015d,0x00060041,0x000000b8,0x00000160,0x000000b6,0x000000b7,
0x000000b2,0x0004003d,0x00000006,0x00000161,0x00000160,0x00050088,0x00000006,0x00000162,
0x00000161,0x000000bb,0x0006000c,0x00000006,0x00000163,0x00000001,0x00000008,0x00000162,
0x0003003e,0x00000164,0x00000163,0x0004003d,0x0000001e,0x00000166,0x00000159,0x0003003e,
0x00000165,0x00000166,0x00060039,0x00000024,0x00000167,0x00000028,0x00000164,0x00000165,
0x0003003e,0x0000015f,0x00000167,0x0004003d,0x00000024,0x00000169,0x0000015f,0x000300f7,
0x0000016b,0x00000000,0x000400fa,0x00000169,0x0000016a,0x0000016b,0x000200f8,0x0000016a,
0x00070041,0x000000b8,0x0000016d,0x000000b6,0x00000127,0x000000be,0x000000b2,0x0004003d,
0x00000006,0x0000016e,0x0000016d,0x0003003e,0x0000016c,0x0000016e,0x0004003d,0x0000001e,
0x00000170,0x00000159,0x0003003e,0x0000016f,0x00000170,0x00060039,0x00000024,0x00000171,
0x00000028,0x0000016c,0x0000016f,0x000200f9,0x0000016b,0x000200f8,0x0000016b,0x000700f5,
0x00000024,0x00000172,0x00000169,0x00000005,0x00000171,0x0000016a,0x0003003e,0x00000168,
0x00000172,0x00060041,0x000000b8,0x00000174,0x000000b6,0x000000b7,0x000000d8,0x0004003d,
0x00000006,0x00000175,0x00000174,0x0007000c,0x00000006,0x00000176,0x00000001,0x00000028,
0x00000175,0x0000005d,0x0003003e,0x00000173,0x00000176,0x00060041,0x000000b8,0x00000178,
0x000000b6,0x000000b7,0x00000177,0x0004003d,0x00000006,0x00000179,0x00000178,0x000500b8,
0x00000024,0x0000017a,0x00000179,0x000000ca,0x000300f7,0x0000017c,0x00000000,0x000400fa,
0x0000017a,0x0000017b,0x000001ab,0x000200f8,0x0000017b,0x0004003d,0x00000024,0x0000017d,
0x00000168,0x000300f7,0x0000017f,0x00000000,0x000400fa,0x0000017d,0x0000017e,0x0000018b,
0x000200f8,0x0000017e,0x0004003d,0x00000007,0x00000182,0x0000014a,0x0003003e,0x00000181,
0x00000182,0x00050039,0x00000007,0x00000183,0x0000002b,0x00000181,0x00060050,0x00000007,
0x00000184,0x0000005c,0x0000005c,0x0000005c,0x0007000c,0x00000007,0x00000185,0x00000001,
0x00000028,0x00000183,0x00000184,0x00060050,0x00000007,0x00000187,0x00000186,0x00000186,
0x00000186,0x00050088,0x00000007,0x00000188,0x00000185,0x00000187,0x0003003e,0x00000189,
0x00000188,0x00050039,0x00000007,0x0000018a,0x00000014,0x00000189,0x0003003e,0x00000180,
0x0000018a,0x000200f9,0x0000017f,0x000200f8,0x0000018b,0x0004003d,0x00000024,0x0000018c,
0x0000015f,0x000300f7,0x0000018e,0x00000000,0x000400fa,0x0000018c,0x0000018d,0x00000190,
0x000200f8,0x0000018d,0x0004003d,0x00000007,0x0000018f,0x0000014a,0x0003003e,0x00000180,
0x0000018f,0x000200f9,0x0000018e,0x000200f8,0x00000190,0x0004003d,0x00000007,0x000001a1,
0x0000014a,0x0003003e,0x000001a0,0x000001a1,0x00050039,0x00000007,0x000001a2,0x0000000b,
0x000001a0,0x00050091,0x00000007,0x000001a3,0x0000019f,0x000001a2,0x0004003d,0x00000006,
0x000001a4,0x00000173,0x0005008e,0x00000007,0x000001a5,0x000001a3,0x000001a4,0x0003003e,
0x00000191,0x000001a5,0x0004003d,0x00000007,0x000001a6,0x00000191,0x00060050,0x00000007,
0x000001a7,0x00000186,0x00000186,0x00000186,0x00050088,0x00000007,0x000001a8,0x000001a6,
0x000001a7,0x0003003e,0x000001a9,0x000001a8,0x00050039,0x00000007,0x000001aa,0x00000014,
0x000001a9,0x0003003e,0x00000180,0x000001aa,0x000200f9,0x0000018e,0x000200f8,0x0000018e,
0x000200f9,0x0000017f,0x000200f8,0x0000017f,0x000200f9,0x0000017c,0x000200f8,0x000001ab,
0x0004003d,0x00000024,0x000001ac,0x0000015f,0x000400a8,0x00000024,0x000001ad,0x000001ac,
0x000300f7,0x000001af,0x00000000,0x000400fa,0x000001ad,0x000001ae,0x000001b1,0x000200f8,
0x000001ae,0x0004003d,0x00000007,0x000001b0,0x0000014a,0x0003003e,0x00000180,0x000001b0,
0x000200f9,0x000001af,0x000200f8,0x000001b1,0x0004003d,0x00000024,0x000001b3,0x00000168,
0x000300f7,0x000001b6,0x00000000,0x000400fa,0x000001b3,0x000001b5,0x000001ba,0x000200f8,
0x000001b5,0x0004003d,0x00000007,0x000001b8,0x0000014a,0x0003003e,0x000001b7,0x000001b8,
0x00050039,0x00000007,0x000001b9,0x0000002b,0x000001b7,0x0003003e,0x000001b4,0x000001b9,
0x000200f9,0x000001b6,0x000200f8,0x000001ba,0x0004003d,0x00000007,0x000001bc,0x0000014a,
0x0003003e,0x000001bb,0x000001bc,0x00050039,0x00000007,0x000001bd,0x00000011,0x000001bb,
0x0005008e,0x00000007,0x000001be,0x000001bd,0x00000186,0x0003003e,0x000001b4,0x000001be,
0x000200f9,0x000001b6,0x000200f8,0x000001b6,0x0004003d,0x00000007,0x000001bf,0x000001b4,
0x0003003e,0x000001b2,0x000001bf,0x0004003d,0x00000007,0x000001ce,0x000001b2,0x00050091,
0x00000007,0x000001cf,0x000001cd,0x000001ce,0x00060050,0x00000007,0x000001d0,0x0000005c,
0x0000005c,0x0000005c,0x0007000c,0x00000007,0x000001d1,0x00000001,0x00000028,0x000001cf,
0x000001d0,0x0004003d,0x00000006,0x000001d2,0x00000173,0x00060050,0x00000007,0x000001d3,
0x000001d2,0x000001d2,0x000001d2,0x00050088,0x00000007,0x000001d4,0x000001d1,0x000001d3,
0x0003003e,0x000001c0,0x000001d4,0x00050041,0x00000016,0x000001d6,0x000001c0,0x000000d8,
0x0004003d,0x00000006,0x000001d7,0x000001d6,0x00050041,0x00000016,0x000001d8,0x000001c0,
0x000000e6,0x0004003d,0x00000006,0x000001d9,0x000001d8,0x0007000c,0x00000006,0x000001da,
0x00000001,0x00000028,0x000001d7,0x000001d9,0x00050041,0x00000016,0x000001db,0x000001c0,
0x00000177,0x0004003d,0x00000006,0x000001dc,0x000001db,0x0007000c,0x00000006,0x000001dd,
0x00000001,0x00000028,0x000001da,0x000001dc,0x0003003e,0x000001d5,0x000001dd,0x0004003d,
0x00000006,0x000001de,0x000001d5,0x000500ba,0x00000024,0x000001df,0x000001de,0x00000070,
0x000300f7,0x000001e1,0x00000000,0x000400fa,0x000001df,0x000001e0,0x000001e1,0x000200f8,
0x000001e0,0x00060041,0x000000b8,0x000001e2,0x000000b6,0x000000b7,0x000000e6,0x0004003d,
0x00000006,0x000001e3,0x000001e2,0x0004003d,0x00000006,0x000001e4,0x00000173,0x0007000c,
0x00000006,0x000001e5,0x00000001,0x00000028,0x000001e3,0x000001e4,0x0004003d,0x00000006,
0x000001e6,0x00000173,0x00050088,0x00000006,0x000001e7,0x000001e5,0x000001e6,0x0004003d,
0x00000006,0x000001e9,0x000001d5,0x0003003e,0x000001e8,0x000001e9,0x0003003e,0x000001ea,
0x000001e7,0x00060039,0x00000006,0x000001eb,0x0000001a,0x000001e8,0x000001ea,0x0004003d,
0x00000006,0x000001ec,0x000001d5,0x00050088,0x00000006,0x000001ed,0x000001eb,0x000001ec,
0x0004003d,0x00000007,0x000001ee,0x000001c0,0x0005008e,0x00000007,0x000001ef,0x000001ee,
0x000001ed,0x0003003e,0x000001c0,0x000001ef,0x000200f9,0x000001e1,0x000200f8,0x000001e1,
0x0004003d,0x00000007,0x000001f0,0x000001c0,0x00060050,0x00000007,0x000001f1,0x0000005c,
0x0000005c,0x0000005c,0x00060050,0x00000007,0x000001f2,0x0000005d,0x0000005d,0x0000005d,
0x0008000c,0x00000007,0x000001f3,0x00000001,0x0000002b,0x000001f0,0x000001f1,0x000001f2,
0x0003003e,0x000001f4,0x000001f3,0x00050039,0x00000007,0x000001f5,0x0000000e,0x000001f4,
0x0003003e,0x00000180,0x000001f5,0x000200f9,0x000001af,0x000200f8,0x000001af,0x000200f9,
0x0000017c,0x000200f8,0x0000017c,0x0004003d,0x00000007,0x000001f8,0x00000180,0x00050051,
0x00000006,0x000001f9,0x000001f8,0x00000000,0x00050051,0x00000006,0x000001fa,0x000001f8,
0x00000001,0x00050051,0x00000006,0x000001fb,0x000001f8,0x00000002,0x00070050,0x000000ad,
0x000001fc,0x000001f9,0x000001fa,0x000001fb,0x0000005d,0x0003003e,0x000001f7,0x000001fc,
0x000100fd,0x00010038,0x00050036,0x00000007,0x0000000b,0x00000000,0x00000009,0x00030037,
0x00000008,0x0000000a,0x000200f8,0x0000000c,0x0004003b,0x00000008,0x00000023,0x00000007,
0x0004003b,0x00000008,0x00000028,0x00000007,0x0004003d,0x00000007,0x00000024,0x0000000a,
0x00060050,0x00000007,0x00000026,0x00000025,0x00000025,0x00000025,0x00050088,0x00000007,
0x00000027,0x00000024,0x00000026,0x0003003e,0x00000023,0x00000027,0x0004003d,0x00000007,
0x00000029,0x0000000a,0x00060050,0x00000007,0x0000002b,0x0000002a,0x0000002a,0x0000002a,
0x00050081,0x00000007,0x0000002c,0x00000029,0x0000002b,0x00060050,0x00000007,0x0000002e,
0x0000002d,0x0000002d,0x0000002d,0x00050088,0x00000007,0x0000002f,0x0000002c,0x0000002e,
0x0007000c,0x00000007,0x00000032,0x00000001,0x0000001a,0x0000002f,0x00000031,0x0003003e,
0x00000028,0x00000032,0x0004003d,0x00000007,0x00000033,0x00000023,0x0004003d,0x00000007,
0x00000034,0x00000028,0x0004003d,0x00000007,0x00000037,0x0000000a,0x0007000c,0x00000007,
0x00000038,0x00000001,0x00000030,0x00000036,0x00000037,0x0008000c,0x00000007,0x00000039,
0x00000001,0x0000002e,0x00000033,0x00000034,0x00000038,0x000200fe,0x00000039,0x00010038,
0x00000008,0x0000000a,0x000200f8,0x0000000c,0x0004003b,0x00000008,0x0000002d,0x00000007,
0x0004003b,0x00000008,0x00000032,0x00000007,0x0004003d,0x00000007,0x0000002e,0x0000000a,
0x00060050,0x00000007,0x00000030,0x0000002f,0x0000002f,0x0000002f,0x00050088,0x00000007,
0x00000031,0x0000002e,0x00000030,0x0003003e,0x0000002d,0x00000031,0x0004003d,0x00000007,
0x00000033,0x0000000a,0x00060050,0x00000007,0x00000035,0x00000034,0x00000034,0x00000034,
0x00050081,0x00000007,0x00000036,0x00000033,0x00000035,0x00060050,0x00000007,0x00000038,
0x00000037,0x00000037,0x00000037,0x00050088,0x00000007,0x00000039,0x00000036,0x00000038,
0x0007000c,0x00000007,0x0000003c,0x00000001,0x0000001a,0x00000039,0x0000003b,0x0003003e,
0x00000032,0x0000003c,0x0004003d,0x00000007,0x0000003d,0x0000002d,0x0004003d,0x00000007,
0x0000003e,0x00000032,0x0004003d,0x00000007,0x00000041,0x0000000a,0x0007000c,0x00000007,
0x00000042,0x00000001,0x00000030,0x00000040,0x00000041,0x0008000c,0x00000007,0x00000043,
0x00000001,0x0000002e,0x0000003d,0x0000003e,0x00000042,0x000200fe,0x00000043,0x00010038,
0x00050036,0x00000007,0x0000000e,0x00000000,0x00000009,0x00030037,0x00000008,0x0000000d,
0x000200f8,0x0000000f,0x0004003b,0x00000008,0x0000003c,0x00000007,0x0004003b,0x00000008,
0x0000003f,0x00000007,0x0004003d,0x00000007,0x0000003d,0x0000000d,0x0005008e,0x00000007,
0x0000003e,0x0000003d,0x00000025,0x0003003e,0x0000003c,0x0000003e,0x0004003d,0x00000007,
0x00000040,0x0000000d,0x0007000c,0x00000007,0x00000043,0x00000001,0x0000001a,0x00000040,
0x00000042,0x0005008e,0x00000007,0x00000044,0x00000043,0x0000002d,0x00060050,0x00000007,
0x00000045,0x0000002a,0x0000002a,0x0000002a,0x00050083,0x00000007,0x00000046,0x00000044,
0x00000045,0x0003003e,0x0000003f,0x00000046,0x0004003d,0x00000007,0x00000047,0x0000003c,
0x0004003d,0x00000007,0x00000048,0x0000003f,0x0004003d,0x00000007,0x0000004b,0x0000000d,
0x0007000c,0x00000007,0x0000004c,0x00000001,0x00000030,0x0000004a,0x0000004b,0x0008000c,
0x00000007,0x0000004d,0x00000001,0x0000002e,0x00000047,0x00000048,0x0000004c,0x000200fe,
0x0000004d,0x00010038,0x00050036,0x00000007,0x00000011,0x00000000,0x00000009,0x00030037,
0x00000008,0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000008,0x00000050,0x00000007,
0x0004003d,0x00000007,0x00000051,0x00000010,0x00060050,0x00000007,0x00000054,0x00000052,
0x00000052,0x00000052,0x00060050,0x00000007,0x00000055,0x00000053,0x00000053,0x00000053,
0x0008000c,0x00000007,0x00000056,0x00000001,0x0000002b,0x00000051,0x00000054,0x00000055,
0x0007000c,0x00000007,0x00000059,0x00000001,0x0000001a,0x00000056,0x00000058,0x0003003e,
0x00000050,0x00000059,0x0004003d,0x00000007,0x0000005a,0x00000050,0x00060050,0x00000007,
0x0000005c,0x0000005b,0x0000005b,0x0000005b,0x00050083,0x00000007,0x0000005d,0x0000005a,
0x0000005c,0x00060050,0x00000007,0x0000005e,0x00000052,0x00000052,0x00000052,0x0007000c,
0x00000007,0x0000005f,0x00000001,0x00000028,0x0000005d,0x0000005e,0x0004003d,0x00000007,
0x00000062,0x00000050,0x0005008e,0x00000007,0x00000063,0x00000062,0x00000061,0x00060050,
0x00000007,0x00000064,0x00000060,0x00000060,0x00000060,0x00050083,0x00000007,0x00000065,
0x00000064,0x00000063,0x00060050,0x00000007,0x00000067,0x00000066,0x00000066,0x00000066,
0x0007000c,0x00000007,0x00000068,0x00000001,0x00000028,0x00000065,0x00000067,0x00050088,
0x00000007,0x00000069,0x0000005f,0x00000068,0x0007000c,0x00000007,0x0000006c,0x00000001,
0x0000001a,0x00000069,0x0000006b,0x000200fe,0x0000006c,0x00010038,0x00050036,0x00000007,
0x000200f8,0x0000000f,0x0004003b,0x00000008,0x00000046,0x00000007,0x0004003b,0x00000008,
0x00000049,0x00000007,0x0004003d,0x00000007,0x00000047,0x0000000d,0x0005008e,0x00000007,
0x00000048,0x00000047,0x0000002f,0x0003003e,0x00000046,0x00000048,0x0004003d,0x00000007,
0x0000004a,0x0000000d,0x0007000c,0x00000007,0x0000004d,0x00000001,0x0000001a,0x0000004a,
0x0000004c,0x0005008e,0x00000007,0x0000004e,0x0000004d,0x00000037,0x00060050,0x00000007,
0x0000004f,0x00000034,0x00000034,0x00000034,0x00050083,0x00000007,0x00000050,0x0000004e,
0x0000004f,0x0003003e,0x00000049,0x00000050,0x0004003d,0x00000007,0x00000051,0x00000046,
0x0004003d,0x00000007,0x00000052,0x00000049,0x0004003d,0x00000007,0x00000055,0x0000000d,
0x0007000c,0x00000007,0x00000056,0x00000001,0x00000030,0x00000054,0x00000055,0x0008000c,
0x00000007,0x00000057,0x00000001,0x0000002e,0x00000051,0x00000052,0x00000056,0x000200fe,
0x00000057,0x00010038,0x00050036,0x00000007,0x00000011,0x00000000,0x00000009,0x00030037,
0x00000008,0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000008,0x0000005a,0x00000007,
0x0004003d,0x00000007,0x0000005b,0x00000010,0x00060050,0x00000007,0x0000005e,0x0000005c,
0x0000005c,0x0000005c,0x00060050,0x00000007,0x0000005f,0x0000005d,0x0000005d,0x0000005d,
0x0008000c,0x00000007,0x00000060,0x00000001,0x0000002b,0x0000005b,0x0000005e,0x0000005f,
0x0007000c,0x00000007,0x00000063,0x00000001,0x0000001a,0x00000060,0x00000062,0x0003003e,
0x0000005a,0x00000063,0x0004003d,0x00000007,0x00000064,0x0000005a,0x00060050,0x00000007,
0x00000066,0x00000065,0x00000065,0x00000065,0x00050083,0x00000007,0x00000067,0x00000064,
0x00000066,0x00060050,0x00000007,0x00000068,0x0000005c,0x0000005c,0x0000005c,0x0007000c,
0x00000007,0x00000069,0x00000001,0x00000028,0x00000067,0x00000068,0x0004003d,0x00000007,
0x0000006c,0x0000005a,0x0005008e,0x00000007,0x0000006d,0x0000006c,0x0000006b,0x00060050,
0x00000007,0x0000006e,0x0000006a,0x0000006a,0x0000006a,0x00050083,0x00000007,0x0000006f,
0x0000006e,0x0000006d,0x00060050,0x00000007,0x00000071,0x00000070,0x00000070,0x00000070,
0x0007000c,0x00000007,0x00000072,0x00000001,0x00000028,0x0000006f,0x00000071,0x00050088,
0x00000007,0x00000073,0x00000069,0x00000072,0x0007000c,0x00000007,0x00000076,0x00000001,
0x0000001a,0x00000073,0x00000075,0x000200fe,0x00000076,0x00010038,0x00050036,0x00000007,
0x00000014,0x00000000,0x00000009,0x00030037,0x00000008,0x00000013,0x000200f8,0x00000015,
0x0004003b,0x00000008,0x0000006f,0x00000007,0x0004003d,0x00000007,0x00000070,0x00000013,
0x00060050,0x00000007,0x00000071,0x00000052,0x00000052,0x00000052,0x00060050,0x00000007,
0x00000072,0x00000053,0x00000053,0x00000053,0x0008000c,0x00000007,0x00000073,0x00000001,
0x0000002b,0x00000070,0x00000071,0x00000072,0x0007000c,0x00000007,0x00000076,0x00000001,
0x0000001a,0x00000073,0x00000075,0x0003003e,0x0000006f,0x00000076,0x0004003d,0x00000007,
0x00000077,0x0000006f,0x0005008e,0x00000007,0x00000078,0x00000077,0x00000060,0x00060050,
0x00000007,0x00000079,0x0000005b,0x0000005b,0x0000005b,0x00050081,0x00000007,0x0000007a,
0x00000079,0x00000078,0x0004003d,0x00000007,0x0000007b,0x0000006f,0x0005008e,0x00000007,
0x0000007c,0x0000007b,0x00000061,0x00060050,0x00000007,0x0000007d,0x00000053,0x00000053,
0x00000053,0x00050081,0x00000007,0x0000007e,0x0000007d,0x0000007c,0x00050088,0x00000007,
0x0000007f,0x0000007a,0x0000007e,0x0007000c,0x00000007,0x00000082,0x00000001,0x0000001a,
0x0000007f,0x00000081,0x000200fe,0x00000082,0x00010038,0x00050036,0x00000006,0x0000001a,
0x0004003b,0x00000008,0x00000079,0x00000007,0x0004003d,0x00000007,0x0000007a,0x00000013,
0x00060050,0x00000007,0x0000007b,0x0000005c,0x0000005c,0x0000005c,0x00060050,0x00000007,
0x0000007c,0x0000005d,0x0000005d,0x0000005d,0x0008000c,0x00000007,0x0000007d,0x00000001,
0x0000002b,0x0000007a,0x0000007b,0x0000007c,0x0007000c,0x00000007,0x00000080,0x00000001,
0x0000001a,0x0000007d,0x0000007f,0x0003003e,0x00000079,0x00000080,0x0004003d,0x00000007,
0x00000081,0x00000079,0x0005008e,0x00000007,0x00000082,0x00000081,0x0000006a,0x00060050,
0x00000007,0x00000083,0x00000065,0x00000065,0x00000065,0x00050081,0x00000007,0x00000084,
0x00000083,0x00000082,0x0004003d,0x00000007,0x00000085,0x00000079,0x0005008e,0x00000007,
0x00000086,0x00000085,0x0000006b,0x00060050,0x00000007,0x00000087,0x0000005d,0x0000005d,
0x0000005d,0x00050081,0x00000007,0x00000088,0x00000087,0x00000086,0x00050088,0x00000007,
0x00000089,0x00000084,0x00000088,0x0007000c,0x00000007,0x0000008c,0x00000001,0x0000001a,
0x00000089,0x0000008b,0x000200fe,0x0000008c,0x00010038,0x00050036,0x00000006,0x0000001a,
0x00000000,0x00000017,0x00030037,0x00000016,0x00000018,0x00030037,0x00000016,0x00000019,
0x000200f8,0x0000001b,0x0004003b,0x00000016,0x0000008c,0x00000007,0x0004003b,0x00000016,
0x00000091,0x00000007,0x0004003d,0x00000006,0x00000085,0x00000018,0x000500bc,0x0000001e,
0x00000087,0x00000085,0x00000086,0x000300f7,0x00000089,0x00000000,0x000400fa,0x00000087,
0x00000088,0x00000089,0x000200f8,0x00000088,0x0004003d,0x00000006,0x0000008a,0x00000018,
0x000200fe,0x0000008a,0x000200f8,0x00000089,0x0004003d,0x00000006,0x0000008d,0x00000019,
0x00050083,0x00000006,0x0000008e,0x0000008d,0x00000086,0x0007000c,0x00000006,0x00000090,
0x00000001,0x00000028,0x0000008e,0x0000008f,0x0003003e,0x0000008c,0x00000090,0x0004003d,
0x00000006,0x00000092,0x0000008c,0x00050088,0x00000006,0x00000094,0x00000092,0x00000093,
0x0007000c,0x00000006,0x00000096,0x00000001,0x00000028,0x00000094,0x00000095,0x0003003e,
0x00000091,0x00000096,0x0004003d,0x00000006,0x00000097,0x00000018,0x00050083,0x00000006,
0x00000098,0x00000097,0x00000086,0x0004007f,0x00000006,0x00000099,0x00000098,0x0004003d,
0x00000006,0x0000009a,0x00000091,0x00050088,0x00000006,0x0000009b,0x00000099,0x0000009a,
0x0006000c,0x00000006,0x0000009c,0x00000001,0x0000001b,0x0000009b,0x00050083,0x00000006,
0x0000009d,0x00000053,0x0000009c,0x00050085,0x00000006,0x0000009e,0x00000095,0x0000009d,
0x00050081,0x00000006,0x0000009f,0x00000086,0x0000009e,0x000200fe,0x0000009f,0x00010038,
0x000200f8,0x0000001b,0x0004003b,0x00000016,0x00000096,0x00000007,0x0004003b,0x00000016,
0x0000009b,0x00000007,0x0004003d,0x00000006,0x0000008f,0x00000018,0x000500bc,0x00000024,
0x00000091,0x0000008f,0x00000090,0x000300f7,0x00000093,0x00000000,0x000400fa,0x00000091,
0x00000092,0x00000093,0x000200f8,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000018,
0x000200fe,0x00000094,0x000200f8,0x00000093,0x0004003d,0x00000006,0x00000097,0x00000019,
0x00050083,0x00000006,0x00000098,0x00000097,0x00000090,0x0007000c,0x00000006,0x0000009a,
0x00000001,0x00000028,0x00000098,0x00000099,0x0003003e,0x00000096,0x0000009a,0x0004003d,
0x00000006,0x0000009c,0x00000096,0x00050088,0x00000006,0x0000009e,0x0000009c,0x0000009d,
0x0007000c,0x00000006,0x000000a0,0x00000001,0x00000028,0x0000009e,0x0000009f,0x0003003e,
0x0000009b,0x000000a0,0x0004003d,0x00000006,0x000000a1,0x00000018,0x00050083,0x00000006,
0x000000a2,0x000000a1,0x00000090,0x0004007f,0x00000006,0x000000a3,0x000000a2,0x0004003d,
0x00000006,0x000000a4,0x0000009b,0x00050088,0x00000006,0x000000a5,0x000000a3,0x000000a4,
0x0006000c,0x00000006,0x000000a6,0x00000001,0x0000001b,0x000000a5,0x00050083,0x00000006,
0x000000a7,0x0000005d,0x000000a6,0x00050085,0x00000006,0x000000a8,0x0000009f,0x000000a7,
0x00050081,0x00000006,0x000000a9,0x00000090,0x000000a8,0x000200fe,0x000000a9,0x00010038,
0x00050036,0x0000001e,0x00000021,0x00000000,0x0000001f,0x00030037,0x0000001d,0x00000020,
0x000200f8,0x00000022,0x0004003b,0x00000016,0x000000a2,0x00000007,0x0004003b,0x00000016,
0x000000b0,0x00000007,0x0004003b,0x00000016,0x000000b4,0x00000007,0x0004003b,0x000000b8,
0x000000b9,0x00000007,0x0004003b,0x000000cc,0x000000cd,0x00000007,0x0004003b,0x00000016,
0x000000f5,0x00000007,0x00060041,0x000000ad,0x000000ae,0x000000a9,0x000000ab,0x000000ac,
0x0004003d,0x00000006,0x000000af,0x000000ae,0x0003003e,0x000000a2,0x000000af,0x0004003d,
0x00000006,0x000000b1,0x000000a2,0x0005008d,0x00000006,0x000000b3,0x000000b1,0x000000b2,
0x0003003e,0x000000b0,0x000000b3,0x0004003d,0x00000006,0x000000b5,0x000000a2,0x00050088,
0x00000006,0x000000b6,0x000000b5,0x000000b2,0x0006000c,0x00000006,0x000000b7,0x00000001,
0x00000008,0x000000b6,0x0003003e,0x000000b4,0x000000b7,0x0003003e,0x000000b9,0x000000ba,
0x000200f9,0x000000bb,0x000200f8,0x000000bb,0x000400f6,0x000000bd,0x000000be,0x00000000,
0x000200f9,0x000000bf,0x000200f8,0x000000bf,0x0004003d,0x000000aa,0x000000c0,0x000000b9,
0x000500b1,0x0000001e,0x000000c2,0x000000c0,0x000000c1,0x000400fa,0x000000c2,0x000000bc,
0x000000bd,0x000200f8,0x000000bc,0x0004003d,0x000000aa,0x000000c3,0x000000b9,0x0004006f,
0x00000006,0x000000c4,0x000000c3,0x0004003d,0x00000006,0x000000c5,0x000000b0,0x00050083,
0x00000006,0x000000c7,0x000000c5,0x000000c6,0x000500be,0x0000001e,0x000000c8,0x000000c4,
0x000000c7,0x000300f7,0x000000ca,0x00000000,0x000400fa,0x000000c8,0x000000c9,0x000000ca,
0x000200f8,0x000000c9,0x000200f9,0x000000bd,0x000200f8,0x000000ca,0x0004003d,0x000000aa,
0x000000cf,0x000000b9,0x00060041,0x000000d0,0x000000d1,0x000000a9,0x000000ce,0x000000cf,
0x0004003d,0x000000a3,0x000000d2,0x000000d1,0x0003003e,0x000000cd,0x000000d2,0x00050041,
0x00000016,0x000000d4,0x00000020,0x000000d3,0x0004003d,0x00000006,0x000000d5,0x000000d4,
0x00050041,0x00000016,0x000000d6,0x000000cd,0x000000d3,0x0004003d,0x00000006,0x000000d7,
0x000000d6,0x000500be,0x0000001e,0x000000d8,0x000000d5,0x000000d7,0x000300f7,0x000000da,
0x00000000,0x000400fa,0x000000d8,0x000000d9,0x000000da,0x000200f8,0x000000d9,0x00050041,
0x00000016,0x000000dc,0x00000020,0x000000db,0x0004003d,0x00000006,0x000000dd,0x000000dc,
0x00050041,0x00000016,0x000000de,0x000000cd,0x000000db,0x0004003d,0x00000006,0x000000df,
0x000000de,0x000500be,0x0000001e,0x000000e0,0x000000dd,0x000000df,0x000200f9,0x000000da,
0x000200f8,0x000000da,0x000700f5,0x0000001e,0x000000e1,0x000000d8,0x000000ca,0x000000e0,
0x000000d9,0x000300f7,0x000000e3,0x00000000,0x000400fa,0x000000e1,0x000000e2,0x000000e3,
0x000200f8,0x000000e2,0x00050041,0x00000016,0x000000e4,0x00000020,0x000000d3,0x0004003d,
0x00000006,0x000000e5,0x000000e4,0x00050041,0x00000016,0x000000e7,0x000000cd,0x000000e6,
0x0004003d,0x00000006,0x000000e8,0x000000e7,0x000500b8,0x0000001e,0x000000e9,0x000000e5,
0x000000e8,0x000200f9,0x000000e3,0x000200f8,0x000000e3,0x000700f5,0x0000001e,0x000000ea,
0x000000e1,0x000000da,0x000000e9,0x000000e2,0x000300f7,0x000000ec,0x00000000,0x000400fa,
0x000000ea,0x000000eb,0x000000ec,0x000200f8,0x000000eb,0x00050041,0x00000016,0x000000ed,
0x00000020,0x000000db,0x0004003d,0x00000006,0x000000ee,0x000000ed,0x00050041,0x00000016,
0x000000ef,0x000000cd,0x000000ac,0x0004003d,0x00000006,0x000000f0,0x000000ef,0x000500b8,
0x0000001e,0x000000f1,0x000000ee,0x000000f0,0x000200f9,0x000000ec,0x000200f8,0x000000ec,
0x000700f5,0x0000001e,0x000000f2,0x000000ea,0x000000e3,0x000000f1,0x000000eb,0x000300f7,
0x000000f4,0x00000000,0x000400fa,0x000000f2,0x000000f3,0x000000f4,0x000200f8,0x000000f3,
0x0004003d,0x00000006,0x000000f6,0x000000b4,0x0004003d,0x000000aa,0x000000f7,0x000000b9,
0x0004006f,0x00000006,0x000000f8,0x000000f7,0x0006000c,0x00000006,0x000000f9,0x00000001,
0x0000001d,0x000000f8,0x00050088,0x00000006,0x000000fa,0x000000f6,0x000000f9,0x0006000c,
0x00000006,0x000000fb,0x00000001,0x00000008,0x000000fa,0x0005008d,0x00000006,0x000000fd,
0x000000fb,0x000000fc,0x0003003e,0x000000f5,0x000000fd,0x0004003d,0x00000006,0x000000fe,
0x000000f5,0x000500ba,0x0000001e,0x000000ff,0x000000fe,0x000000c6,0x000200fe,0x000000ff,
0x000200f8,0x000000f4,0x000200f9,0x000000be,0x000200f8,0x000000be,0x0004003d,0x000000aa,
0x00000101,0x000000b9,0x00050080,0x000000aa,0x00000102,0x00000101,0x000000ab,0x0003003e,
0x000000b9,0x00000102,0x000200f9,0x000000bb,0x000200f8,0x000000bd,0x000200fe,0x00000103,
0x00010038
0x000200f8,0x00000022,0x0004003b,0x00000016,0x000000ac,0x00000007,0x0004003b,0x00000023,
0x000000bd,0x00000007,0x0004003b,0x000000d0,0x000000d1,0x00000007,0x0004003b,0x0000001d,
0x000000d7,0x00000007,0x0004003b,0x0000001d,0x000000e5,0x00000007,0x00060041,0x000000b8,
0x000000b9,0x000000b6,0x000000b7,0x000000b2,0x0004003d,0x00000006,0x000000ba,0x000000b9,
0x0005008d,0x00000006,0x000000bc,0x000000ba,0x000000bb,0x0003003e,0x000000ac,0x000000bc,
0x0003003e,0x000000bd,0x000000be,0x000200f9,0x000000bf,0x000200f8,0x000000bf,0x000400f6,
0x000000c1,0x000000c2,0x00000000,0x000200f9,0x000000c3,0x000200f8,0x000000c3,0x0004003d,
0x0000001e,0x000000c4,0x000000bd,0x000500b1,0x00000024,0x000000c6,0x000000c4,0x000000c5,
0x000400fa,0x000000c6,0x000000c0,0x000000c1,0x000200f8,0x000000c0,0x0004003d,0x0000001e,
0x000000c7,0x000000bd,0x0004006f,0x00000006,0x000000c8,0x000000c7,0x0004003d,0x00000006,
0x000000c9,0x000000ac,0x00050083,0x00000006,0x000000cb,0x000000c9,0x000000ca,0x000500be,
0x00000024,0x000000cc,0x000000c8,0x000000cb,0x000300f7,0x000000ce,0x00000000,0x000400fa,
0x000000cc,0x000000cd,0x000000ce,0x000200f8,0x000000cd,0x000200f9,0x000000c1,0x000200f8,
0x000000ce,0x0004003d,0x0000001e,0x000000d3,0x000000bd,0x00060041,0x000000d4,0x000000d5,
0x000000b6,0x000000d2,0x000000d3,0x0004003d,0x000000af,0x000000d6,0x000000d5,0x0003003e,
0x000000d1,0x000000d6,0x00050041,0x000000d9,0x000000da,0x000000d1,0x000000d8,0x0004003d,
0x000000ae,0x000000db,0x000000da,0x000500c7,0x000000ae,0x000000dd,0x000000db,0x000000dc,
0x00040070,0x00000006,0x000000de,0x000000dd,0x00050041,0x000000d9,0x000000df,0x000000d1,
0x000000d8,0x0004003d,0x000000ae,0x000000e0,0x000000df,0x000500c2,0x000000ae,0x000000e2,
0x000000e0,0x000000e1,0x00040070,0x00000006,0x000000e3,0x000000e2,0x00050050,0x0000001c,
0x000000e4,0x000000de,0x000000e3,0x0003003e,0x000000d7,0x000000e4,0x00050041,0x000000d9,
0x000000e7,0x000000d1,0x000000e6,0x0004003d,0x000000ae,0x000000e8,0x000000e7,0x000500c7,
0x000000ae,0x000000e9,0x000000e8,0x000000dc,0x00040070,0x00000006,0x000000ea,0x000000e9,
0x00050041,0x000000d9,0x000000eb,0x000000d1,0x000000e6,0x0004003d,0x000000ae,0x000000ec,
0x000000eb,0x000500c2,0x000000ae,0x000000ed,0x000000ec,0x000000e1,0x00040070,0x00000006,
0x000000ee,0x000000ed,0x00050050,0x0000001c,0x000000ef,0x000000ea,0x000000ee,0x0003003e,
0x000000e5,0x000000ef,0x00050041,0x00000016,0x000000f0,0x00000020,0x000000d8,0x0004003d,
0x00000006,0x000000f1,0x000000f0,0x00050041,0x00000016,0x000000f2,0x000000d7,0x000000d8,
0x0004003d,0x00000006,0x000000f3,0x000000f2,0x000500be,0x00000024,0x000000f4,0x000000f1,
0x000000f3,0x000300f7,0x000000f6,0x00000000,0x000400fa,0x000000f4,0x000000f5,0x000000f6,
0x000200f8,0x000000f5,0x00050041,0x00000016,0x000000f7,0x00000020,0x000000e6,0x0004003d,
0x00000006,0x000000f8,0x000000f7,0x00050041,0x00000016,0x000000f9,0x000000d7,0x000000e6,
0x0004003d,0x00000006,0x000000fa,0x000000f9,0x000500be,0x00000024,0x000000fb,0x000000f8,
0x000000fa,0x000200f9,0x000000f6,0x000200f8,0x000000f6,0x000700f5,0x00000024,0x000000fc,
0x000000f4,0x000000ce,0x000000fb,0x000000f5,0x000300f7,0x000000fe,0x00000000,0x000400fa,
0x000000fc,0x000000fd,0x000000fe,0x000200f8,0x000000fd,0x00050041,0x00000016,0x000000ff,
0x00000020,0x000000d8,0x0004003d,0x00000006,0x00000100,0x000000ff,0x00050041,0x00000016,
0x00000101,0x000000e5,0x000000d8,0x0004003d,0x00000006,0x00000102,0x00000101,0x000500b8,
0x00000024,0x00000103,0x00000100,0x00000102,0x000200f9,0x000000fe,0x000200f8,0x000000fe,
0x000700f5,0x00000024,0x00000104,0x000000fc,0x000000f6,0x00000103,0x000000fd,0x000300f7,
0x00000106,0x00000000,0x000400fa,0x00000104,0x00000105,0x00000106,0x000200f8,0x00000105,
0x00050041,0x00000016,0x00000107,0x00000020,0x000000e6,0x0004003d,0x00000006,0x00000108,
0x00000107,0x00050041,0x00000016,0x00000109,0x000000e5,0x000000e6,0x0004003d,0x00000006,
0x0000010a,0x00000109,0x000500b8,0x00000024,0x0000010b,0x00000108,0x0000010a,0x000200f9,
0x00000106,0x000200f8,0x00000106,0x000700f5,0x00000024,0x0000010c,0x00000104,0x000000fe,
0x0000010b,0x00000105,0x000300f7,0x0000010e,0x00000000,0x000400fa,0x0000010c,0x0000010d,
0x0000010e,0x000200f8,0x0000010d,0x0004003d,0x0000001e,0x0000010f,0x000000bd,0x000200fe,
0x0000010f,0x000200f8,0x0000010e,0x000200f9,0x000000c2,0x000200f8,0x000000c2,0x0004003d,
0x0000001e,0x00000111,0x000000bd,0x00050080,0x0000001e,0x00000112,0x00000111,0x000000b7,
0x0003003e,0x000000bd,0x00000112,0x000200f9,0x000000bf,0x000200f8,0x000000c1,0x000200fe,
0x00000113,0x00010038,0x00050036,0x00000024,0x00000028,0x00000000,0x00000025,0x00030037,
0x00000016,0x00000026,0x00030037,0x00000023,0x00000027,0x000200f8,0x00000029,0x0004003d,
0x0000001e,0x00000116,0x00000027,0x000500af,0x00000024,0x00000117,0x00000116,0x000000be,
0x000300f7,0x00000119,0x00000000,0x000400fa,0x00000117,0x00000118,0x00000119,0x000200f8,
0x00000118,0x0004003d,0x00000006,0x0000011a,0x00000026,0x0004003d,0x0000001e,0x0000011b,
0x00000027,0x0004006f,0x00000006,0x0000011c,0x0000011b,0x0006000c,0x00000006,0x0000011d,
0x00000001,0x0000001d,0x0000011c,0x00050088,0x00000006,0x0000011e,0x0000011a,0x0000011d,
0x0006000c,0x00000006,0x0000011f,0x00000001,0x00000008,0x0000011e,0x0005008d,0x00000006,
0x00000121,0x0000011f,0x00000120,0x000500ba,0x00000024,0x00000122,0x00000121,0x000000ca,
0x000200f9,0x00000119,0x000200f8,0x00000119,0x000700f5,0x00000024,0x00000123,0x00000117,
0x00000029,0x00000122,0x00000118,0x000200fe,0x00000123,0x00010038,0x00050036,0x00000007,
0x0000002b,0x00000000,0x00000009,0x00030037,0x00000008,0x0000002a,0x000200f8,0x0000002c,
0x0004003b,0x00000008,0x00000126,0x00000007,0x0004003b,0x00000008,0x0000012b,0x00000007,
0x0004003b,0x00000008,0x00000130,0x00000007,0x00070041,0x000000b8,0x00000128,0x000000b6,
0x00000127,0x000000b7,0x000000b2,0x0004003d,0x00000006,0x00000129,0x00000128,0x000500ba,
0x00000024,0x0000012a,0x00000129,0x000000ca,0x000300f7,0x0000012d,0x00000000,0x000400fa,
0x0000012a,0x0000012c,0x0000012f,0x000200f8,0x0000012c,0x0004003d,0x00000007,0x0000012e,
0x0000002a,0x0003003e,0x0000012b,0x0000012e,0x000200f9,0x0000012d,0x000200f8,0x0000012f,
0x0004003d,0x00000007,0x00000131,0x0000002a,0x0003003e,0x00000130,0x00000131,0x00050039,
0x00000007,0x00000132,0x00000011,0x00000130,0x0003003e,0x0000012b,0x00000132,0x000200f9,
0x0000012d,0x000200f8,0x0000012d,0x0004003d,0x00000007,0x00000133,0x0000012b,0x0003003e,
0x00000126,0x00000133,0x00060041,0x00000134,0x00000135,0x000000b6,0x00000127,0x000000be,
0x0004003d,0x000000ad,0x00000136,0x00000135,0x0008004f,0x00000007,0x00000137,0x00000136,
0x00000136,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000007,0x00000138,0x00000126,
0x00050094,0x00000006,0x00000139,0x00000137,0x00000138,0x00060041,0x00000134,0x0000013a,
0x000000b6,0x00000127,0x000000b7,0x0004003d,0x000000ad,0x0000013b,0x0000013a,0x0008004f,
0x00000007,0x0000013c,0x0000013b,0x0000013b,0x00000000,0x00000001,0x00000002,0x0004003d,
0x00000007,0x0000013d,0x00000126,0x00050094,0x00000006,0x0000013e,0x0000013c,0x0000013d,
0x00060041,0x00000134,0x0000013f,0x000000b6,0x00000127,0x000000d2,0x0004003d,0x000000ad,
0x00000140,0x0000013f,0x0008004f,0x00000007,0x00000141,0x00000140,0x00000140,0x00000000,
0x00000001,0x00000002,0x0004003d,0x00000007,0x00000142,0x00000126,0x00050094,0x00000006,
0x00000143,0x00000141,0x00000142,0x00060050,0x00000007,0x00000144,0x00000139,0x0000013e,
0x00000143,0x00070041,0x000000b8,0x00000145,0x000000b6,0x00000127,0x000000d2,0x000000b2,
0x0004003d,0x00000006,0x00000146,0x00000145,0x0005008e,0x00000007,0x00000147,0x00000144,
0x00000146,0x000200fe,0x00000147,0x00010038
};
+219 -44
View File
@@ -3,6 +3,7 @@
#include "ahb_swapchain.h"
#include "droiddeck_color.h"
#include "vk_present.h"
#include "framegen_bridge.h"
#include <android/hardware_buffer.h>
#include <android/native_window.h>
#include <android/rect.h>
@@ -64,6 +65,8 @@ static struct {
void (*setHdrMetadata_cta861_3)(ASurfaceTransaction *, ASurfaceControl *, const struct droiddeck_hdr_cta861_3 *);
const void *(*getNativeHandle)(const AHardwareBuffer *);
void (*setDesiredHdrHeadroom)(ASurfaceTransaction *, ASurfaceControl *, float);
void (*setEnableBackPressure)(ASurfaceTransaction *, ASurfaceControl *, bool);
void (*setDesiredPresentTime)(ASurfaceTransaction *, int64_t);
int state;
} api;
@@ -105,6 +108,8 @@ static int load_api(void) {
SYM(setHdrMetadata_smpte2086, "ASurfaceTransaction_setHdrMetadata_smpte2086");
SYM(setHdrMetadata_cta861_3, "ASurfaceTransaction_setHdrMetadata_cta861_3");
SYM(setDesiredHdrHeadroom, "ASurfaceTransaction_setDesiredHdrHeadroom");
SYM(setEnableBackPressure, "ASurfaceTransaction_setEnableBackPressure");
SYM(setDesiredPresentTime, "ASurfaceTransaction_setDesiredPresentTime");
#undef SYM
if (!api.createFromWindow || !api.release || !api.txCreate || !api.txDelete || !api.txApply ||
!api.setBuffer || !api.setZOrder || !api.setVisibility || !api.setGeometry ||
@@ -134,7 +139,7 @@ void sc_layer_set_frame_rate(float fps) {
}
#define POOL_MAX 5
#define POOL_MAX 8
struct slot {
AHardwareBuffer *ahb;
@@ -183,6 +188,12 @@ static int g_layers_ready;
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
static int g_pending_cb;
static unsigned g_stat_layer_frames;
static pthread_mutex_t g_timeline_lock = PTHREAD_MUTEX_INITIALIZER;
static int64_t g_timeline_present_ns, g_timeline_deadline_ns, g_timeline_period_ns;
static int g_timeline_late;
static int64_t g_cadence_seen_ns, g_cadence_gap_ns, g_cadence_target_ns;
static int g_group_frames = 1, g_group_index;
static unsigned g_stat_aimed_next, g_stat_aimed_later, g_stat_aimed_even;
static int g_two_logged;
static AHardwareBuffer *g_blank;
static ASurfaceControl *g_base_sc;
@@ -219,6 +230,58 @@ static int64_t now_ns(void) {
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
}
void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns) {
pthread_mutex_lock(&g_timeline_lock);
g_timeline_present_ns = present_ns;
g_timeline_deadline_ns = deadline_ns;
g_timeline_period_ns = period_ns;
pthread_mutex_unlock(&g_timeline_lock);
}
static int64_t cadence_target(int64_t now, int64_t earliest, int64_t period) {
const int64_t gap = now - g_cadence_seen_ns;
g_cadence_seen_ns = now;
if (gap <= 0 || gap > 8 * period) {
g_cadence_gap_ns = 0;
g_cadence_target_ns = earliest;
return earliest;
}
g_cadence_gap_ns = g_cadence_gap_ns ? (g_cadence_gap_ns * 15 + gap) / 16 : gap;
const int64_t steps = (g_cadence_gap_ns + period / 2) / period;
const int64_t even = g_cadence_target_ns + steps * period;
int64_t target = earliest;
if (steps >= 1 && llabs(g_cadence_gap_ns - steps * period) < period / 8 &&
even > earliest + period / 2 && even < earliest + steps * period + period / 2) {
target = even;
g_stat_aimed_even++;
}
g_cadence_target_ns = target;
return target;
}
static void apply_present_time(ASurfaceTransaction *tx, int game) {
if (!api.setDesiredPresentTime) return;
pthread_mutex_lock(&g_timeline_lock);
const int64_t present = g_timeline_present_ns, deadline = g_timeline_deadline_ns, period = g_timeline_period_ns;
pthread_mutex_unlock(&g_timeline_lock);
const int64_t now = now_ns();
if (period <= 0 || now - deadline > 4 * period) return;
int64_t ahead = now > deadline ? (now - deadline + period - 1) / period : -((deadline - now) / period);
const int64_t slack = deadline + ahead * period - now;
g_timeline_late = slack < (g_timeline_late ? period * 5 / 8 : period / 8);
if (g_timeline_late) { ahead++; g_stat_aimed_later++; } else g_stat_aimed_next++;
int64_t target = present + ahead * period;
if (game && g_group_index > 0) {
int64_t steps = (g_group_index * g_cadence_gap_ns / g_group_frames + period / 2) / period;
if (steps < g_group_index) steps = g_group_index;
if (target < g_cadence_target_ns + steps * period) target = g_cadence_target_ns + steps * period;
} else if (game) {
target = cadence_target(now, target, period);
}
if (game && g_group_frames > 1 && ++g_group_index >= g_group_frames) { g_group_index = 0; g_group_frames = 1; }
api.setDesiredPresentTime(tx, target - period / 2);
}
static void on_complete(void *context, ASurfaceTransactionStats *stats) {
struct complete_ctx *ctx = context;
pthread_mutex_lock(&g_lock);
@@ -401,10 +464,22 @@ static void describe_handle(const struct droiddeck_native_handle *h, char *out,
o += (size_t)snprintf(out + o, n - o, " %#x", (unsigned)h->data[h->numFds + i]);
}
static int handle_fd(const struct droiddeck_native_handle *h, off_t need, int *which) {
for (int i = 0; h && i < h->numFds; i++) {
off_t sz = lseek(h->data[i], 0, SEEK_END);
if (sz >= 0) lseek(h->data[i], 0, SEEK_SET);
if (sz >= need) { if (which) *which = i; return h->data[i]; }
}
return -1;
}
int sc_layer_ahb_fd(AHardwareBuffer *ahb, uint64_t need) {
return load_api() == 0 ? handle_fd(api.getNativeHandle(ahb), (off_t)need, NULL) : -1;
}
static int g_alloc_failed;
enum { TIER_UBWC, TIER_PLAIN, TIER_LINEAR };
#define DROIDDECK_AHB_USAGE_VENDOR_UBWC (1ULL << 28)
static const char *tier_name(int tier) {
return tier == TIER_UBWC ? "asked for UBWC" : tier == TIER_PLAIN ? "no UBWC request" : "linear by request (CPU bit)";
@@ -419,7 +494,7 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
.format = fmt,
.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY |
(tier == TIER_UBWC ? DROIDDECK_AHB_USAGE_VENDOR_UBWC : 0) |
(tier == TIER_UBWC ? SC_LAYER_AHB_USAGE_VENDOR_UBWC : 0) |
(tier == TIER_LINEAR ? AHARDWAREBUFFER_USAGE_CPU_READ_RARELY : 0)};
AHardwareBuffer *ahb = NULL;
if (AHardwareBuffer_allocate(&d, &ahb) != 0 || !ahb) {
@@ -443,6 +518,10 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
img = vkp_image_import_dmabuf(nh->data[0], fmt == AHB_RGB10A2 ? DRM_ABGR2101010 : DRM_ABGR8888, mod, w, h,
got.stride * 4, 0, 1);
path = "dma-buf (QTI handle)";
if (!img && mod == MOD_LINEAR && vkp_can_import_ahb()) {
img = vkp_image_import_ahb(ahb, info, sizeof(info));
if (img) { mod = SC_MOD_GRALLOC; path = "AHardwareBuffer"; }
}
} else {
if (tier == TIER_UBWC) {
char hd[256];
@@ -459,13 +538,8 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
path = "AHardwareBuffer";
img = vkp_image_import_ahb(ahb, info, sizeof(info));
if (!img && tier == TIER_LINEAR) {
const off_t need = (off_t)got.stride * 4 * h;
int fd = -1, which = -1;
for (int i = 0; nh && i < nh->numFds; i++) {
off_t sz = lseek(nh->data[i], 0, SEEK_END);
if (sz >= 0) lseek(nh->data[i], 0, SEEK_SET);
if (sz >= need) { fd = nh->data[i]; which = i; break; }
}
int which = -1;
int fd = handle_fd(nh, (off_t)got.stride * 4 * h, &which);
if (fd < 0 && nh && nh->numFds > 0) { fd = nh->data[0]; which = 0; }
mod = MOD_LINEAR;
path = "linear dma-buf";
@@ -506,16 +580,27 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
return -1;
}
static int fence_signalled(int fd) {
static int fence_wait(int fd, int timeout_ms) {
struct pollfd p = {.fd = fd, .events = POLLIN};
int r;
do { r = poll(&p, 1, 0); } while (r < 0 && errno == EINTR);
return r > 0;
do { r = poll(&p, 1, timeout_ms); } while (r < 0 && errno == EINTR);
return r;
}
static int fence_signalled(int fd) {
return fence_wait(fd, 0) > 0;
}
static void slot_keep_fence(struct slot *s, int fd) {
pthread_mutex_lock(&g_lock);
if (s->release_fd < 0) s->release_fd = fd; else close(fd);
pthread_mutex_unlock(&g_lock);
}
static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait_fd) {
int idx = -1, pending = -1, fd = -1;
*wait_fd = -1;
g_alloc_failed = 0;
pthread_mutex_lock(&g_lock);
for (int i = 0; i < l->pool_n; i++) {
if (i == l->cur_slot || l->slots[i].busy) continue;
@@ -535,15 +620,7 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
memset(s, 0, sizeof(*s)); s->release_fd = -1;
}
if (fd >= 0 && !vkp_can_wait_sync_fd()) {
struct pollfd p = {.fd = fd, .events = POLLIN};
int r;
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
if (r == 0) {
pthread_mutex_lock(&g_lock);
if (s->release_fd < 0) s->release_fd = fd; else close(fd);
pthread_mutex_unlock(&g_lock);
return -1;
}
if (fence_wait(fd, 100) == 0) { slot_keep_fence(s, fd); return -1; }
close(fd);
fd = -1;
}
@@ -558,6 +635,8 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait
int sc_layer_available(void) { return load_api() == 0; }
int sc_layer_queues(void) { return load_api() == 0 && api.setEnableBackPressure != NULL; }
void sc_layer_probe_dmabuf_fd(int fd) {
static int done;
if (done || fd < 0) return;
@@ -595,9 +674,10 @@ static int ensure_sc(struct layer *l) {
return 0;
}
static int layer_geometry(int w, int h, int scene_w, int scene_h, int r[8]) {
static int layer_geometry(int w, int h, int scene_w, int scene_h, const struct vkp_draw *draw, int r[8]) {
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
return vkp_map_rect(w, h, scene_w, scene_h, r) ? 1 : 0;
if (draw) return vkp_map_draw(draw, r) ? 1 : 0;
return vkp_map_rect(w, h, (const int[4]){0, 0, scene_w, scene_h}, r) ? 1 : 0;
}
static ARect g_game_src, g_game_dst;
@@ -757,6 +837,7 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
ASurfaceControl *old = swap_sc_begin(l);
if (old) api.setZOrder(tx, l->sc, l->z);
api.setBuffer(tx, l->sc, s->ahb, -1);
if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true);
api.setBufferTransparency(tx, l->sc,
translucent ? ASC_TRANSPARENCY_TRANSLUCENT : ASC_TRANSPARENCY_OPAQUE);
apply_geometry(tx, l, r);
@@ -769,6 +850,7 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
pthread_mutex_lock(&g_lock);
s->busy = 1;
pthread_mutex_unlock(&g_lock);
apply_present_time(tx, l == &g_layers[SC_LAYER_GAME]);
api.txApply(tx);
api.txDelete(tx);
l->cur_slot = idx;
@@ -799,11 +881,12 @@ unsigned sc_layer_drops_take(void) {
}
int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, void *token, int scene_w, int scene_h,
const struct vkp_draw *draw,
const struct droiddeck_color *color, uint32_t ahb_format) {
struct layer *l = layer_of(SC_LAYER_GAME);
int r[8];
if (!ahb || !token || ensure_sc(l) != 0) goto unavailable;
int g = layer_geometry(w, h, scene_w, scene_h, r);
int g = layer_geometry(w, h, scene_w, scene_h, draw, r);
if (g < 0) goto unavailable;
if (g == 0) { if (acquire_fd >= 0) close(acquire_fd); sc_layer_hide(); return 1; }
if (token == l->cur_token && l->shown && !l->recreate_pending) {
@@ -821,6 +904,7 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
ASurfaceControl *old = swap_sc_begin(l);
if (old) api.setZOrder(tx, l->sc, l->z);
api.setBuffer(tx, l->sc, ahb, acquire_fd);
if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true);
api.setBufferTransparency(tx, l->sc, ASC_TRANSPARENCY_OPAQUE);
apply_geometry(tx, l, r);
apply_frame_rate(tx, l);
@@ -834,6 +918,7 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f;
return -1;
}
apply_present_time(tx, 1);
api.txApply(tx);
api.txDelete(tx);
l->cur_slot = -1;
@@ -848,18 +933,19 @@ unavailable:
return -1;
}
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct droiddeck_color *color) {
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
const struct droiddeck_color *color) {
struct layer *l = layer_of(SC_LAYER_GAME);
if (!src || ensure_sc(l) != 0) return -1;
int sw = vkp_image_width(src), sh = vkp_image_height(src);
int r[8];
int g = layer_geometry(sw, sh, scene_w, scene_h, r);
int g = layer_geometry(sw, sh, scene_w, scene_h, draw, r);
if (g < 0) return -1;
if (g == 0) { sc_layer_hide(); return 0; }
int wait_fd;
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
if (idx < 0) { log_drop(l); return 0; }
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
if (present_slot(l, idx, r, color, 0) != 0) return -1;
if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_LAYER_COPY, AHB_RGBA8);
@@ -879,10 +965,10 @@ int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int
if (!draws || n <= 0 || ensure_sc(l) != 0) return -1;
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
if (vkp_pass_begin(scene_w, scene_h, draws, n, &rw, &rh) != 0) return -1;
if (!vkp_map_rect(rw, rh, scene_w, scene_h, r)) { vkp_pass_abort(); sc_layer_hide(); return 0; }
if (!vkp_map_rect(rw, rh, (const int[4]){0, 0, scene_w, scene_h}, r)) { vkp_pass_abort(); sc_layer_hide(); return 0; }
int wait_fd;
int idx = take_free_slot(l, rw, rh, AHB_RGBA8, &wait_fd);
if (idx < 0) { vkp_pass_abort(); log_drop(l); return 0; }
if (idx < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
if (vkp_pass_copy_to(l->slots[idx].img, wait_fd) != 0) return -1;
if (present_slot(l, idx, r, NULL, 0) != 0) return -1;
if (!l->first_logged) {
@@ -895,8 +981,97 @@ int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int
return 0;
}
static void slots_idle(struct layer *l, const int *idx, int from, int to) {
pthread_mutex_lock(&g_lock);
for (int i = from; i < to; i++) l->slots[idx[i]].busy = 0;
pthread_mutex_unlock(&g_lock);
}
static uint32_t g_hdr_pool_fmt = AHB_RGB10A2;
static int take_hdr_slot(struct layer *l, int w, int h, int *wait_fd) {
int idx = take_free_slot(l, w, h, g_hdr_pool_fmt, wait_fd);
if (idx < 0 && g_alloc_failed && g_hdr_pool_fmt == AHB_RGB10A2) {
g_hdr_pool_fmt = AHB_RGBA8;
droiddeck_log("color", "%s: this device will not make a 10-bit layer buffer (RGBA1010102): the HDR picture goes "
"on 8-bit buffers instead (still tagged BT2020_PQ; less precision)", l->name);
idx = take_free_slot(l, w, h, g_hdr_pool_fmt, wait_fd);
}
return idx;
}
int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const struct vkp_hdr_frame *hf,
int scene_w, int scene_h, int composed, const struct droiddeck_color *color) {
struct layer *l = layer_of(SC_LAYER_GAME);
int rw = 0, rh = 0, r[8], idx[VKP_FG_MAX_GENERATIONS + 1], m = 0, first_fd = -1, have_fd = 0;
struct vkp_image *dst[VKP_FG_MAX_GENERATIONS], *real = NULL;
g_group_index = 0;
g_group_frames = 1;
if (!draws || n_draws <= 0 || ensure_sc(l) != 0) return -1;
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
const int deep = hf && !hf->tonemap;
if (hf) composed = 1;
if (hf && hf->tonemap) color = NULL;
int n = vkp_pass_begin_generate(scene_w, scene_h, draws, n_draws, hf, &rw, &rh);
if (n < 0) return -1;
const int mapped = vkp_map_rect(rw, rh, (const int[4]){0, 0, scene_w, scene_h}, r);
if (!mapped) n = 0;
if (composed) {
if (!mapped) { vkp_pass_abort(); sc_layer_hide(); return 0; }
idx[VKP_FG_MAX_GENERATIONS] = deep ? take_hdr_slot(l, rw, rh, &first_fd)
: take_free_slot(l, rw, rh, AHB_RGBA8, &first_fd);
if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
pthread_mutex_lock(&g_lock);
l->slots[idx[VKP_FG_MAX_GENERATIONS]].busy = 1;
pthread_mutex_unlock(&g_lock);
real = l->slots[idx[VKP_FG_MAX_GENERATIONS]].img;
have_fd = 1;
}
for (; m < n; m++) {
int fd;
idx[m] = take_free_slot(l, rw, rh, deep ? g_hdr_pool_fmt : AHB_RGBA8, &fd);
if (idx[m] < 0) { log_drop(l); break; }
if (have_fd && fd >= 0) {
if (fence_wait(fd, 100) == 0) { slot_keep_fence(&l->slots[idx[m]], fd); log_drop(l); break; }
close(fd);
}
pthread_mutex_lock(&g_lock);
l->slots[idx[m]].busy = 1;
pthread_mutex_unlock(&g_lock);
dst[m] = l->slots[idx[m]].img;
if (!have_fd) { first_fd = fd; have_fd = 1; }
}
if (vkp_pass_copy_generated(dst, m, real, first_fd) != 0) {
slots_idle(l, idx, 0, m);
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
return -1;
}
g_group_frames = m + 1;
for (int k = 0; k < m; k++) {
if (present_slot(l, idx[k], r, color, 0) == 0) continue;
slots_idle(l, idx, k, m);
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
g_group_index = 0;
g_group_frames = 1;
return -1;
}
vkp_framegen_presented(m);
if (real) {
if (present_slot(l, idx[VKP_FG_MAX_GENERATIONS], r, color, 0) != 0) {
slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
g_group_index = 0;
g_group_frames = 1;
return -1;
}
l->first_logged = 1;
vkp_signal_first_frame();
}
if (hf && hf->color && hf->color->dataspace)
droiddeck_color_frame_shown(hf->color, deep ? DROIDDECK_HDR_COMPOSED : DROIDDECK_HDR_TONEMAPPED,
deep ? g_hdr_pool_fmt : AHB_RGBA8);
return m;
}
int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf,
int scene_w, int scene_h, const struct droiddeck_color *color) {
struct layer *l = layer_of(SC_LAYER_GAME);
@@ -904,19 +1079,11 @@ int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct
if (!draws || n <= 0 || !hf || ensure_sc(l) != 0) return -1;
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
if (vkp_pass_begin_hdr(scene_w, scene_h, draws, n, hf, &rw, &rh) != 0) return -1;
if (!vkp_map_rect(rw, rh, scene_w, scene_h, r)) { vkp_pass_abort(); sc_layer_hide(); return 0; }
if (!vkp_map_rect(rw, rh, (const int[4]){0, 0, scene_w, scene_h}, r)) { vkp_pass_abort(); sc_layer_hide(); return 0; }
const int tm = hf->tonemap;
const uint32_t fmt = tm ? AHB_RGBA8 : g_hdr_pool_fmt;
g_alloc_failed = 0;
int wait_fd;
int idx = take_free_slot(l, rw, rh, fmt, &wait_fd);
if (idx < 0 && g_alloc_failed && fmt == AHB_RGB10A2) {
g_hdr_pool_fmt = AHB_RGBA8;
droiddeck_log("color", "%s: this device will not make a 10-bit layer buffer (RGBA1010102): the HDR picture goes "
"on 8-bit buffers instead (still tagged BT2020_PQ; less precision)", l->name);
idx = take_free_slot(l, rw, rh, g_hdr_pool_fmt, &wait_fd);
}
if (idx < 0) { vkp_pass_abort(); log_drop(l); return 0; }
int idx = tm ? take_free_slot(l, rw, rh, AHB_RGBA8, &wait_fd) : take_hdr_slot(l, rw, rh, &wait_fd);
if (idx < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
if (vkp_pass_copy_to(l->slots[idx].img, wait_fd) != 0) return -1;
if (present_slot(l, idx, r, tm ? NULL : color, 0) != 0) return -1;
if (color && color->dataspace)
@@ -967,8 +1134,9 @@ int sc_layer_overlay_affordable(void) {
if (want)
droiddeck_log("layer", "overlay layer declined: this display rotates every layer %d° and the game "
"layer is scaled %dx%d -> %dx%d, and on that combination a second layer drops the "
"whole frame to GPU composition for the rest of the session (measured). The window "
"above the game goes on the copy path instead - same picture, one blit.",
"whole frame to GPU composition for the rest of the session (measured). A nested "
"compositor is asked to compose its own overlays into the game picture; any other "
"window above the game goes on the copy path instead.",
deg, sr[0], sr[1], ds[0], ds[1]);
else if (!first)
droiddeck_log("layer", "overlay layer allowed again: the game layer is no longer both rotated and "
@@ -986,7 +1154,7 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl
if (sw <= 0 || sh <= 0) return -1;
int wait_fd;
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
if (idx < 0) { log_drop(l); return 0; }
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1;
if (!l->first_logged) {
@@ -1033,6 +1201,13 @@ void sc_layer_window_gone(void) {
drain_and_free_pools();
}
void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even) {
*next = g_stat_aimed_next;
*later = g_stat_aimed_later;
*even = g_stat_aimed_even;
g_stat_aimed_next = g_stat_aimed_later = g_stat_aimed_even = 0;
}
unsigned sc_layer_frames_take(void) {
unsigned n = g_stat_layer_frames;
g_stat_layer_frames = 0;
+12 -3
View File
@@ -7,10 +7,13 @@
struct vkp_image;
struct vkp_draw;
struct droiddeck_color;
struct vkp_hdr_frame;
enum sc_layer_id { SC_LAYER_GAME = 0, SC_LAYER_OVERLAY = 1, SC_LAYER_COUNT = 2 };
int sc_layer_available(void);
#define SC_LAYER_AHB_USAGE_VENDOR_UBWC (1ULL << 28)
int sc_layer_ahb_fd(AHardwareBuffer *ahb, uint64_t need);
void sc_layer_probe_dmabuf_fd(int fd);
@@ -18,21 +21,25 @@ int sc_layer_can_tag_hdr(void);
void sc_layer_hdr_symbols(char *out, size_t size);
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct droiddeck_color *color);
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
const struct droiddeck_color *color);
int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int scene_h);
int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const struct vkp_hdr_frame *hf,
int scene_w, int scene_h, int composed, const struct droiddeck_color *color);
struct vkp_hdr_frame;
int sc_layer_present_hdr_scene(const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf,
int scene_w, int scene_h, const struct droiddeck_color *color);
int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, void *token,
int scene_w, int scene_h, const struct droiddeck_color *color, uint32_t ahb_format);
int scene_w, int scene_h, const struct vkp_draw *draw, const struct droiddeck_color *color, uint32_t ahb_format);
void sc_layer_set_frame_rate(float fps);
int sc_layer_overlay_affordable(void);
int sc_layer_queues(void);
int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent);
void sc_layer_hide(void);
@@ -42,6 +49,8 @@ void sc_layer_hide_overlay(void);
void sc_layer_window_gone(void);
void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns);
void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even);
unsigned sc_layer_frames_take(void);
unsigned sc_layer_drops_take(void);
@@ -0,0 +1,61 @@
#ifndef VK_LINEAR_DMABUF_H
#define VK_LINEAR_DMABUF_H
#include <stdint.h>
#include <vulkan/vulkan.h>
static inline int vkp_linear_dmabuf_through_buffer(int drm_modifiers, uint64_t modifier, int blit_dst) {
return !drm_modifiers && modifier == 0 && !blit_dst;
}
static inline int vkp_linear_dmabuf_foreign_image(int dmabuf, int staged) {
return dmabuf && !staged;
}
static inline VkPipelineStageFlags vkp_linear_dmabuf_readback_stage(int in_general) {
return in_general ? VK_PIPELINE_STAGE_TRANSFER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
}
static inline VkAccessFlags vkp_linear_dmabuf_readback_access(int in_general) {
return in_general ? VK_ACCESS_TRANSFER_WRITE_BIT : 0;
}
static inline uint32_t vkp_linear_dmabuf_texel_bytes(VkFormat fmt) {
return fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? 8u : 4u;
}
static inline int vkp_padded_linear_target_needs_layout(int drm_modifiers, uint64_t modifier, VkFormat fmt,
int w, uint32_t stride, uint32_t offset) {
return !drm_modifiers && modifier == 0 &&
(offset != 0 || (uint64_t)stride != (uint64_t)w * vkp_linear_dmabuf_texel_bytes(fmt));
}
static inline VkDeviceSize vkp_linear_dmabuf_copy(VkFormat fmt, int w, int h, uint32_t stride, uint32_t offset,
VkBufferImageCopy *copy) {
const uint32_t texel = vkp_linear_dmabuf_texel_bytes(fmt);
if (!copy || w <= 0 || h <= 0 || stride % texel || offset % texel || stride / texel < (uint32_t)w) return 0;
*copy = (VkBufferImageCopy){
.bufferOffset = offset,
.bufferRowLength = stride / texel,
.bufferImageHeight = (uint32_t)h,
.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.imageExtent = {(uint32_t)w, (uint32_t)h, 1},
};
return (VkDeviceSize)offset + (VkDeviceSize)stride * (VkDeviceSize)(h - 1) + (VkDeviceSize)w * texel;
}
static inline VkBufferMemoryBarrier vkp_linear_dmabuf_ownership(VkBuffer buffer, uint32_t queue_family,
VkAccessFlags access, int acquire) {
return (VkBufferMemoryBarrier){
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
.srcAccessMask = acquire ? 0 : access,
.dstAccessMask = acquire ? access : 0,
.srcQueueFamilyIndex = acquire ? VK_QUEUE_FAMILY_FOREIGN_EXT : queue_family,
.dstQueueFamilyIndex = acquire ? queue_family : VK_QUEUE_FAMILY_FOREIGN_EXT,
.buffer = buffer,
.offset = 0,
.size = VK_WHOLE_SIZE,
};
}
#endif
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <android/log.h>
#include <string.h>
#define TAG "DroidDeckWayland"
@@ -45,6 +46,13 @@ int vk_loader_open(const char *driver_path, const char *library_name,
return g_vk.CreateInstance ? 0 : -1;
}
void vk_loader_close(void) {
if (g_handle) dlclose(g_handle);
g_handle = NULL;
g_gip = NULL;
memset(&g_vk, 0, sizeof(g_vk));
}
PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return g_gip; }
void vk_loader_load_instance(VkInstance instance) {
+5 -2
View File
@@ -6,7 +6,7 @@
#define VK_GLOBAL_FUNCS(X) X(CreateInstance) X(EnumerateInstanceExtensionProperties)
#define VK_INSTANCE_FUNCS(X) \
X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
X(DestroyInstance) X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
X(GetPhysicalDeviceQueueFamilyProperties) X(GetPhysicalDeviceSurfaceSupportKHR) \
X(GetPhysicalDeviceSurfaceCapabilitiesKHR) X(GetPhysicalDeviceSurfaceFormatsKHR) \
X(CreateAndroidSurfaceKHR) X(DestroySurfaceKHR) X(CreateDevice) \
@@ -22,7 +22,9 @@
X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) X(GetAndroidHardwareBufferPropertiesANDROID) \
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) \
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) X(CmdCopyImageToBuffer) \
X(CreateBuffer) X(DestroyBuffer) X(GetBufferMemoryRequirements) X(BindBufferMemory) \
X(CmdCopyBufferToImage) \
\
X(CreateShaderModule) X(DestroyShaderModule) X(CreatePipelineLayout) X(DestroyPipelineLayout) \
X(CreateGraphicsPipelines) X(DestroyPipeline) X(CreateRenderPass) X(DestroyRenderPass) \
@@ -43,6 +45,7 @@ extern struct vk_api g_vk;
int vk_loader_open(const char *driver_path, const char *library_name,
const char *native_lib_dir);
void vk_loader_close(void);
void vk_loader_load_instance(VkInstance instance);
void vk_loader_load_device(VkDevice device);
PFN_vkGetInstanceProcAddr vk_loader_gipa(void);
+344 -78
View File
@@ -2,6 +2,7 @@
#include "vk_present.h"
#include "vk_loader.h"
#include "vk_external_image_sync.h"
#include "vk_linear_dmabuf.h"
#include "sc_layer.h"
#include "effects_chain.h"
#include "cardboard.h"
@@ -13,6 +14,7 @@
#include "quest_device.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sys/system_properties.h>
#include <unistd.h>
@@ -41,11 +43,17 @@ struct vkp_image {
VkFormat fmt;
int sampled;
AHardwareBuffer *android_buffer;
int staged;
VkBuffer linear_buf;
VkDeviceMemory linear_mem;
VkBufferImageCopy linear_copy;
};
static ANativeWindow *g_window;
static int g_ahb_import;
static int g_drm_modifiers;
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
static int g_allow_driver_fallback;
static int g_dev_state;
static void device_lost(const char *where);
static const char *vk_result_name(VkResult r);
@@ -250,6 +258,8 @@ void vk_present_set_driver(const char *driver_path, const char *library_name,
g_native_lib_dir = native_lib_dir ? strdup(native_lib_dir) : NULL;
}
void vk_present_set_driver_fallback(int allow) { g_allow_driver_fallback = allow; }
static void reset_sync(void) {
VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO};
for (int k = 0; k < MAX_PRESENTS; k++) {
@@ -413,8 +423,13 @@ static void update_map(int scene_w, int scene_h) {
if (mode == VKP_MODE_FILL) aspect = sx > sy ? sx : sy;
else if (mode == VKP_MODE_INTEGER) {
float m = sx < sy ? sx : sy;
aspect = (float)(int)m;
if (aspect < 1.0f) aspect = 1.0f;
float nearest = roundf(m);
if (nearest >= 1.0f && nearest > m &&
nearest - m < 0.15f) {
aspect = nearest;
} else {
aspect = m >= 1.0f ? (float)(int)m : m;
}
} else aspect = sx < sy ? sx : sy;
g_map.kx = g_map.ky = aspect;
g_map.off_x = (float)(g_map.rx + (int)((g_map.rw - scene_w * aspect) * 0.5f));
@@ -426,7 +441,7 @@ static void update_map(int scene_w, int scene_h) {
else if (align == VKP_ALIGN_PICTURE_RIGHT) g_map.off_x = W - scene_w * g_map.kx;
g_map.valid = 1;
pthread_mutex_lock(&g_game_picture_lock);
g_game_picture_placed = align == VKP_ALIGN_PICTURE_TOP || align == VKP_ALIGN_PICTURE_BOTTOM || align == VKP_ALIGN_PICTURE_LEFT || align == VKP_ALIGN_PICTURE_RIGHT;
g_game_picture_placed = mode == VKP_MODE_INTEGER || align == VKP_ALIGN_PICTURE_TOP || align == VKP_ALIGN_PICTURE_BOTTOM || align == VKP_ALIGN_PICTURE_LEFT || align == VKP_ALIGN_PICTURE_RIGHT;
g_game_picture_rect[0] = g_map.off_x;
g_game_picture_rect[1] = g_map.off_y;
g_game_picture_rect[2] = g_map.off_x + scene_w * g_map.kx;
@@ -549,6 +564,18 @@ static int dev_init(void) {
uint32_t npd = 0;
g_vk.EnumeratePhysicalDevices(g_inst, &npd, NULL);
if (!npd) {
if (g_allow_driver_fallback && g_driver_path && g_library_name) {
LOGE("present: display driver exposed no physical devices; retrying the system Vulkan driver");
g_vk.DestroyInstance(g_inst, NULL);
g_inst = VK_NULL_HANDLE;
vk_loader_close();
free(g_driver_path); g_driver_path = NULL;
free(g_library_name); g_library_name = NULL;
g_allow_driver_fallback = 0;
g_colorspace_ext = 0;
g_dev_state = 0;
return dev_init();
}
LOGE("present: no physical devices"); g_dev_state = -1;
set_fault("the display driver exposed no GPU to the app");
return -1;
@@ -607,6 +634,7 @@ static int dev_init(void) {
if (has_ext(exts, ne, import_exts[i])) dev_exts[n_dev_exts++] = import_exts[i];
else LOGE("present: driver MISSING %s (dmabuf import will fail)", import_exts[i]);
}
g_drm_modifiers = has_ext(exts, ne, "VK_EXT_image_drm_format_modifier");
int want_hdr_md = 0;
if (droiddeck_color_requested()) {
want_hdr_md = has_ext(exts, ne, VK_EXT_HDR_METADATA_EXTENSION_NAME);
@@ -1067,6 +1095,10 @@ struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t mo
return vkp_image_import_dmabuf(fd, drm_format, modifier, w, h, stride, offset, 0);
}
static int foreign_image(const struct vkp_image *img) {
return vkp_linear_dmabuf_foreign_image(img->dmabuf, img->staged);
}
/* Return client sources to FOREIGN after their final read. The consuming paths
* wait for our fence before Wayland can release an ordinary dma-buf or an
* android_wlegl AHardwareBuffer. Producer-fence synchronization is separate from
@@ -1074,7 +1106,7 @@ struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t mo
static void release_external_client_image(VkCommandBuffer cmd, struct vkp_image *img) {
struct vkp_external_client_barrier_pair pair;
if (!img || !vkp_external_client_barrier_pair(
img->image, g_qfam, img->dmabuf, img->blit_dst, &pair))
img->image, g_qfam, foreign_image(img), img->blit_dst, &pair))
return;
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &pair.release);
@@ -1088,6 +1120,37 @@ static void release_external_client_draws(VkCommandBuffer cmd, const struct vkp_
}
}
static void stage_linear_dmabuf(VkCommandBuffer cmd, const struct vkp_image *img) {
if (!img || !img->linear_buf) return;
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkBufferMemoryBarrier acquire = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, VK_ACCESS_TRANSFER_READ_BIT, 1);
VkImageMemoryBarrier write = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = img->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
0, NULL, 1, &acquire, 1, &write);
g_vk.CmdCopyBufferToImage(cmd, img->linear_buf, img->image, VK_IMAGE_LAYOUT_GENERAL, 1, &img->linear_copy);
VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, VK_ACCESS_TRANSFER_READ_BIT, 0);
VkImageMemoryBarrier read = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = img->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0,
0, NULL, 1, &release, 1, &read);
}
static void stage_linear_dmabufs(VkCommandBuffer cmd, const struct vkp_draw *draws, int count) {
for (int i = 0; i < count; i++) {
int seen = 0;
for (int j = 0; j < i; j++) if (draws[j].img == draws[i].img) { seen = 1; break; }
if (!seen) stage_linear_dmabuf(cmd, draws[i].img);
}
}
int vkp_image_is_dmabuf(const struct vkp_image *img) {
return img && vkp_is_external_client_image(img->dmabuf, img->blit_dst);
}
@@ -1160,18 +1223,122 @@ fail:
return NULL;
}
static int optimal_sampled(VkFormat fmt) {
if (!g_vk.GetPhysicalDeviceFormatProperties2) return 0;
VkFormatProperties2 fp = {.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2};
g_vk.GetPhysicalDeviceFormatProperties2(g_pd, fmt, &fp);
const VkFormatFeatureFlags need = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
return (fp.formatProperties.optimalTilingFeatures & need) == need;
}
static void destroy_image_objects(struct vkp_image *img) {
if (img->image) g_vk.DestroyImage(g_dev, img->image, NULL);
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
if (img->linear_buf) g_vk.DestroyBuffer(g_dev, img->linear_buf, NULL);
if (img->linear_mem) g_vk.FreeMemory(g_dev, img->linear_mem, NULL);
img->image = VK_NULL_HANDLE; img->mem = VK_NULL_HANDLE;
img->linear_buf = VK_NULL_HANDLE; img->linear_mem = VK_NULL_HANDLE;
img->staged = 0; img->in_general = 0;
}
static int import_linear_dmabuf(struct vkp_image *img, int fd, const VkBufferImageCopy *copy, VkDeviceSize need) {
int dupfd = dup(fd);
if (dupfd < 0) return -1;
VkDeviceSize size = need;
off_t end = lseek(dupfd, 0, SEEK_END);
if (end > 0 && (VkDeviceSize)end >= need) size = (VkDeviceSize)end;
lseek(dupfd, 0, SEEK_SET);
if (end > 0 && (VkDeviceSize)end < need) {
LOGE("dmabuf: the linear %dx%d buffer holds %lld bytes, its row pitch needs %llu", img->w, img->h,
(long long)end, (unsigned long long)need);
close(dupfd);
return -1;
}
VkExternalMemoryBufferCreateInfo ext = {
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT};
VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = &ext, .size = size,
.usage = img->blit_dst ? VK_BUFFER_USAGE_TRANSFER_DST_BIT : VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE};
VkResult r = g_vk.CreateBuffer(g_dev, &bci, NULL, &img->linear_buf);
if (r != VK_SUCCESS) goto fail;
uint32_t allowed = 0xffffffff;
if (g_vk.GetMemoryFdPropertiesKHR) {
VkMemoryFdPropertiesKHR fp = {.sType = VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR};
if (g_vk.GetMemoryFdPropertiesKHR(g_dev, VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
dupfd, &fp) == VK_SUCCESS)
allowed = fp.memoryTypeBits;
}
VkMemoryRequirements breq;
g_vk.GetBufferMemoryRequirements(g_dev, img->linear_buf, &breq);
int bidx = memory_type(breq.memoryTypeBits & allowed, 0);
r = VK_ERROR_FORMAT_NOT_SUPPORTED;
if (bidx < 0) goto fail;
VkImportMemoryFdInfoKHR imp = {.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, .fd = dupfd};
VkMemoryDedicatedAllocateInfo ded = {.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
.pNext = &imp, .buffer = img->linear_buf};
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &ded,
.allocationSize = breq.size, .memoryTypeIndex = (uint32_t)bidx};
r = g_vk.AllocateMemory(g_dev, &mai, NULL, &img->linear_mem);
if (r != VK_SUCCESS) goto fail;
dupfd = -1;
r = g_vk.BindBufferMemory(g_dev, img->linear_buf, img->linear_mem, 0);
if (r != VK_SUCCESS) goto fail;
VkImageCreateInfo ici = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, .format = img->fmt,
.extent = {(uint32_t)img->w, (uint32_t)img->h, 1}, .mipLevels = 1, .arrayLayers = 1,
.samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
(img->sampled ? VK_IMAGE_USAGE_SAMPLED_BIT : 0),
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
r = g_vk.CreateImage(g_dev, &ici, NULL, &img->image);
if (r != VK_SUCCESS) goto fail;
VkMemoryRequirements ireq;
g_vk.GetImageMemoryRequirements(g_dev, img->image, &ireq);
int iidx = memory_type(ireq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
if (iidx < 0) iidx = memory_type(ireq.memoryTypeBits, 0);
r = VK_ERROR_FORMAT_NOT_SUPPORTED;
if (iidx < 0) goto fail;
VkMemoryAllocateInfo iai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = ireq.size, .memoryTypeIndex = (uint32_t)iidx};
r = g_vk.AllocateMemory(g_dev, &iai, NULL, &img->mem);
if (r != VK_SUCCESS) goto fail;
r = g_vk.BindImageMemory(g_dev, img->image, img->mem, 0);
if (r != VK_SUCCESS) goto fail;
img->linear_copy = *copy;
img->staged = 1;
img->in_general = 1;
return 0;
fail:
LOGE("dmabuf: %s the linear %dx%d buffer at its row pitch failed (%s)",
img->blit_dst ? "writing" : "reading", img->w, img->h, vk_result_name(r));
if (dupfd >= 0) close(dupfd);
destroy_image_objects(img);
return -1;
}
struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier, int w, int h,
uint32_t stride, uint32_t offset, int as_blit_dst) {
if (modifier == MOD_INVALID || w <= 0 || h <= 0) return NULL;
if (dev_init() != 0) return NULL;
const VkFormat format = drm_to_vk(drm_format);
const int padded_target = as_blit_dst &&
vkp_padded_linear_target_needs_layout(g_drm_modifiers, modifier, format, w, stride, offset);
if (padded_target && !g_vk.CmdCopyImageToBuffer) return NULL;
struct vkp_image *img = calloc(1, sizeof(*img));
if (!img) return NULL;
img->w = w; img->h = h; img->dmabuf = 1; img->blit_dst = as_blit_dst ? 1 : 0;
img->fmt = drm_to_vk(drm_format);
img->fmt = format;
const int through_buffer = padded_target || vkp_linear_dmabuf_through_buffer(g_drm_modifiers, modifier, as_blit_dst);
const VkImageUsageFlags sampled_usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
img->sampled = !as_blit_dst && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
modifier_importable(img->fmt, modifier, sampled_usage);
const int modifier_sampled = !as_blit_dst && g_drm_modifiers && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
modifier_importable(img->fmt, modifier, sampled_usage);
img->sampled = !as_blit_dst && (through_buffer ? optimal_sampled(img->fmt) : modifier_sampled);
/* Each new format/modifier/size a client hands over, once, for the graphics report: a colour
* or swizzle mismatch on a non-Adreno driver shows up as the pair it arrived as. */
{
@@ -1182,10 +1349,11 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
if (seen[i].fmt == drm_format && seen[i].mod == modifier && seen[i].w == w && seen[i].h == h) known = 1;
if (!known && nseen < 32) {
seen[nseen].fmt = drm_format; seen[nseen].mod = modifier; seen[nseen].w = w; seen[nseen].h = h; nseen++;
droiddeck_log("gpu", "dmabuf import: %c%c%c%c %s %dx%d stride %u offset %u -> vk format %d, %s%s",
droiddeck_log("gpu", "dmabuf import: %c%c%c%c %s %dx%d stride %u offset %u -> vk format %d, %s%s%s",
drm_format & 0xff, (drm_format >> 8) & 0xff, (drm_format >> 16) & 0xff, (drm_format >> 24) & 0xff,
vkp_modifier_name(modifier), w, h, stride, offset, (int)img->fmt,
img->sampled ? "sampled" : "copied", as_blit_dst ? ", blit target" : "");
img->sampled ? "sampled" : "copied", as_blit_dst ? ", blit target" : "",
through_buffer ? ", trying a copy at its row pitch (no VK_EXT_image_drm_format_modifier)" : "");
}
}
@@ -1193,6 +1361,17 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
* vkCreateImage, which left the whole window unshown (David Cimo). One packed, 64-byte aligned
* row is what a linear buffer that small holds. */
if (stride == 0 && modifier == 0) stride = ((uint32_t)w * 4 + 63) & ~63u;
if (through_buffer) {
VkBufferImageCopy linear_copy;
const VkDeviceSize linear_size = vkp_linear_dmabuf_copy(img->fmt, w, h, stride, offset, &linear_copy);
if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) {
if (padded_target) droiddeck_log("gpu", "linear layer target %dx%d writes at pitch %u via DMA-BUF",
w, h, stride);
return img;
}
if (padded_target) { free(img); return NULL; }
img->sampled = modifier_sampled;
}
VkSubresourceLayout plane = {.offset = offset, .rowPitch = stride};
VkImageDrmFormatModifierExplicitCreateInfoEXT modInfo = {
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
@@ -1480,8 +1659,7 @@ void vkp_image_destroy(struct vkp_image *img) {
if (g_dev) {
blendp_forget_image(img->image);
if (img->map) g_vk.UnmapMemory(g_dev, img->mem);
if (img->image) g_vk.DestroyImage(g_dev, img->image, NULL);
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
destroy_image_objects(img);
}
if (img->android_buffer) AHardwareBuffer_release(img->android_buffer);
free(img);
@@ -1579,7 +1757,7 @@ static void effects_source_note(int scene_w, int scene_h, const struct vkp_draw
static void record_draw(VkCommandBuffer cmd, const struct vkp_draw *d, const VkImageBlit *blit, VkImage target,
VkFormat target_fmt, int target_w, int target_h, VkFilter filter) {
const struct vkp_image *im = d->img;
const int external_client = vkp_image_is_dmabuf(im);
const int external_client = vkp_is_external_client_image(foreign_image(im), im->blit_dst);
if (d->blend && im->sampled &&
blendp_draw(cmd, im->image, im->fmt, im->w, im->h, !external_client,
target, target_fmt, target_w, target_h,
@@ -1713,6 +1891,11 @@ static int compose_hdr(VkCommandBuffer cmd, const struct vkp_draw *draws, int n,
struct hdrc_params p = {.mode = mode, .sdr_white_nits = droiddeck_color_sdr_white(),
.peak_nits = hf->peak_nits > 0.0f ? hf->peak_nits : 1000.0f};
if (hf->convert) {
p.conv_linear = hf->convert->convert == 2;
p.conv_gain = hf->convert->gain;
memcpy(p.conv, hf->convert->to2020, sizeof(p.conv));
}
int lowest_hdr = -1;
for (int i = 0; i < n; i++) {
VkImageBlit blit;
@@ -1729,6 +1912,7 @@ static int compose_hdr(VkCommandBuffer cmd, const struct vkp_draw *draws, int n,
p.rects[p.count][0] = (float)blit.dstOffsets[0].x; p.rects[p.count][1] = (float)blit.dstOffsets[0].y;
p.rects[p.count][2] = (float)blit.dstOffsets[1].x; p.rects[p.count][3] = (float)blit.dstOffsets[1].y;
if (hf->is_hdr[i]) p.hdr_mask |= 1u << p.count;
if (hf->is_hdr[i] == 2 && hf->convert) p.conv_mask |= 1u << p.count;
p.count++;
}
if (i >= lowest_hdr && !truncated_said) {
@@ -1985,7 +2169,9 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
1 + vkp_framegen_extra_images(), vkp_framegen_extra_images() ? "s" : "");
destroy_swapchain();
}
const int want_hdr = hf && !hf->tonemap && g_colorspace_ext && !g_swap_hdr_unavailable;
/* A black refresh carries no HDR frame; it keeps the swapchain's colour mode rather than flipping it. */
const int want_hdr = (g_plain_frame && !hf) ? (g_swapchain && g_swap_is_hdr)
: (hf && !hf->tonemap && g_colorspace_ext && !g_swap_hdr_unavailable);
if (g_swapchain && want_hdr != g_swap_is_hdr) {
droiddeck_log("color", want_hdr ? "HDR frames with frame generation: rebuilding the screen swapchain as HDR10"
: hf ? "HDR output switched off: rebuilding the screen swapchain as SDR (frames tone-mapped)"
@@ -2061,6 +2247,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
g_vk.BeginCommandBuffer(cmd, &bi);
blendp_begin_frame();
stage_linear_dmabufs(cmd, draws, n);
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkImageMemoryBarrier *bars = calloc((size_t)n + 1, sizeof(*bars));
@@ -2078,7 +2265,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
if (seen || !im) continue;
struct vkp_external_client_barrier_pair pair;
if (vkp_external_client_barrier_pair(
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
im->image, g_qfam, foreign_image(im), im->blit_dst, &pair)) {
bars[nb++] = pair.acquire;
} else if (!im->blit_dst && !im->in_general) {
bars[nb++] = (VkImageMemoryBarrier){
@@ -2156,7 +2343,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
VkImageLayout result_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
if (fx) {
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
if (fg) { mapped_w = scene_w; mapped_h = scene_h; }
if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
vkp_effects_set_formats(scene_fmt, scene_fmt);
result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh);
effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h,
@@ -2330,9 +2517,9 @@ int vkp_update_map(int scene_w, int scene_h) {
return g_map.valid ? 0 : -1;
}
int vkp_map_rect(int img_w, int img_h, int scene_w, int scene_h, int out[8]) {
int vkp_map_rect(int img_w, int img_h, const int dst[4], int out[8]) {
struct vkp_image tmp = {.w = img_w, .h = img_h};
struct vkp_draw d = {&tmp, 0, 0, (float)img_w, (float)img_h, 0, 0, scene_w, scene_h};
struct vkp_draw d = {&tmp, 0, 0, (float)img_w, (float)img_h, dst[0], dst[1], dst[2], dst[3]};
return vkp_map_draw(&d, out);
}
@@ -2346,6 +2533,48 @@ int vkp_map_draw(const struct vkp_draw *d, int out[8]) {
return 1;
}
static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_layout, struct vkp_image *dst,
const VkImageBlit *blit, VkFilter filter) {
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
const VkImageMemoryBarrier acquire = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.srcQueueFamilyIndex = dst->staged ? VK_QUEUE_FAMILY_IGNORED : VK_QUEUE_FAMILY_FOREIGN_EXT,
.dstQueueFamilyIndex = dst->staged ? VK_QUEUE_FAMILY_IGNORED : g_qfam,
.image = dst->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, 0, NULL, 0, NULL, 1, &acquire);
g_vk.CmdBlitImage(cmd, src, src_layout, dst->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, blit, filter);
if (dst->staged) {
const VkImageMemoryBarrier read = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = dst->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, 0, NULL, 0, NULL, 1, &read);
const VkBufferMemoryBarrier write = vkp_linear_dmabuf_ownership(dst->linear_buf, g_qfam, VK_ACCESS_TRANSFER_WRITE_BIT, 1);
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, 0, NULL, 1, &write, 0, NULL);
VkBufferImageCopy copy = dst->linear_copy;
copy.imageExtent.width = (uint32_t)blit->dstOffsets[1].x;
copy.imageExtent.height = (uint32_t)blit->dstOffsets[1].y;
g_vk.CmdCopyImageToBuffer(cmd, dst->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->linear_buf, 1, &copy);
const VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(dst->linear_buf, g_qfam, VK_ACCESS_TRANSFER_WRITE_BIT, 0);
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
0, 0, NULL, 1, &release, 0, NULL);
return;
}
const VkImageMemoryBarrier release = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
0, 0, NULL, 0, NULL, 1, &release);
}
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
if (!src || src->blit_dst || !dst || !dst->blit_dst || g_dev_state == -2 || dev_init() != 0) {
if (wait_fd >= 0) close(wait_fd);
@@ -2360,44 +2589,32 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
g_vk.BeginCommandBuffer(g_cmd, &bi);
stage_linear_dmabuf(g_cmd, src);
struct vkp_external_client_barrier_pair src_pair;
const int src_external = vkp_external_client_barrier_pair(
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
VkImageMemoryBarrier acq[2] = {
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .dstQueueFamilyIndex = g_qfam,
.image = dst->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT}};
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
if (!src_external) {
acq[0].oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
acq[0].newLayout = VK_IMAGE_LAYOUT_GENERAL;
acq[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
acq.newLayout = VK_IMAGE_LAYOUT_GENERAL;
acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
src->in_general = 1;
}
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 2, acq);
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq);
int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h;
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.srcOffsets = {{0, 0, 0}, {bw, bh, 1}},
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.dstOffsets = {{0, 0, 0}, {bw, bh, 1}}};
g_vk.CmdBlitImage(g_cmd, src->image,
src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
dst->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_NEAREST);
blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
dst, &blit, VK_FILTER_NEAREST);
release_external_client_image(g_cmd, src);
VkImageMemoryBarrier rel = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
0, 0, NULL, 0, NULL, 1, &rel);
g_vk.EndCommandBuffer(g_cmd);
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
@@ -2466,22 +2683,26 @@ int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) {
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
g_vk.BeginCommandBuffer(cmd, &bi);
stage_linear_dmabuf(cmd, src);
struct vkp_external_client_barrier_pair src_pair;
const int src_external = vkp_external_client_barrier_pair(
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
VkImageMemoryBarrier acq[2] = {
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
.image = src->image, .subresourceRange = range,
.srcAccessMask = vkp_linear_dmabuf_readback_access(src->in_general),
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = g_rb->image, .subresourceRange = range,
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT}};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, 0, NULL, 0, NULL, 2, acq);
g_vk.CmdPipelineBarrier(cmd, vkp_linear_dmabuf_readback_stage(src->in_general),
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 2, acq);
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.srcOffsets = {{0, 0, 0}, {src->w, src->h, 1}},
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
@@ -2528,24 +2749,33 @@ static struct {
int active;
VkImage result;
int rw, rh;
int ngen;
VkImage gens[VKP_FG_MAX_GENERATIONS];
} g_pass;
static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *rw, int *rh);
const struct vkp_hdr_frame *hf, int generate, int *rw, int *rh);
int vkp_pass_begin(int scene_w, int scene_h, const struct vkp_draw *draws, int n, int *rw, int *rh) {
return pass_begin_impl(scene_w, scene_h, draws, n, NULL, rw, rh);
return pass_begin_impl(scene_w, scene_h, draws, n, NULL, 0, rw, rh);
}
int vkp_pass_begin_generate(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *rw, int *rh) {
if (pass_begin_impl(scene_w, scene_h, draws, n, hf, 1, rw, rh) != 0) return -1;
return g_pass.ngen;
}
int vkp_pass_begin_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *rw, int *rh) {
if (!hf) return -1;
return pass_begin_impl(scene_w, scene_h, draws, n, hf, rw, rh);
return pass_begin_impl(scene_w, scene_h, draws, n, hf, 0, rw, rh);
}
static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *rw, int *rh) {
const struct vkp_hdr_frame *hf, int generate, int *rw, int *rh) {
if (g_pass.active) vkp_pass_abort();
g_pass.ngen = 0;
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
int input_w = scene_w, input_h = scene_h;
int pass_n = n, overlay_start = n;
@@ -2565,13 +2795,31 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
effects_source_note(scene_w, scene_h, draws, n, input_w, input_h,
(int)(scene_w * g_map.kx + 0.5f), (int)(scene_h * g_map.ky + 0.5f));
}
if (hf) {
const int deep = hf && generate && !hf->tonemap && vkp_framegen_format_ok(FG_HDR_FMT) &&
ensure_img(&g_fgscene, scene_w, scene_h, FG_HDR_FMT,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
"HDR frame generation (scene)") == 0;
const int narrow = hf && generate && !deep;
if (hf && !deep && !narrow) {
if (ensure_img(&g_hdrscene, scene_w, scene_h, HDR_FMT,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
"HDR composition (picture)") != 0)
return -1;
} else if (ensure_scene_image(input_w, input_h) != 0) return -1;
} else if (!deep && ensure_scene_image(input_w, input_h) != 0) return -1;
const VkFormat scene_fmt = deep ? FG_HDR_FMT : narrow || !hf ? SCENE_FMT : HDR_FMT;
if (hf && generate) {
static int said = -1;
if (said != deep + 2 * hf->tonemap) {
said = deep + 2 * hf->tonemap;
droiddeck_log("color", hf->tonemap
? "frame generation runs on the tone-mapped picture in 8 bits, onto the game's display layer"
: deep ? "frame generation runs on the HDR picture in FP16 (RGBA16F), onto the game's display layer"
: "frame generation runs on the HDR picture in 8 bits (the engine cannot take FP16 here), onto "
"the game's display layer: banding possible in smooth gradients");
}
}
VkCommandBuffer cmd = g_cmds[0];
g_vk.ResetCommandBuffer(cmd, 0);
@@ -2579,12 +2827,13 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
g_vk.BeginCommandBuffer(cmd, &bi);
blendp_begin_frame();
stage_linear_dmabufs(cmd, draws, n);
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkImageMemoryBarrier *bars = calloc((size_t)n + 1, sizeof(*bars));
if (!bars) { g_vk.EndCommandBuffer(cmd); return -1; }
int nb = 0;
VkImage scene_img = hf ? g_hdrscene.img : g_scene.img;
VkImage scene_img = deep ? g_fgscene.img : narrow || !hf ? g_scene.img : g_hdrscene.img;
bars[nb++] = (VkImageMemoryBarrier){
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
@@ -2597,7 +2846,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
if (seen || !im) continue;
struct vkp_external_client_barrier_pair pair;
if (vkp_external_client_barrier_pair(
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
im->image, g_qfam, foreign_image(im), im->blit_dst, &pair)) {
bars[nb++] = pair.acquire;
} else if (!im->blit_dst && !im->in_general) {
bars[nb++] = (VkImageMemoryBarrier){
@@ -2615,12 +2864,12 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
free(bars);
if (hf) {
if (compose_hdr(cmd, draws, n, hf, scene_w, scene_h, g_hdrscene.img, HDR_FMT,
if (compose_hdr(cmd, draws, n, hf, scene_w, scene_h, scene_img, scene_fmt,
hf->tonemap ? HDRC_OUT_SDR : HDRC_OUT_PQ) != 0) {
g_vk.EndCommandBuffer(cmd);
return -1;
}
if (vkp_effects_active()) vkp_effects_set_formats(HDR_FMT, HDR_FMT);
if (vkp_effects_active()) vkp_effects_set_formats(scene_fmt, scene_fmt);
} else {
VkClearColorValue black = {.float32 = {0.0f, 0.0f, 0.0f, 1.0f}};
g_vk.CmdClearColorImage(cmd, g_scene.img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &black, 1, &range);
@@ -2639,53 +2888,57 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
}
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
if (generate && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
g_pass.rw = input_w; g_pass.rh = input_h;
g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h,
&g_pass.rw, &g_pass.rh);
effects_overlay_draws(cmd, g_pass.result, g_pass.rw, g_pass.rh, scene_w, scene_h,
draws ? draws + overlay_start : NULL, n - overlay_start);
release_external_client_draws(cmd, draws, n);
if (generate) {
VkImageMemoryBarrier b = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = g_pass.result, .subresourceRange = range,
.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT,
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
0, 0, NULL, 0, NULL, 1, &b);
int ngen = vkp_framegen_run(cmd, g_pass.result, VK_NULL_HANDLE, g_pass.rw, g_pass.rh, scene_fmt, g_pass.gens);
if (ngen < 0) ngen = 0;
g_pass.ngen = ngen > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : ngen;
}
g_pass.active = 1;
if (rw) *rw = g_pass.rw;
if (rh) *rh = g_pass.rh;
return 0;
}
int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd) {
static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp_image *const *dsts, int n,
int wait_fd) {
if (!g_pass.active) { if (wait_fd >= 0) close(wait_fd); return -1; }
g_pass.active = 0;
if (g_dev_state != 1) { if (wait_fd >= 0) close(wait_fd); return -1; }
VkCommandBuffer cmd = g_cmds[0];
if (!dst || !dst->blit_dst) {
for (int i = 0; i < n; i++) {
if (dsts[i] && dsts[i]->blit_dst) continue;
if (wait_fd >= 0) close(wait_fd);
g_vk.EndCommandBuffer(cmd);
return -1;
}
const int gpu_wait = take_wait_fd(wait_fd);
if (gpu_wait < 0) { g_vk.EndCommandBuffer(cmd); return -1; }
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkImageMemoryBarrier acq = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT,
.dstQueueFamilyIndex = g_qfam, .image = dst->image, .subresourceRange = range,
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, 0, NULL, 0, NULL, 1, &acq);
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 1}},
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}};
g_vk.CmdBlitImage(cmd, g_pass.result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit,
for (int i = 0; i < n; i++) {
struct vkp_image *dst = dsts[i];
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 1}},
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
.dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}};
blit_to_layer(cmd, srcs[i], src_layout, dst, &blit,
(g_pass.rw == dst->w && g_pass.rh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
VkImageMemoryBarrier rel = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
0, 0, NULL, 0, NULL, 1, &rel);
}
g_vk.EndCommandBuffer(cmd);
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
@@ -2705,6 +2958,19 @@ int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd) {
return 0;
}
int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd) {
return pass_finish(&g_pass.result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, &dst, 1, wait_fd);
}
int vkp_pass_copy_generated(struct vkp_image *const *dsts, int n, struct vkp_image *real, int wait_fd) {
VkImage srcs[VKP_FG_MAX_GENERATIONS + 1];
struct vkp_image *all[VKP_FG_MAX_GENERATIONS + 1];
if (n > g_pass.ngen) n = g_pass.ngen;
for (int i = 0; i < n; i++) { srcs[i] = g_pass.gens[i]; all[i] = dsts[i]; }
if (real) { srcs[n] = g_pass.result; all[n] = real; }
return pass_finish(srcs, VK_IMAGE_LAYOUT_GENERAL, all, n + (real ? 1 : 0), wait_fd);
}
void vkp_pass_abort(void) {
if (!g_pass.active) return;
g_pass.active = 0;
@@ -7,6 +7,7 @@
void vk_present_set_driver(const char *driver_path, const char *library_name,
const char *native_lib_dir);
void vk_present_set_driver_fallback(int allow);
void vk_present_set_window(ANativeWindow *window);
int vkp_apply_window_request(void);
@@ -95,6 +96,7 @@ struct vkp_hdr_frame {
float peak_nits;
int tonemap;
const struct droiddeck_color *color;
const struct droiddeck_color *convert;
};
int vkp_render_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *how);
@@ -105,7 +107,7 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd);
int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px);
int vkp_update_map(int scene_w, int scene_h);
int vkp_map_draw(const struct vkp_draw *d, int out[8]);
int vkp_map_rect(int img_w, int img_h, int scene_w, int scene_h, int out[8]);
int vkp_map_rect(int img_w, int img_h, const int dst[4], int out[8]);
int vkp_surface_rotation_degrees(void);
ANativeWindow *vkp_window(void);
@@ -113,6 +115,9 @@ void vkp_signal_first_frame(void);
int vkp_pass_begin(int scene_w, int scene_h, const struct vkp_draw *draws, int n, int *rw, int *rh);
int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd);
int vkp_pass_begin_generate(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *rw, int *rh);
int vkp_pass_copy_generated(struct vkp_image *const *dsts, int n, struct vkp_image *real, int wait_fd);
void vkp_pass_abort(void);
void droiddeck_log(const char *tag, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
@@ -18,11 +18,13 @@
#include "cardboard.h"
#include "droiddeck_color.h"
#include "gpu_clock_pin.h"
#include "clock_domain.h"
extern int droiddeck_wayland_run(void);
extern void droiddeck_wayland_set_scale_mode(int mode, int alignment);
extern void droiddeck_wayland_send_pointer(int action, int x, int y);
extern void droiddeck_wayland_send_touch(int action, int pointer_id, int x, int y);
extern void droiddeck_wayland_send_pen(int flags, int x, int y);
extern int droiddeck_cursor_snapshot(int *out, int cap);
extern int droiddeck_cursor_serial(void);
extern int droiddeck_hud_frame_times(float *out, int len, int64_t *total);
@@ -32,18 +34,24 @@ extern int droiddeck_cursor_input_pos(int *x, int *y);
extern void droiddeck_wayland_send_scene_input(int type, int a, int b);
extern void droiddeck_wayland_set_cursor_composite(int on);
extern void droiddeck_wayland_vsync(int64_t frame_time_ns);
extern void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns);
extern void droiddeck_stream_set(int on);
extern void droiddeck_stream_frame(AHardwareBuffer *ahb);
extern unsigned droiddeck_stream_frames(void);
extern void droiddeck_wayland_output_resized(void);
extern void droiddeck_wayland_set_output_refresh_rate(int mhz);
extern void droiddeck_wayland_set_panel_rates(const int *rates, int count);
extern volatile int g_fps_limit;
extern volatile int g_release_unpaced;
extern volatile int g_render_on_commit;
extern volatile int g_bfi;
extern volatile int g_bfi_picture_hold;
extern volatile int g_hide_shell;
extern volatile int g_zero_copy;
extern volatile unsigned g_zero_copy_last;
extern volatile int g_ubwc;
extern volatile int g_display_buffer_driver;
void droiddeck_dmabuf_formats_stale(void);
extern volatile int g_no_render_node;
extern volatile int g_output_w, g_output_h;
@@ -59,6 +67,9 @@ static jmethodID g_on_game_program;
static jmethodID g_on_pointer_lock;
static jmethodID g_on_clipboard;
static jmethodID g_on_text_input;
static jmethodID g_on_overlay_planes;
static jmethodID g_on_refresh_target;
static jmethodID g_on_content_rate;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
(void)reserved;
@@ -80,6 +91,9 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
g_on_clipboard = (*env)->GetStaticMethodID(env, g_compositor_cls, "onClipboardText", "([B)V");
g_on_text_input = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInput",
"(ZLjava/lang/String;IIII)V");
g_on_overlay_planes = (*env)->GetStaticMethodID(env, g_compositor_cls, "onOverlayPlanes", "(I)V");
g_on_refresh_target = (*env)->GetStaticMethodID(env, g_compositor_cls, "onRefreshTarget", "(II)V");
g_on_content_rate = (*env)->GetStaticMethodID(env, g_compositor_cls, "onContentRate", "(I)V");
}
}
return JNI_VERSION_1_6;
@@ -140,6 +154,27 @@ void droiddeck_on_game_frame(void) {
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
}
void droiddeck_on_refresh_target(int refresh, int frame_rate) {
JNIEnv *env;
if (!g_compositor_cls || !g_on_refresh_target || !(env = thread_env())) return;
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_refresh_target, (jint)refresh, (jint)frame_rate);
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
}
void droiddeck_on_content_rate(int fps) {
JNIEnv *env;
if (!g_compositor_cls || !g_on_content_rate || !(env = thread_env())) return;
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_content_rate, (jint)fps);
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
}
void droiddeck_on_overlay_planes(int planes) {
JNIEnv *env;
if (!g_compositor_cls || !g_on_overlay_planes || !(env = thread_env())) return;
(*env)->CallStaticVoidMethod(env, g_compositor_cls, g_on_overlay_planes, (jint)planes);
if ((*env)->ExceptionCheck(env)) (*env)->ExceptionClear(env);
}
void droiddeck_on_pointer_lock(int locked, int x, int y) {
JNIEnv *env;
if (!g_compositor_cls || !g_on_pointer_lock || !(env = thread_env())) return;
@@ -252,12 +287,13 @@ static char *dup_jstr(JNIEnv *env, jstring s) {
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStartWithSurface(
JNIEnv *env, jclass clazz, jobject surface, jstring xdgRuntimeDir,
jstring driverPath, jstring libraryName, jstring nativeLibDir) {
jstring driverPath, jstring libraryName, jstring nativeLibDir, jboolean allowDriverFallback) {
set_runtime_dir(env, xdgRuntimeDir);
char *dp = dup_jstr(env, driverPath);
char *ln = dup_jstr(env, libraryName);
char *nl = dup_jstr(env, nativeLibDir);
vk_present_set_driver(dp, ln, nl);
vk_present_set_driver_fallback(allowDriverFallback == JNI_TRUE);
free(dp); free(ln); free(nl);
if (surface) {
ANativeWindow *win = ANativeWindow_fromSurface(env, surface);
@@ -279,6 +315,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendTouch(
droiddeck_wayland_send_touch(action, pointer_id, x, y);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendPen(
JNIEnv *env, jclass clazz, jint flags, jint x, jint y) {
droiddeck_wayland_send_pen(flags, x, y);
}
JNIEXPORT jint JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCursorSnapshot(
JNIEnv *env, jclass clazz, jintArray out) {
@@ -354,6 +396,19 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeVsync(JNIEnv *env, j
droiddeck_wayland_vsync((int64_t)frameTimeNanos);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameTimeline(JNIEnv *env, jclass clazz, jlong presentNanos,
jlong deadlineNanos, jlong periodNanos) {
sc_layer_frame_timeline((int64_t)presentNanos, (int64_t)deadlineNanos, (int64_t)periodNanos);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetClockControl(JNIEnv *env, jclass clazz, jstring path) {
const char *value = path ? (*env)->GetStringUTFChars(env, path, NULL) : NULL;
droiddeck_clock_domain_set_control(value);
if (value) (*env)->ReleaseStringUTFChars(env, path, value);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHideShell(JNIEnv *env, jclass clazz, jboolean hide) {
g_hide_shell = hide ? 1 : 0;
@@ -362,11 +417,18 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHideShell(JNIEnv
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv *env, jclass clazz, jboolean on) {
int live = droiddeck_get_display() != NULL;
if (!live) g_zero_copy = on ? 1 : 0;
if (!live) { g_zero_copy = on ? 1 : 0; droiddeck_dmabuf_formats_stale(); }
droiddeck_host_zero_copy(on ? 1 : 0, live);
__android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : "");
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDisplayBufferDriver(JNIEnv *env, jclass clazz, jboolean on) {
g_display_buffer_driver = on ? 1 : 0;
droiddeck_dmabuf_formats_stale();
__android_log_print(ANDROID_LOG_INFO, TAG, "session driver %s for display buffers", on ? "asks" : "does not ask");
}
JNIEXPORT jint JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeZeroCopyLastFrameAgeMs(JNIEnv *env, jclass clazz) {
return (jint)ahb_swapchain_last_frame_age_ms();
@@ -400,6 +462,16 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetOutputRefreshRate
droiddeck_wayland_set_output_refresh_rate(hz > 1.0f ? (int)(hz * 1000.0f + 0.5f) : 0);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetPanelRates(JNIEnv *env, jclass clazz, jintArray rates) {
(void)clazz;
jint values[16];
jsize count = rates ? (*env)->GetArrayLength(env, rates) : 0;
if (count > 16) count = 16;
if (count > 0) (*env)->GetIntArrayRegion(env, rates, 0, count, values);
droiddeck_wayland_set_panel_rates((const int *)values, (int)count);
}
extern void vkp_reset_first_frame(void);
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeResetFirstFrame(JNIEnv *env, jclass clazz) {
@@ -440,6 +512,18 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGamePictureRect(JNIE
return JNI_TRUE;
}
JNIEXPORT jboolean JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeOutputSize(JNIEnv *env, jclass clazz, jintArray out) {
(void)clazz;
if (!out || (*env)->GetArrayLength(env, out) < 2) return JNI_FALSE;
int width = 0, height = 0;
vkp_output_size(&width, &height);
if (width <= 0 || height <= 0) return JNI_FALSE;
jint size[2] = {(jint)width, (jint)height};
(*env)->SetIntArrayRegion(env, out, 0, 2, size);
return JNI_TRUE;
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetUpscaler(JNIEnv *env, jclass clazz, jint mode) {
vkp_effects_set_scaling(mode);
@@ -467,8 +551,8 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDeband(JNIEnv *en
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetScreenEffects(JNIEnv *env, jclass clazz, jfloat brightness,
jfloat contrast, jfloat gamma, jfloat saturation, jboolean fxaa, jboolean toon, jboolean crt, jboolean ntsc) {
vkp_effects_set_screen(brightness, contrast, gamma, saturation, fxaa ? 1 : 0, toon ? 1 : 0, crt ? 1 : 0, ntsc ? 1 : 0);
jfloat contrast, jfloat gamma, jfloat saturation, jint aa_mode, jboolean toon, jboolean crt, jboolean ntsc) {
vkp_effects_set_screen(brightness, contrast, gamma, saturation, aa_mode, toon ? 1 : 0, crt ? 1 : 0, ntsc ? 1 : 0);
}
JNIEXPORT void JNICALL
@@ -641,6 +725,17 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetRenderOnCommit(JN
__android_log_print(ANDROID_LOG_INFO, TAG, "render on commit %s", on ? "on" : "off");
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetBlackFrameInsertion(JNIEnv *env, jclass clazz, jboolean on) {
g_bfi = on ? 1 : 0;
__android_log_print(ANDROID_LOG_INFO, TAG, "black frame insertion %s", on ? "requested" : "off");
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetPictureHold(JNIEnv *env, jclass clazz, jboolean on) {
g_bfi_picture_hold = on ? 1 : 0;
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFpsLimit(JNIEnv *env, jclass clazz, jint fps) {
g_fps_limit = fps > 0 ? fps : 0;
+176 -31
View File
@@ -84,15 +84,18 @@ static struct {
static _Atomic int g_gate = -1;
static char g_gate_why[320];
static _Atomic int g_output_on = 1;
static _Atomic int g_output_wanted = 1;
static pthread_mutex_t g_output_mu = PTHREAD_MUTEX_INITIALIZER;
void droiddeck_color_set_request(int mode, const char *source, int dxvk_hdr, int zero_copy_forced) {
pthread_mutex_lock(&g_mu);
g_req.mode = mode < 0 ? 0 : mode > 2 ? 2 : mode;
g_req.mode = mode < 0 ? 0 : mode > 3 ? 3 : mode;
snprintf(g_req.source, sizeof(g_req.source), "%s", source ? source : "environment");
g_req.dxvk_hdr = dxvk_hdr ? 1 : 0;
g_req.zero_copy_forced = zero_copy_forced ? 1 : 0;
pthread_mutex_unlock(&g_mu);
atomic_store(&g_output_on, 1);
atomic_store(&g_output_wanted, 1);
}
void droiddeck_color_set_display(int id, const char *name, const char *formats, int hdr10, float max_lum,
@@ -610,11 +613,23 @@ int droiddeck_color_tonemapped_on_screen(void) {
void droiddeck_color_set_output(int on) {
on = on ? 1 : 0;
if (atomic_load(&g_gate) != 1) {
droiddeck_log(TAG, "HDR output switch (%s) ignored: HDR is not open in this session", on ? "on" : "off");
pthread_mutex_lock(&g_mu);
const int tonemap_only = g_req.mode == 3;
pthread_mutex_unlock(&g_mu);
pthread_mutex_lock(&g_output_mu);
atomic_store(&g_output_wanted, on);
const int gate = atomic_load(&g_gate);
const int changed = gate == 1 && !(on && tonemap_only) && atomic_exchange(&g_output_on, on) != on;
pthread_mutex_unlock(&g_output_mu);
if (gate != 1) {
if (gate == 0) droiddeck_log(TAG, "HDR output switch (%s) ignored: HDR is not open in this session", on ? "on" : "off");
return;
}
if (atomic_exchange(&g_output_on, on) == on) return;
if (on && tonemap_only) {
droiddeck_log(TAG, "HDR output switch (on) ignored: this display cannot show HDR10, HDR frames stay tone-mapped");
return;
}
if (!changed) return;
char who[160];
int age = droiddeck_color_last_frame_age_ms(), tm = droiddeck_color_tonemapped_on_screen();
pthread_mutex_lock(&g_mu);
@@ -658,6 +673,8 @@ static void desc_unref(struct cm_desc *d) { if (d && --d->refs <= 0) free(d); }
struct cm_params {
uint32_t tf, primaries;
int has_prim; int32_t prim[8];
int has_lum; uint32_t lum_ref;
int has_mprim; int32_t mprim[8];
int has_mlum; uint32_t mlum_min, mlum_max;
int has_cll; uint32_t cll;
@@ -730,9 +747,83 @@ static void make_output_description(struct wl_client *c, struct wl_resource *par
droiddeck_client_name(c), what, col->text);
}
static const float BT709_XY[8] = {0.64f, 0.33f, 0.30f, 0.60f, 0.15f, 0.06f, 0.3127f, 0.3290f};
static const float BT2020_XY[8] = {0.708f, 0.292f, 0.170f, 0.797f, 0.131f, 0.046f, 0.3127f, 0.3290f};
static void mat_mul(const double a[9], const double b[9], double out[9]) {
double m[9];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
m[3 * i + j] = a[3 * i] * b[j] + a[3 * i + 1] * b[3 + j] + a[3 * i + 2] * b[6 + j];
memcpy(out, m, sizeof(m));
}
static int mat_invert(const double m[9], double out[9]) {
const double det = m[0] * (m[4] * m[8] - m[5] * m[7]) - m[1] * (m[3] * m[8] - m[5] * m[6]) +
m[2] * (m[3] * m[7] - m[4] * m[6]);
if (det > -1e-12 && det < 1e-12) return -1;
const double k = 1.0 / det;
double r[9] = {(m[4] * m[8] - m[5] * m[7]) * k, (m[2] * m[7] - m[1] * m[8]) * k, (m[1] * m[5] - m[2] * m[4]) * k,
(m[5] * m[6] - m[3] * m[8]) * k, (m[0] * m[8] - m[2] * m[6]) * k, (m[2] * m[3] - m[0] * m[5]) * k,
(m[3] * m[7] - m[4] * m[6]) * k, (m[1] * m[6] - m[0] * m[7]) * k, (m[0] * m[4] - m[1] * m[3]) * k};
memcpy(out, r, sizeof(r));
return 0;
}
static int rgb_to_xyz(const float xy[8], double out[9], double white[3]) {
for (int i = 0; i < 4; i++)
if (xy[2 * i + 1] < 1e-4f) return -1;
double p[9], inv[9];
for (int i = 0; i < 3; i++) {
const double x = xy[2 * i], y = xy[2 * i + 1];
p[i] = x / y; p[3 + i] = 1.0; p[6 + i] = (1.0 - x - y) / y;
}
white[0] = xy[6] / xy[7]; white[1] = 1.0; white[2] = (1.0 - xy[6] - xy[7]) / xy[7];
if (mat_invert(p, inv) != 0) return -1;
for (int i = 0; i < 3; i++) {
const double scale = inv[3 * i] * white[0] + inv[3 * i + 1] * white[1] + inv[3 * i + 2] * white[2];
out[i] = p[i] * scale; out[3 + i] = p[3 + i] * scale; out[6 + i] = p[6 + i] * scale;
}
return 0;
}
static int matrix_to_bt2020(const float xy[8], float out[9]) {
static const double bradford[9] = {0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296};
double src[9], dst[9], dst_inv[9], sw[3], dw[3], cone_inv[9], adapt[9], m[9];
if (rgb_to_xyz(xy, src, sw) != 0 || rgb_to_xyz(BT2020_XY, dst, dw) != 0) return -1;
if (mat_invert(dst, dst_inv) != 0 || mat_invert(bradford, cone_inv) != 0) return -1;
double scale[9] = {0};
for (int i = 0; i < 3; i++) {
const double from = bradford[3 * i] * sw[0] + bradford[3 * i + 1] * sw[1] + bradford[3 * i + 2] * sw[2];
const double to = bradford[3 * i] * dw[0] + bradford[3 * i + 1] * dw[1] + bradford[3 * i + 2] * dw[2];
if (from > -1e-9 && from < 1e-9) return -1;
scale[4 * i] = to / from;
}
mat_mul(scale, bradford, adapt);
mat_mul(cone_inv, adapt, adapt);
mat_mul(adapt, src, m);
mat_mul(dst_inv, m, m);
for (int i = 0; i < 9; i++) out[i] = (float)m[i];
return 0;
}
static struct wl_resource *publish_description(struct wl_client *client, struct wl_resource *parent, uint32_t id,
struct cm_desc *d) {
struct wl_resource *out = wl_resource_create(client, &wp_image_description_v1_interface,
wl_resource_get_version(parent), id);
if (!out) { free(d); wl_client_post_no_memory(client); return NULL; }
d->refs = 1;
wl_resource_set_implementation(out, &image_description_impl, d, image_description_resource_destroy);
wp_image_description_v1_send_ready(out, d->c.identity);
pthread_mutex_lock(&g_mu);
g_hdr.descs++;
pthread_mutex_unlock(&g_mu);
return out;
}
static void params_create(struct wl_client *client, struct wl_resource *r, uint32_t id) {
struct cm_params *p = wl_resource_get_user_data(r);
if (!p->tf || !p->primaries) {
if (!p->tf || (!p->primaries && !p->has_prim)) {
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET,
"transfer function and primaries must both be set");
return;
@@ -744,10 +835,29 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
if (!g_next_identity) g_next_identity = 1;
c->primaries = p->primaries;
c->tf = p->tf;
if (p->primaries == WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 && p->tf == WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ)
const float ref = p->has_lum ? (float)p->lum_ref : 203.0f;
float xy[8];
for (int i = 0; i < 8; i++)
xy[i] = p->has_prim ? p->prim[i] / 1e6f
: p->primaries == WP_COLOR_MANAGER_V1_PRIMARIES_SRGB ? BT709_XY[i] : BT2020_XY[i];
if (p->primaries == WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 && ref == 203.0f) {
c->dataspace = DROIDDECK_ADATASPACE_BT2020_PQ;
else if (p->primaries == WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 && p->tf == WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_HLG)
c->dataspace = DROIDDECK_ADATASPACE_BT2020_HLG;
} else if (matrix_to_bt2020(xy, c->to2020) == 0) {
c->convert = 1;
c->gain = 10000.0f * 203.0f / ref;
} else {
struct wl_resource *bad = wl_resource_create(client, &wp_image_description_v1_interface,
wl_resource_get_version(r), id);
free(d);
if (!bad) { wl_client_post_no_memory(client); return; }
wl_resource_set_implementation(bad, &image_description_impl, NULL, NULL);
wp_image_description_v1_send_failed(bad, WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED,
"the primaries do not form a colour space");
droiddeck_log(TAG, "image description from %s refused: its primaries do not form a colour space",
droiddeck_client_name(client));
wl_resource_destroy(r);
return;
}
char dropped[160] = "";
float mlum_min = 0.005f, mlum_max = 10000.0f;
@@ -781,7 +891,12 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
}
if (cll > 0.0f || fall > 0.0f) { c->has_cta861 = 1; c->max_cll = cll; c->max_fall = fall; }
int n = snprintf(c->text, sizeof(c->text), "%s, %s", primaries_name(c->primaries), tf_name(c->tf));
int n = snprintf(c->text, sizeof(c->text), "%s, %s", p->has_prim ? "custom primaries" : primaries_name(c->primaries),
tf_name(c->tf));
if (c->convert && n < (int)sizeof(c->text))
n += snprintf(c->text + n, sizeof(c->text) - (size_t)n,
"; R %.4f,%.4f G %.4f,%.4f B %.4f,%.4f W %.4f,%.4f, reference white %.0f nits",
xy[0], xy[1], xy[2], xy[3], xy[4], xy[5], xy[6], xy[7], ref);
if (c->has_st2086 && n < (int)sizeof(c->text))
n += snprintf(c->text + n, sizeof(c->text) - (size_t)n,
"; mastering R %.4f,%.4f G %.4f,%.4f B %.4f,%.4f W %.4f,%.4f, %.4f-%.0f nits%s",
@@ -793,19 +908,13 @@ static void params_create(struct wl_client *client, struct wl_resource *r, uint3
if (!c->has_st2086 && !c->has_cta861 && n < (int)sizeof(c->text))
snprintf(c->text + n, sizeof(c->text) - (size_t)n, " (no HDR metadata: the game has not called vkSetHdrMetadataEXT)");
struct wl_resource *out = wl_resource_create(client, &wp_image_description_v1_interface,
wl_resource_get_version(r), id);
if (!out) { free(d); wl_client_post_no_memory(client); return; }
d->refs = 1;
wl_resource_set_implementation(out, &image_description_impl, d, image_description_resource_destroy);
wp_image_description_v1_send_ready(out, c->identity);
if (c->dataspace) {
pthread_mutex_lock(&g_mu);
g_hdr.descs++;
pthread_mutex_unlock(&g_mu);
}
droiddeck_log(TAG, "image description #%u from %s: %s -> ready (on a display layer: dataspace %s)", c->identity,
droiddeck_client_name(client), c->text, dataspace_name(c->dataspace));
if (!publish_description(client, r, id, d)) return;
if (c->convert)
droiddeck_log(TAG, "image description #%u from %s: %s -> ready (converted to BT.2020 PQ when the scene is "
"composed)", c->identity, droiddeck_client_name(client), c->text);
else
droiddeck_log(TAG, "image description #%u from %s: %s -> ready (on a display layer: dataspace %s)", c->identity,
droiddeck_client_name(client), c->text, dataspace_name(c->dataspace));
if (dropped[0]) {
size_t l = strlen(dropped);
if (l && dropped[l - 1] == ',') dropped[l - 1] = 0;
@@ -840,8 +949,8 @@ static void params_set_tf_power(struct wl_client *c, struct wl_resource *r, uint
}
static void params_set_primaries_named(struct wl_client *c, struct wl_resource *r, uint32_t primaries) {
struct cm_params *p = wl_resource_get_user_data(r);
PARAMS_ONCE(p->primaries, "primaries");
if (primaries != WP_COLOR_MANAGER_V1_PRIMARIES_BT2020) {
PARAMS_ONCE(p->primaries || p->has_prim, "primaries");
if (primaries != WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 && primaries != WP_COLOR_MANAGER_V1_PRIMARIES_SRGB) {
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_PRIMARIES_NAMED,
"primaries %u were not advertised", primaries);
return;
@@ -850,12 +959,21 @@ static void params_set_primaries_named(struct wl_client *c, struct wl_resource *
}
static void params_set_primaries(struct wl_client *c, struct wl_resource *r, int32_t rx, int32_t ry, int32_t gx,
int32_t gy, int32_t bx, int32_t by, int32_t wx, int32_t wy) {
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_UNSUPPORTED_FEATURE,
"set_primaries is not supported");
struct cm_params *p = wl_resource_get_user_data(r);
PARAMS_ONCE(p->primaries || p->has_prim, "primaries");
p->has_prim = 1;
p->prim[0] = rx; p->prim[1] = ry; p->prim[2] = gx; p->prim[3] = gy;
p->prim[4] = bx; p->prim[5] = by; p->prim[6] = wx; p->prim[7] = wy;
}
static void params_set_luminances(struct wl_client *c, struct wl_resource *r, uint32_t mn, uint32_t mx, uint32_t ref) {
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_UNSUPPORTED_FEATURE,
"set_luminances is not supported");
struct cm_params *p = wl_resource_get_user_data(r);
PARAMS_ONCE(p->has_lum, "luminances");
if ((uint64_t)mx * 10000u <= mn || (uint64_t)ref * 10000u <= mn) {
wl_resource_post_error(r, WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE,
"maximum and reference luminance must be above the minimum");
return;
}
p->has_lum = 1; p->lum_ref = ref;
}
static void params_set_mastering_display_primaries(struct wl_client *c, struct wl_resource *r, int32_t rx, int32_t ry,
int32_t gx, int32_t gy, int32_t bx, int32_t by, int32_t wx, int32_t wy) {
@@ -1083,7 +1201,20 @@ static void cm_create_parametric_creator(struct wl_client *c, struct wl_resource
}
static void cm_create_windows_scrgb(struct wl_client *c, struct wl_resource *r, uint32_t id) {
wl_resource_post_error(r, WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "windows_scrgb is not supported");
struct cm_desc *d = calloc(1, sizeof(*d));
if (!d) { wl_client_post_no_memory(c); return; }
struct droiddeck_color *col = &d->c;
col->identity = g_next_identity++;
if (!g_next_identity) g_next_identity = 1;
col->primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB;
col->tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR;
col->convert = 2;
col->gain = 80.0f;
matrix_to_bt2020(BT709_XY, col->to2020);
snprintf(col->text, sizeof(col->text), "%s, %s (1.0 = 80 nits)", primaries_name(col->primaries), tf_name(col->tf));
if (!publish_description(c, r, id, d)) return;
droiddeck_log(TAG, "image description #%u from %s: %s -> ready (converted to BT.2020 PQ when the scene is composed)",
col->identity, droiddeck_client_name(c), col->text);
}
static const struct wp_color_manager_v1_interface cm_impl = {
@@ -1103,14 +1234,20 @@ static void bind_cm(struct wl_client *c, void *data, uint32_t ver, uint32_t id)
wl_resource_set_implementation(r, &cm_impl, NULL, NULL);
wp_color_manager_v1_send_supported_intent(r, WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME);
wp_color_manager_v1_send_supported_feature(r, WP_COLOR_MANAGER_V1_FEATURE_WINDOWS_SCRGB);
wp_color_manager_v1_send_supported_primaries_named(r, WP_COLOR_MANAGER_V1_PRIMARIES_SRGB);
wp_color_manager_v1_send_supported_primaries_named(r, WP_COLOR_MANAGER_V1_PRIMARIES_BT2020);
wp_color_manager_v1_send_supported_tf_named(r, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ);
wp_color_manager_v1_send_done(r);
if (last_named != c) {
last_named = c;
droiddeck_log(TAG, "%s bound wp_color_manager_v1 version %u (offered: perceptual intent; parametric descriptions "
"with mastering metadata; BT.2020 primaries; ST 2084 PQ) - its Vulkan driver can now list "
"with custom primaries, luminances and mastering metadata; Windows scRGB; sRGB and BT.2020 primaries; "
"ST 2084 PQ) - its Vulkan driver can now list "
"VK_COLOR_SPACE_HDR10_ST2084_EXT", droiddeck_client_name(c), ver > 1 ? 1u : ver);
}
}
@@ -1150,6 +1287,7 @@ void droiddeck_color_init(struct wl_display *display) {
char asked[128];
if (mode == 2) snprintf(asked, sizeof(asked), "DROIDDECK_WAYLAND_HDR=force (%s)", source);
else if (mode == 3) snprintf(asked, sizeof(asked), "HDR is on, tone-mapped for this display (%s)", source);
else if (strstr(source, "env")) snprintf(asked, sizeof(asked), "DROIDDECK_WAYLAND_HDR=1 (%s)", source);
else snprintf(asked, sizeof(asked), "HDR output is on (%s)", source);
@@ -1168,7 +1306,7 @@ void droiddeck_color_init(struct wl_display *display) {
snprintf(why, sizeof(why), "this Android has no display layers with dataspace control "
"(ASurfaceControl + ASurfaceTransaction_setBufferDataSpace, Android 10+)");
else if (!ahb_ok)
snprintf(why, sizeof(why), "zero-copy presentation is unavailable here (banner_ahb_v1 not advertised), and an "
snprintf(why, sizeof(why), "zero-copy presentation is unavailable here (droiddeck_ahb_v1 not advertised), and an "
"HDR frame is only honest on the game's own display layer");
if (why[0]) {
@@ -1198,13 +1336,20 @@ void droiddeck_color_init(struct wl_display *display) {
log_verdict(1);
return;
}
pthread_mutex_lock(&g_output_mu);
atomic_store(&g_gate, 1);
if (mode == 3 || !atomic_load(&g_output_wanted)) atomic_store(&g_output_on, 0);
pthread_mutex_unlock(&g_output_mu);
char syms[160];
sc_layer_hdr_symbols(syms, sizeof(syms));
droiddeck_log(TAG, "HDR gate %s: %s and %s. Offering games HDR10: wp_color_manager_v1 version 1 (BT.2020 primaries "
"+ ST 2084 PQ, parametric descriptions with mastering metadata) and 10-bit AB30/XB30 dma-buf formats; HDR "
"frames go on the game's own display layer as BT2020_PQ (%s)",
mode == 2 ? "FORCED OPEN (testing)" : "OPEN", asked, disp, syms);
if (mode == 3) {
droiddeck_log(TAG, "this display cannot show HDR10: games still render HDR and every HDR frame is tone-mapped to "
"SDR on the game's display layer");
}
if (mode == 2 && !hdr10)
droiddeck_log(TAG, "DROIDDECK_WAYLAND_HDR=force on a display without HDR10 - testing only: SurfaceFlinger will tone-map "
"the game layer for this panel (expect GPU/CLIENT composition for it), nothing looks HDR");
+18 -3
View File
@@ -14,6 +14,7 @@
#include "droiddeck_ext.h"
#include "droiddeck_color.h"
#include "compositor_internal.h"
#include "display_buffers.h"
static void dbuf_buffer_resource_destroy(struct wl_resource *r) {
@@ -58,6 +59,7 @@ static struct wl_resource *params_do_create(struct wl_client *c, struct wl_resou
wl_resource_set_implementation(buf, &dbuf_buffer_impl, b, dbuf_buffer_resource_destroy);
struct client_info *ci = client_info_of(c);
if (ci) ci->dmabuf_buffers++;
display_buffers_match(c, buf, b);
return buf;
}
static void params_create(struct wl_client *c, struct wl_resource *r, int32_t w, int32_t h,
@@ -111,13 +113,16 @@ static const struct zwp_linux_dmabuf_v1_interface dmabuf_impl = {
static struct { uint32_t fmt; uint64_t mods[DMABUF_NMOD]; int n; } g_dmabuf_fmts[DMABUF_NFMT_MAX] = {
{DRM_ARGB8888}, {DRM_XRGB8888}, {DRM_ABGR8888}, {DRM_XBGR8888}, {DRM_ABGR2101010}, {DRM_XBGR2101010}};
static int g_dmabuf_nfmt = DMABUF_NFMT_SDR;
static int g_dmabuf_fmts_ready;
static volatile int g_dmabuf_fmts_ready;
static void dmabuf_build_feedback(void);
void droiddeck_dmabuf_formats_stale(void) { g_dmabuf_fmts_ready = 0; }
static void dmabuf_build_formats(void) {
char line[320];
int pos = 0, compressed = 0;
int pos = 0, compressed = 0, backed = 0;
g_dmabuf_fmts_ready = 1;
display_buffers_withdraw_ubwc();
g_dmabuf_nfmt = droiddeck_color_hdr_open() ? DMABUF_NFMT_MAX : DMABUF_NFMT_SDR;
for (int f = 0; f < g_dmabuf_nfmt; f++) {
uint64_t got[DMABUF_NMOD];
@@ -129,6 +134,12 @@ static void dmabuf_build_formats(void) {
g_dmabuf_fmts[f].mods[k++] = got[i];
if (got[i] == VKP_MOD_QCOM_COMPRESSED) compressed++;
}
int listed = 0;
for (int i = 0; i < k; i++) if (g_dmabuf_fmts[f].mods[i] == VKP_MOD_QCOM_COMPRESSED) listed = 1;
if (display_buffers_offer_ubwc(g_dmabuf_fmts[f].fmt) && !listed) {
g_dmabuf_fmts[f].mods[k++] = VKP_MOD_QCOM_COMPRESSED;
backed++;
}
g_dmabuf_fmts[f].mods[k++] = MOD_INVALID;
g_dmabuf_fmts[f].n = k;
uint32_t fmt = g_dmabuf_fmts[f].fmt;
@@ -141,7 +152,10 @@ static void dmabuf_build_formats(void) {
}
droiddeck_log("dmabuf", "formats: %s%s", line,
!g_ubwc ? " (DROIDDECK_WAYLAND_UBWC=0: qcom_compressed not advertised)" : "");
if (g_ubwc && !compressed)
if (backed)
droiddeck_log("dmabuf", "qcom_compressed is advertised for %d formats the compositor's driver (%s) does not "
"import as dma-bufs: this session's driver renders them into gralloc buffers", backed, vkp_gpu_name());
else if (g_ubwc && !compressed)
droiddeck_log("dmabuf", "the compositor's driver (%s) reports no importable qcom_compressed layout: "
"game swapchains stay linear", vkp_gpu_name());
if (g_dmabuf_nfmt > DMABUF_NFMT_SDR) {
@@ -212,6 +226,7 @@ static void dmabuf_build_feedback(void) {
return;
}
fcntl(fd, F_ADD_SEALS, F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE);
if (g_fmt_table_fd >= 0) close(g_fmt_table_fd);
g_fmt_table_fd = fd;
g_fmt_table_size = size;
g_fmt_table_n = (uint16_t)n;
@@ -20,6 +20,7 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
com.droiddeck.launcher.runtime.NativeGuest.init(this)
Thread({ runCatching { EnhancedSessionLogShare.cleanupAbandonedStages(this) } }, "diagnostic-stage-cleanup").start()
com.droiddeck.launcher.ui.Themes.loadGradient(this)
com.droiddeck.launcher.ui.BuildWatermark.install(this)
@@ -42,17 +43,24 @@ class App : Application() {
if (process == "$packageName:vr_recovery" || process == "$packageName:rgb_diagnostic" ||
process == "$packageName:shortcuts_sync" || process == "$packageName:bottom_desktop") return
CrashHandler.install(this)
com.droiddeck.launcher.input.ShortcutsRelay.Holder.install(this)
com.droiddeck.launcher.agent.AgentHost.refresh(this)
if (com.droiddeck.launcher.agent.AgentHost.available) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
com.droiddeck.launcher.ui.NavTabs.load(this)
com.droiddeck.launcher.ui.DrawerPages.load(this)
com.droiddeck.launcher.ui.DeveloperTools.load(this)
com.droiddeck.launcher.ui.AgentPet.install(this)
if (com.droiddeck.launcher.agent.AgentTab.visible) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
com.droiddeck.launcher.lab.LabNotice.started(this)
com.droiddeck.launcher.core.SteamIntegration.syncShortcutsListing(this)
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
com.droiddeck.launcher.session.SessionPrefs.applyNtsyncDefault(this)
com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this)
com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.entries.map { it.id })
com.droiddeck.launcher.update.AppUpdates.init(this)
com.droiddeck.launcher.update.UpdateWatch.sync(this, com.droiddeck.launcher.update.AppUpdates.follow(this, null))
com.droiddeck.launcher.core.DownloadSource.init(this)
prefetchAddonPacks()
GpuClockPin.clearLeftover(this)
com.droiddeck.launcher.input.UsbMouse.returnLeftover(this)
com.droiddeck.launcher.glasses.Glasses.init(this)
com.droiddeck.launcher.glasses.GlassesMenuMirror.initialize(this)
BwrapSpawner.start(this)
@@ -70,6 +78,7 @@ class App : Application() {
com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ubisoft.UbisoftBackend)
com.droiddeck.launcher.stores.ea.EaBackend.app = this
com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ea.EaBackend)
com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.rockstar.RockstarBackend)
}
private fun prefetchAddonPacks() {
@@ -77,14 +86,19 @@ class App : Application() {
Thread({
runCatching {
if (com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).isDirectory) {
com.droiddeck.launcher.core.AddonPack.PROOT.ensure(app)
if (!com.droiddeck.launcher.runtime.LinuxRuntime.patchedProot(app)) com.droiddeck.launcher.core.AddonPack.PROOT.ensure(app)
com.droiddeck.launcher.core.AddonPack.DIRECTAUDIO.ensure(app)
com.droiddeck.launcher.session.SessionFiles.ensureDirtStandIn(app)
}
if (com.droiddeck.launcher.stores.gog.GogComet.enabled(app)) com.droiddeck.launcher.core.AddonPack.COMET.ensure(app)
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.XBOX) != null)
com.droiddeck.launcher.core.AddonPack.XBOX.ensure(app)
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.UBISOFT) != null)
com.droiddeck.launcher.session.SessionFiles.ensureUbisoftService(app)
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.ROCKSTAR) != null)
com.droiddeck.launcher.session.SessionFiles.ensureRockstarService(app)
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.EPIC) != null)
com.droiddeck.launcher.session.SessionFiles.ensureEpicParent(app)
com.droiddeck.launcher.handtracking.HandTracking.load(app)
}.onFailure { android.util.Log.w("App", "add-on pack prefetch failed", it) }
}, "addon-packs").start()
@@ -0,0 +1,167 @@
package com.droiddeck.launcher
import android.app.ActivityOptions
import android.app.PictureInPictureParams
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.util.Rational
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.core.AppLanguage
import com.droiddeck.launcher.ui.DroidDeckTheme
import com.droiddeck.launcher.ui.FitText
import com.droiddeck.launcher.ui.LocalPalette
import com.droiddeck.launcher.ui.PrimaryButton
import com.droiddeck.launcher.ui.SecondaryButton
import java.lang.ref.WeakReference
/** Floats a sign-in code over the browser page that asks for it. */
class DeviceCodeActivity : ComponentActivity() {
private var code by mutableStateOf("")
private var url = ""
private var display: Int? = null
private var inPip by mutableStateOf(false)
private var openPending = false
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(AppLanguage.wrap(newBase))
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
current = WeakReference(this)
read(intent)
openPending = savedInstanceState == null
setContent { DroidDeckTheme { Float() } }
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
read(intent)
openPending = true
}
override fun onDestroy() {
if (current?.get() === this) current = null
super.onDestroy()
}
override fun onResume() {
super.onResume()
if (!openPending) return
if (isInPictureInPictureMode) {
openPage()
return
}
enterPip()
if (!inPip) {
openPage()
finish()
}
}
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
inPip = isInPictureInPictureMode
if (isInPictureInPictureMode && openPending) openPage()
}
private fun read(intent: Intent) {
code = intent.getStringExtra(EXTRA_CODE).orEmpty()
url = intent.getStringExtra(EXTRA_URL).orEmpty()
display = intent.getIntExtra(EXTRA_DISPLAY, -1).takeIf { it > 0 }
copy()
}
private fun copy() {
runCatching { getSystemService(ClipboardManager::class.java)?.setPrimaryClip(ClipData.newPlainText("GitHub", code)) }
}
private fun enterPip() {
inPip = runCatching {
enterPictureInPictureMode(PictureInPictureParams.Builder().setAspectRatio(Rational(16, 9)).build())
}.getOrDefault(false)
}
private fun openPage() {
openPending = false
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val at = display
val opened = runCatching {
if (at == null) startActivity(intent)
else startActivity(intent, ActivityOptions.makeBasic().setLaunchDisplayId(at).toBundle())
}.recoverCatching { startActivity(intent) }.isSuccess
com.droiddeck.launcher.agent.AgentHost.deviceCodeOpened(applicationContext, opened)
}
@androidx.compose.runtime.Composable
private fun Float() {
val colors = MaterialTheme.colorScheme
val accent = LocalPalette.current.signal
BackHandler(enabled = !inPip) { enterPip() }
Box(Modifier.fillMaxSize().background(colors.background), contentAlignment = Alignment.Center) {
Column(
Modifier.widthIn(max = 520.dp).fillMaxWidth().padding(if (inPip) 8.dp else 24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(if (inPip) 2.dp else 16.dp),
) {
Text(stringResource(R.string.agent_step_github), style = MaterialTheme.typography.labelLarge, color = colors.onSurfaceVariant)
FitText(code, maxSize = if (inPip) 40.sp else 56.sp, fontWeight = FontWeight.Bold, color = accent,
modifier = Modifier.fillMaxWidth())
Text(Uri.parse(url).let { it.host + it.path }, style = MaterialTheme.typography.labelMedium, color = colors.onSurfaceVariant, maxLines = 1)
if (!inPip) Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
PrimaryButton(stringResource(R.string.fm_copy), onClick = ::copy)
SecondaryButton(stringResource(R.string.common_close), onClick = ::finish)
}
}
}
}
companion object {
private const val EXTRA_CODE = "code"
private const val EXTRA_URL = "url"
private const val EXTRA_DISPLAY = "display"
private var current: WeakReference<DeviceCodeActivity>? = null
/** False when this device cannot float a window, so the caller opens the page itself. */
fun show(context: Context, code: String, url: String, display: Int): Boolean {
if (!PairingGuideActivity.canFloat(context)) return false
val intent = Intent(context, DeviceCodeActivity::class.java)
.putExtra(EXTRA_CODE, code).putExtra(EXTRA_URL, url).putExtra(EXTRA_DISPLAY, display)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return runCatching {
if (display > 0) context.startActivity(intent, ActivityOptions.makeBasic().setLaunchDisplayId(display).toBundle())
else context.startActivity(intent)
}.isSuccess
}
fun close() {
current?.get()?.finish()
}
}
}
@@ -286,7 +286,13 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
// Builds before 0.5.0-nad1 turned the bridge on under Auto without recording it, and
// left it on for good (it wins over the pair). Under Auto that switch is taken as Auto's.
if (!SessionPrefs.maliFallbackKnown(activity))
SessionPrefs.setMaliFallbackByAuto(activity, if (SessionPrefs.vkBridge(activity)) "bridge" else "")
SessionPrefs.setMaliFallbackByAuto(
activity,
MaliAutoRoute.initialOwnership(
SessionPrefs.vkBridge(activity), bridgeExplicit(),
SessionPrefs.venus(activity), venusExplicit(),
),
)
// A lone imported PanVK Android driver set by hand stalls the display the same way
// ("black screen with the start-up logo"), so under Auto any imported display goes.
val display = SessionPrefs.androidDriver(activity)
@@ -313,7 +319,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
refreshDrivers()
return
}
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null &&
if (gpu.family.mali && !DriverPairs.autoEligible(gpu) &&
com.droiddeck.launcher.gpu.VulkanInfo.cachedOrNull() == null) {
releaseChecking = true
autoStatus = activity.getString(R.string.drivers_checking_latest)
@@ -329,14 +335,14 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
}, "gpu-name").start()
return
}
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) -> " + (DriverPairs.recommendedKey(gpu, emptyList()) ?: "no pair"))
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null) {
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) eligible=${DriverPairs.autoEligible(gpu)}")
if (gpu.family.mali && !DriverPairs.autoEligible(gpu)) {
// No PanVK build covers this Mali (e.g. the G1 series, arch v14): the phone's own driver.
autoStatus = useMaliFallback(null)
refreshDrivers()
return
}
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
if (!DriverPairs.autoEligible(gpu)) {
autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity, com.droiddeck.launcher.core.DeviceSupport.vkBridge(activity)).lowercase())
return
}
@@ -356,11 +362,21 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
val pair = pairs.firstOrNull { it.key == key }
val row = pairRows.firstOrNull { it.key == key }
when {
row?.active == true -> autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
?: activity.getString(R.string.upd_current_status)
row?.active == true -> {
if (MaliAutoRoute.shouldEnd(
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali,
pair?.key?.let { DriverPairs.isNonAdreno(it) } == true,
)) endMaliFallback()
autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
?: activity.getString(R.string.upd_current_status)
}
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
// RADV is not published right now: the Xclipse falls back to the system route.
SessionPrefs.ensurePowerVrAutoDrivers(activity)
if (gpu.name.contains("Xclipse", ignoreCase = true) && DriverPairs.xclipseNeedsUpstream(gpu.name)) {
if (!SessionState.running) SessionPrefs.ensurePowerVrAutoDrivers(activity, powerVr = true, autoOwnedOnly = true)
} else {
SessionPrefs.ensurePowerVrAutoDrivers(activity)
}
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
refreshDrivers()
}
@@ -397,6 +413,12 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
}, "gpu-driver-auto").start()
}
private fun bridgeExplicit(): Boolean =
MaliAutoRoute.userChoice(SessionPrefs.vkBridgeExplicit(activity), SessionPrefs.maliFallbackByAuto(activity), MaliAutoRoute.BRIDGE)
private fun venusExplicit(): Boolean =
MaliAutoRoute.userChoice(SessionPrefs.venusExplicit(activity), SessionPrefs.maliFallbackByAuto(activity), MaliAutoRoute.VENUS)
/**
* A Mali with no open driver pair to install ([missing] names the unpublished pair, or null when
* no PanVK build covers this GPU) runs through the phone's own driver: Mali (Venus) where this
@@ -410,12 +432,21 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity)
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), venusExplicit(),
)
if (venus && !SessionPrefs.venus(activity)) {
SessionPrefs.setVenus(activity, true)
SessionPrefs.setMaliFallbackByAuto(activity, "venus")
if (SessionPrefs.vkBridge(activity) && !bridgeExplicit())
SessionPrefs.setVkBridge(activity, false)
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (!venus && !SessionPrefs.vkBridge(activity)) {
SessionPrefs.setVkBridge(activity, true)
SessionPrefs.setMaliFallbackByAuto(activity, "bridge")
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (ownership != MaliAutoRoute.NONE) {
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
}
val route = activity.getString(if (venus) R.string.drivers_route_venus else R.string.drivers_route_bridge)
Log.i(TAG, "auto: Mali stand-in route $route (missing pair: ${missing ?: "none covers ${gpu.name}"})")
@@ -503,7 +534,9 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
// A route Auto switched on in place of a missing pair goes off now that one is
// here. A Mali bridge or Venus switch the user set stays: it wins for the session
// (DeviceSupport.vkBridge, VenusComponent.wanted) and the pair waits.
if (gpu.family.mali && DriverPairs.isNonAdreno(pair.key)) endMaliFallback()
if (MaliAutoRoute.shouldEnd(
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali, DriverPairs.isNonAdreno(pair.key),
)) endMaliFallback()
val restart = displayChanged && CompositorHost.isStarted
if (auto) {
val trial = AutoDriverTrial.current(activity)
@@ -744,4 +777,3 @@ internal fun Context.displayNameOf(uri: Uri): String? = if (uri.scheme == "file"
} catch (e: Exception) {
null
}
File diff suppressed because it is too large. Load diff
@@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.droiddeck.launcher.session.SessionService
import com.droiddeck.launcher.session.SessionState
class HomeActivity : Activity() {
override fun attachBaseContext(newBase: android.content.Context) {
@@ -18,15 +19,22 @@ class HomeActivity : Activity() {
}
private fun routeHome() {
val destination = if (HomeApp.isActiveSteamSession()) {
val destination = if (HomeApp.isActiveSteamSession() && !SessionState.pipActive) {
Intent(this, SessionActivity::class.java)
.setAction(SessionService.ACTION_HOME_GUIDE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
} else {
Intent(this, FrontEndActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
.apply {
val page = com.droiddeck.launcher.core.AppUiPrefs.homePage(this@HomeActivity)
if (page != com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) {
putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, page)
}
}
}
startActivity(destination)
if (SessionState.pipActive && destination.component?.className == FrontEndActivity::class.java.name) HomeApp.showFrontEnd(this, destination)
else startActivity(destination)
finish()
}
}
@@ -18,6 +18,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.graphics.drawable.toBitmap
import com.droiddeck.launcher.core.AppUiPrefs
import com.droiddeck.launcher.session.SessionService
import com.droiddeck.launcher.session.SessionState
import kotlin.math.roundToInt
@@ -41,7 +42,7 @@ object HomeApp {
val userSerial: Long = 0L,
) {
val component get() = ComponentName(packageName, className)
val key get() = "$packageName/$className" + if (userSerial != 0L) "#$userSerial" else ""
val key get() = appKey(packageName, className, userSerial)
val work get() = userSerial != 0L
}
@@ -101,6 +102,9 @@ object HomeApp {
?: resolved.loadLabel(pm)?.toString()?.trim()?.takeIf { it.isNotEmpty() }
}
private fun appKey(packageName: String, className: String, userSerial: Long) =
"$packageName/$className" + if (userSerial != 0L) "#$userSerial" else ""
fun roleRequestIntent(context: Context): Intent? {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return null
val roles = context.getSystemService(RoleManager::class.java) ?: return null
@@ -116,13 +120,25 @@ object HomeApp {
val pm = context.packageManager
val own = Process.myUserHandle()
val iconPx = (ICON_DP * context.resources.displayMetrics.density).roundToInt()
val densityDpi = context.resources.displayMetrics.densityDpi
val pack = IconPack.active(context)
val appColors = IconPack.appColors(context)
HomeIcons.load(context)
val overrides = HomeIcons.overrides
val apps = users.userProfiles.flatMap { user ->
val serial = if (user == own) 0L else users.getSerialNumberForUser(user)
runCatching { launcher.getActivityList(null, user) }.getOrDefault(emptyList()).mapNotNull { info ->
val component = info.componentName
if (component.packageName == context.packageName && user == own) return@mapNotNull null
val label = info.label?.toString()?.trim().orEmpty().ifEmpty { component.packageName }
val icon = runCatching { info.getBadgedIcon(0).toBitmap(iconPx, iconPx) }.getOrNull()
val icon = runCatching {
(overrides[appKey(component.packageName, component.className, serial)]
?.let { IconPack.drawable(context, it.pack, it.drawable, densityDpi) }
?: pack?.icon(component, densityDpi)
?: pack?.plated(info.getIcon(0), iconPx, densityDpi, appColors))
?.let { pm.getUserBadgedIcon(it, user) }
?.toBitmap(iconPx, iconPx)
}.getOrNull() ?: runCatching { info.getBadgedIcon(0).toBitmap(iconPx, iconPx) }.getOrNull()
val app = info.applicationInfo
val updated = if (user == own) runCatching { pm.getPackageInfo(component.packageName, 0).lastUpdateTime }.getOrNull() else null
@Suppress("DEPRECATION")
@@ -181,7 +197,10 @@ object HomeApp {
}
private fun syncRecents(activity: android.app.Activity) =
keepOutOfRecents(activity, activity is FrontEndActivity && !SessionState.running && isDefault(activity))
keepOutOfRecents(
activity,
activity is FrontEndActivity && !SessionState.running && isDefault(activity) && AppUiPrefs.hideHomeFromRecents(activity),
)
internal enum class RecentsStep { HIDE, SHOW, FORGET, NONE }
@@ -243,6 +262,19 @@ object HomeApp {
fun isActiveSteamSession(): Boolean =
SessionState.running && SessionState.mode == SessionService.MODE_STEAM
fun showFrontEnd(context: Context, intent: Intent = Intent(context, FrontEndActivity::class.java)) {
val frontEnd = FrontEndActivity::class.java.name
val tasks = runCatching { context.getSystemService(android.app.ActivityManager::class.java)?.appTasks }.getOrNull().orEmpty()
val own = tasks.firstOrNull { task ->
runCatching { task.taskInfo.let { it.baseIntent.component?.className == frontEnd && it.topActivity?.className == frontEnd } }
.getOrDefault(false)
}
val launch = Intent(intent).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
if (own != null && runCatching { own.startActivity(context, launch, null) }.isSuccess) return
// The session task shares the front end's affinity, so without MULTIPLE_TASK the front end lands inside the session's PiP window.
context.startActivity(launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK))
}
fun openSystemHomeSettings(context: Context) {
try {
context.startActivity(settingsIntent())
@@ -0,0 +1,46 @@
package com.droiddeck.launcher
import android.content.Context
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
object HomeIcons {
private const val PREFS = "home_launcher"
private const val KEY = "icon_overrides"
private const val SEPARATOR = '\t'
data class Choice(val pack: String, val drawable: String)
var overrides by mutableStateOf<Map<String, Choice>>(emptyMap())
private set
@Volatile private var loaded = false
@Synchronized
fun load(context: Context) {
if (loaded) return
overrides = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.getStringSet(KEY, emptySet()).orEmpty().mapNotNull(::decode).toMap()
loaded = true
}
fun set(context: Context, key: String, pack: String, drawable: String) = save(context, overrides + (key to Choice(pack, drawable)))
fun clear(context: Context, key: String) = save(context, overrides - key)
fun clearAll(context: Context) = save(context, emptyMap())
private fun save(context: Context, next: Map<String, Choice>) {
overrides = next
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
.putStringSet(KEY, next.map { (key, choice) -> encode(key, choice) }.toSet()).apply()
}
internal fun encode(key: String, choice: Choice) = listOf(key, choice.pack, choice.drawable).joinToString(SEPARATOR.toString())
internal fun decode(entry: String): Pair<String, Choice>? {
val parts = entry.split(SEPARATOR)
if (parts.size != 3 || parts.any { it.isEmpty() }) return null
return parts[0] to Choice(parts[1], parts[2])
}
}
@@ -0,0 +1,198 @@
package com.droiddeck.launcher
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.PorterDuffXfermode
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.Xml
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.createBitmap
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.drawable.toDrawable
import androidx.palette.graphics.Palette
import org.xmlpull.v1.XmlPullParser
import java.time.LocalDate
import kotlin.math.roundToInt
object IconPack {
const val NONE = ""
private const val PREFS = "home_launcher"
private const val KEY = "icon_pack"
private const val APP_COLORS = "icon_pack_app_colors"
private const val FILTER = "appfilter"
private const val DRAWABLES = "drawable"
private val ACTIONS = listOf("org.adw.launcher.THEMES", "com.novalauncher.THEME")
data class Pack(val packageName: String, val label: String)
internal data class Plate(val back: String?, val mask: String?, val upon: String?, val scale: Float)
internal data class Filter(val icons: Map<String, String>, val calendars: Map<String, String>, val plate: Plate?) {
fun names(component: String, day: Int) = listOfNotNull(calendars[component]?.plus(day), icons[component])
}
class Loaded internal constructor(
private val resources: Resources,
internal val pack: String,
internal val updatedAt: Long,
private val filter: Filter,
) {
fun icon(component: ComponentName, densityDpi: Int) =
filter.names(component.flattenToString(), LocalDate.now().dayOfMonth).firstNotNullOfOrNull { load(resources, pack, it, densityDpi) }
val hasBack get() = filter.plate?.back != null
fun plated(icon: Drawable, size: Int, densityDpi: Int, appColor: Boolean): Drawable? {
val plate = filter.plate ?: return null
fun image(name: String?) = name?.let { load(resources, pack, it, densityDpi) }?.toBitmap(size, size)
val base = icon.toBitmap(size, size)
val color = if (appColor) Palette.from(base).generate().getDominantColor(0).takeIf { it != 0 } else null
return compose(base, image(plate.back), image(plate.mask), image(plate.upon), plate.scale, color).toDrawable(resources)
}
}
@Volatile private var cached: Loaded? = null
fun selected(context: Context): String =
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY, NONE).orEmpty()
fun select(context: Context, pack: String) {
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY, pack).apply()
}
fun appColors(context: Context): Boolean =
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean(APP_COLORS, false)
fun setAppColors(context: Context, on: Boolean) {
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(APP_COLORS, on).apply()
}
fun installed(context: Context): List<Pack> {
val pm = context.packageManager
return ACTIONS.flatMap { pm.queryIntentActivities(Intent(it), 0) }
.map { it.activityInfo.applicationInfo }
.distinctBy { it.packageName }
.filter { app -> resources(pm, app.packageName)?.let { withXml(it, app.packageName, FILTER) { true } } == true }
.map { app -> Pack(app.packageName, app.loadLabel(pm).toString().trim().ifEmpty { app.packageName }) }
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.label })
}
fun active(context: Context): Loaded? {
val pack = selected(context)
if (pack == NONE) return null
val pm = context.packageManager
val updatedAt = runCatching { pm.getPackageInfo(pack, 0).lastUpdateTime }.getOrNull() ?: return null
cached?.takeIf { it.pack == pack && it.updatedAt == updatedAt }?.let { return it }
val resources = resources(pm, pack) ?: return null
val filter = withXml(resources, pack, FILTER) { parse(it) } ?: return null
return Loaded(resources, pack, updatedAt, filter).also { cached = it }
}
fun drawable(context: Context, pack: String, name: String, densityDpi: Int): Drawable? {
val resources = resources(context.packageManager, pack) ?: return null
return load(resources, pack, name, densityDpi)
}
fun names(context: Context, pack: String): List<String> {
val resources = resources(context.packageManager, pack) ?: return emptyList()
return withXml(resources, pack, DRAWABLES) { parseNames(it) }?.takeIf { it.isNotEmpty() }
?: withXml(resources, pack, FILTER) { parse(it).icons.values.distinct().sorted() }.orEmpty()
}
private fun resources(pm: PackageManager, pack: String): Resources? =
runCatching { pm.getResourcesForApplication(pack) }.getOrNull()
private fun load(resources: Resources, pack: String, name: String, densityDpi: Int): Drawable? {
val id = resources.getIdentifier(name, "drawable", pack).takeIf { it != 0 }
?: resources.getIdentifier(name, "mipmap", pack).takeIf { it != 0 }
?: return null
return runCatching { ResourcesCompat.getDrawableForDensity(resources, id, densityDpi, null) }.getOrNull()
}
internal fun parseNames(xml: XmlPullParser): List<String> {
val names = LinkedHashSet<String>()
forEachTag(xml) { if (xml.name == "item") xml.getAttributeValue(null, "drawable")?.trim()?.takeIf { it.isNotEmpty() }?.let { names.add(it) } }
return names.toList()
}
internal fun parse(xml: XmlPullParser): Filter {
val icons = HashMap<String, String>()
val calendars = HashMap<String, String>()
var back: String? = null
var mask: String? = null
var upon: String? = null
var scale = 1f
fun image() = xml.getAttributeValue(null, "img1")?.trim()?.takeIf { it.isNotEmpty() }
forEachTag(xml) {
when (xml.name) {
"item" -> {
val key = componentKey(xml.getAttributeValue(null, "component"))
val drawable = xml.getAttributeValue(null, "drawable")?.trim()
if (key != null && !drawable.isNullOrEmpty()) icons.putIfAbsent(key, drawable)
}
"calendar" -> {
val key = componentKey(xml.getAttributeValue(null, "component"))
val prefix = xml.getAttributeValue(null, "prefix")?.trim()
if (key != null && !prefix.isNullOrEmpty()) calendars.putIfAbsent(key, prefix)
}
"iconback" -> back = back ?: image()
"iconmask" -> mask = mask ?: image()
"iconupon" -> upon = upon ?: image()
"scale" -> scale = xml.getAttributeValue(null, "factor")?.toFloatOrNull() ?: scale
}
}
return Filter(icons, calendars, if (back == null && mask == null && upon == null) null else Plate(back, mask, upon, scale))
}
internal fun compose(icon: Bitmap, back: Bitmap?, mask: Bitmap?, upon: Bitmap?, scale: Float, backColor: Int? = null): Bitmap {
val size = icon.width
val inset = (size * (1 - scale) / 2).roundToInt()
val result = createBitmap(size, size)
val canvas = Canvas(result)
val paint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG)
val full = Rect(0, 0, size, size)
canvas.drawBitmap(icon, null, Rect(inset, inset, size - inset, size - inset), paint)
mask?.let {
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT)
canvas.drawBitmap(it, null, full, paint)
}
back?.let {
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OVER)
paint.colorFilter = backColor?.let { color -> PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN) }
canvas.drawBitmap(it, null, full, paint)
}
paint.xfermode = null
paint.colorFilter = null
upon?.let { canvas.drawBitmap(it, null, full, paint) }
return result
}
private inline fun forEachTag(xml: XmlPullParser, block: () -> Unit) {
var event = xml.eventType
while (event != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) block()
event = xml.next()
}
}
internal fun componentKey(component: String?): String? =
component?.trim()?.removePrefix("ComponentInfo{")?.removeSuffix("}")?.let(ComponentName::unflattenFromString)?.flattenToString()
private fun <T> withXml(resources: Resources, pack: String, file: String, block: (XmlPullParser) -> T): T? = runCatching {
val xml = resources.getIdentifier(file, "xml", pack)
val raw = resources.getIdentifier(file, "raw", pack)
if (xml != 0) resources.getXml(xml).use(block)
else (if (raw != 0) resources.openRawResource(raw) else resources.assets.open("$file.xml"))
.use { stream -> block(Xml.newPullParser().also { it.setInput(stream, null) }) }
}.getOrNull()
}
@@ -0,0 +1,31 @@
package com.droiddeck.launcher
internal object MaliAutoRoute {
const val NONE = ""
const val BRIDGE = "bridge"
const val VENUS = "venus"
fun initialOwnership(bridgeOn: Boolean, bridgeExplicit: Boolean, venusOn: Boolean, venusExplicit: Boolean): String =
when {
venusOn && !venusExplicit -> VENUS
bridgeOn && !bridgeExplicit -> BRIDGE
else -> NONE
}
fun fallbackOwnership(
venusAvailable: Boolean,
bridgeOn: Boolean,
bridgeExplicit: Boolean,
venusOn: Boolean,
venusExplicit: Boolean,
): String = if (venusAvailable) {
if (!venusOn || !venusExplicit) VENUS else NONE
} else {
if (!bridgeOn || !bridgeExplicit) BRIDGE else NONE
}
fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route
fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean =
mali && installedPair && ownsRoute != NONE
}
@@ -7,6 +7,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.session.ExperimentalProtons
import com.droiddeck.launcher.session.ProtonExtras
import com.droiddeck.launcher.ui.ProtonRow
import com.droiddeck.launcher.session.SessionState
@@ -19,6 +20,7 @@ internal class ProtonMenu(
private val activity: android.app.Activity,
private val ui: Handler,
private val onInstalled: () -> Unit = {},
private val onRemoved: () -> Unit = {},
private val idle: () -> Boolean = { true },
) {
private object Operation {
@@ -27,13 +29,23 @@ internal class ProtonMenu(
val stage = mutableStateOf<String?>(null)
val percent = mutableIntStateOf(-1)
val problem = mutableStateOf<String?>(null)
val experimental = mutableStateOf<List<String>>(emptyList())
val experimentalReleases = mutableStateOf<List<ExperimentalProtons.Release>>(emptyList())
var fetchedReleases = emptyList<ExperimentalProtons.Release>()
val checking = java.util.concurrent.atomic.AtomicBoolean(false)
}
var protonRows by Operation.rows
var protonBusyId by Operation.busyId
var protonStage by Operation.stage
var protonPercent by Operation.percent
var protonProblem by Operation.problem
private val checking = java.util.concurrent.atomic.AtomicBoolean(false)
var experimentalDirs by Operation.experimental
var experimentalReleases by Operation.experimentalReleases
companion object {
const val EXPERIMENTAL = "experimental"
}
@VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) }
@VisibleForTesting internal var experimentalRefresh: () -> List<ExperimentalProtons.Release>? = { ExperimentalProtons.refresh(activity) }
@VisibleForTesting internal var installer: (ProtonExtras.Tool, (String, Int) -> Unit) -> String? =
{ tool, progress -> ProtonExtras.install(activity, tool, progress) }
@@ -86,21 +98,80 @@ internal class ProtonMenu(
}, "remove-proton-$id").start()
}
fun installExperimental(work: ((String, Int) -> Unit) -> String?) {
if (protonBusyId != null || ProtonExtras.installInProgress || SessionState.running) return
protonBusyId = EXPERIMENTAL
protonProblem = null
protonStage = activity.getString(R.string.store_starting)
protonPercent = -1
Thread({
val problem = runCatching {
work { label, value -> ui.post { protonStage = label; protonPercent = value } }
}.getOrElse { it.message ?: it.javaClass.simpleName }
ui.post {
protonProblem = problem
protonBusyId = null
protonStage = null
protonPercent = -1
refreshProtons()
android.widget.Toast.makeText(activity, problem ?: activity.getString(R.string.xproton_installed), android.widget.Toast.LENGTH_LONG).show()
if (problem == null) onInstalled()
}
}, "install-proton-experimental").start()
}
fun installExperimentalRelease(release: ExperimentalProtons.Release) {
installExperimental { progress -> ExperimentalProtons.installRelease(activity, release, progress) }
}
fun removeExperimental(dir: String) {
if (protonBusyId != null || SessionState.running) return
protonBusyId = EXPERIMENTAL
protonProblem = null
protonStage = activity.getString(R.string.main_removing_named, dir)
protonPercent = -1
Thread({
val removed = runCatching { ExperimentalProtons.remove(activity, dir) }.getOrDefault(false)
ui.post {
protonBusyId = null
protonStage = null
refreshProtons()
if (!removed) android.widget.Toast.makeText(activity, activity.getString(R.string.xproton_remove_failed, dir), android.widget.Toast.LENGTH_LONG).show()
}
}, "remove-proton-experimental").start()
}
private fun refreshExperimental() {
val installed = ExperimentalProtons.installed(activity)
experimentalDirs = installed.map { it.dir }
experimentalReleases = ExperimentalProtons.available(Operation.fetchedReleases, installed)
}
fun refreshProtons() {
protonRows = ProtonExtras.tools.map {
refreshExperimental()
protonRows = ProtonExtras.offered(activity).map {
val all = ProtonExtras.installedAll(activity, it)
ProtonRow(it.id, it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it))
}
}
fun checkUpdates(force: Boolean = false) {
if (!checking.compareAndSet(false, true)) return
if (!Operation.checking.compareAndSet(false, true)) return
Thread({
val asked = try { ProtonExtras.checkLatest(activity, force) } catch (_: Throwable) { false } finally { checking.set(false) }
ui.post {
if (asked) refreshProtons()
val asked = runCatching { latestCheck(force) }.getOrDefault(false)
val experimental = runCatching { experimentalRefresh() }.getOrNull()
val published = ui.post {
try {
val before = experimentalDirs
Operation.fetchedReleases = experimental ?: emptyList()
if (asked) refreshProtons() else refreshExperimental()
if (!experimentalDirs.containsAll(before)) onRemoved()
} finally {
Operation.checking.set(false)
}
ensureAutoUpdates()
}
if (!published) Operation.checking.set(false)
}, "proton-updates").start()
}
File diff suppressed because it is too large. Load diff
@@ -17,6 +17,7 @@ import com.droiddeck.launcher.ui.UpdatesActions
import com.droiddeck.launcher.ui.UpdatesState
import com.droiddeck.launcher.update.AppUpdates
import com.droiddeck.launcher.update.SelfInstaller
import com.droiddeck.launcher.update.UpdateWatch
internal class UpdatesMenu(private val activity: Activity, private val ui: Handler) {
var catalog by mutableStateOf<AppUpdates.Catalog?>(null)
@@ -43,6 +44,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl
.onFailure { error = activity.getString(R.string.upd_unknown_apps_failed); pending = null }
},
onDismissPermission = { askPermission = false; pending = null },
onSeen = { r -> UpdateWatch.seen(activity, r) },
)
val hasUpdate: Boolean get() = AppUpdates.hasUpdate(catalog, follow)
@@ -77,6 +79,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl
private fun choose(f: AppUpdates.Follow) {
AppUpdates.setFollow(activity, f)
UpdateWatch.sync(activity, f, catalog?.let { AppUpdates.release(it, f) })
follow = f
error = null
}
@@ -93,7 +96,17 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl
percent = 0
Thread({
val result = runCatching {
val file = SelfInstaller.download(activity, apk) { pct -> ui.post { percent = pct } }
val file = try {
SelfInstaller.download(activity, apk) { pct -> ui.post { percent = pct } }
} catch (e: java.io.IOException) {
// Each push replaces a test build's APK, so a list read before the push names a file that is gone.
if (r.pr <= 0) throw e
val fresh = runCatching { AppUpdates.refresh(activity) }.getOrNull() ?: throw e
ui.post { catalog = fresh }
val newer = fresh.tests.firstOrNull { it.tag == r.tag }?.apk?.takeIf { it.url != apk.url } ?: throw e
ui.post { percent = 0 }
SelfInstaller.download(activity, newer) { pct -> ui.post { percent = pct } }
}
ui.post { stage = activity.getString(R.string.upd_stage_installing); percent = -1 }
SelfInstaller.install(activity, file) { id -> session = id }
}
@@ -23,7 +23,7 @@ object AgentAccess {
fun requireCommands(context: Context) {
if (!commandsAllowed(context)) throw AgentException(
"AGENT_COMMANDS_DISABLED",
"Debugging tools are off: turn on Setup > Diagnostics > Debugging tools on the device",
"Debugging tools are off: turn on Setup > Developer > Debugging tools on the device",
)
}
@@ -1,9 +1,13 @@
package com.droiddeck.launcher.agent
import android.content.Context
import android.graphics.Bitmap
import android.net.Uri
import android.provider.OpenableColumns
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
@@ -50,6 +54,22 @@ object AgentAttachments {
if (host(context, path).renameTo(moved)) "$GUEST_DIR/$chat/${moved.name}" else path
}
/** Copies the running game's frame; set while a session is open. */
var gameFrame by mutableStateOf<(((Bitmap?) -> Unit) -> Unit)?>(null)
/** Saves [frame] for [chat] (or a new conversation) on the calling thread; returns its guest path. */
fun saveFrame(context: Context, chat: String?, frame: Bitmap): String? = runCatching {
val folder = chat ?: NEW
val dir = File(hostDir(context), folder).apply { mkdirs() }
val target = File(dir, "game-${System.currentTimeMillis()}.jpg")
val written = target.outputStream().use { frame.compress(Bitmap.CompressFormat.JPEG, 88, it) }
if (!written) {
target.delete()
return@runCatching null
}
"$GUEST_DIR/$folder/${target.name}"
}.getOrNull()
/** Deletes copies that will not be sent. */
fun discard(context: Context, files: List<String>) = files.forEach { host(context, it).delete() }
@@ -76,6 +76,9 @@ class AgentBridgeProvider : ContentProvider() {
"stop" -> stop(context)
"resume" -> resume(context)
"launch" -> launch(context, request)
"library" -> AgentStores.library(context, request)
"xodus" -> AgentStores.xodus(context, request)
"cloud" -> AgentStores.cloud(context, request)
"focus" -> guest(context, JSONObject().put("kind", "focus"), 15_000)
"quit" -> guest(context, JSONObject().put("kind", "quit").put("appId", request.opt("appId"))
.put("timeout", request.optDouble("timeout", 15.0)), timeoutMs(request, 15.0, 30_000))
@@ -37,6 +37,21 @@ object AgentChats {
}
.sortedByDescending { it.updated }
/** The chats among [chats] where the user or the agent wrote [query], ignoring case. */
fun search(context: Context, chats: List<Chat>, query: String): List<Chat> {
val q = query.trim()
if (q.isEmpty()) return chats
return chats.filter { chat ->
chat.title.contains(q, ignoreCase = true) || read(file(context, chat.id)).entries.any { matches(it, q) }
}
}
internal fun matches(entry: Entry, query: String) = when (entry) {
is Entry.Asked -> entry.text.contains(query, ignoreCase = true)
is Entry.Said -> entry.text.contains(query, ignoreCase = true)
else -> false
}
fun delete(context: Context, id: String) {
file(context, id).delete()
File(AgentAttachments.hostDir(context), id).deleteRecursively()
@@ -69,12 +84,18 @@ object AgentChats {
internal fun encode(entry: Entry): String = when (entry) {
is Entry.Asked -> JSONObject().put("asked", entry.text).apply { if (entry.files.isNotEmpty()) put("files", JSONArray(entry.files)) }
is Entry.Said -> JSONObject().put("said", entry.text)
is Entry.Notice -> JSONObject().put("notice", entry.text)
is Entry.Thought -> JSONObject().put("thought", entry.text)
is Entry.Result -> JSONObject().put("result", entry.id).put("output", entry.output).put("failed", entry.failed)
is Entry.Used -> JSONObject().put("used", entry.tool).put("detail", entry.detail).put("id", entry.id).put("input", entry.input)
.apply { if (entry.parent.isNotEmpty()) put("parent", entry.parent) }
.apply { entry.output?.let { put("output", it).put("failed", entry.failed) } }
is Entry.Finished -> JSONObject().put("finished", true).put("error", entry.error ?: JSONObject.NULL).put("stopped", entry.stopped).apply {
entry.usage?.let { put("ms", it.durationMs).put("cost", it.costUsd).put("in", it.inputTokens).put("out", it.outputTokens) }
if (entry.planned) put("planned", true)
entry.usage?.let {
put("ms", it.durationMs).put("cost", it.costUsd).put("in", it.inputTokens).put("out", it.outputTokens)
if (it.context > 0) put("ctx", it.context).put("win", it.window)
}
}
}.toString()
@@ -99,13 +120,15 @@ object AgentChats {
private fun decode(o: JSONObject): Entry? = when {
o.has("asked") -> Entry.Asked(o.getString("asked"), o.optJSONArray("files")?.let { a -> (0 until a.length()).map { a.getString(it) } }.orEmpty())
o.has("said") -> Entry.Said(o.getString("said"))
o.has("notice") -> Entry.Notice(o.getString("notice"))
o.has("thought") -> Entry.Thought(o.getString("thought"))
o.has("used") -> Entry.Used(o.optString("id"), o.getString("used"), o.optString("detail"), o.optString("input"),
if (o.has("output")) o.optString("output") else null, o.optBoolean("failed"))
if (o.has("output")) o.optString("output") else null, o.optBoolean("failed"), o.optString("parent"))
o.has("result") -> Entry.Result(o.getString("result"), o.optString("output"), o.optBoolean("failed"))
o.has("finished") -> Entry.Finished(
if (o.isNull("error")) null else o.optString("error"), o.optBoolean("stopped"),
if (o.has("ms")) AgentHost.Usage(o.optLong("ms"), o.optDouble("cost", 0.0), o.optLong("in"), o.optLong("out")) else null,
if (o.has("ms")) AgentHost.Usage(o.optLong("ms"), o.optDouble("cost", 0.0), o.optLong("in"), o.optLong("out"), o.optLong("ctx"), o.optLong("win")) else null,
o.optBoolean("planned"),
)
else -> null
}
@@ -0,0 +1,27 @@
package com.droiddeck.launcher.agent
import android.content.Context
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
/** The text typed in the Agent tab and not yet sent, kept across leaving the tab and restarts. */
object AgentDraft {
private const val KEY = "draft"
private var state: MutableState<String>? = null
fun state(context: Context): MutableState<String> = state ?: run {
val prefs = AgentHost.prefs(context.applicationContext)
val backing = mutableStateOf(prefs.getString(KEY, "") ?: "")
object : MutableState<String> {
override var value: String
get() = backing.value
set(text) {
if (text == backing.value) return
backing.value = text
prefs.edit().apply { if (text.isEmpty()) remove(KEY) else putString(KEY, text) }.apply()
}
override fun component1() = value
override fun component2(): (String) -> Unit = { value = it }
}.also { state = it }
}
}
@@ -58,7 +58,8 @@ object AgentEnv {
fun override(context: Context, name: String): JSONObject = synchronized(lock) {
AgentAccess.requireCommands(context)
if (NAME.matchEntire(name) == null || name in setOf(".", "..")) throw AgentException("INVALID_NAME", "Override names are letters, digits, '.', '_' and '-'")
if (name == "libblfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
if (name == LEGACY_FAST_PATH) throw AgentException("INVALID_NAME", "The fast-path library is now $FAST_PATH")
if (name == "libddfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
throw AgentException("SESSION_ACTIVE", "Stop the session before installing a fast-path library")
}
val source = File(inbox(context), name)
@@ -73,7 +74,7 @@ object AgentEnv {
staged.delete()
throw AgentException("OVERRIDE_FAILED", "Could not stage the override")
}
if (name == "libblfastpath.so" && !arm64SharedLibrary(staged)) {
if (name == "libddfastpath.so" && !arm64SharedLibrary(staged)) {
staged.delete()
throw AgentException("INVALID_LIBRARY", "The fast path must be a 64-bit little-endian ARM64 ELF shared library")
}
@@ -86,7 +87,7 @@ object AgentEnv {
state.put("pendingOverrides", JSONArray(merge(strings(state.optJSONArray("pendingOverrides")), listOf(name))))
save(context, state)
state.put("installed", "$GUEST_BIN/$name")
if (name == "libblfastpath.so") {
if (name == "libddfastpath.so") {
val digest = MessageDigest.getInstance("SHA-256")
target.inputStream().use { input ->
val buffer = ByteArray(65536)
@@ -103,10 +104,10 @@ object AgentEnv {
fun fastPathLibrary(context: Context): String = synchronized(lock) {
if (!AgentAccess.commandsAllowed(context)) return@synchronized ProotFastPath.LIBRARY
if ("libblfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libblfastpath.so")
if ("libddfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libddfastpath.so")
if (!file.isFile || Files.isSymbolicLink(file.toPath())) return@synchronized ProotFastPath.LIBRARY
"$GUEST_BIN/libblfastpath.so"
"$GUEST_BIN/libddfastpath.so"
}
private fun arm64SharedLibrary(file: File): Boolean = file.inputStream().use { input ->
@@ -129,13 +130,18 @@ object AgentEnv {
}
val state = load(context)
val active = strings(state.optJSONArray("pending"))
val overrides = strings(state.optJSONArray("pendingOverrides"))
val queued = strings(state.optJSONArray("pendingOverrides"))
val legacy = File(bin(context), LEGACY_FAST_PATH)
val stranded = FAST_PATH in queued && legacy.isFile && !File(bin(context), FAST_PATH).exists() &&
!legacy.renameTo(File(bin(context), FAST_PATH))
if (stranded) Log.w(TAG, "could not rename the queued $LEGACY_FAST_PATH; it stays queued for the next session")
val overrides = if (stranded) queued - FAST_PATH else queued
bin(context).listFiles()
?.filter { it.name !in overrides }?.forEach { it.delete() }
?.filter { it.name !in overrides && !(stranded && it.name == LEGACY_FAST_PATH) }?.forEach { it.delete() }
val lines = strings(state.optJSONArray("persistent")) + active
val withPath = if (overrides.none { it != "libblfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
val withPath = if (overrides.none { it != "libddfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
state.put("active", JSONArray(active)).put("pending", JSONArray())
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray())
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray(if (stranded) listOf(FAST_PATH) else emptyList()))
save(context, state)
if (withPath.isNotEmpty()) Log.i(TAG, "agent environment keys for this session: ${withPath.map { it.substringBefore('=') }}")
withPath
@@ -158,6 +164,9 @@ object AgentEnv {
save(context, state)
}
private const val FAST_PATH = "libddfastpath.so"
private const val LEGACY_FAST_PATH = "libblfastpath.so"
private fun pathOf(lines: List<String>) =
lines.lastOrNull { it.startsWith("PATH=") }?.substringAfter('=')?.takeIf { it.isNotBlank() } ?: LinuxRuntime.GUEST_PATH
@@ -186,6 +195,9 @@ object AgentEnv {
for (key in listOf("pending", "active", "persistent", "pendingOverrides", "activeOverrides")) {
if (!state.has(key)) state.put(key, JSONArray())
}
for (key in listOf("pendingOverrides", "activeOverrides")) {
state.put(key, JSONArray(strings(state.optJSONArray(key)).map { if (it == LEGACY_FAST_PATH) FAST_PATH else it }.distinct()))
}
return state
}
@@ -230,6 +230,20 @@ object AgentGuest {
call(context, JSONObject().put("kind", "cdp").put("expression", expression).put("timeout", timeoutMs / 1000.0),
timeoutMs + 2_000, trusted = true)
fun setGamescopeConvar(context: Context, name: String, value: Int): Boolean {
val request = JSONObject()
.put("kind", "exec")
.put("argv", org.json.JSONArray(listOf("gamescopectl", name, value.toString())))
.put("timeout", 5.0)
val result = runCatching { call(context, request, 8_000, trusted = true) }
val answer = result.getOrNull()
val applied = answer?.optBoolean("ok") == true
&& answer.optInt("exitCode", -1) == 0
&& !answer.optBoolean("timedOut")
if (!applied) Log.w(TAG, "gamescope did not take $name $value: ${result.exceptionOrNull() ?: answer}")
return applied
}
fun call(context: Context, request: JSONObject, timeoutMs: Long, trusted: Boolean = false): JSONObject {
if (!trusted && request.optString("kind") in setOf("exec", "cdp")) AgentAccess.requireCommands(context)
if (!SessionState.running) throw AgentException("NO_ACTIVE_SESSION", "There is no running session")
File diff suppressed because it is too large. Load diff
@@ -14,35 +14,56 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.R
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.OrphanReaper
import com.droiddeck.launcher.session.SessionPrefs
import java.io.File
import java.nio.file.Files
/**
* The launcher's agent: a coding agent CLI ([AgentHarness]) from the Linux userland, run headless
* one process per turn, outside any game or desktop session. Conversations are kept on disk
* outside any game or desktop session as one process that takes its messages over stdin and stays open
* between turns, so background work can start a turn of its own. Conversations are kept on disk
* ([AgentChats]), so a restart (a Lab build, a crash) continues the same one.
*/
object AgentHost {
sealed interface Entry {
data class Asked(val text: String, val files: List<String> = emptyList()) : Entry
data class Said(val text: String) : Entry
data class Notice(val text: String) : Entry
data class Thought(val text: String) : Entry
/** A tool call; [output] stays null until its result arrives. */
data class Used(val id: String, val tool: String, val detail: String, val input: String = "", val output: String? = null, val failed: Boolean = false) : Entry
/**
* A tool call; [output] stays null until its result arrives. [parent] is the subagent call it was made under, if any.
* [background]: the call starts work that can wake the CLI after its turn (run_in_background, Monitor).
*/
data class Used(
val id: String, val tool: String, val detail: String, val input: String = "", val output: String? = null, val failed: Boolean = false,
val parent: String = "", val background: Boolean = false,
) : Entry
data class Result(val id: String, val output: String, val failed: Boolean) : Entry
data class Finished(val error: String?, val stopped: Boolean = false, val usage: Usage? = null) : Entry
/** [planned]: the turn ran in plan mode, so it ends on a plan that nothing has carried out yet. */
data class Finished(val error: String?, val stopped: Boolean = false, val usage: Usage? = null, val planned: Boolean = false) : Entry
}
data class Usage(val durationMs: Long, val costUsd: Double, val inputTokens: Long, val outputTokens: Long)
/** [context] of [window] tokens is what the conversation held when the turn ended. */
data class Usage(
val durationMs: Long, val costUsd: Double, val inputTokens: Long, val outputTokens: Long,
val context: Long = 0, val window: Long = 0,
)
/** A plan usage limit over a rolling window of [minutes]; [resetsAt] is in epoch seconds. */
data class Limit(val minutes: Int, val usedPercent: Int, val resetsAt: Long)
/** A message typed while the agent was working, sent when the turn ends. */
data class Queued(val text: String, val files: List<String>)
/** A tool call the CLI waits on the user to allow; [payload] is what its protocol needs to answer. */
data class Approval(val id: String, val tool: String, val detail: String, val input: String, val payload: String = "")
enum class State { MISSING, IDLE, WORKING }
private const val TAG = "AgentHost"
private const val WORKSPACE = "/root/DroidDeck"
internal const val GUEST_PATH = "/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
private const val TICK_MS = 1_000L
private const val IDLE_TICK_MS = 5_000L
@@ -50,13 +71,12 @@ object AgentHost {
@VisibleForTesting
internal const val BRIEF = "You run inside DroidDeck on the user's handheld, in its Linux userland (Ubuntu under proot, aarch64), " +
"and the user talks to you from DroidDeck's Agent tab, often on a small screen, so keep replies short. " +
"droiddeckctl (in the /root/DroidDeck checkout, tools/droiddeckctl) inspects and drives the app over loopback adb (\$ADB_SERIAL). " +
"dd-lab-build builds the checkout as a Lab build and restarts DroidDeck on it (docs/lab-builds.md). DroidDeck runs the build in a " +
"process of its own and shows the user its progress and time left; dd-lab-build follows that build's log until it is done. " +
"Run it with run_in_background and keep checking its output, so the user can talk to you meanwhile. " +
"The restart ends this process, and this conversation continues on the new build. " +
"DroidDeck's rules for working here are in your global instructions file (~/.claude/CLAUDE.md or ~/.codex/AGENTS.md); " +
"if they are not loaded, read ${AgentSetup.CTL}/AGENTS.md before acting on the device. " +
"Never kill by a command-line pattern (pkill -f, pgrep -f piped to kill): your own command line holds the user's message, so the pattern matches you. " +
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " +
"Commits and pull requests you make are the user's own: add no co-author line, AI credit or generated-by note."
"To have the user pick between options, end your reply with a fenced code block whose language is choices, one short option per line, " +
"and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message."
val entries = mutableStateListOf<Entry>()
val queue = mutableStateListOf<Queued>()
@@ -72,8 +92,17 @@ object AgentHost {
/** The chosen model for [harness]; null is the CLI's default. */
var model by mutableStateOf<String?>(null)
private set
/** The chosen reasoning effort for [harness]; null is the CLI's default. */
var effort by mutableStateOf<String?>(null)
private set
var plan by mutableStateOf(false)
private set
/** The chosen [AgentHarness.Permission] of [harness]; asking first until the user picks another. */
var permission by mutableStateOf(AgentHarness.ASK)
private set
/** Tool calls of the running turn that wait for the user, oldest first. */
val approvals = mutableStateListOf<Approval>()
private var approvalNoticed = false
var chat by mutableStateOf<String?>(null)
private set
/** A reply finished since the conversation was last on screen. */
@@ -94,13 +123,35 @@ object AgentHost {
/** Tokens in the conversation's context after its last step. */
var context by mutableLongStateOf(0L)
private set
/** Tokens the model's context can hold; 0 until a turn has told. */
var window by mutableLongStateOf(0L)
private set
/** The account's plan limits as [harness] last reported them. */
var limits by mutableStateOf<List<Limit>>(emptyList())
private set
var lab by mutableStateOf<LabProgress?>(null)
private set
private class Turn(val process: Process, val pid: Int)
private class Turn(val process: Process, val pid: Int, val protocol: AgentProtocol, val stdin: java.io.OutputStream) {
fun write(lines: List<String>) = synchronized(this) { stdin.apply { lines.forEach { write((it + "\n").toByteArray()) }; flush() } }
var writingGeneration: Int? = null
var exitStatus: Int? = null
var costs: AgentCostTracker? = null
var clearingCosts = false
}
private val main = Handler(Looper.getMainLooper())
private var turn: Turn? = null
/**
* The CLI process when it takes its messages over stdin. It outlives a turn, so work it started in the
* background can wake it: the answer to a finished task then arrives without a message from the user.
*/
private var session: Turn? = null
private var sessionKey: String? = null
/** The running turn is one the CLI started itself, not an answer to the user. */
private var background = false
private val reap = Runnable { if (state != State.WORKING) dropSession() }
/** Counts turns, so a process that starts after its turn was stopped is not adopted by the next one. */
private var generation = 0
private var labProcess: Process? = null
@@ -110,13 +161,17 @@ object AgentHost {
/** The running Lab build was asked for by the current turn, so stopping the turn stops it. */
private var labFromTurn = false
private var conversation: String? = null
private var turnPlanned = false
private var loaded = false
private var appContext: Context? = null
/** A tool call in this CLI process started work that can wake it after its turn (run_in_background). */
private var launchedBackground = false
val turnPid: Int get() = turn?.pid ?: 0
fun seen() {
unseen = false
appContext?.let { AgentNotice.clear(it) }
}
fun refresh(context: Context) {
@@ -125,7 +180,11 @@ object AgentHost {
File(app.filesDir, "agent").mkdirs()
harness = AgentHarness.byId(prefs(app).getString(HARNESS_KEY, null))
model = prefs(app).getString(modelKey(harness), null)
effort = prefs(app).getString(effortKey(harness), null)?.takeIf { it in harness.efforts }
plan = prefs(app).getBoolean(PLAN_KEY, false)
permission = prefs(app).getString(permissionKey(harness), null)?.takeIf { id -> harness.permissions.any { it.id == id } }
?: harness.permissions.first().id
limits = decodeLimits(prefs(app).getString(limitsKey(harness), null))
available = LinuxRuntime.hasRootfs(app)
installed = harness.files.all { guestFileExists(app, it) }
if (!installed) state = State.MISSING else if (state == State.MISSING) state = State.IDLE
@@ -148,7 +207,9 @@ object AgentHost {
conversation = loaded.conversation
entries.clear()
entries.addAll(loaded.entries)
context = 0
val last = loaded.entries.lastOrNull { it is Entry.Finished && (it.usage?.context ?: 0) > 0 } as? Entry.Finished
context = last?.usage?.context ?: 0
window = last?.usage?.window ?: 0
}
/** Opens a kept conversation, switching to the CLI it belongs to. */
@@ -162,6 +223,7 @@ object AgentHost {
AgentSetup.forget()
refresh(app)
}
dropSession()
load(app, id)
prefs(app).edit().putString(CHAT_KEY, id).apply()
}
@@ -214,11 +276,52 @@ object AgentHost {
prefs(context).edit().putString(modelKey(harness), id).apply()
}
fun chooseEffort(context: Context, level: String?) {
effort = level
prefs(context).edit().putString(effortKey(harness), level).apply()
}
fun choosePlan(context: Context, on: Boolean) {
plan = on
prefs(context).edit().putBoolean(PLAN_KEY, on).apply()
}
/** Kept per CLI, for every conversation; the CLI process restarts with it on the next message. */
fun choosePermission(context: Context, id: String) {
if (harness.permissions.none { it.id == id }) return
permission = id
prefs(context).edit().putString(permissionKey(harness), id).apply()
}
/** Lets the CLI run [approval]'s tool call, or tells it the user said no. */
fun answer(context: Context, approval: Approval, allow: Boolean) {
if (!approvals.remove(approval)) return
val running = turn ?: session ?: return
val line = running.protocol.answer(approval, allow)
val app = context.applicationContext
val current = harness
Thread({ runCatching { running.write(listOf(line)) }.onFailure { lost(app, running, current, it) } }, "agent-approval").start()
approvalsChanged(app)
}
/** The approval notice goes once nothing waits on the user any more. */
private fun approvalsChanged(app: Context) {
if (approvals.isNotEmpty() || !approvalNoticed) return
approvalNoticed = false
AgentNotice.clear(app)
}
/**
* A line the CLI waits for could not be written, so it would wait forever: its process ends, which ends
* the turn, and the chat says why. A request that may have reached it is not sent again.
*/
private fun lost(app: Context, from: Turn, current: AgentHarness, error: Throwable) {
Log.w(TAG, "could not write to ${current.name}", error)
main.post { if (turn === from || session === from) record(app, Entry.Notice("Could not write to ${current.name}: ${error.message ?: error.javaClass.simpleName}")) }
AgentProcesses.killTree(from.pid)
from.process.destroy()
}
fun models(context: Context) = harness.models(LinuxRuntime.rootDir(context.applicationContext))
/** Sends [text] now, or after the current turn when the agent is working. */
@@ -245,13 +348,52 @@ object AgentHost {
live = ""
liveThinking = ""
turnStarted = SystemClock.elapsedRealtime()
AgentHostService.start(app)
AgentHostService.start(app)?.let { serviceWarning(app, it) }
val current = harness
val prompt = AgentAttachments.prompt(message, attached)
val command = current.turn(prompt, conversation, AgentHarness.Options(model, plan && current.plans, BRIEF))
val workdir = workspace(app)
turnPlanned = plan && current.plans
val options = AgentHarness.Options(model, turnPlanned, BRIEF, effort, permission, workspace(app))
val key = "${current.id}|$id|$model|$turnPlanned|$effort|$permission"
val resumed = conversation
background = false
approvals.clear()
approvalsChanged(app)
val kept = session
if (kept != null && sessionKey == key && kept.process.isAlive) {
main.removeCallbacks(reap)
turn = kept
kept.writingGeneration = gen
kept.clearingCosts = prompt == "/clear"
Thread({
val written = runCatching { kept.write(kept.protocol.input(prompt, resumed, options, started = false)) }.isSuccess
// The process died between turns: the same message goes to a new one, which resumes the conversation.
main.post {
if (kept.writingGeneration == gen) kept.writingGeneration = null
if (generation == gen && session === kept) {
if (!written) {
dropSession()
turn = null
spawn(app, gen, current, prompt, resumed, options, key)
} else kept.exitStatus?.let { processExited(app, kept, current, it) }
}
}
}, "agent-input").start()
return
}
dropSession()
spawn(app, gen, current, prompt, resumed, options, key)
}
private fun spawn(app: Context, gen: Int, current: AgentHarness, prompt: String, resumed: String?, options: AgentHarness.Options, key: String) {
val workdir = options.workdir
val command = current.turn(prompt, resumed, options)
val protocol = current.protocol()
var threadConversation = resumed
Thread({
runCatching { current.prepare(LinuxRuntime.rootDir(app)) }
runCatching { AgentSetup.installHelpers(app) }
// Without a session nothing else keeps the userland's resolver current.
runCatching { com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent(app, LinuxRuntime.rootDir(app)).publish() }
val child = try {
guest(app, command, workdir).start()
} catch (e: Exception) {
@@ -259,34 +401,109 @@ object AgentHost {
main.post { if (generation == gen) finish(app, e.message ?: "could not start") }
return@Thread
}
val started = Turn(child, AgentProcesses.pidOf(child))
main.post { if (generation == gen && state == State.WORKING && turn == null) turn = started else AgentProcesses.killTree(started.pid) }
child.outputStream.close()
var ended = false
val started = Turn(child, AgentProcesses.pidOf(child), protocol, child.outputStream).apply {
if (current === ClaudeCode) costs = AgentCostTracker()
}
OrphanReaper.keep(started.pid)
main.post {
if (generation == gen && state == State.WORKING && turn == null) {
turn = started
session = started
sessionKey = key
} else AgentProcesses.killTree(started.pid)
}
runCatching { started.write(protocol.input(prompt, resumed, options, started = true)) }.onFailure { lost(app, started, current, it) }
val raw = runCatching {
val log = File(app.filesDir, TURN_LOG).apply { parentFile?.mkdirs() }
log.renameTo(File(app.filesDir, "$TURN_LOG.1"))
log.bufferedWriter()
}.getOrNull()
runCatching {
child.inputStream.bufferedReader().forEachLine { line ->
runCatching { raw?.apply { write(line); newLine(); flush() } }
val event = current.parse(line) ?: return@forEachLine
if (event.entries.any { it is Entry.Finished }) ended = true
main.post { if (turn === started) apply(app, event) }
child.inputStream.bufferedReader().forEachLine { output ->
runCatching { raw?.apply { write(output); newLine(); flush() } }
val parsed = protocol.parse(output) ?: return@forEachLine
if (parsed.reply.isNotEmpty()) runCatching { started.write(parsed.reply) }.onFailure { lost(app, started, current, it) }
parsed.conversation?.let { threadConversation = it }
val done = parsed.entries.any { it is Entry.Finished }
val event = if (!done) parsed else runCatching { current.usage(LinuxRuntime.rootDir(app), threadConversation) }.getOrNull()
?.let { parsed.copy(context = it.context ?: parsed.context, window = it.window ?: parsed.window, limits = it.limits ?: parsed.limits) } ?: parsed
main.post { if (turn === started || session === started) handle(app, started, event) }
}
}
runCatching { raw?.close() }
val status = runCatching { child.waitFor() }.getOrDefault(-1)
OrphanReaper.release(started.pid)
main.post {
if (turn === started) {
turn = null
if (state == State.WORKING && !ended) finish(app, app.getString(R.string.agent_exited, current.name, status))
}
if (started.writingGeneration != null) started.exitStatus = status
else processExited(app, started, current, status)
}
}, "agent-output").start()
}
private fun processExited(app: Context, exited: Turn, current: AgentHarness, status: Int) {
if (session === exited) {
session = null
launchedBackground = false
main.removeCallbacks(reap)
AgentHostService.backgroundDone(app)
}
if (turn === exited) {
turn = null
if (state == State.WORKING) finish(app, app.getString(R.string.agent_exited, current.name, status))
}
}
private fun serviceWarning(app: Context, error: Throwable) {
record(app, Entry.Notice("Unable to keep the agent running in the background: ${error.message ?: error.javaClass.simpleName}"))
}
/** One event from the CLI, which may belong to a turn it started on its own once the user's has ended. */
private fun handle(app: Context, from: Turn, event: AgentEvent) {
if (event.background) {
// A leftover task answered before the user's message is not the user's turn; one the CLI started is its own.
if (background && state == State.WORKING) finish(app, event.backgroundError, usage = event.usage?.let { from.costs?.perTurn(it) ?: it })
return
}
val content = event.text != null || event.thinking != null || event.approval != null || event.entries.any { it !is Entry.Finished }
if (content && state == State.IDLE && session === from) {
main.removeCallbacks(reap)
background = true
turn = from
turnPlanned = false
state = State.WORKING
live = ""
liveThinking = ""
turnStarted = SystemClock.elapsedRealtime()
AgentHostService.start(app)?.let { serviceWarning(app, it) }
}
val finished = event.entries.filterIsInstance<Entry.Finished>().firstOrNull()
if (finished != null && state == State.WORKING && from.clearingCosts) {
if (finished.error == null) from.costs?.reset()
from.clearingCosts = false
}
val applied = if (finished != null && state == State.WORKING && event.usage != null)
event.copy(usage = turnCost(from.costs?.perTurn(event.usage) ?: event.usage)) else event
apply(app, applied)
}
/** A CLI that reports the conversation's whole cost spent what this chat has not recorded yet. */
private fun turnCost(usage: Usage): Usage {
if (!harness.sessionCost) return usage
val recorded = entries.sumOf { (it as? Entry.Finished)?.usage?.costUsd ?: 0.0 }
return usage.copy(costUsd = (usage.costUsd - recorded).coerceAtLeast(0.0))
}
/** Ends the CLI process kept between turns, and with it whatever it still runs in the background. */
private fun dropSession() {
main.removeCallbacks(reap)
launchedBackground = false
appContext?.let { AgentHostService.backgroundDone(it) }
val kept = session ?: return
session = null
AgentProcesses.killTree(kept.pid)
kept.process.destroy()
}
/** Ends the turn now: its process and everything it started, a build included. */
fun stop(context: Context) {
val app = context.applicationContext
@@ -298,6 +515,7 @@ object AgentHost {
AgentProcesses.killTree(running.pid)
running.process.destroy()
}
dropSession()
if (state == State.WORKING) finish(app, null, stopped = true)
}
@@ -305,6 +523,16 @@ object AgentHost {
queue.remove(item)
}
/** Sends [item] now: the running turn stops where it is, and the rest of the queue waits for the next one. */
fun sendNow(context: Context, item: Queued) {
val app = context.applicationContext
if (!queue.remove(item)) return
val rest = queue.toList()
stop(app)
queue.addAll(rest)
send(app, item.text, item.files)
}
/** Starts a new conversation; the current one stays in the history. */
fun forget(context: Context) {
stop(context)
@@ -313,6 +541,7 @@ object AgentHost {
chat = null
conversation = null
this.context = 0
window = 0
prefs(context).edit().remove(CHAT_KEY).apply()
state = if (installed) State.IDLE else State.MISSING
}
@@ -322,11 +551,11 @@ object AgentHost {
* proot over the installed rootfs, without a session. Loopback adb is connected first so
* droiddeckctl reaches the app.
*/
fun guest(app: Context, command: List<String>, workdir: String = "/root", connectAdb: Boolean = true): ProcessBuilder {
fun guest(app: Context, command: List<String>, workdir: String = "/root", connectAdb: Boolean = true, fakeRoot: Boolean = false): ProcessBuilder {
val adb = AgentAdb.prepare(app)
val env = listOf(
"/usr/bin/env", "HOME=/root", "PATH=/root/.local/bin:/usr/local/bin:/usr/bin:/bin", "LANG=C.UTF-8",
"ADB_SERIAL=${adb.serial}", "ADB_VENDOR_KEYS=${adb.vendorKeys}",
"/usr/bin/env", "HOME=/root", "PATH=$GUEST_PATH", "LANG=C.UTF-8",
"ADB_SERIAL=${adb.serial}", "ADB_VENDOR_KEYS=${adb.vendorKeys}", "DROIDDECK_PACKAGE=${app.packageName}",
"DD_AGENT=1", "DD_AGENT_INBOX=${File(app.filesDir, "agent").path}", "BROWSER=/root/.local/bin/android-open", "DD_BROWSER_DISPLAY=${AgentAdb.browserDisplay}",
)
val shell = listOf(
@@ -335,7 +564,7 @@ object AgentHost {
(if (connectAdb) "adb start-server >/dev/null 2>&1; adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " else "") +
"cd \"$1\" 2>/dev/null; shift; exec \"$@\"", "sh", workdir,
)
val proot = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), env + shell + command)
val proot = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), null, env + shell + command, fakeRoot)
return ProcessBuilder(proot).redirectErrorStream(true).apply {
environment().apply {
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
@@ -361,7 +590,21 @@ object AgentHost {
}
event.text?.let { live += it }
event.thinking?.let { liveThinking += it }
event.resolved?.let { id ->
approvals.removeAll { it.id == id }
approvalsChanged(app)
}
event.approval?.takeIf { a -> state == State.WORKING && approvals.none { it.id == a.id } }?.let {
approvals += it
approvalNoticed = true
AgentNotice.post(app, AgentNotice.Kind.APPROVAL, listOf(it.tool, it.detail).filter { s -> s.isNotEmpty() }.joinToString(": "))
}
event.context?.let { context = it }
event.window?.let { window = it }
event.limits?.let { reported ->
limits = (limits.filter { old -> reported.none { it.minutes == old.minutes } } + reported).sortedBy { it.minutes }
prefs(app).edit().putString(limitsKey(harness), encodeLimits(limits)).apply()
}
for (entry in event.entries) when (entry) {
is Entry.Finished -> finish(app, entry.error, usage = event.usage)
else -> {
@@ -376,18 +619,27 @@ object AgentHost {
private fun finish(app: Context, error: String?, stopped: Boolean = false, usage: Usage? = null) {
if (state != State.WORKING) return
turn = null
approvals.clear()
approvalsChanged(app)
val answeredTask = background
background = false
main.removeCallbacks(reap)
if (session != null) main.postDelayed(reap, LINGER_MS)
if (!stopped) labFromTurn = false
live = ""
liveThinking = ""
record(app, Entry.Finished(error, stopped, usage))
val held = if (context > 0) (usage ?: Usage(0, 0.0, 0, 0)).copy(context = context, window = window) else usage
state = State.IDLE
unseen = true
failed = error != null
AgentHostService.stop(app)
if (session != null && launchedBackground) {
AgentHostService.waitForBackground(app)?.let { serviceWarning(app, it) }
} else AgentHostService.stop(app)
record(app, Entry.Finished(error, stopped, held, planned = turnPlanned && !stopped && error == null))
// Claude Code now and then ends a resumed turn at once without reading the message; nothing
// happened, so the message is sent once more.
val asked = entries.lastOrNull { it is Entry.Asked } as? Entry.Asked
if (!stopped && error == null && asked != null && answerless(entries) && !retrying) {
if (!stopped && error == null && !answeredTask && asked != null && answerless(entries) && !retrying) {
retrying = true
val retryChat = chat
resend = Runnable {
@@ -400,7 +652,19 @@ object AgentHost {
if (!stopped && queue.isNotEmpty()) {
val next = queue.removeAt(0)
send(app, next.text, next.files)
} else if (!stopped) notifyEnded(app, error)
}
private fun notifyEnded(app: Context, error: String?) {
val start = entries.indexOfLast { it is Entry.Asked }
val said = entries.subList(start + 1, entries.size).lastOrNull { it is Entry.Said } as? Entry.Said
val reply = said?.let { choices(it.text) }
val kind = when {
error != null -> AgentNotice.Kind.FAILED
!reply?.options.isNullOrEmpty() -> AgentNotice.Kind.QUESTION
else -> AgentNotice.Kind.DONE
}
AgentNotice.post(app, kind, error ?: reply?.text?.takeIf { it.isNotBlank() }?.let { firstLine(it) } ?: "")
}
/** A message typed or retried by the user replaces the automatic resend. */
@@ -413,6 +677,7 @@ object AgentHost {
private fun record(app: Context, entry: Entry) {
if (!AgentChats.merge(entries, entry)) return
if (entry is Entry.Used && entry.background) launchedBackground = true
chat?.let { AgentChats.append(AgentChats.file(app, it), entry) }
}
@@ -439,13 +704,14 @@ object AgentHost {
}
/** The latest todo list the agent wrote in this conversation. */
fun todos(): String? = entries.lastOrNull { it is Entry.Used && it.tool == "TodoWrite" }?.let { (it as Entry.Used).input }
fun todos(): String? = entries.lastOrNull { it is Entry.Used && it.tool == "TodoWrite" && it.parent.isEmpty() }?.let { (it as Entry.Used).input }
private fun tick() {
now = SystemClock.elapsedRealtime()
appContext?.let { app ->
claimLabRequest(app)
claimOpenUrl(app)
claimDeviceCode(app)
// proot comes from an add-on pack fetched after the app starts, so the runtime can become usable later.
if (!available && state != State.WORKING) available = LinuxRuntime.hasRootfs(app)
lab = LabProgress.read(LinuxRuntime.rootDir(app))
@@ -467,15 +733,43 @@ object AgentHost {
val url = runCatching { claimed.readText().trim() }.getOrNull()
claimed.delete()
if (url == null || !(url.startsWith("https://") || url.startsWith("http://"))) return
if (!openUrl(app, url)) runCatching { File(app.filesDir, "$OPEN_URL.failed").writeText("") }
}
/** dd-gh-login leaves "<code> <url>" here to float the code over the page, and an empty file when it ends. */
private fun claimDeviceCode(app: Context) {
val request = File(app.filesDir, DEVICE_CODE)
if (!request.isFile) return
val claimed = File(app.filesDir, "$DEVICE_CODE.claimed")
if (!request.renameTo(claimed)) return
val parts = runCatching { claimed.readText().trim() }.getOrDefault("").split(' ', limit = 2)
claimed.delete()
val code = parts[0]
val url = parts.getOrNull(1)?.takeIf { it.startsWith("https://") }
if (code.isEmpty() || url == null) {
com.droiddeck.launcher.DeviceCodeActivity.close()
return
}
if (!com.droiddeck.launcher.DeviceCodeActivity.show(app, code, url, AgentAdb.browserDisplay)) deviceCodeOpened(app, openUrl(app, url))
}
/** Tells dd-gh-login whether the device page opened, so it can fall back to android-open. */
fun deviceCodeOpened(app: Context, opened: Boolean) {
runCatching {
val part = File(app.filesDir, "$DEVICE_CODE.result.part")
part.writeText(if (opened) "ok" else "failed")
part.renameTo(File(app.filesDir, "$DEVICE_CODE.result"))
}
}
private fun openUrl(app: Context, url: String): Boolean {
val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url))
.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
val options = android.app.ActivityOptions.makeBasic().setLaunchDisplayId(AgentAdb.browserDisplay).toBundle()
runCatching { app.startActivity(intent, options) }
return runCatching { app.startActivity(intent, options) }
.recoverCatching { app.startActivity(intent) }
.onFailure {
Log.w(TAG, "could not open a sign-in link: ${it.javaClass.simpleName}")
runCatching { File(app.filesDir, "$OPEN_URL.failed").writeText("") }
}
.onFailure { Log.w(TAG, "could not open a sign-in link: ${it.javaClass.simpleName}") }
.isSuccess
}
/**
@@ -500,9 +794,15 @@ object AgentHost {
val child = guest(app, listOf("sh", "-c",
"mkdir -p /root/.cache; DD_LAB_DETACHED=1 exec dd-lab-build \"\$@\" > /root/.cache/dd-lab-build.log 2>&1", "dd-lab-build") + args, cwd).start()
main.post { labProcess = child }
child.outputStream.close()
child.inputStream.readBytes()
child.waitFor()
val pid = AgentProcesses.pidOf(child)
OrphanReaper.keep(pid)
try {
child.outputStream.close()
child.inputStream.readBytes()
child.waitFor()
} finally {
OrphanReaper.release(pid)
}
}.onFailure { Log.w(TAG, "could not run a Lab build", it) }
main.post {
labProcess = null
@@ -525,12 +825,74 @@ object AgentHost {
private const val RESUME = "agent/resume"
private const val LAB_REQUEST = "agent/lab-request"
private const val OPEN_URL = "agent/open-url"
private const val DEVICE_CODE = "agent/device-code"
private const val LAB_CHAT_KEY = "lab_chat"
/** The raw output of the latest turn, for working out what a CLI did when the chat shows nothing. */
private const val TURN_LOG = "agent/turn.log"
private const val RETRY_MS = 3_000L
/** How long the CLI process stays open after a turn, waiting for background work to wake it. */
private const val LINGER_MS = 20 * 60_000L
private fun modelKey(harness: AgentHarness) = "model_${harness.id}"
private fun permissionKey(harness: AgentHarness) = "permission_${harness.id}"
private fun limitsKey(harness: AgentHarness) = "limits_${harness.id}"
@VisibleForTesting
internal fun encodeLimits(list: List<Limit>) = org.json.JSONArray(list.map {
org.json.JSONObject().put("minutes", it.minutes).put("used", it.usedPercent).put("resets", it.resetsAt)
}).toString()
@VisibleForTesting
internal fun decodeLimits(text: String?): List<Limit> = runCatching {
val a = org.json.JSONArray(text ?: return emptyList())
(0 until a.length()).map { a.getJSONObject(it) }.map { Limit(it.optInt("minutes"), it.optInt("used"), it.optLong("resets")) }
}.getOrDefault(emptyList())
private fun effortKey(harness: AgentHarness) = "effort_${harness.id}"
internal fun prefs(context: Context) = context.getSharedPreferences("agent", Context.MODE_PRIVATE)
}
/** A reply split into its text and the options of a trailing choices block. */
internal data class Choices(val text: String, val options: List<String>)
private val FENCE = Regex("""[ \t]{0,3}(`{3,}|~{3,})(.*)""")
/** Walks Markdown fences so a choices block counts only at the top level and only as the last thing in the reply. */
internal fun choices(reply: String): Choices {
val lines = reply.split('\n')
var open = ""
var opener = -1
var openChoices = false
var block: IntRange? = null
lines.forEachIndexed { i, line ->
val fence = FENCE.matchEntire(line)
if (open.isEmpty()) {
if (fence != null) {
open = fence.groupValues[1]
opener = i
openChoices = fence.groupValues[2].trim() == "choices"
block = null
} else if (line.isNotBlank()) block = null
} else if (fence != null && fence.groupValues[1][0] == open[0] && fence.groupValues[1].length >= open.length && fence.groupValues[2].isBlank()) {
block = if (openChoices) opener..i else null
open = ""
}
}
val found = block?.takeIf { open.isEmpty() } ?: return Choices(reply, emptyList())
val options = lines.subList(found.first + 1, found.last).map { it.trim().removePrefix("- ").removePrefix("* ").trim() }.filter { it.isNotEmpty() }
return Choices(lines.subList(0, found.first).joinToString("\n").trimEnd(), options)
}
internal class AgentCostTracker {
private var previous = 0.0
fun reset() { previous = 0.0 }
fun perTurn(usage: AgentHost.Usage): AgentHost.Usage {
val total = usage.costUsd
if (total == 0.0 && previous > 0.0) return usage
val delta = if (total >= previous) total - previous else total
previous = total
return usage.copy(costUsd = delta)
}
}
@@ -42,19 +42,37 @@ class AgentHostService : Service() {
/** Setup steps that keep the app alive while they run, besides the agent's turn. */
private var setupSteps = 0
fun start(context: Context) {
fun start(context: Context): Throwable? {
if (started) { update(context); return null }
lastText = null
started = true
runCatching { context.startForegroundService(Intent(context, AgentHostService::class.java)) }
.onSuccess { awaiting++ }
return runCatching { context.startForegroundService(Intent(context, AgentHostService::class.java)) }
.onSuccess { started = true; awaiting++ }
.exceptionOrNull()
}
fun stop(context: Context) {
if (setupSteps > 0) return
if (setupSteps > 0 || waiting) return
started = false
if (awaiting == 0) context.stopService(Intent(context, AgentHostService::class.java))
}
/**
* The turn has ended but its CLI process stays open with background work that can wake it; the app must stay
* alive to read that answer, so the service keeps running until the process is dropped.
*/
@Volatile private var waiting = false
fun waitForBackground(context: Context): Throwable? {
waiting = true
return if (started) { update(context); null } else start(context)
}
fun backgroundDone(context: Context) {
if (!waiting) return
waiting = false
if (AgentHost.state != AgentHost.State.WORKING) stop(context)
}
fun setupStarted(context: Context) {
setupSteps++
start(context)
@@ -77,7 +95,11 @@ class AgentHostService : Service() {
private fun describe(context: Context): String {
val lab = AgentHost.lab?.takeIf { it.running }
if (lab != null) return context.getString(R.string.agent_lab_progress, lab.permille / 10, minutes(lab.etaSeconds.toLong().coerceAtLeast(0)))
if (AgentHost.state != AgentHost.State.WORKING) return context.getString(R.string.agent_setting_up)
AgentSetup.detail[AgentSetup.Step.GITHUB]?.takeIf {
AgentSetup.status[AgentSetup.Step.GITHUB] == AgentSetup.Status.WORKING && it.startsWith("GitHub device code:")
}?.let { return it }
if (AgentHost.state != AgentHost.State.WORKING)
return context.getString(if (waiting && setupSteps == 0) R.string.agent_waiting_background else R.string.agent_setting_up)
val tool = AgentHost.running()
val elapsed = minutes((SystemClock.elapsedRealtime() - AgentHost.turnStarted) / 1000)
return if (tool != null) "${tool.tool} · ${tool.detail}".take(120) + " · $elapsed" else context.getString(R.string.agent_thinking_for, elapsed)
@@ -0,0 +1,59 @@
package com.droiddeck.launcher.agent
import android.app.ActivityManager
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
import com.droiddeck.launcher.ui.AgentPet
/** Tells the user a turn has ended when nothing on screen already does. */
internal object AgentNotice {
private const val CHANNEL_ID = "agent_done"
private const val NOTIFICATION_ID = 4108
enum class Kind { DONE, FAILED, QUESTION, APPROVAL }
fun post(context: Context, kind: Kind, text: String) {
if (onScreen(context, kind)) return
val manager = context.getSystemService(NotificationManager::class.java) ?: return
manager.createNotificationChannel(NotificationChannel(CHANNEL_ID, context.getString(R.string.agent_done_channel), NotificationManager.IMPORTANCE_DEFAULT))
val open = PendingIntent.getActivity(context, 2,
Intent(context, FrontEndActivity::class.java)
.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
.putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent"),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
val title = context.getString(when (kind) {
Kind.DONE -> R.string.agent_done
Kind.FAILED -> R.string.agent_done_failed
Kind.QUESTION -> R.string.agent_done_question
Kind.APPROVAL -> R.string.agent_done_approval
})
runCatching {
manager.notify(NOTIFICATION_ID, Notification.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_stat_session)
.setContentTitle(title)
.setContentText(text)
.setStyle(Notification.BigTextStyle().bigText(text))
.setContentIntent(open)
.setAutoCancel(true)
.setCategory(Notification.CATEGORY_STATUS)
.build())
}
}
fun clear(context: Context) {
context.getSystemService(NotificationManager::class.java)?.cancel(NOTIFICATION_ID)
}
/** The chat in a DroidDeck window in front, or the pet, which shows the reply in its own bubble but has no way to answer an approval. */
private fun onScreen(context: Context, kind: Kind): Boolean {
if (AgentPet.floating && kind != Kind.APPROVAL) return true
val state = ActivityManager.RunningAppProcessInfo().also { ActivityManager.getMyMemoryState(it) }
return AgentPet.agentOnScreen > 0 && state.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
}
}
@@ -40,7 +40,11 @@ object AgentProcesses {
val now = SystemClock.elapsedRealtime()
val uptimeTicks = now * HZ / 1000
val elapsed = (now - lastAt).coerceAtLeast(1)
fun isProot(pid: Int) = args[pid].orEmpty().substringBefore(' ').endsWith("proot.so") || args[pid].orEmpty().substringBefore(' ').endsWith("/proot")
fun isProot(pid: Int): Boolean {
val argv = args[pid].orEmpty().split(' ')
val program = if (argv.first().endsWith("/linker64")) argv.getOrElse(1) { "" } else argv.first()
return program.endsWith("proot.so") || program.endsWith("/proot")
}
fun ancestors(pid: Int) = generateSequence(stats[pid]?.ppid) { stats[it]?.ppid }.takeWhile { it > 1 }.take(64)
val out = stats.values.filter { s ->
!isProot(s.pid) && args[s.pid].orEmpty().isNotEmpty() && ancestors(s.pid).any { isProot(it) }
@@ -4,10 +4,12 @@ import android.content.Context
import android.os.Handler
import android.os.Looper
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.OrphanReaper
import java.io.File
import java.util.concurrent.TimeUnit
@@ -25,6 +27,55 @@ object AgentSetup {
val detail = mutableStateMapOf<Step, String>()
var runtimeInstalled by mutableStateOf(true)
private set
/** Ids of the harness's [AgentHarness.providers] with a key saved; signed in without one means its free models. */
var keys by mutableStateOf(emptySet<String>())
private set
/** The provider and custom server picked in the key field, kept while a save is checked. */
var provider by mutableStateOf<String?>(null)
var server by mutableStateOf("")
/** Saves a pasted key for a harness that signs in with one, then checks the sign-in again. */
fun saveKey(context: Context, provider: AgentHarness.Provider, key: String, endpoint: String? = null) = signInLocally(context) { harness, root ->
harness.saveKey(root, provider, key, endpoint) { url, token -> fetch(context.applicationContext, url, token) }
}
fun removeKey(context: Context, provider: AgentHarness.Provider) = signInLocally(context) { harness, root -> harness.removeKey(root, provider) }
/** A GET from the userland, which reaches the LAN servers the app's own cleartext policy does not. */
private fun fetch(app: Context, url: String, token: String?): String {
// The key goes in on stdin, so it is never in a command line.
val process = AgentHost.guest(app, listOf("curl", "-fsSL", "--max-time", "20", "-H", "@-", url), connectAdb = false).start()
process.outputStream.bufferedWriter().use { if (token != null) it.write("Authorization: Bearer $token\n") }
val output = process.inputStream.bufferedReader().readText()
check(process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) { output.trim().lines().lastOrNull()?.takeIf { it.isNotEmpty() } ?: "Cannot reach $url" }
return output
}
fun useFree(context: Context) = signInLocally(context) { harness, root -> harness.useFree(root) }
private val signInLock = Any()
private fun signInLocally(context: Context, write: (AgentHarness, File) -> Unit) {
val app = context.applicationContext
val harness = AgentHost.harness
set(Step.SIGN_IN, Status.WORKING)
Thread({
// Each write reads the files the one before it left, including across a save's model request.
val result = synchronized(signInLock) { runCatching { write(harness, LinuxRuntime.rootDir(app)) } }
main.post {
// A failure stays on the row with the key field open, since the next check would clear it.
val error = result.exceptionOrNull()
if (error != null) {
status[Step.SIGN_IN] = Status.FAILED
detail[Step.SIGN_IN] = error.message ?: "failed"
} else {
status[Step.SIGN_IN] = Status.UNKNOWN
detail.remove(Step.SIGN_IN)
check(app)
}
}
}, "agent-sign-in").start()
}
val ready: Boolean get() = Step.entries.filter { it.required }.all { status[it] == Status.DONE }
@@ -39,7 +90,10 @@ object AgentSetup {
private val main = Handler(Looper.getMainLooper())
private const val REPO = "https://github.com/Droid-Deck/DroidDeck.git"
private const val CHECKOUT = "/root/DroidDeck"
private val HELPERS = listOf("android-open", "dd-gh-login")
private val HELPERS = listOf("android-open", "dd-gh-login", "droiddeckctl", "droiddeck-scenario")
/** DroidDeck's own skills (tools/agent/skills), given to every harness. */
private const val SKILLS = "agent/skills"
internal const val CTL = "/root/.local/share/droiddeck/ctl"
private const val PROBE_TIMEOUT_S = 60L
fun check(context: Context) {
@@ -48,6 +102,7 @@ object AgentSetup {
if (!runtimeInstalled) return
AgentHost.refresh(app)
val harness = AgentHost.harness
keys = harness.keys(LinuxRuntime.rootDir(app))
val probes = mutableListOf<Pair<Step, List<String>>>()
for (step in Step.entries) if (status[step] != Status.WORKING) {
when (step) {
@@ -71,15 +126,26 @@ object AgentSetup {
Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start()
}
fun runsAsRoot(step: Step) = step == Step.INSTALL
/** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */
fun run(context: Context, step: Step) {
fun run(context: Context, step: Step) = run(context, step, null)
/** Opens the page where a provider's key is made, as the sign-in of a harness that takes pasted keys. */
fun openKeyPage(context: Context, page: String) = run(context, Step.SIGN_IN, listOf("/root/.local/bin/android-open", page))
private fun run(context: Context, step: Step, override: List<String>?) {
val app = context.applicationContext
val harness = AgentHost.harness
val command = when (step) {
val command = override ?: when (step) {
Step.CONNECTION -> return
Step.INSTALL -> {
listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " +
"apt-get update; apt-get install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
"for i in 1 2 3; do apt update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
"apt -f install -y --fix-missing; " +
"apt install -y --fix-missing --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
}
Step.SIGN_IN -> harness.signIn
Step.GITHUB -> listOf("dd-gh-login")
@@ -94,13 +160,25 @@ object AgentSetup {
val result = runCatching {
installHelpers(app)
runCatching { harness.prepare(LinuxRuntime.rootDir(app)) }
val child = AgentHost.guest(app, command).start()
child.outputStream.close()
child.inputStream.bufferedReader().forEachLine { line ->
val text = line.trim()
if (text.isNotEmpty() && !noise(text)) main.post { detail[step] = text.take(160) }
val child = AgentHost.guest(app, command, fakeRoot = runsAsRoot(step)).start()
val pid = AgentProcesses.pidOf(child)
OrphanReaper.keep(pid)
try {
child.outputStream.close()
logFile(app, step).apply { parentFile?.mkdirs() }.bufferedWriter().use { log ->
child.inputStream.bufferedReader().forEachLine { line ->
log.appendLine(line)
val text = line.trim()
if (text.isNotEmpty() && !noise(text)) main.post {
detail[step] = text.take(160)
if (step == Step.GITHUB && text.startsWith("GitHub device code:")) AgentHostService.update(app)
}
}
child.waitFor().also { log.appendLine("exit $it") }
}
} finally {
OrphanReaper.release(pid)
}
child.waitFor()
}
main.post {
AgentHostService.setupEnded(app)
@@ -116,6 +194,9 @@ object AgentSetup {
}, "agent-setup-${step.name.lowercase()}").start()
}
/** The whole output of a step's last run; the card shows only its last line. */
fun logFile(app: Context, step: Step) = File(app.filesDir, "agent/setup-${step.name.lowercase()}.log")
fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git")
/** dd-lab-build compiled this install's commit, so a Lab build compiles only what changed. */
@@ -165,12 +246,127 @@ object AgentSetup {
}
/** Written before every step, so the helpers a step relies on are there and match this DroidDeck version. */
private fun installHelpers(app: Context) {
val bin = File(LinuxRuntime.rootDir(app), "root/.local/bin").apply { mkdirs() }
for (name in HELPERS) {
val target = File(bin, name)
app.assets.open("agent/$name").use { input -> target.outputStream().use { input.copyTo(it) } }
target.setExecutable(true, false)
internal fun installHelpers(app: Context) {
val root = LinuxRuntime.rootDir(app)
val failed = mutableListOf<String>()
fun attempt(what: String, block: () -> Unit) = runCatching(block).onFailure {
android.util.Log.w("AgentSetup", "could not install $what", it)
failed += what
}
val bin = File(root, "root/.local/bin").apply { mkdirs() }
for (name in HELPERS) attempt(name) { copyAsset(app, "agent/$name", File(bin, name)) }
val ctl = File(root, CTL.removePrefix("/")).apply { mkdirs() }
for (name in app.assets.list("agent/ctl").orEmpty()) attempt("ctl/$name") { copyAsset(app, "agent/ctl/$name", File(ctl, name)) }
val skills = app.assets.list(SKILLS).orEmpty().associateWith { app.assets.list("$SKILLS/$it").orEmpty().toList() }
failed += installSkills(root, skills) { app.assets.open("$SKILLS/$it") }
attempt("AGENTS.md") {
val rules = app.assets.open("agent/ctl/AGENTS.md").use { it.readBytes().decodeToString() }
failed += installInstructions(root, rules)
}
unpinAdbSerial(File(root, "root/.bashrc"))
main.post { problems.clear(); problems.addAll(failed.distinct()) }
}
/** What [installHelpers] could not install last time, shown in the Agent tab; empty when all is in place. */
val problems = mutableStateListOf<String>()
/**
* Writes each of DroidDeck's [skills] (name to its files) into every harness's skills folder, so
* Claude Code, Codex and any later harness load the same ones, as of this DroidDeck version.
* Skills the user added there are left alone. Returns the skills that could not be written.
*/
internal fun installSkills(root: File, skills: Map<String, List<String>>, open: (String) -> java.io.InputStream): List<String> {
val failed = mutableListOf<String>()
for (harness in AgentHarness.all) for ((name, files) in skills) runCatching {
val dir = File(root, "${harness.skills}/$name")
// A folder of that name without DroidDeck's mark is the user's own skill: keep it.
if (dir.exists() && !File(dir, SKILL_MARK).exists()) return@runCatching
dir.mkdirs()
// Marked before copying, so a copy that fails part way is retried next turn, not taken for the user's.
File(dir, SKILL_MARK).writeText("Installed by DroidDeck and replaced on every turn. Delete this file to keep your own edits.\n")
for (file in files) open("$name/$file").use { replaceFile(it, File(dir, file), executable = false) }
}.onFailure {
android.util.Log.w("AgentSetup", "could not install skill $name for ${harness.name}", it)
failed += "skill $name"
}
return failed
}
/** Marks a skill folder as DroidDeck's, so it may be replaced; one without it belongs to the user. */
internal const val SKILL_MARK = ".droiddeck"
/**
* Where [file] really is when it is a symlink, as the guest sees it: an absolute target is a
* userland path, so it is looked up under [root]. A dotfiles link keeps working that way.
*/
internal fun guestTarget(root: File, file: File): File {
var current = file
repeat(8) {
val path = current.toPath()
if (!java.nio.file.Files.isSymbolicLink(path)) return current
val target = java.nio.file.Files.readSymbolicLink(path).toString()
current = if (target.startsWith("/")) File(root, target.removePrefix("/")) else File(current.parentFile, target)
}
return current
}
internal const val BLOCK_BEGIN = "<!-- BEGIN DroidDeck: replaced on every turn. Write your own rules outside this block. -->"
internal const val BLOCK_END = "<!-- END DroidDeck -->"
/**
* Puts DroidDeck's [rules] in a marked block of every harness's global instructions file,
* keeping whatever the user wrote around it. Returns the files that could not be written.
*/
internal fun installInstructions(root: File, rules: String): List<String> {
val failed = mutableListOf<String>()
for (harness in AgentHarness.all) runCatching {
val file = guestTarget(root, File(root, harness.instructions)).apply { parentFile?.mkdirs() }
val existing = if (file.exists()) file.readText() else null
val merged = withBlock(existing, rules)
if (merged != existing) replaceFile(merged.byteInputStream(), file, executable = false)
}.onFailure {
android.util.Log.w("AgentSetup", "could not write ${harness.instructions}", it)
failed += harness.instructions.substringAfterLast("root/")
}
return failed
}
/** [existing] with DroidDeck's block set to [rules]: replaced in place, or put first when there is none yet. */
internal fun withBlock(existing: String?, rules: String): String {
val block = "$BLOCK_BEGIN\n${rules.trim()}\n$BLOCK_END\n"
if (existing.isNullOrBlank()) return block
val start = existing.indexOf(BLOCK_BEGIN)
val end = existing.indexOf(BLOCK_END, start.coerceAtLeast(0))
if (start < 0 || end < 0) return "$block\n$existing"
val after = existing.substring(end + BLOCK_END.length).removePrefix("\n")
return existing.substring(0, start) + block + after
}
/** Older tools/agent/setup pinned the adb port in .bashrc, which overrides the live port DroidDeck passes. */
internal fun unpinAdbSerial(bashrc: File) {
val text = runCatching { bashrc.readText() }.getOrNull() ?: return
val fixed = text.replace("ADB_SERIAL=127.0.0.1:5555 ", "ADB_SERIAL=\"\${ADB_SERIAL:-127.0.0.1:5555}\" ")
if (fixed != text) runCatching { bashrc.writeText(fixed) }
}
/**
* Written beside [target] and renamed over it, so a symlink left there by a hand-made setup is
* replaced rather than followed: its absolute target is a userland path the app cannot reach,
* and the failed write stopped every helper after it, the droiddeckctl guide included.
*/
private fun copyAsset(app: Context, asset: String, target: File) {
app.assets.open(asset).use { replaceFile(it, target) }
}
/** Replaces [target], or the symlink at it, with [input]. */
internal fun replaceFile(input: java.io.InputStream, target: File, executable: Boolean = true) {
// A unique name, since an agent turn and a setup step can install at the same time.
val staged = File.createTempFile(".${target.name}.", ".part", target.parentFile)
staged.outputStream().use { input.copyTo(it) }
if (executable) staged.setExecutable(true, false)
if (!staged.renameTo(target)) {
staged.delete()
throw java.io.IOException("could not replace $target")
}
}
}
@@ -16,13 +16,14 @@ import java.nio.file.attribute.BasicFileAttributes
/**
* What the agent adds to the Linux userland, measured and removable piece by piece. Sign-ins
* (~/.claude, ~/.codex, gh's config) are left alone, so removing a CLI and installing it again
* does not sign out.
* (~/.claude, ~/.codex, ~/.local/share/opencode, gh's config) are left alone, so removing a CLI
* and installing it again does not sign out.
*/
object AgentStorage {
enum class Item(val paths: List<String>) {
CLAUDE_CODE(listOf("/root/.local/share/claude", "/root/.local/bin/claude", "/root/cc")),
CODEX(listOf("/root/.local/bin/codex", "/root/.local/bin/codex-code-mode-host")),
OPENCODE(listOf("/root/.opencode")),
BUILD_TOOLS(listOf("/root/android-sdk", "/root/aapt2", "/root/x86root", "/root/.gradle")),
SOURCE(listOf("/root/DroidDeck")),
CACHES(listOf("/root/.cache", "/root/.npm")),
@@ -0,0 +1,91 @@
package com.droiddeck.launcher.agent
import android.content.Context
import com.droiddeck.launcher.frontend.LibraryCache
import com.droiddeck.launcher.stores.CloudSaves
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.xbox.Xodus
import java.io.ByteArrayOutputStream
import java.io.InputStream
import java.util.concurrent.TimeUnit
import org.json.JSONArray
import org.json.JSONObject
internal object AgentStores {
private const val OUTPUT_CAP = 160 * 1024
fun library(context: Context, request: JSONObject): JSONObject {
val query = request.optString("query").trim()
val source = request.optString("source").trim()
val games = JSONArray()
LibraryCache.load(context)
.filter { (query.isEmpty() || it.name.contains(query, ignoreCase = true)) && (source.isEmpty() || it.source.equals(source, ignoreCase = true)) }
.forEach {
games.put(JSONObject().put("id", it.gameIdString).put("name", it.name).put("source", it.source)
.put("storeId", it.storeId ?: JSONObject.NULL).put("folder", it.gameFiles?.path ?: JSONObject.NULL))
}
return JSONObject().put("ok", true).put("command", "library").put("games", games)
}
fun xodus(context: Context, request: JSONObject): JSONObject {
AgentAccess.requireCommands(context)
val list = request.optJSONArray("args")
val args = if (list == null) emptyList() else List(list.length()) { list.optString(it) }
if (args.isEmpty() || args.any { it.isEmpty() }) throw AgentException("INVALID_REQUEST", "xodus needs its arguments")
val timeoutMs = (request.optDouble("timeout", 120.0) * 1000).toLong().coerceIn(1_000L, 900_000L)
return Xodus.start(context.applicationContext, args).use { child ->
val out = Tail(child.process.inputStream)
val err = Tail(child.process.errorStream)
val finished = child.process.waitFor(timeoutMs, TimeUnit.MILLISECONDS)
if (!finished) child.close()
JSONObject().put("ok", true).put("command", "xodus").put("timedOut", !finished)
.put("exit", if (finished) child.process.exitValue() else JSONObject.NULL)
.put("stdout", out.text()).put("stderr", err.text())
}
}
fun cloud(context: Context, request: JSONObject): JSONObject {
AgentAccess.requireCommands(context)
val store = Store.byId(request.optString("store"))?.takeIf(CloudSaves::supports)
?: throw AgentException("INVALID_REQUEST", "store must be one with cloud saves")
val id = request.optString("id").ifEmpty { throw AgentException("INVALID_REQUEST", "cloud needs a game id") }
val force = request.optBoolean("force")
val result = when (val direction = request.optString("direction")) {
"down" -> CloudSaves.download(context.applicationContext, store, id, force)
"up" -> CloudSaves.upload(context.applicationContext, store, id, force)
else -> throw AgentException("INVALID_REQUEST", "direction '$direction' is not down or up")
}
return JSONObject().put("ok", true).put("command", "cloud").put("result", result.result).put("files", result.files)
.put("bytes", result.bytes).put("reason", result.reason).put("conflicts", result.conflicts).put("detail", result.detail)
}
private class Tail(stream: InputStream) {
private val kept = ByteArrayOutputStream()
private var dropped = false
private val reader = Thread({
val buffer = ByteArray(8192)
stream.use { input ->
while (true) {
val n = runCatching { input.read(buffer) }.getOrDefault(-1)
if (n < 0) break
synchronized(kept) {
kept.write(buffer, 0, n)
if (kept.size() > OUTPUT_CAP * 2) {
val bytes = kept.toByteArray()
kept.reset()
kept.write(bytes, bytes.size - OUTPUT_CAP, OUTPUT_CAP)
dropped = true
}
}
}
}
}, "agent-xodus-output").apply { isDaemon = true; start() }
fun text(): String {
reader.join(2_000)
val bytes = synchronized(kept) { kept.toByteArray() }
val tail = if (bytes.size > OUTPUT_CAP) bytes.copyOfRange(bytes.size - OUTPUT_CAP, bytes.size) else bytes
return (if (dropped || bytes.size > OUTPUT_CAP) "...\n" else "") + String(tail, Charsets.UTF_8)
}
}
}
@@ -0,0 +1,9 @@
package com.droiddeck.launcher.agent
import com.droiddeck.launcher.ui.NavTabs
object AgentTab {
val shown: Boolean get() = "agent" !in NavTabs.hidden
val visible: Boolean get() = shown && AgentHost.available
}
@@ -0,0 +1,143 @@
package com.droiddeck.launcher.agent
import android.content.Context
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.LinkOption
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
import java.util.concurrent.TimeUnit
/** Claude Code's MCP servers and skills in the userland, through its own CLI and skills folder. */
internal object AgentTools {
data class Server(val name: String, val target: String, val status: String) {
/** Connectors come from the claude.ai account and are managed there, not by the CLI. */
val account get() = name.startsWith("claude.ai ")
}
data class Skill(val name: String, val description: String)
class Result(val ok: Boolean, val output: String)
private const val SKILLS = "root/.claude/skills"
private val SERVER = Regex("""^(.+?): (.+) - (.+)$""")
fun servers(context: Context): List<Server>? {
val result = run(context, listOf(ClaudeCode.binary, "mcp", "list"))
if (!result.ok) return null
return parseServers(result.output)
}
internal fun parseServers(output: String): List<Server> = output.lines().mapNotNull { line ->
SERVER.find(line.trim())?.destructured?.let { (name, target, status) -> Server(name, target, status) }
}
/** A URL is added as an HTTP server; anything else is the command that starts a stdio server. */
internal fun addCommand(name: String, target: String): List<String> {
val t = target.trim()
val base = listOf(ClaudeCode.binary, "mcp", "add", "--scope", "user")
return if (t.startsWith("http://") || t.startsWith("https://")) base + listOf("--transport", "http", name.trim(), t)
else base + listOf(name.trim(), "--") + words(t)
}
/** Splits a command line the way a shell would for quotes and backslashes, without expanding anything. */
internal fun words(line: String): List<String> {
val words = mutableListOf<String>()
val word = StringBuilder()
var inWord = false
var quote: Char? = null
var i = 0
while (i < line.length) {
val c = line[i]
when {
quote == '\'' -> if (c == '\'') quote = null else word.append(c)
c == '\\' && i + 1 < line.length && (quote == null || line[i + 1] == '"' || line[i + 1] == '\\') -> {
word.append(line[++i])
inWord = true
}
quote == '"' -> if (c == '"') quote = null else word.append(c)
c == '\'' || c == '"' -> {
quote = c
inWord = true
}
c.isWhitespace() -> if (inWord) {
words += word.toString()
word.clear()
inWord = false
}
else -> {
word.append(c)
inWord = true
}
}
i++
}
if (inWord) words += word.toString()
return words
}
fun add(context: Context, name: String, target: String) = run(context, addCommand(name, target))
fun remove(context: Context, name: String) = run(context, listOf(ClaudeCode.binary, "mcp", "remove", name))
fun skills(context: Context): List<Skill> =
File(LinuxRuntime.rootDir(context), SKILLS).listFiles { f -> f.isDirectory }.orEmpty().sortedBy { it.name.lowercase() }.map { dir ->
Skill(dir.name, description(File(dir, "SKILL.md")))
}
internal fun description(file: File): String = runCatching {
val lines = file.readLines()
if (lines.firstOrNull()?.trim() != "---") return@runCatching ""
lines.drop(1).takeWhile { it.trim() != "---" }.firstOrNull { it.startsWith("description:") }
?.removePrefix("description:")?.trim()?.trim('"', '\'').orEmpty()
}.getOrDefault("")
fun deleteSkill(context: Context, name: String): Boolean {
if (name.isEmpty() || name.contains('/') || name.startsWith(".")) return false
val root = File(LinuxRuntime.rootDir(context), SKILLS)
val dir = File(root, name)
if (dir.parentFile?.path != root.path) return false
return deleteTree(dir.toPath())
}
/** Deletes [path] and what is under it; a symbolic link is removed itself, never what it points to. */
internal fun deleteTree(path: Path): Boolean = runCatching {
if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) return@runCatching true
Files.walkFileTree(path, object : SimpleFileVisitor<Path>() {
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
Files.delete(file)
return FileVisitResult.CONTINUE
}
override fun postVisitDirectory(dir: Path, exc: java.io.IOException?): FileVisitResult {
if (exc != null) throw exc
Files.delete(dir)
return FileVisitResult.CONTINUE
}
})
true
}.getOrDefault(false)
private fun run(context: Context, command: List<String>): Result {
val child = runCatching { AgentHost.guest(context.applicationContext, command, connectAdb = false).start() }
.getOrElse { return Result(false, it.message.orEmpty()) }
val output = StringBuffer()
// The CLI can hold its output open past the deadline, so it is read beside the wait rather than before it.
val reader = Thread({ runCatching { child.inputStream.bufferedReader().forEachLine { output.append(it).append('\n') } } }, "agent-tools").apply { start() }
return try {
val ended = child.waitFor(90, TimeUnit.SECONDS)
if (!ended) child.destroyForcibly()
reader.join(2_000)
Result(ended && child.exitValue() == 0, output.toString().trim())
} catch (e: InterruptedException) {
child.destroyForcibly()
Thread.currentThread().interrupt()
Result(false, output.toString().trim())
} finally {
runCatching { child.inputStream.close() }
}
}
}
Loaded 100 of 1122 files, more files were not shown because too many files have changed in this diff. Show more