Skip to content

iPhone Duo work: D3D12 pipelines and GPU, LMDB section views, ARM64EC DXC, Vulkan caches, overlay, profiling and frame diagnostics - #632

Draft
Dragooon wants to merge 76 commits into
willfaust:codex/d3d12-consolidationfrom
Dragooon:duo-all
Draft

Dragooon wants to merge 76 commits into
willfaust:codex/d3d12-consolidationfrom
Dragooon:duo-all

Conversation

@Dragooon

Copy link
Copy Markdown

Impact

No run compared this branch with an unmodified Madeira at matched content, so this PR claims no overall figure. Most changes are opt-in. With an empty madeira.cfg the branch behaves like the base apart from the default-on items under Defaults.

For reference, the best sustained map figures on the Duo with these changes: Mire 31.5 fps over 10 minutes (median 32.8, slowest tenth 20.7) and Ravine 31.9 over 5 minutes, 14 Nov 2026, Path of Exile 2. That is a reference point, not a before/after.

Measured on an iPhone with Path of Exile 2, per change:

  • jr-pe-entries (new): list-journal's x64-facing addresses were pool-copy aliases, which FEX never caches a block for. Installed through the PE view, the frame threads' FEX share of CPU went from 28.6% to 3.0%, the main thread's L1 misses from about 450K a second to 27-37K, and CPU per frame from 30.1 to 25-26.6 ms on the main thread and from 27 to 19-25 ms on the two job threads (20 Nov 2026). Frame rate at matched vertex load did not change: the heavy scenes were GPU-bound and the two runs were different maps. It went onto the phone together with the FEX PR's alias redirect, so the two are not separated, but that run logged no alias redirects at all, so there was little left for the FEX change to do.
  • list-journal: x64 -> native crossings about 10x lower; d3d12's share of them 57% -> 4%.
  • pso-async-threads = 4: draws skipped while their pipeline compiled, 11,043 -> 1,302 in a comparable session.
  • pso-warm-compute-only: first-use compile stalls in a session 62-96 s -> about 12 s.
  • section-view-grow: Path of Exile 2's LMDB caches (Shaders, Pipelines) failed to open in every session before ("Access denied"). With it they open (Shaders 7.1 MB, then 22 MB on the next launch, 14 Nov), so the game stops rebuilding its shaders every session.
  • DXIL loose-entry scan skipped with the shader pack: the scan stat()ed 17,348 files (451 MB) every launch, 2.5% of process CPU in the hideout. It no longer runs.
  • Pool trim (MADEIRA_POOL_TRIM = 2): about 120 MB of the JIT pool saved a session, no regressions seen.
  • ARM64EC dxcompiler.dll: the 0.5-1.2M combase crossings a second from the game's compile threads are gone. 444 of 449 shaders compile byte-identical to Microsoft's DLL, the other 5 to equivalent orderings. The mem2reg patch removes a walk that was 19% of DXC's time; DXC's 500 test cases compile byte-identical with and without it. The after-time was not measured on the phone.
  • pso-create-block = 2: with 1, MapMire held the game's loading thread for 315 s over 1,100 archive misses. 2 only looks in the archive inside the create call and sends misses to the background builders.
  • fence-chain-frag: GPU ms per frame at matched vertex load, 10-15M vertices 21.0 -> 18.2, 15M+ 28.6 -> 26.1. Other settings also differed between those runs, so this is not isolated.
  • root-cbv-fast and reset-wait-event: the one run with both on was slower (median 29.4 vs 33.1 fps, more frames over 50 ms). Not isolated. Both are off by default.
  • panel-hz = 80: held 80.0 Hz for whole sessions. panel-hz 40 came out as 30 Hz.
  • [xp] run= fix (new, a fix to the base's sampler): run= read ri_runnable_time as Mach ticks, but it is in nanoseconds, so it printed 41.67 times too high. In one session the printed value was exactly 41.67 times the nanosecond reading in all 199 samples that had both.
  • Diagnostics added since 18 Nov (new, all off by default): frame-timeline ([ftl], one line per frame: game thread, queue, worker, GPU), pso-slow-ms, fence poll runs, [xp-thr] thread table, [xp-vm] paging split, dep-trace (which encoder waits for which). What they found on the Duo: async-present-ahead = 0 cost 25-33% of the frame loop; in a heavy map 108 of 206 encoders wait per frame, and only 5 of those have no conflict before them (1.85 ms of GPU span), so the barrier waits are already tight.
  • cs-create-build 2/3, sampler-max-aniso, MADEIRA_AUDIO_MIX_RATE, MADEIRA_PROF_THREADS, the display-link kick change: on the phone since 18 Nov. sampler-max-aniso = 1 saved nothing measurable; 24 kHz mixing did not change the audio thread's CPU. No other claim.
  • Everything else: diagnostics, tools, or not measured. Said per commit below.

What is in it

madeira-d3d12: pipelines

  • 26275eba pso-async-threads: N background builders (default 2, unchanged).
  • 104c5608 pso-warm-compute-only: warm compute pipelines only.
  • a175b18b The device build's d3d12 work (prof12-prof18): encoder labels by shader digest, hp-release (default on), pso-create-build 0/1/2 and pso-seen-record, converter options (non-default values salt the shader cache key), vtx-census.
  • 7c23c09e, 6c833a49 cs-create-build: 1 queues every compute pipeline at creation on the low-priority builder queue; 2 queues only new ones on an urgent ring; 3 builds a new one inside the game's create call (never on a thread that has called ExecuteCommandLists). 2 and 3 need pso-origin.
  • ee134d79, b7a42ced pso-create-block 1/2: drawn-before pipelines built inside the create call; 2 only on archive hits.
  • c7b19f4b, 76909d4c pso-origin (diagnostic): pipelines classed drawn-before / created-before / new, with compile time per class, probe hit/miss cost and [pso-rebuilt].
  • 17e02310 shader-cache-app-key = 0: a pinned converter keeps the cache across app builds.
  • 902c2bf9 no loose DXIL scan while the shader pack is on (MADEIRA_D3D12_DXIL_LOOSE_SCAN=1 runs it anyway).

madeira-d3d12: GPU and recording

  • d4aec472 list-journal (x64 hot methods journaled inside the hybrid DLL) and api-census, both opt-in. 6dadb9f5 builds the x64 objects in build-pe.sh and adds the journal tests.
  • b068b5fb jr-pe-entries: list-journal installs its x64-facing addresses (trampolines, x64 methods, GetGPUVirtualAddress, the ARM64EC targets and flush) through mad_x64_graphics_entry_pe. jr-pe-entries = 0 keeps the pool addresses. Only acts with list-journal on.
  • 766bcb57 fence-chain-frag, 9d8c0173 root-cbv-fast, b3419e82 reset-wait-event: all opt-in.
  • ee3fb0b9 sampler-max-aniso = N caps maxAnisotropy in mad_sampler_info. The root-signature data the converter hashes keeps the game's value, so no shader converts again. Unset, nothing new runs or logs.
  • 3b9fea41 rcas-fill: gives Path of Exile 2's FSR sharpening pass a strength when the game writes 0.
  • 62fe9190 xess-metalfx: MetalFX temporal upscaling behind a builtin libxess.dll (opt-in through wine's MADEIRA_XESS_METALFX=1). 8128b298 adds build/madeira-d3d12/build-libxess.sh; the DLL is not committed.
  • 2269107a tex-pfv-minimal and 121f9d59 its removal: it is the suspect for one run's block corruption and GPU faults, so the branch leaves it out. Squash-merging drops both.

Diagnostics

  • 049f87fb, 3cf7034e hitch recorder ([hitch], [hitch-ecl], [hitch-sum]), with no CPU-time reads.
  • af2edf6e, 63a44f9b, e4a493f1 [gpu-mix] and [gpu-work] in [perf].
  • eaa7d101 names the pso-async, prebuild and submission threads.
  • c1d89462, 71354c23, ea1da570 the overlay's Shader misses field and the counter block behind it.
  • ae49dd73 MADEIRA_PROF=1 CPU-time-weighted sampling profiler; 6271b670 MADEIRA_PROF_THREADS limits it to threads by name; 6093f998 tools/prof-report.py.
  • 6ff41415, 449f01c8 frame-timeline ([ftl]), pso-slow-ms ([pso-slow]), fence poll runs in [perf], and [hitch] lines that end with the clock time and the [ftl] frame number. The clock is Wine's local time; on the phone that is UTC, and the header line says so.
  • 267812c7, 7c564724 dep-trace = N: for the frame's command buffers in the first second of every N, each encoder's fence wait, draws, pipelines and the resources it writes and reads, and every barrier with whether it makes the next encoder wait. A barrier command keeps its new bits in what was tail padding (checked at compile time), so commands do not grow.
  • 9fa25ba3, d9a4a8b9 [xp-thr] (every thread with half a second of CPU: Windows and Mach ids, name, priority, policy, P/E CPU, about every 30 s, split so it fits the 1,024-byte log line) and [xp-vm] (system decompressions, page-ins, faults, free and compressor memory, this process's memory by kind, about every second). The [wake-census] reader that 9fa25ba3 adds is taken out again in d9a4a8b9, because the wine side it reads is not in the wine PR.

ntdll, wineserver and audio (unix side)

  • 4e23f553, 4cf01a9a, 7bcd6c62 section-view-grow: a MEM_RESERVE view past the end of a file section grows the file (sparse, grow only) and is capped at MADEIRA_SECTION_VIEW_CAP_GB (default 16). MADEIRA_SECTION_VIEW_GROW=0 restores the refusal.
  • 2d587ddf MADEIRA_POOL_TRIM 1/2: the JIT pool's image copies skip pages nothing reads.
  • 0acdbc38 MADEIRA_AUDIO_MIX_RATE sets the rate the mix format reports (default 48000, unchanged).
  • 650cf3c0 [xp] run= reads ri_runnable_time as nanoseconds.

App

  • 5c1f01ed panel-hz pins the display link to a fixed rate. c2fc5780 the display link reads MADEIRA_PROMOTE_KICK once per arming.
  • cca77484 Blend display mode, halfway between Fill and Stretch. Not built or run on a device.
  • 0edf16bd, ca8d08e8, a07d5b44 Library ▸ Shaders: cache sizes and Compile shaders now (replays recorded Vulkan pipelines with progress).

Build: ARM64EC DXC

  • bddcb544 build/dxc-arm64ec: DXC 1.8.2407 as ARM64EC with llvm-mingw (patches 0001-0003; 0004 is an argument log). Loaded only with wine's MADEIRA_DXC_NATIVE=1. The 28 MB DLL itself is not committed.
  • f2412d39 SPIR-V code generation on, for games that compile with -spirv on Vulkan.
  • d198f804 patch 0005, mem2reg live-in check without the block walk; 0006, [dxc-time].
  • 8265644a dxcompiler.dll is a custom component in the windows runtime, so build-ipa leaves it alone.

Vulkan (KosmicKrisp, Fossilize, loader)

  • 7f67569f KosmicKrisp shader cache, implicit pipeline cache, Metal 4 pipeline archives, compile and frame stats.
  • bc02dcff, 5644113f, e420d45b Fossilize record/replay through the Khronos loader (fossilize = record|replay|on).
  • 8f299b27, 146e25db, 02784c86 patches 0010-0012: name unsupported features at vkCreateDevice; timestamp query pools split across counter heaps, or heapless when Metal refuses. Without these Path of Exile 2 fell back to DirectX 11.
  • d32dc663 patch 0015 (giant MSL hashes and dumps, compile QoS).

Tests, catalog and pins

  • 5e24ab07, d23bb336, a1a934e7 host checks that follow the changes above. No behaviour change found in any of them.
  • b8340dfc, 93185320, 5bc0c695, f3557a74, adb34d89, b6e16e75, 94075c59 intermediate pins and catalogs; 79e9a18a the final pins and a catalog regenerated with the three submodules checked out. The catalog the 18 Nov form of this branch carried had been generated without them and had lost 130 of the base's options; all are back and gen-config-catalog.py --check passes.

Defaults

Default on: section-view-grow, the loose DXIL scan skip with the shader pack, hp-release, jr-pe-entries (only with list-journal on), the KosmicKrisp caches (Vulkan games), the dxcompiler custom-component listing, the Shaders page. Everything else needs a madeira.cfg key or an env variable. The pso-async builder count stays 2.

Left out

  • Duo-only work: three import probes, a converter-identity pin, and the Duo tools (an x64 fast-path stub patcher with its tests, a log summary).
  • Frame generation fed by the game's motion vectors and depth (framegen, two commits, with dxmt MadeiraCtl ops 30-32). It works when the game holds its cap, but world-anchored labels drawn into the HUD layer step at the game's rate against the interpolated world, and the rate gate cycles when the game cannot hold the cap. A separate PR once that is fixed.

Other branches

  • No branch of willfaust/Madeira already has any of these commits (checked by patch id on 22 Nov).
  • codex/dxmt-upstream-build-port starts from the same commit as this base. This branch merges into it with conflicts only in the submodule pins, the generated catalog, and one hunk of madeira_ir_unix.mm, where the loose DXIL scan skip meets that branch's own form of the cache-scan changes.
  • playport/kosmickrisp conflicts with the KosmicKrisp patches here in build/mesa-ios/build-kosmickrisp.sh. The playport/*, codex/pr-build-235-df2540c0 and codex/wine-11.20-runtime branches conflict with the base itself; this branch adds only build/windows-runtime/targets.py to the last one's list.

Testing

  • Phone: everything except Blend has run on the iPhone, though not every option in a175b18b was set there. The diagnostics since 18 Nov ran in the sessions of 21-22 Nov. The commits made for this branch (121f9d59 onwards) are removals, a log-line split, the run= unit, a script and a code move; the phone runs the form before them.
  • Build: the D3D12 DLLs build on Linux with this branch's own build/madeira-d3d12/build-pe.sh (MADEIRA_REQUIRE_KERNELS=1, llvm-mingw 20260421): 937,984 bytes, 4 warnings, all in functions the base already has. Converter identity ab73628285415449, so a device converts its shaders again once. The DLLs are not committed: the maintainer's branch keeps the baseline DLLs until it rebuilds them ("Restore baseline DLLs until D3D12 is rebuilt").
  • Host checks: on Linux the branch fails 129 of 293 tests/host checks, all of them ones the base also fails (they need macOS, swiftc or a signed build). The base fails 130: check-config-catalog passes here.
  • App and unix side: compiled on the Mac (install39 and the diag1 build, 21 Nov). The unix-side commits made for this branch were not compiled there.

🤖 Generated with Claude Code

ShitizZip and others added 30 commits November 22, 2026 17:07
list-journal = 1: the hot ID3D12GraphicsCommandList methods and
ID3D12Resource::GetGPUVirtualAddress run as x64 code inside the hybrid
d3d12.dll (lld links the x64 objects into the ARM64EC image) and append to a
per-list journal; the ARM64EC side replays it through the same list_*
functions at Close, when full, or before any method that is not journaled.
PoE2: x64->native crossings about 10x lower (d3d12 share 57% -> 4%).

The x64 code never addresses the DLL's globals: Madeira runs ARM64EC code
from a JIT-pool copy of the image, .data included, while x64 code runs at
the PE address. State is reached through the object (vtable[-1] holds a
struct mad_jr_ctx).

api-census = 1: [d3d12-census] lines every 5 s with calls per frame by
method and how many state sets repeat what is bound.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Logs every frame over hitch-ms (default 50) and every replay over
hitch-ecl-ms (default 33) with where the time went: game/worker thread
CPU vs wall, ExecuteCommandLists/Present split, encoding, commits,
first-use pipelines, footprint and headroom. 5 s summary of frame-time
buckets. Capped at 30 lines per 5 s.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PoE2 creates ~10k graphics pipelines and draws with ~2.6k; warming all of
them compiled for the whole session on a clamped CPU. Graphics pipelines are
already async (pso-async); compute ones block the render thread.

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

GetThreadTimes/GetProcessTimes are Wine server round trips (~100/s from the
game thread) and GetThreadTimes returned process time on Madeira. The pso
time line now splits out what shader cache hits cost.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d/store pixels in [perf]

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ender+compute pipelines in [perf]

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HREAD_QOS can class them)

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
madeira_d3d12 records MC_FX_TEMPORAL (MadeiraD3D12TemporalUpscale, madeira_fx.h):
the replay runs one MetalFX temporal scale into a private texture and blits it
to the game's output, ordered by the device fence. Scalers are cached per
formats/sizes and never released. Every object answers IID_MadeiraObject so the
exports can reach ours behind a Streamline wrapper.

src/libxess: the XeSS 2.0 D3D12 API (all 2.0.2 export names) answered with it.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es (FSR RCAS, NIS) show

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

RCASCS reads its strength from root CBV register 10 .x; on the Duo PoE2 writes
0 there at any slider position, so the pass returned its input. With
rcas-fill = <sharpness>, the dispatch binds a copy of the buffer with FSR's
strength for that sharpness when the game's word is 0.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What madeira_d3d12.dll 69cd8c8c and the app's madeira_ir_unix.mm bc99ccdb
carry beyond the local commits:

- encoder labels by shader digest ("R ps:<digest> vs:<digest> WxH",
  "C <name> cs:<fnv>") for gpu-pass-timing (encoder-labels = 1)
- hp-release: free fully empty runtime texture heaps, keep one spare
  (default on)
- pso-create-build (0/1/2) and pso-seen-record: queue pipeline builds at
  creation behind draw-time builds
- msc-gpu-family, msc-min-os, msc-ignore-debug-info, msc-validation
  (converter options; non-default values salt the shader cache key)
- rp-learn-store / rp-learn-census (retired, default off)
- vtx-census = N with VS-output/PS-input varyings census

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

[cpu-split] counts a sample whenever a thread's run state says RUNNING, which
includes threads that are only runnable (a thread yielding in swtch_pri looks
as busy as one computing), and it keeps only the top 64 JIT buckets per burst,
about a quarter of the samples. That was not enough to find where a game's
CPU time goes.

With MADEIRA_PROF=1 a sampler thread reads every thread's CPU time each pass
(THREAD_EXTENDED_INFO, no suspend) and samples only the threads whose CPU
time moved; a sample's weight is the CPU time used since that thread's
previous sample, so idle and runnable-but-waiting threads weigh nothing.
MADEIRA_PROF_HZ sets the pass rate (default 100, 20-1000). Each record has
the host pc, the guest rip for FEX threads, the class (FEX JIT code, ARM64EC
image copy, native), the thread slot and whether the thread was running when
sampled. Records go to madeira-prof-<time>.bin next to the stderr log, and a
.txt sidecar names threads, native symbols (dladdr), the pool range and each
Wine process's modules (re-dumped every 30 s, since Wine's processes share
the task and reuse each other's PE addresses). [prof] summary lines every
30 s include the sampler's own cost. Nothing between thread_suspend and
thread_resume takes a lock.

tools/prof-report.py turns a capture into a report: top modules, functions
(through the exe's .pdata) and threads, filterable by thread name and time.

Default off: without the variable nothing starts. Used on an iPhone for a
dozen Path of Exile 2 sessions at 100 Hz; it found, among others, the
reverse-translation walk in the JIT alias table (7.5% of the process's
CPU), a game thread busy-spinning on gamepad rumble, and the share of clock
reads in the game's job dispatcher.

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

Every image loaded into the JIT pool is copied whole, so every 16 KB page of
the copy is dirty, resident and kept warm by the pool warmer, including pages
the copy never needs: the zero gaps between sections that no section, header
or relocation block reaches, and the resource section (resource lookups go
through the module handle, which is the PE view, not the copy). With 272
per-process DLL copies in one Path of Exile 2 session that was about 290 MB
of the pool.

MADEIRA_POOL_TRIM = 1 leaves the gap pages untouched when the copy goes to a
virgin main-pool range (above the bump mark it was taken from, or the
big-image slot on its first use; never the low region, a recycled range or
an image reload), where the pool is still zero-fill: the copy's bytes are
identical and the pages cost nothing. 2 also skips a read-only,
non-executable .rsrc section that hosts no other data directory. Skipped
pages are recorded in a bitmap, so the warmer, the copy check and the icache
flush (a cache operation by address faults a page in) leave them alone. Any
full copy over a range, and any release of it, clears its bits. [pool-trim]
lines and the warmer's trimmed= field report it. Default 0: unchanged.

A Linux harness that ran the copy against real DLLs byte-checked the result
(shell32 saves 8.7 of 9.8 MB, kernelbase 2.1 of 3.0 MB at level 2). On an
iPhone at level 2 the trim held at about 120 MB a session with no
regressions seen.

Risk: anything that reads resources through a pool-copy address instead of
the module handle (for example &__ImageBase from ARM64EC code) would see
zeros at level 2; level 1 only skips pages outside every section.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
madeira.cfg panel-hz = N asks CoreAnimation for minimum = preferred =
maximum = N Hz (capped at the panel's maximum) for every pacing mode,
overriding the pacing mode's own display intent. ProMotion rates include
120, 80, 60, 48, 40, 30 and 24 Hz (Apple, "Optimizing iPhone and iPad apps
to support ProMotion displays"); iOS may still choose another. A 40 FPS
limit on a 40 Hz panel wakes the main thread a third as often as at 120 Hz,
but a frame that misses 25 ms then waits until 50 ms. Unset or 0: off, no
change. The [promote] log line shows the setting.

On an iPhone with a 120 Hz panel: panel-hz 80 held 80.0 Hz for a whole
session; panel-hz 40 came out as 30 Hz (iOS picked a 33 ms link target).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
madeira_list_journal.x64.{c,S} are x64 code linked into the ARM64EC
madeira_d3d12.dll; build-pe.sh compiles them and stops if one references a
symbol outside itself. tests/journal (jrtest, x86-64 Linux host) replays
recorded sequences with and without the journal. Taken from
pr/d3d12-list-journal.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Games that compile HLSL at run time ship Microsoft's x64 dxcompiler.dll and
run the whole compiler under FEX. Every allocation it makes through
CoTaskMemAlloc is an x64 -> native crossing: Path of Exile 2's compile
threads made 0.5-1.2 million combase crossings a second, and its shader
compiles were a large part of the hitching on new areas.

build/dxc-arm64ec/build.sh builds the same DXC release (v1.8.2407) as
ARM64EC with llvm-mingw:
  0001  MinGW and ARM64EC build, based on raedrizqie's MinGW patch set
        (microsoft/DirectXShaderCompiler#8265, not merged), adapted to
        1.8.2407, with the version string pinned to Microsoft's build;
  0002  HLSL language options under MinGW, a COM allocator for the blobs
        the game frees with CoTaskMemFree, Windows DLL names;
  0003  opt-in env.MADEIRA_DXC_DXIL = 0: validate with the built-in
        validator and sign the container without the game's dxil.dll
        (hexops' MIT signing code).
The output is marked as a Wine builtin (prefer-native) and is meant for
app/Madeira/arm64ec-windows/. The wine fork's MADEIRA_DXC_NATIVE=1 makes the
loader take it from system32 instead of the game's copy; without that
switch nothing changes. notices/ carries the DXC and hexops licence texts.

Tested on Linux under Wine (x64 build of the same source against the
game's DLL, 449 shaders the game compiled): 444 outputs byte-identical, the
other 5 equivalent orderings. On an iPhone with MADEIRA_DXC_NATIVE=1 it has
compiled Path of Exile 2's shaders in every session since 4 Nov 2026, with
no failures seen; the emulated combase crossing bursts are gone.

Not in this change: the built DLL itself (28 MB) and its staging into the
bundle, and the THIRD-PARTY-NOTICES.md entries for DXC, raedrizqie's
patches and hexops' code.

Duo build: also carries patches/0004 (MADEIRA_DXC_ARGS_LOG/_ADD/_DROP, the
opt-in argument log and rewrite the device DLL 7fe04daa was built with).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From pr/ios-prof-sampler (our tools/prof2.py).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wine 0dd02374aef = madeira-lgpl ddf92babc5b + the Duo changes
dxmt 4d19798 = ios-port 3d62913 + query parking (on) and gpu-pass-timing
FEX 6479ed1c8 = ios-port-2607 1dc6ed493 + the six FEX changes
madeira-dock stays at 67780ba (no changes).

These commits exist only in the local clones (pr-prep/wine, dxmt, FEX).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build/tools/gen-config-catalog.py with wine, dxmt, FEX and madeira-dock at their
duo/integration commits; --check passes.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A game that renders at a fixed aspect ratio different from the screen's
either gets cropped (Fill) or squashed (Stretch). Blend takes the geometric
mean of the guest's shape and the view's and covers the view with it, so
half of the shape difference is cropped and half is stretched. For a 16:10
game on a 1.42:1 screen: Stretch squashes 11%, Fill crops 5.5% a side, Blend
squashes about 5.5% and crops about 3% a side.

It is a new DisplayMode case ("blend", label "Blend", symbol
rectangle.compress.vertical) in the per-game Aspect & scaling picker; the
other modes are unchanged.

Not yet built or tried on a device.

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

mad_texinfo_from_desc gave every texture PixelFormatView usage, and Apple's
MTLTextureUsage.pixelFormatView page says iOS GPU family 5 and later then skip
lossless compression for it: no render target, depth buffer or FSR target was
ever compressed, though PoE2 stores 50-150 MB of attachments a frame and reads
nearly all of it back. The same page says the option is for views with another
component layout, not for sRGB/linear-only or swizzle-only views.

madeira.cfg tex-pfv-minimal = 1 keeps the usage on TYPELESS formats (the only
resources D3D12 lets an SRV/UAV view in another format; castable lists are
refused), depth formats with stencil (the ml1101 X32_Stencil8 SRV) and
ShaderAtomic textures (ml1149). RTVs and DSVs bind the texture itself and make
no view. A view or resolve that would still need the usage on a texture made
without it keeps the texture's format (a resolve is skipped) and is logged as
[pfv-miss]. GetResourceAllocationInfo shares the builder, so heap sizes stay
consistent. The cumulative report gains a tex-pfv-minimal line (textures with
and without the usage, pfv-miss count). Default 0: unchanged.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1118's rule)

Fence-chain 3 waits only after a barrier on a resource written since the last
wait, but a render pass that waits always waited at its vertex stage, so its
vertex and tiling work could not overlap the previous pass's fragment work.
PoE2 fight dumps show 52-66 render encoders a frame starting exactly when
everything before them ends (a 330 us vertex stage behind a 1092 us fragment
stage, and the e8bca615 -> 5ca13d8a boundary serialised in every heavy dump).

madeira.cfg fence-chain-frag = 1 applies mode 5's rule (ml1118) in mode 3: the
wait moves to the fragment stage unless a compute or blit encoder ended since
the last vertex-stage wait, so skinning, culling, uploads and indirect
arguments still hold the vertex stage. Not covered, as in mode 5: a vertex
shader reading a texture or buffer the previous render pass wrote. A
"[perf] fence-chain-frag per frame" line counts the fragment-stage waits.
Default 0: mode 3 as before.

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

Every root CBV/SRV/UAV is resolved to its resource at record time (address
index binary search plus the alias walk) so the replay can declare it with
useResource. PoE2 records ~13k root CBVs a frame in fights, and
mad_resolve_address was ~1.1-1.7 % of each frame thread (d3d12 df0eb25f
profile, prof12), about one cache miss per step on 40-byte entries.

madeira.cfg root-cbv-fast = 1: each list remembers the buffer its last root
descriptor resolved to, and an address inside it reuses that answer. Only
buffers with their own Metal storage (not placed in a heap) are remembered, so
no other resource can alias the range and the search would give the same one;
the entry holds only while the address index version is unchanged with no
rebuild pending, so a create or release in between sends the next address to
the search. The resource noted for useResource is always the one the search
returns. Hit and search counts are summed per list at Close (one atomic add
per list) and logged as "[perf] root-cbv-fast per frame". Default 0: unchanged.

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

A command list Reset while the submission worker still replays it spun in
mad_list_wait_idle: 256 pauses, up to 3,840 Sleep(0) yields, then Sleep(1).
In PoE2 that happens 0.1-0.2 times a frame but lasts 100-400 ms (the replay is
compiling a pipeline), so the yields burn an E-core under the power cap and
Sleep(1) adds wake-up lag on top.

madeira.cfg reset-wait-event = 1: the Reset sleeps on a condition variable,
and the worker wakes it when a list's inflight count reaches 0 while anyone
waits (one interlocked read per released list otherwise; the waiter registers
before reading inflight, the waker reads the count after the decrement, so
one of them sees the other). The sleep re-checks every 2 ms as a safety net,
and the old loop still runs after it, so the exit condition is unchanged. The
existing "[perf] ml1120 async" line shows the Reset waits. Default 0: the
spin, as before.

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

A lazy compute pipeline was built at its first dispatch, on the thread that
replays the frame. Unlike a draw, a dispatch can't be skipped while a builder
works (its output feeds later passes), so pso-async never covered compute, and
each build that misses Metal's caches held the frame for hundreds of ms (PoE2's
100-400 ms Reset waits are these compile stalls).

madeira.cfg cs-create-build = 1 queues a compute pipeline at
CreateComputePipelineState on the background builders' low-priority queue (the
one pso-create-build uses, behind pipelines draws are waiting for). A queued
pipeline keeps its libraries for the build (pso-lazy-libs does not drop them)
and skips pso-warm's separate warm-up compile. A dispatch that arrives while a
builder compiles it waits on the pipeline's lock for that build instead of
compiling again (counted, and added to the hitch recorder's compute first-use
time); one that comes before a builder took it builds it itself as before, and
the queued entry finds it built. The builder threads start on the first queued
pipeline, pso-async or not; a full queue builds at the first dispatch as
before. A "cs-create-build:" line every 250 builds gives built, failed,
queued, queue-full, waited (ms) and built-first counts. Every created compute
pipeline is built, dispatched or not (more Metal memory). Default 0: unchanged.

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

The performance overlay is to show shader misses and the pso-async backlog
(invisible monsters in a Breach are draws skipped while their pipeline is
queued). The PE side keeps them in the counter block it already hands the unix
side with MadeiraCtl op 5, appended after the fps-gov fields as that block's
comment asks (struct mad_xp_shader at byte 184, asserted at build time):

- sc_miss: stages the shader cache did not have and sent to the converter,
  counted once per stage: the call that hands the metallib back or a refusal
  (convert_full's stored and refused results, mad_ovl_conv on the plain and
  cache-off paths; a sizing call is left out, its fill call follows);
- pa_wait: pipelines in the pso-async queue a draw is waiting for, plus those a
  builder is working on (+1 at the enqueue, -1 when the builder is done);
- pcb_wait: the same for the create-time queue (pso-create-build and
  cs-create-build);
- flags: 1 shader cache on, 2 pso-async on.

Interlocked ops only where a shader misses or a pipeline is queued; nothing per
draw or per frame. No madeira.cfg key. The shader-cache identity is unchanged
(converter 56fb4dd0853b81df).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new performance-overlay field, off unless picked like the others, adds two
cells:

- MISS/s: shader stages madeira-d3d12's cache did not have, per second, then
  "/" and the pipelines the pso-archive did not have, per second (the second
  figure only while the archive is in use; without it a compile can't be told
  from a Metal cache hit). Any miss in the interval shows as at least 1. "–"
  without madeira-d3d12's counters (a D3D11 game, or before its first frame).
- PSO Q: pipelines a draw is waiting for right now (pso-async queue plus the
  ones being built); "off" without pso-async. The spoken summary adds the
  create-time queue.

Both come from madeira_shader_overlay_stats (DXMT winemetal, bumped to
0b1c058), read once per overlay tick while the field is shown. The field sits
after GPU in the menu; check-overlay-frame-times.py's copy of the list follows,
and check-overlay-shader.py checks the block layout on all three sides and the
anchors.

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

Before building a pre-launch compile step (prewarm study, section 1) we need
to know how many of the pipelines compiled in a session had been created in an
earlier one without being drawn: only those could be compiled ahead of time.
Drawn ones are in the pso-archive already, new ones can't be known. Today only
the drawn set is kept (pso-seen), so the question can't be answered.

madeira.cfg pso-origin = 1 (default 0):
- at creation, every plain lazy render pipeline gets pso-create-build's
  content key, and every lazy compute pipeline a key of its CS digest and
  parsed root signature; the keys created go to
  %LOCALAPPDATA%\Madeira\pso-created-<exe>.bin ("MPSC", pso-seen's layout,
  same exe hash), saved every 30 s when it changed and at exit;
- the pipeline is classed then, against the lists as they stood at launch:
  drawn before (a sorted snapshot of pso-seen), created before, or new. This
  session's draws and creations don't move a class. The class is set before
  pso-create-build / cs-create-build can queue it;
- every build (mad_pso_realize, mad_cpso_build, mad_pso_for_strides) counts
  under its class; one of 150 ms or more counts as a compile (archive hits
  1-24 ms, compiles 600-1500 ms). A stride variant counts under its
  pipeline's class;
- a [pso-origin] line every 30 s when something changed, and one at process
  detach that goes only to Wine's debug output (no stderr lock) after a save
  that neither waits on the lock nor allocates.

The first session only fills the list; the answer is in the sessions after it.
Compute pipelines pso-warm compiles are compiled in winemetal, out of sight
here: for those the created split is the figure.

Off: one branch per lazy creation and one per build, nothing else. The
shader-cache identity is unchanged (converter 56fb4dd0853b81df); no converter
input is touched. tests/host/check-pso-origin.py holds the anchors.

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

- build-kosmickrisp.sh: -Dshader-cache=enabled.
- kosmickrisp-ios-0007: on-disk shader cache and an implicit pipeline cache.
- kosmickrisp-ios-0008: Metal 4 pipeline archives (MTL4PipelineDataSetSerializer
  chunks, loaded as lookupArchives) and [kk-compile]/[kk-slow] timing.
- kosmickrisp-ios-0009: [kk-frame] presents/intervals/submit/GPU stats and a
  madeira_vulkan_present_mark hook.
- WineProcessBridge: KosmicKrisp caches under <prefix>/madeira-cache/kosmickrisp.
- WiniosGL: madeira_vulkan_present_mark feeds madeira_frame_count and frame times.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shitiz Garg <mail@shitiz.me>
ShitizZip and others added 26 commits November 22, 2026 17:07
… pso-create-block = 2

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build-ipa stopped with "No source owner for app/Madeira/arm64ec-windows/
dxcompiler.dll" whenever the native DXC (build/dxc-arm64ec) sat in the farm,
so it had to be copied in after the build. List it with the other custom
components so the runtime step leaves it alone.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[pso-origin] adds a line with the compile time of each class (render
drawn-before / created-before / new, compute created-before / new), so a
map's cost can be split without estimating from averages.

The pso-create-block = 2 lookup line gives the average cost of a hit and
of a miss (a miss walks every saved chunk).

[pso-rebuilt]: with pipelines keyed (pso-create-block or
pso-create-build), a key that compiles again 30 s or more after this
session built it means the archive did not answer for it (a lookup that
does not match what was added, or an add that never got in). Counted, the
first 20 named.

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

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With d3d12-shader-pack on, new DXIL entries go to the pack and loose ones
are only read (and moved into the pack on a hit), so the loose bound has
nothing to bound. The startup scan still stat()ed every leftover loose
entry each launch: 17,348 files, 451 MB on the iPhone, 2.5% of the
process's CPU in Path of Exile 2's hideout. Skipped then;
MADEIRA_D3D12_DXIL_LOOSE_SCAN=1 runs it anyway.

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

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wine 1009659e9d47a76263165d87394198fcefdbbd8e, dxmt 2220fbfc7fe4f3cf0513e4aa8b8ac9c39dc395bd, FEX 58eb8cc833d828babb24f92ff943cd6663bf64fe: the pr/duo-all branches opened against
willfaust/wine madeira-lgpl, willfaust/dxmt ios-port and willfaust/FEX
ios-port-2607. Re-pin to the merged commits once those land.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven host checks that pass on the base failed on this branch. Each
anchored on text one of our changes moved; none found a behaviour
change. With them the branch fails the same checks as the base on a
Linux host (the ones that need macOS, swiftc or a signed build) and no
others.

- dxbc-register-spaces: the runtime cache identity is fed with the
  padded length mad_sc_key uses.
- got-diagnostics: the sync harness compiles a source region that now
  holds rcas-fill; it gets <math.h>, a mad_cfg_str_pe stub and -lm.
- monitor-cadence: the warmer's loops also skip pages MADEIRA_POOL_TRIM
  released (ios_pool_cold_test, 0 for every page with the switch off).
- msc-unbounded-retry: the overlay's converter-miss counter sits between
  mad_ir_convert_cached_impl's declaration and mad_ir_convert_cached.
- pool-low-images: pool trim's "was the range virgin" bookkeeping sits
  between the normal image allocation and its overflow; the check now
  asserts the order and that nothing in between allocates, and the
  harness stubs ios_pool_cold_clear.
- pso-lazy-libs: a pipeline queued at creation keeps its libraries
  (!queued), and the compute build is mad_cpso_build.
- vis-trace: [gpu-work]'s per-frame counters sit between the encode and
  the vis-trace hook.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A lazy compute pipeline is built at its first dispatch, on the thread that
replays the frame, and a dispatch can't be skipped while a builder works.
Path of Exile 2, 18 Nov 2026 (vk8c), one map: 26 frames of 166-777 ms
held 10.7 s of such builds, 30 compute pipelines.

Of the 2,079 compute pipelines the game created in that session, 34 were
new (in no earlier session's created list, pso-origin), and those are
the ones that compile: 14 of the 15 compiles counted at the last
[pso-origin] line. The other 2,045 are in the pso-archive and cost a
lookup.

The game creates its pipelines on a thread of its own (LOW0 made 4,612
of the 4,700 render pipelines built inside the create call that session)
and can dispatch one only after its create call has returned. With lazy
creation that is at once, so the compile lands on the frame.

cs-create-build = 1 queues all 2,079 on the low-priority builders. Two
modes act on the new ones only and leave the rest to pso-warm:

  3  the pipeline is built inside CreateComputePipelineState, on the
     game's creating thread, as Direct3D does on Windows. The game
     dispatches it once the call returns, so no frame waits for the
     compile. A creating thread that has called ExecuteCommandLists
     (it submits frames) is not held: its pipeline goes to the builders.
  2  the pipeline goes to the background builders on a ring they take
     before the render pipelines a draw waits for; a first dispatch
     waits for the build in progress.

Both need pso-origin = 1 and say so when it is off. Each new compute
pipeline gets one [cs-create-build] line: where it was built, on which
thread, how long, and for a queued one how long after creation its first
dispatch came.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An anisotropic sampler takes up to N taps along the stretched axis of
every texture read. Path of Exile 2 at texture_filtering = 8 uses one
such sampler (filter 0x55, 8x, wrap) for its material textures, and on
the iPhone its GPU is at least 80% busy for 46% of a map at a 720x450
internal resolution.

madeira.cfg sampler-max-aniso = N (1..16; 0, the default: as the game
asks) caps maxAnisotropy in mad_sampler_info, the one place a D3D12
sampler (static or CreateSampler) becomes a Metal sampler. 1 is plain
trilinear. The root-signature data the converter and the shader cache
hash keeps the game's value, so no shader is converted again. With the
cap set, the first capped sampler is logged with what the game asked
and what it got. Unset, nothing new runs and nothing is logged, which
check-got-diagnostics' sampler harness now also checks.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MADEIRA_PROF samples every thread: at 200 Hz with 110 threads that is
22,000 thread_info calls a second plus a suspend for each one that ran,
too much to leave on through a play session. With
MADEIRA_PROF_THREADS = <part of a name>[;<part>...] only threads whose
name contains one of the parts are sampled, and only they are ever
suspended; every other thread costs one name read a second (a thread is
named after it starts, so the test is repeated). "FMOD" gives a
session-long profile of the audio mixer beside a normal run.

Unset or empty: every thread, as before.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
GetMixFormat always reported 48 kHz. A sound engine that mixes at the
device's rate does that much work per second: Path of Exile 2's FMOD
mixer thread runs 912 M instructions a second in a map, 9.5% of the
process's CPU, and FMOD documents 24 kHz as its own default on mobile
"to reduce CPU cost" (System::setSoftwareFormat).

env.MADEIRA_AUDIO_MIX_RATE = 8000..96000 reports that rate instead
(unset, 0 or out of range: 48000, as before). The RemoteIO endpoint is
already created at the rate of its first client, so iOS converts to the
hardware rate. An engine whose game fixed the mixer rate converts at its
output instead and gains nothing; the ml1066 create_stream line gives
the rate each client opened. Settings > All settings lists it under
Audio as "Sound mixing rate" (48 / 32 / 24 kHz).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The link's tick asked MadeiraConfig.flag for MADEIRA_PROMOTE_KICK every
time. Each call stats madeira.cfg twice and builds the cache stamp
string: 160 stat calls a second on the main thread at panel-hz 80. In a
profile of Path of Exile 2 (9 Nov 2026) stat/lstat were 44% of the main
thread's running samples, on a thread that takes about 3.8% of the
process's CPU in a map.

The flag is now read once per arming, where the display-sync setting is
applied (a second after the link starts). A change to it applies at the
next game start instead of mid-session.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…w switches

dxmt b548b251: [pso-warm] counts a warm-up as a hit when the saved chunks
had its pipeline, not by its wall time.

The catalog gains cs-create-build's modes 2 and 3, sampler-max-aniso,
env.MADEIRA_PROF_THREADS and env.MADEIRA_AUDIO_MIX_RATE.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Native code takes addresses in Madeira's pool copy of the image, so the
x64-facing addresses list-journal installs (the trampolines, the x64 methods,
GetGPUVirtualAddress, and the ARM64EC targets and flush they jump to) were
pool-copy aliases. FEX never caches a block for one: every call took its slow
lookup and a redirect to the PE view, about 450K calls a second per Path of
Exile 2 frame thread and 27% of their CPU (fexl1-run1, 20 Nov 2026).

Install them through mad_x64_graphics_entry_pe: x64 entries then hit FEX's
block cache and the ARM64EC targets take the normal x64 -> ARM64EC crossing.
jr-pe-entries = 0 keeps the pool addresses. Logged once at install.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measurement only, for the Duo CPU/GPU dig.

frame-timeline = 1 (default 0): one [ftl] line per presented frame, written
by the submission worker four frames late: the frame time on the game's
threads, the queue as Present left it, the worker's time by job kind and
the Present job's parts, and the GPU's own start/end for the frame's
command buffers (busy, span, idle gap to the previous frame, completion
counted from the Present call).

pso-slow-ms (default 0 = off): a [pso-slow] line for every pipeline
creation or first-use build at least that long, with the thread and frame.

[perf] fence poll runs: how long one thread polls a fence that does not
move. [hitch] lines end with the local clock time and the timeline's
frame number so they join with [ftl] and [xp].

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Measurement only, Duo dig.

[wake-census] (~10 s): the wake census kept by unix/sync.c.
[xp-thr] (~30 s): every thread with half a second of CPU so far: Windows
thread id, Mach thread id, name, scheduled/base priority, policy, CPU on
P and E cores. Names the threads the other lines show by id only.
[xp-vm] (~1 s): the system's decompressions, compressions, page-ins and
faults since the last line, free and compressor memory, this process's
internal/compressed/external memory, and the [xp] run= value read as
nanoseconds to settle its unit.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Measurement only, for the Duo GPU dig.

dep-trace = N (default 0 = off): [dep] lines for the first three command
buffers whose first list is replayed in the first second of every N on
the device's uptime clock, the ones gpu-pass-timing times and dumps
encoder by encoder when N is its period. Per encoder: the fence wait the
replay gave it (vertex stage, fragment stage, none), its draw, vertex and
dispatch counts, the pipelines it ran, and the resources it writes
(attachments, UAVs, copy destinations) and reads (SRVs by the stages
their root parameter is visible to, vertex and index buffers, indirect
arguments, copy sources), with byte ranges for buffers. Only resources
the GPU can write are listed. Each ResourceBarrier is logged with its
resources and states, and whether it makes the next encoder wait.

gpu-pass-timing says how long each encoder ran and that a heavy frame's
GPU is never idle. This says which encoder had to wait for which, so the
two together show which waits a frame could do without.

A barrier command keeps its StateAfter bits in what was tail padding of
the union member (checked at compile time): commands do not grow.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The trace took the first three command buffers begun in the traced second,
whatever they were. PoE2 submits a short upload list on its copy queue each
frame, and a trace begun there stayed the active one until that queue's next
call, so the frame on the direct queue was never taken: in the first run on
a device 77 of 78 traces were of 3 to 16 copy encoders.

A trace now starts only for an ExecuteCommandLists call of at least
dep-trace-min-cmds (300) recorded commands, counted over all its lists. A
smaller call that has no trace to end or to join does not touch the trace's
lock. A traced command buffer that ends with fewer than dep-trace-min-enc
(50) encoders is not counted as one of the second's three; starts are capped
at 8 a second.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tex-pfv-minimal (off by default) made textures without PixelFormatView usage
where no view seemed to need it, so Apple's lossless compression could stay
on. It is the suspect for the block corruption and GPU faults of one run on
the iPhone (perf1, 9 Nov 2026), and no run since has shown a gain worth
keeping it for. Removed rather than offered as an option.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The [xp] sampler converted every rusage time with the Mach timebase, but
ri_runnable_time is already in nanoseconds, so run= came out 125/3 = 41.67
times too high on Apple silicon. In one iPhone session (22 Nov 2026, 801
[xp] lines) the printed run= was 41.67 times the same delta read as
nanoseconds in all 199 samples that had both. Read as ticks, the median
sample says 5.6 threads waited for a core the whole time while the process
was using about 3 of the phone's 6 cores, which the scheduler would not
allow. Read as nanoseconds the median is 0.14 thread-seconds a second
(tenth to ninetieth percentile 0.03 to 0.38).

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wine_log_write formats into 1,024 bytes, and the [xp-thr] thread table was
built in 1,400 before it was written out, so the threads past the first
1,024 bytes of each line were lost. The table now starts a new line before
it would pass that.

[wake-census] printed a census kept by a wine sync.c change that is not
part of this branch, so its reader goes too.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build/madeira-d3d12/build-libxess.sh builds the ARM64EC libxess.dll that
xess-metalfx answers XeSS with and marks it as a Wine builtin. The DLL is
not committed; with wine's MADEIRA_XESS_METALFX=1 it is loaded from
system32 in place of the game's own copy.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The frame timeline and [pso-slow] functions sat inside the stretch of
madeira_d3d12.c, from g_es_enc_t to the encoder macros, that the
draw-dedup and encode-batch host checks compile on their own, and that
stretch has no FILETIME or Interlocked*64 stand-ins. They now follow it.
No code changes.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check-vis-trace matched the draw and dispatch cases of the replay
literally; dep-trace adds its hook to both. check-rusage-sdk found the
page-wait expression by the old run= conversion, which the [xp] fix
replaced.

Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wine 8a404df8193, dxmt 03d4720d and FEX 3b70cde73 are the tips of the pull requests
opened against willfaust/wine codex/wine-runtime-consolidation, willfaust/dxmt ios-port and
willfaust/FEX ios-port-2607. Re-pin to the merged commits once they land.

The config catalog is regenerated with those three checked out. The
catalog this branch carried before was generated without the submodules,
so it had lost 130 of the base branch's options (wine, dxmt and FEX);
all are back, 59 options are new, and gen-config-catalog.py --check passes.

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

Copy link
Copy Markdown

Hi @Dragooon, nice work on the performance side. I wanted to flag how this relates to #624 (iPhone Duo: screen-shaped resolutions, fold re-frame, working bar buttons), since both are "Duo" PRs and they could get mixed up.

They cover different ground and don't replace each other:

On Blend: with #624, the game renders at a size shaped to the screen, so on the Duo the picture already fits without cropping or stretching. Blend is still a reasonable option when the game renders at a fixed size of its own. The two don't clash in function.

Both PRs edit GuestDisplay.swift (the DisplayMode enum and GameSurfaceLayout.rect) and Library.swift (the settings pages), so whichever merges second will need a small rebase. I'm happy to do it on my side if #632 lands first.

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.

3 participants