Skip to content

DXC memory gate: reserve only the running compiles' growth, no stampede after a minute - #139

Closed
hexgeon1 wants to merge 3 commits into
xcl-dev:mainfrom
hexgeon1:dxc-memory-gate
Closed

hexgeon1 wants to merge 3 commits into
xcl-dev:mainfrom
hexgeon1:dxc-memory-gate

Conversation

@hexgeon1

Copy link
Copy Markdown
Contributor

The memory gate from #113 throttles DXC hard on a normal desktop. With 8.1 GB of commit free, Minecraft Preview's 716 programs took 12.7–15.2 s on the default 15 threads; with this change, 6.35–6.71 s. The DXIL is identical.

What was wrong

wait_for_memory let a compile start while the system had 6 GB of commit left plus 1 GB for every compile already running.

  • Counted twice: the available commit already excludes what the running compiles use, so the 1 GB each was on top of their own use. With a browser and chat open this machine has ~8 GB of commit free, so about three compiles ran and the other workers polled every 50 ms.
  • Stampede after a minute: after a minute's wait, a compile went in regardless of commit. Every waiting worker did so at once, which happens exactly when commit is shortest – the case the gate exists for.
  • One reading, many starts: workers read the commit and incremented the running count in two steps, so several could start on the same reading.

Changes (crates/xcl/src/gpu/recomp/dxc.rs)

  • may_start: a compile goes in at once while commit covers 6 GB plus 300 MB per running compile. The 300 MB covers their growth still to come; Faster shader compiles: one window switch per four dwords, every core, --precompile builds the cache titles use #113 measured a typical retail compile's peak at 0.1–0.3 GB. With less, compiles go one at a time.
  • Escape: a compile that has waited a minute still goes in when commit is short, but only one per minute.
  • Count: the running count only rises from the value the decision saw (compare and swap).
  • Waking: waiters wake when a compile ends (condition variable), not on a 50 ms poll.
  • HANDOFF.md: the two places that describe the gate are updated.

The second commit adds dxc_bench_folder, an ignored test that times DXC for a folder of console shaders and prints HLSL and DXIL digests. It's how the numbers below were measured; drop it if you'd rather not have it.

Numbers

Ryzen 7 5700X (8 cores / 16 threads), RTX 3090, DXC 1.9.2602, Minecraft Preview's 716 programs, 4 memory windows, default 15 threads. Free commit was 8.1 GB before every run. Both builds use the same benchmark, run interleaved, 3 runs each:

wall time
main (484dd57) 12.88 s, 12.67 s, 15.23 s
this PR 6.71 s, 6.71 s, 6.35 s
no gate at all (reference only) 5.55 s, 5.33 s
  • DXIL: the digest of all 716 programs is the same on main and with this PR.
  • More commit free: with lots of free commit the old and new gates both let everything through. The difference shows when free commit is ~6–12 GB, which is common with other apps open or a game running.

Checked

Not covered

  • Driver pipeline compiles: the driver's PSO compiles on the xcl-pso workers are still not memory-gated.
  • Runaway compiles: a compile whose memory runs away (the 38 GB case) can't be stopped in-process. That would need DXC in a separate process with a memory limit per compile.

🤖 Generated with Claude Code

ivall added a commit that referenced this pull request Nov 23, 2026
… rect lists

A home in a sparse window is only reserved until its page is used there and gives its
memory back while the page is mapped elsewhere: the retail game's 5.7 GB of pages were
committed twice, with video-memory tiles (28.7 GB of commit, now 16-17 GB). chad.dll
(XDsp) connects and takes commands; the newer list layout's #139 is Reset; console rect
lists are drawn as triangles; a stream without a topology type is TRIANGLE.
XCL_TRACE_MEM=n logs the first n allocations.
@tronLives111

Copy link
Copy Markdown

The concurrency test can fail even when the gate admits every worker correctly. It computes allowed from one GlobalMemoryStatusEx snapshot, while wait_for_memory checks available commit again for each admission.

I checked a short schedule against the thresholds in 5d84b26: the test initially sees 6,144 MiB, so it asserts peak <= 2 (allowed + 1). The first worker enters at 6,144 MiB. If another process then releases 600 MiB, the second and third workers can both enter at 6,744 MiB while the first is still running. Their thresholds are 6,444 and 6,744 MiB, so all three admissions are valid, but the test rejects peak == 3. The initial probe also ignores the Windows API return, so a failed probe can supply a zero baseline while later probes succeed.

Could the admission loop take a test-only memory sampler so all workers in this test see a fixed budget? That would let the test assert the exact cap and leave a live-memory run as a smoke check. I verified the admission arithmetic with a deterministic schedule on macOS. I did not run the Windows concurrency test. AI-assisted review.

hexgeon1 and others added 2 commits November 23, 2026 19:33
…de after a minute

`wait_for_memory` (xcl-dev#113) let a compile start with 6 GB of commit left plus
1 GB per compile already running. The available commit already excludes what
the running compiles use, so that counted them twice: on a desktop with
8.1 GB of commit free (a browser and chat open) about three compiles ran and
the other workers polled.

- `may_start`: in at once while commit covers 6 GB + 300 MB per running
  compile (their growth still to come; a typical retail compile peaks at
  0.1-0.3 GB per xcl-dev#113's measurements); with less, one at a time.
- After a minute's wait a compile still goes in when commit is short, but one
  per minute; before, every waiting worker went in at once - when commit was
  shortest.
- The running count only rises from the value the decision saw (compare and
  swap), so workers deciding on the same reading cannot all go in.
- Waiters wake when a compile ends (condition variable) instead of polling
  every 50 ms.

Minecraft Preview's 716 programs, 4 memory windows, 15 threads (default),
Ryzen 7 5700X, 8.1 GB of commit free, main and this interleaved, 3 runs each:
12.7-15.2 s -> 6.35-6.71 s wall (5.3-5.6 s with no gate at all); DXIL
digest identical. Tests: `gate_tests` (the rule, short commit / one escape
per interval, 32 threads never exceeding what the commit allows);
`cargo test --workspace --release` green on an RTX 3090 with the Agility SDK
(0 GPU skips). Driver PSO compiles are still not gated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ignored test for measuring compile changes: every program of a folder of
console containers (`XCL_BENCH_DIR`) translated as a title does
(`XCL_BENCH_WINDOWS`, `XCL_BENCH_SPLIT`) or saved HLSL (`XCL_BENCH_HLSL=1`),
compiled on `XCL_BENCH_THREADS` threads with `XCL_DXC_ARGS`. Prints translate
time, HLSL and DXIL digests (an HLSL change that keeps the DXIL shows the same
DXIL digest), DXC wall / per-program times, cost per KB and peak commit;
`XCL_BENCH_TIMES=<file>` writes each program's time, `XCL_BENCH_SLICE=k/n`
splits a folder across processes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed commit

The test computed its limit from one `GlobalMemoryStatusEx` reading while the
gate reads the commit again at every decision: memory another process freed
mid-test let the gate rightly admit more than the test allowed (review on
xcl-dev#139). It also ignored a failed reading, and other tests' compiles share the
real gate's count.

The gate is now a `Gate` (running count, lock with the last escape, wake-up)
and `admit(gate, commit)` takes the commit reading; `wait_for_memory` is
`admit(&GATE, available_commit)`. The test gives a gate of its own a fixed
commit with room for exactly three and asserts that three run at once
(the first ones in wait until the cap is full) and never four. A gate that
lets one more in fails it (peak 4); 30 runs of `gate_tests` in a row pass.
A second test sends 32 workers through the real gate and checks they all
finish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hexgeon1

hexgeon1 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks – you're right, the test could fail on a correct gate: its limit came from one reading while the gate re-reads commit per decision, and other tests' compiles share the real gate's count too. Fixed in 03e2efe: the gate is now a Gate value and admit(gate, commit) takes the commit reading, so the test runs on its own gate with a fixed budget (room for 3) and asserts the exact cap – 3 reached, 4 never (a gate letting one more in fails it). A separate test checks 32 workers get through the real gate. 30/30 runs pass; full suite green with the GPU on an RTX 3090. Would be glad to get feedback.

@gefydev

gefydev commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Measured on a machine with little commit: Ryzen 5 1600 (6C/12T), 16 GB RAM, 20.7 GB commit limit, GTX 1650, Windows 11 26300, DXC from SDK 10.0.26100, 11 DXC threads, debug build.

Synthetic bench, no game data: 200 different compute shaders through pso_async + DXC, no cache, no driver PSO. 3 runs each, interleaved, commit free before every run:

commit free all 200
main db5dc26 (this PR's base) 13.4 / 13.5 / 13.4 GB 7.42 / 7.38 / 7.41 s
this PR, 03e2efe 13.4 / 13.5 / 13.4 GB 6.37 / 6.37 / 6.35 s

So about 14 % less here. These shaders are small and alike, so this says little about memory growth of big programs. The 4 gate_tests pass, including the reworked concurrency one. I did not run the rest of the suite on this PR.

main is at 956a476 now and conflicts in dxc.rs: it added RESERVE_GB / set_memory_reserve (6 GB with a title, 2 GB for --precompile) on the line this PR changes. The 1 GB per running compile is still there, so the PR's point still stands by reading; I have not measured it on top of 956a476.

@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

AI-assisted review (Claude Code). Windows 11 (10.0.26200), Ryzen 9 9950X (32 threads), Rust 1.99.0 MSVC, debug build, Windows SDK DXC 1.7.2308. Synthetic programs only, no game files, no GPU.

Tested 03e2efe on its base db5dc26. It does not merge onto main (956a476, and still not onto current eaa36b6). dxc.rs conflicts, because main made the 6 GB floor RESERVE_GB / set_memory_reserve (2 GB for --precompile), as gefydev noted. A rebase should use RESERVE_GB for COMMIT_FLOOR. I did not test a rebased version.

The PR's gate_tests pass on the head (4/4).

Method: real concurrent DXC compiles through the gate, against a fixed commit budget.

  • A job commit cap (14 GiB) bounds the run. It can't drive the gate, though: GlobalMemoryStatusEx ignores a job's memory limit. Under a 9 GiB cap it still reported about 30 GB available.
  • System commit on this shared machine also swung between 18 and 26 GB from run to run.
  • So each worker goes through the PR's admit(gate, commit), on a gate of its own, exactly as a pool worker does, and then runs compile_here on a real translated program (xcl-pso's NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156 bench generator: wave32, 4 windows, 15 workers). The commit it sees is a budget minus the process's real private-commit growth since the start. That is the model in the PR: what the running compiles already use is out of available commit.
  • The "before" side is db5dc26's wait_for_memory loop, copied verbatim with the same commit source.
  • A sampler reads that commit every 5 ms.

One compile alone grows private commit by 160 MB for a 2000-round program (987 KB of HLSL) and by 460 MB for 4000 rounds (1.9 MB). A probe of 8000 rounds (3.8 MB, 65 s) grew 1.5 GB.

scenario gate compiles wall peak running min commit seen time below the 6 GB floor failed
S1: 8.5 GB budget, 2000 rounds base 45 49.3 s 6 7,881 MB 0 0
this PR 45 24.0 s 9 7,234 MB 0 0
S2: 8.5 GB budget, 4000 rounds base 30 125.7 s 15 2,887 MB 41.0 s 0
this PR 30 100.5 s 9 4,536 MB 38.8 s 0
S3: 6.05 GB budget (short), 2000 rounds base 40 89.5 s 15 3,913 MB 79.5 s 0
this PR 40 126.7 s 2 5,872 MB 113.2 s* 0

* In S3 the budget is below floor + one compile, so any running compile puts the commit under 6 GB. That is the "one at a time" case working as intended.

What this shows:

  • The stampede is real, and the PR removes it. In S2 and S3 the base gate lets every waiting worker in at the same instant at t = 60.0 s: 12 in S2 (3 running → 15), and 14 admissions after a minute's wait in S3. With the PR, S3 escapes exactly once per minute (t = 60.0 s and 120.1 s), and the peak is 2.
  • The race is real, and the PR removes it. In S1 the base rule allows 3 at most (8.5 GB ≥ 6 + 1 × running), yet 6 ran at once. At t = 41.2 s, jobs went in with 4 and 5 running before them, all from one reading of the count. The PR never exceeded its rule.
  • Throughput: S1 is 2× faster, consistent with the PR's Minecraft numbers.

Accounting finding: 300 MB per running compile is too little for bigger programs, and compiles that start together aren't counted at all.

  • In S2, all 9 compiles went in at t = 0. The budget was full then (8.7 GB ≥ 6 GB + 0.3 GB × 8), because none of them had grown yet. Each then grew to about 460 MB. Commit fell to 4.5 GB, 1.5 GB under the floor, and stayed below it for 39 s.
  • The rule reserves 300 MB of growth per running compile, so it holds only while each compile's whole growth is at most 300 MB. S1's 160 MB compiles stay above the floor; S2's 460 MB ones don't.
  • By extrapolation, for 1.5 GB compiles (the 8000-round probe) the same 9 would end about 10 GB under the floor. That is not measured.
  • Faster shader compiles: one window switch per four dwords, every core, --precompile builds the cache titles use #113's typical retail peak of 0.1–0.3 GB fits under 300 MB. Big compute and mesh programs (HANDOFF: "each can still grow to ~0.7 GB") don't.

A cheap improvement: scale the reservation with the source, e.g. reserve per compile by HLSL size, since growth here went roughly with size: 160 MB at 1 MB, 460 MB at 1.9 MB, 1.5 GB at 3.8 MB. Or keep the per-compile reservation until the compile ends instead of only counting it. Even in S2 the PR stays better than the base, whose stampede reached 2.9 GB.

Not tested:

  • the rebase onto main;
  • the real wait_for_memory path with system commit (deliberately not driven on a shared machine);
  • the full suite;
  • a retail pack;
  • runaway compiles (as the PR says, out of reach in-process).

@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Linux / Wine / GNU run of 03e2efe on its own base db5dc26. It doesn't merge onto current main eaa36b6: gpu/recomp/dxc.rs conflicts, because main added RESERVE_GB / set_memory_reserve and a WORKING count where this PR introduces Gate. A rebase onto eaa36b6 is needed (as asked on #198), and the gate has to account for main's set_memory_reserve (xcl shaders --precompile with less reserve).

Setup: Ubuntu 24.04, cross-built for x86_64-pc-windows-gnu (release), under Wine 11.21 Staging. Under Wine, GlobalMemoryStatusEx's available commit is computed from Linux RAM and swap, so the_real_gate_lets_every_worker_through runs on a different commit source than on Windows.

recomp::dxc filter:

passed failed
base db5dc26 10 0
PR 03e2efe 14 0

All four new gate_tests pass: compiles_start_while_commit_covers_the_floor_and_the_running_ones_growth, short_commit_lets_one_compile_at_a_time_and_one_escape_per_interval, concurrent_admissions_reach_and_never_exceed_what_the_commit_allows and the_real_gate_lets_every_worker_through.

Not covered: the rebased PR; a run with little commit (this machine isn't short of it); dxc_bench_folder timing; no control with the old gate under the new tests (the tests need the Gate API).

AI-assisted test report (Claude); tests run locally as stated.

cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shelbykb2 added a commit to shelbykb2/xcl that referenced this pull request Nov 24, 2026
…eset

On the newer console command-list layout (real::QUEUE_SHIFTED), titles reset pooled lists through slot ivall#139 Reset(allocator, initial_pso, flags), which real.rs routes to list_x::reset_x.

title_list's wrapper vtable only overrode slots 0, 1, 2, 9, and 10, leaving slot ivall#139 as a raw forwarder to F_BACKING. Once a mid-list Wait64 split switched F_BACKING to a continuation segment, ivall#139 reset only that continuation segment and never ran title_list::reset: F_PRIMARY stayed bound to the previous recording/allocator, F_BACKING was never restored to F_PRIMARY, and extra_active kept accumulating split segments across frames.

On pre-ivall#897 main that caused D3D12 device removal (0x887a0001 / debug-layer id 541) as soon as the old allocator was reused; even with ivall#897/ivall#907 allocator pooling, stale primary/prior segments continue to be resubmitted and extra_active grows until MAX_EXTRA_SEGMENTS.

The wrapper's ivall#139 is now a guard::make_layout_split of its own: a title on the newer layout goes to a four-argument adapter that runs wrapper reset, while a title on the older layout and the runtime take the generated forwarder. The forwarder's tail jump keeps the caller's return address and arguments, which the backing list's own layout guard at ivall#139 needs to tell a title from the runtime; calling the backing slot from Rust would hide it and send an older-layout title to the PC method.

Tests: one covers the forwarder and the newer-layout reset on fake lists; one calls the slot from a caller in a registered mapped image, with the backing slot behind a layout guard as real.rs installs it and a test-local layout flag (flag clear: the older handler with the title's arguments; flag set: the primary is reset and the split segment reclaimed).

Co-Authored-By: Antigravity <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raylitebull

Copy link
Copy Markdown
Member

Closing as a stale, conflicting pre-template PR (touching HANDOFF.md and missing required CONTRIBUTING.md sections). Feel free to open a fresh rebased PR if this is still needed.

cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
A list split at a recorded memory wait records on in a second PC list; the
console object's Reset (xcl-dev#10) resets the first one and makes the others
spares. The newer layout's Reset (xcl-dev#139, how a retail title resets the lists
of its pool) was forwarded to the active PC list like any other slot: it
reset the last segment only, the recording went on there, and the object
kept its segments. Every later ExecuteCommandLists of that list ran the
first PC list again, with the first part of the recording it had been
split in: its draws and dispatches on memory the title used for other
things since, and its Write64 values after newer ones.

xcl-dev#139 is now the object's Reset when the title's runtime has the newer
layouts (looked at in each call, as the list's other moved slots are).

What run 13 shows of it: an ExecuteCommandLists of 10 lists with two lists
without one mark since they last ran (not even Close), each followed by a
list made later; the GPU stood 30 s between the lists before the first of
them. And one cell's Write64 of 0x50f submitted on q4 after 0x510, then
on q3 after 0x511.

Test: hle::d3d12x::title_list::tests::the_newer_layouts_reset_resets_the_primary_list_and_ends_the_split
Assisted-by: omp (anthropic/claude-mythos-5-2)
theaustinayers pushed a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
…:reset

On the newer console command-list layout (real::QUEUE_SHIFTED), titles reset pooled lists through slot xcl-dev#139 Reset(allocator, initial_pso, flags), which real.rs routes to list_x::reset_x.

title_list's wrapper vtable only overrode slots 0, 1, 2, 9, and 10, leaving slot xcl-dev#139 as a raw forwarder to F_BACKING. Once a mid-list Wait64 split switched F_BACKING to a continuation segment, xcl-dev#139 reset only that continuation segment and never ran title_list::reset: F_PRIMARY stayed bound to the previous recording/allocator, F_BACKING was never restored to F_PRIMARY, and extra_active kept accumulating split segments across frames.

On pre-xcl-dev#897 main that caused D3D12 device removal (0x887a0001 / debug-layer id 541) as soon as the old allocator was reused; even with xcl-dev#897/xcl-dev#907 allocator pooling, stale primary/prior segments continue to be resubmitted and extra_active grows until MAX_EXTRA_SEGMENTS.

The wrapper's xcl-dev#139 is now a guard::make_layout_split of its own: a title on the newer layout goes to a four-argument adapter that runs wrapper reset, while a title on the older layout and the runtime take the generated forwarder. The forwarder's tail jump keeps the caller's return address and arguments, which the backing list's own layout guard at xcl-dev#139 needs to tell a title from the runtime; calling the backing slot from Rust would hide it and send an older-layout title to the PC method.

Tests: one covers the forwarder and the newer-layout reset on fake lists; one calls the slot from a caller in a registered mapped image, with the backing slot behind a layout guard as real.rs installs it and a test-local layout flag (flag clear: the older handler with the title's arguments; flag set: the primary is reset and the split segment reclaimed).

Co-Authored-By: Antigravity <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b3a969b)
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.

5 participants