Repository navigation
Conversation
…A_D3D11_QUERY_PARK)
Games build a GPU fence out of while (GetData(event) == S_FALSE) {}. Path
of Exile 2 does it every frame, up to about 130,000 polls a frame. Under
emulation every poll is an x64 -> ARM64EC round trip plus a Metal call, and
the polling thread keeps a performance core busy for nothing, which on a
phone is heat that throttles the threads doing real work.
With MADEIRA_D3D11_QUERY_PARK=1, once the polls of one event query come in
a burst (pending polls less than 250 us apart, after 2 of them), GetData
parks the caller on the queue's shared event until the query's value is
signaled, at most 1 ms (Metal's wait timeout is in milliseconds), and then
answers. A one-off poll, such as a query read once a frame after it was
issued, never waits. It only parks once the chunk holding the signal has
been committed, since no wait could see it complete before that, and it
does the flush GetData would do anyway (no DONOTFLUSH) first. This is the
same idea as D3D9's WaitCPUFenceBounded parking, on the D3D11 event value. A
[query-park] line at the first event query says the switch is on.
The [gpu-perf] line gains the parked event polls per frame and the time
parked per frame.
Off by default. Tested on an iPhone with it on in every session since 4 Nov
2026 (Path of Exile 2 on D3D11 and D3D12, Steam): no hangs or missed
signals seen.
Signed-off-by: Shitiz Garg <mail@shitiz.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was no way to see which passes cost GPU time on an iPhone that cannot be attached to Instruments. madeira.cfg gpu-pass-timing = P (seconds, 0 = off, the default) times every Metal encoder for one second in every P with an MTLCounterSampleBuffer per command buffer: vertex and fragment start/end samples for render passes, start/end for compute and blit encoders (through pass descriptors, so the dispatch type is kept). Each encoder's label is kept with its samples. Once per window it logs [gpu-pass]: GPU busy per frame, the union of the encoder intervals (what is left are gaps where no encoder ran: fence waits, scheduling), the overlap between encoders, and the passes ranked by GPU time with their vertex and fragment split, keyed by the encoder label. Every gpu-pass-dump-s seconds (default 30) the next three command buffers are listed encoder by encoder with start offsets ([gpu-pass-dump]). Off, nothing is attached and each encoder costs one relaxed load; remote (wmtr) command buffers are never timed. On an iOS 27 iPhone the timestamps came at 1.0 ns per tick with no missing samples. Labels come from the D3D side (encoder-labels in madeira-d3d12). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shitiz Garg <mail@shitiz.me>
The overlay had no way to show why a stretch hitches or monsters stay invisible: shader conversions, pipeline compiles that missed the pso-archive, and the pso-async backlog only appear in log lines written every few hundred events. madeira_shader_overlay_stats() gives the overlay, once per tick: - shader_misses: madeira-d3d12's count of stages its shader cache did not have, read from the counter block it already publishes with MadeiraCtl op 5 (its overlay fields sit at byte 184, after struct ios_xp_pe and ios_xp_pe_cap); - pipeline_misses: pipelines the pso-archive's saved chunks did not have and that were compiled for the game (inline add, queued add, or a plain create once the archive is full). pso-warm's own background compiles are left out through a thread-local flag; - pso_queue / pso_background: the pso-async queue draws wait on (queued or being built) and the create-time queue behind it, from the same block; - flags: block present, shader cache on, pso-async on, archive in use. The block is the game process's memory, gone once the game exits while Steam stays, so it is read with vm_read_overwrite (as server_ios.c reads guest memory): a stale address gives no figures instead of a fault. Counting costs one relaxed atomic add on a path that is compiling a pipeline anyway; nothing runs per frame. An older madeira-d3d12 (shorter block) gives zeros and no "block present" flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shitiz Garg <mail@shitiz.me>
…on a miss A render or compute pipeline created with fail_on_binary_archive_miss and no archives of the caller's own now looks only in the pso-archive's saved chunks: a miss returns no pipeline and no error and compiles nothing. madeira-d3d12 uses it (pso-create-block = 2) to take a pipeline from the archive inside the game's create call and leave misses to its background builders. Nothing set the flag without archives before, so other callers are unchanged. Signed-off-by: Shitiz Garg <mail@shitiz.me> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pso-warm's background compiles share Metal's compiler with the pipelines the game waits for. A warm-up that missed the saved chunks now waits before compiling until no compile for the game is running and the last ended 500 ms ago; archive hits go straight through. MADEIRA_PSO_WARM_YIELD=0 turns the wait off. The effect of the wait on frame time was not isolated. The [pso-warm] line that suggested hundreds of competing warm compiles a session classed a warm-up by its wall time and counted cache hits that waited for a core as compiles; the next commit fixes that count. In Path of Exile 2 the warm-ups that really compile are about 57 a session. The open archives were saved when full (128) or after 10 s without an add. In a map the adds never pause that long, so a session that ended there lost up to five part-filled archives (50-228 pipelines a session in the logs) and the next visit compiled them again. They are now also saved once their oldest unsaved add is MADEIRA_PSO_ARCHIVE_MAX_AGE seconds old (default 20; the check runs every 5 s). [pso-archive] lines give the inline adds made for the game apart from pso-warm's; [pso-warm] lines how often and how long warm-ups waited. Signed-off-by: Shitiz Garg <mail@shitiz.me> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ad it [pso-warm] classed a warm-up by its wall time: under 3 ms a cache hit, anything longer a compile. The warm-ups run on utility-QoS queues, and while a game saturates the cores a utility thread waits seconds for one, so lookups the saved chunks answered were reported as compiles. Path of Exile 2, 18 Nov 2026: "488 compiled (avg 1045.9 ms)" in a session where the archive's own counters show about 57 pipelines pso-warm really had to add (295 misses, 238 of them for the game). The figure read as hundreds of compute pipelines compiled again every session, which they are not. A warm-up is now a hit when the saved-chunk lookup returned its pipeline (a thread-local set by madeira_arch_note_hit around the warm-up's own create). With no saved chunks in use the 3 ms rule stays. No behaviour change; the [pso-warm] line keeps its wording. Signed-off-by: Shitiz Garg <mail@shitiz.me> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ios-port(3d62913, the commit Madeira'scodex/d3d12-consolidationpins) ←Dragooon:duo-all(6 commits, 03d4720; 5 files changed, 694 insertions, 27 deletions)Impact
No run compared this branch with an unmodified dxmt at matched content, so this PR claims no overall figure. Measured on an iPhone with Path of Exile 2, per change:
pso-create-block = 2possible. With block 1, MapMire held the game's loading thread for 315 s over 1,100 archive misses; with 2 a miss goes to the background builders.Commits
3dacbe5bd3d11: opt-in parking of burst GetData polls on event queries (MADEIRA_D3D11_QUERY_PARK). Once the polls of one event query come in a burst (less than 250 us apart, after 2 of them), GetData parks the caller on the queue's shared event until the value is signalled, at most 1 ms, and then answers. A one-off poll never waits. It only parks once the chunk holding the signal has been committed, and it does the flush GetData would do anyway first. The[gpu-perf]line gains parked polls and time parked per frame.fdbf684bwinemetal: opt-in per-encoder GPU timing (gpu-pass-timing).95db7f41winemetal: shader-miss figures for the performance overlay.694f7686winemetal: archive-only pipeline lookup when the caller asks to fail on a miss.fe0ba66awinemetal: pso-warm yields to the game's compiles; archive saves by age.03d4720dwinemetal: pso-warm counts a warm-up as a hit when the saved chunks had it.Defaults
MADEIRA_D3D11_QUERY_PARK=1), gpu-pass-timing.Left out
Other branches
codex/dxmt-upstream-port(the dxmt thatcodex/dxmt-upstream-build-portpins) conflicts with two hunks: the query header (ID3D11Query1there) and the render-encoder creation (tile size there). The same six commits rebased onto it, with both kept, are onDragooon:duo-all-upstream-port(e3b2223..6f57b0a). Every symbol they use exists on that branch; it was not compiled.codex/dxmt-consolidation,codex/graphics-common,codex/vulkan-dxgi,playport/*) merge with this one cleanly.Testing
🤖 Generated with Claude Code