Skip to content

iPhone Duo work: shell folder cache, borderless snap, futex wake fast path, DXC and XeSS loaders - #79

Draft
Dragooon wants to merge 5 commits into
willfaust:codex/wine-runtime-consolidationfrom
Dragooon:duo-all
Draft

Dragooon wants to merge 5 commits into
willfaust:codex/wine-runtime-consolidationfrom
Dragooon:duo-all

Conversation

@Dragooon

@Dragooon Dragooon commented Nov 22, 2026 •

Copy link
Copy Markdown

Impact

No run compared this branch with an unmodified wine at matched content, so this PR claims no overall figure. Measured on an iPhone with Path of Exile 2, per change:

  • Shell folder cache: the registry poll from the game's thread is gone. A sampled RegCreateKeyEx/RegQueryValueEx probe saw no calls after the first 24, against about 26,000 of each per session before.
  • Futex wake fast path: Path of Exile 2 makes about a million RtlWakeAddress calls a second against a few thousand waits. The CPU saved was not isolated. Every session since 4 Nov ran with it, with no hangs seen. The same waiter-count protocol passed a multi-threaded lost-wake stress test on the host, and failed it with the barrier removed.
  • Borderless snap: the window stayed at desktop size across launches and the black bars were gone. Before, 1440x900 grew by 8x34 a launch to 1504x1156.
  • Native DXC loader: with MADEIRA_DXC_NATIVE=1 the game's x64 dxcompiler.dll and dxil.dll are no longer loaded, and the 0.5-1.2M combase crossings a second from its compile threads are gone.
  • XeSS loader: no measurement. It is what lets Madeira's xess-metalfx replace the game's own libxess.dll.

Commits

  1. aa3311c94e6 shell32: cache the base path of shell folders per (folder, flags). SHGetFolderPathAndSubDirW keeps the expanded base path per (CSIDL, type) for the calling user. The subpath, existence check and CSIDL_FLAG_CREATE still run every call. The cache clears when shell32 writes a folder location. A program that edits the Shell Folders keys directly mid-session would see the old path until then.
  2. 3b0f9272853 win32u: opt-in snap of a top-level window that drops its frame at monitor size. When a top-level window loses WS_CAPTION and WS_THICKFRAME while at least monitor-sized (and not exactly that size), it is moved and sized to the monitor. MADEIRA_SNAP_BORDERLESS=1 turns it on.
  3. 33433b51fd5 ntdll: RtlWakeAddress* skip the bucket spinlock when nobody waits in it. A waiter count in the bucket's padding; struct futex_queue stays 24 bytes and matches the unix side's shared table.
  4. 078c295114c ntdll: MADEIRA_DXC_NATIVE=1 loads dxcompiler.dll from system32.
  5. 8a404df8193 ntdll: MADEIRA_XESS_METALFX=1 loads libxess.dll from system32. The iOS loader never replaces an image from the application folder with a builtin, so WINEDLLOVERRIDES cannot do it; a full path to libxess.dll is matched by its base name.

Defaults

  • Opt-in: borderless snap, the DXC and XeSS loader paths.
  • No switch: the futex fast path, the shell folder cache.

Left out

  • kernelbase [reg-poll] / [wait-note] probes and an ntdll wake census: investigation logging.
  • The glue for the Duo's post-link x64 fast-path stubs (the ios_x64_fast block at PEB->SparePointers[1] and decoding of patched export thunks). The stub patcher itself is not going upstream.

Other branches

  • codex/wine-11.20-mobile conflicts with the futex fast path (dlls/ntdll/sync.c) and the borderless snap (dlls/win32u/window.c). Both need porting when that rebase lands.

Testing

  • Every change has run on the phone in every session since it went in (4-7 Nov 2026), with snap on.
  • The commits are the single-feature commits of 8 Nov plus the XeSS hunk of the device build, unchanged, and they apply cleanly on the consolidation branch. They were not compiled after that: wine's unix side needs the iOS SDK.

🤖 Generated with Claude Code

ShitizZip and others added 5 commits November 22, 2026 17:20
Same as pr/shell32-folder-path-cache (on since text13).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
…itor size

Path of Exile 2's borderless fullscreen creates a framed
(WS_OVERLAPPEDWINDOW) window of its saved size plus the frame, then removes
the frame with SWP_NOSIZE. The frameless window is all client, the game
saves that client size, and the next launch adds the frame again: 1440x900
grew by 8x34 a launch to 1504x1156 on a 1440x900 desktop, which Madeira then
showed shrunk with black bars. On Windows the framed window never gets past
the monitor-sized maximum track size, so the size never creeps.

With MADEIRA_SNAP_BORDERLESS=1, when a top-level window loses WS_CAPTION and
WS_THICKFRAME while at least as large as the primary monitor in both
dimensions (and not exactly its size), it is moved and sized to the
monitor. Child windows, windows that keep a frame and smaller windows are
untouched. Off by default.

Tested on an iPhone: the window stayed at desktop size across launches and
the bars were gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
Games release SRW locks and signal condition variables far more often than
anything waits on them. Path of Exile 2 makes about a million
RtlWakeAddressAll/Single calls a second against a few thousand waits, and
every wake took its futex bucket's spinlock, a cache line bounced between all
the game's threads for nothing.

Each bucket now counts its queued waiters in the 4 bytes of padding after
the lock, so struct futex_queue stays 24 bytes and keeps matching the unix
side's shared table (struct ios_shared_futex_queue). A waiter increments the
count under the lock before it compares the value, and decrements it when it
leaves the queue (timeout, mismatch or wake). A waker stores, issues a full
barrier and reads the count: zero means no waiter can have passed its
compare, so it returns without the lock. Otherwise it takes the locked path
as before.

The unix side's ios_shared_futex_wake only alerts threads and never removes
entries, so it needs no change; every PE ntdll build that queues on the
shared table must carry this change (they are all built from this tree).

Tested on an iPhone in every session since 4 Nov 2026 (Path of Exile 2,
Steam): no hangs seen. The same waiter-count protocol, used by an x64 wake
fast path we keep out of tree, passed a multi-threaded lost-wake stress
test on the host (and failed it with the barrier removed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
D3D12 games ship Microsoft's x64 dxcompiler.dll next to their exe and
compile shaders with it at run time, emulated. Path of Exile 2's compile
threads then made 0.5-1.2M combase crossings a second. Madeira's iOS loader
never replaces an app-folder image with a builtin, so WINEDLLOVERRIDES cannot
swap it.

With MADEIRA_DXC_NATIVE=1, a load of dxcompiler.dll by name or by full path
searches system32 only, where the bundle's ARM64EC build of the same DXC
release is linked (build/dxc-arm64ec in Madeira), like the existing
madeira_force_builtin_dll names. Without the variable nothing changes.

Needs the Madeira change that builds and bundles the ARM64EC dxcompiler.dll.
Tested on an iPhone: the [dxc-native] line appears, the loaded image is the
ARM64EC build, and the game's own dxcompiler.dll and dxil.dll are no longer
loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
With MADEIRA_XESS_METALFX=1, libxess.dll resolves to Madeira's builtin in
system32 (from the bundle's arm64ec-windows), which answers XeSS with MetalFX
temporal upscaling, instead of the game's own Intel DLL. The iOS loader never
replaces an image from the application folder with a builtin, so
WINEDLLOVERRIDES cannot do it: Path of Exile 2 loaded its 74 MB x64 libxess
with libxess=b, and with libxess= too. Path of Exile 2 loads it by full path,
so a full path to libxess.dll is matched by its base name.

Unset, nothing changes. Madeira's side is its xess-metalfx commit.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants