D3D12.X: a journal of the pipelines a title queues (<data>\cache\pipelines.bin) #758

Open
github-bot wants to merge 5 commits from github-bot/gh-758 into main AGit
Owner

@⁠oishigeso on GitHub · 2026-11-24 04:44 UTC · original
oishigeso:pipelines-2-journal → main · +647 −25 · 3 files · 5 commits · draft

Part 2 of 3 for #755. Stacked on #757; its own commits are the four after #757's head (the journal, its write-error handling, the heap-window flag, the journal off the title's threads).

Every pipeline with console shaders that goes to pso_async (DXIL not cached yet, or made
lazily) is appended to <data>\cache\pipelines.bin. Each entry holds its desc field by field,
with no pointers and no padding, so the same pipeline always hashes the same. It also holds the
input layout and its shaders by hash (each shader written once), together with the run's memory
windows. A pipeline's first build is marked as used. On open, only the frames' headers are read
to skip entries of earlier runs, and a torn last frame is cut off. One title process writes at a
time; a second one gets no journal. replay reads an entry back with everything it points to
owned and no pointer taken from the file. Part 3 (xcl pipelines) compiles from it.
XCL_PSO_JOURNAL=0 turns it off.

It is on by default in this PR: per pipeline the journal costs an fnv64 of its desc and shader bytes, made with
no lock held, and for a new one an append under the journal's lock. The frame headers of earlier
runs (about 63 000 for a 123 MB journal) are read on a thread of its own; what the title notes
meanwhile waits in memory (each frame once, at most 256 MB) and is written once it is open. The
tool in part 3 has nothing to read without it. 605 lines (pso_journal.rs 597), about 150 of them the reader and the tests.

What is in it

  • the format, writer and reader, with a round-trip test that also checks that padding garbage
    gives the same hash (crates/xcl/src/hle/d3d12x/pso_journal.rs)
  • the calls in go_background (crates/xcl/src/hle/d3d12x/real.rs) and the module
    (crates/xcl/src/hle/d3d12x/mod.rs)
  • the heap-window flag of #680 kept in the top bit of a frame's windows byte (windows_byte,
    mem_windows_of), with a test

Tested

  • AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release
  • c02d059 (opened on its own thread, the lock for appends only): cargo test -p xcl --lib -- pso_journal --test-threads=1: 3 passed, 0 failed, with the new what_is_noted_while_the_journal_opens_is_written_after_in_order; the run below opened a journal of 122 806 entries from earlier runs and appended to it
  • Rebased onto main 9e3831e: cargo test -p xcl --lib -- pso_journal --test-threads=1: 2 passed, 0 failed, with the new the_heap_windows_flag_is_kept (0cc1dee: since #680 mem_windows carries HEAP_WINDOWS = 0x100, which the frame's windows byte cut off; the count is now in its low 7 bits and the flag in the top bit). The workspace run below is from before the rebase, on f4ce27c
  • cargo test --workspace -- --test-threads=4: 659 passed, 3 failed, 21 ignored; the 3 failures (title_textures::placed_title_textures_share_vram_and_preserve_pixels, title_textures::transitions_apply_when_their_list_is_submitted, vram::d32s8_targets_take_their_own_size_of_video_memory) fail on main (f4ce27c) the same way in a full run (657 passed, 3 failed there) and pass alone; no GPU test SKIPPED
  • a 60 s run of a retail title wrote 57 807 pipelines and 5 659 shaders
    (pipelines.bin: 123 MB)

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 373 (PresentX 374)
presents per 2 s (last 3): 0 28 60
device removals: 0
crashes: 0
peak commit: 19259 MB

PR (this PR's head commit; the title is run through a folder named RetailTitle):

xcl-smoke v1
commit: c02d05921a5dae84d2607af4c61dc063d09ecdfb
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 384 (PresentX 385)
presents per 2 s (last 3): 0 16 61
device removals: 0
crashes: 0
peak commit: 19308 MB

The first smoke run on this commit crashed at 31.7 s in the title's own code (a write to 0, game_scarlett_master.exe+0x2215c35, during the Series S startup stall upstream still has); the run above, on the same build, is the re-run.

Not tested

  • a second title process at the same time (it gets no journal by design; not run)
  • NVIDIA, Intel, RDNA4

AI use

  • Claude Code (Claude Opus 5.5) wrote the code, the tests and this description, and ran the tests and runs above on my PC at my direction. An independent Claude Opus 5.5 review of the diff found 2 bugs and 6 risks; all were fixed before this was opened.
**@⁠oishigeso** on GitHub · 2026-11-24 04:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/758) `oishigeso:pipelines-2-journal` → `main` · +647 −25 · 3 files · 5 commits · draft Part 2 of 3 for #755. Stacked on #757; its own commits are the four after #757's head (the journal, its write-error handling, the heap-window flag, the journal off the title's threads). Every pipeline with console shaders that goes to `pso_async` (DXIL not cached yet, or made lazily) is appended to `<data>\cache\pipelines.bin`. Each entry holds its desc field by field, with no pointers and no padding, so the same pipeline always hashes the same. It also holds the input layout and its shaders by hash (each shader written once), together with the run's memory windows. A pipeline's first build is marked as used. On open, only the frames' headers are read to skip entries of earlier runs, and a torn last frame is cut off. One title process writes at a time; a second one gets no journal. `replay` reads an entry back with everything it points to owned and no pointer taken from the file. Part 3 (`xcl pipelines`) compiles from it. `XCL_PSO_JOURNAL=0` turns it off. It is on by default in this PR: per pipeline the journal costs an fnv64 of its desc and shader bytes, made with no lock held, and for a new one an append under the journal's lock. The frame headers of earlier runs (about 63 000 for a 123 MB journal) are read on a thread of its own; what the title notes meanwhile waits in memory (each frame once, at most 256 MB) and is written once it is open. The tool in part 3 has nothing to read without it. 605 lines (`pso_journal.rs` 597), about 150 of them the reader and the tests. **What is in it** - the format, writer and reader, with a round-trip test that also checks that padding garbage gives the same hash (`crates/xcl/src/hle/d3d12x/pso_journal.rs`) - the calls in `go_background` (`crates/xcl/src/hle/d3d12x/real.rs`) and the module (`crates/xcl/src/hle/d3d12x/mod.rs`) - the heap-window flag of #680 kept in the top bit of a frame's windows byte (`windows_byte`, `mem_windows_of`), with a test **Tested** - AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release - c02d059 (opened on its own thread, the lock for appends only): `cargo test -p xcl --lib -- pso_journal --test-threads=1`: 3 passed, 0 failed, with the new `what_is_noted_while_the_journal_opens_is_written_after_in_order`; the run below opened a journal of 122 806 entries from earlier runs and appended to it - Rebased onto `main` 9e3831e: `cargo test -p xcl --lib -- pso_journal --test-threads=1`: 2 passed, 0 failed, with the new `the_heap_windows_flag_is_kept` (0cc1dee: since #680 `mem_windows` carries `HEAP_WINDOWS` = 0x100, which the frame's windows byte cut off; the count is now in its low 7 bits and the flag in the top bit). The workspace run below is from before the rebase, on f4ce27c - `cargo test --workspace -- --test-threads=4`: 659 passed, 3 failed, 21 ignored; the 3 failures (`title_textures::placed_title_textures_share_vram_and_preserve_pixels`, `title_textures::transitions_apply_when_their_list_is_submitted`, `vram::d32s8_targets_take_their_own_size_of_video_memory`) fail on `main` (f4ce27c) the same way in a full run (657 passed, 3 failed there) and pass alone; no GPU test SKIPPED - a 60 s run of a retail title wrote 57 807 pipelines and 5 659 shaders (`pipelines.bin`: 123 MB) **Regression run** main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 373 (PresentX 374) presents per 2 s (last 3): 0 28 60 device removals: 0 crashes: 0 peak commit: 19259 MB ``` PR (this PR's head commit; the title is run through a folder named RetailTitle): ``` xcl-smoke v1 commit: c02d05921a5dae84d2607af4c61dc063d09ecdfb gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 384 (PresentX 385) presents per 2 s (last 3): 0 16 61 device removals: 0 crashes: 0 peak commit: 19308 MB ``` The first smoke run on this commit crashed at 31.7 s in the title's own code (a write to 0, `game_scarlett_master.exe+0x2215c35`, during the Series S startup stall upstream still has); the run above, on the same build, is the re-run. **Not tested** - a second title process at the same time (it gets no journal by design; not run) - NVIDIA, Intel, RDNA4 **AI use** - Claude Code (Claude Opus 5.5) wrote the code, the tests and this description, and ran the tests and runs above on my PC at my direction. An independent Claude Opus 5.5 review of the diff found 2 bugs and 6 risks; all were fixed before this was opened.
prep_graphics: what translated_graphics_pso did between its checks and the driver call (the
translated shaders, XCL's ABI root signature with their static samplers, the rect list GS, PC
formats and topology), returned with the DXIL it points at. No change in behaviour; a later
change makes the same desc outside the title (xcl pipelines).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every pipeline with console shaders that goes to pso_async (its DXIL not in the cache yet, or
made lazily: a retail title queues ~58 000 in its first minute) is appended to a journal: its
desc field by field (no pointers, no padding: the same pipeline always hashes the same), its
input layout and its shaders by hash, each shader once, with the run's memory windows. A
pipeline's first build is marked as used. Entries of earlier runs are not written again (found
from the frames' headers, the shaders stay on disk); a torn last frame is cut off. One title
process writes it at a time (others get none). The reader (replay) gives the desc back with
everything it points to owned and no pointer from the file. Another process can compile the
title's pipelines from it; XCL_PSO_JOURNAL=0 turns it off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A frame is now noted as written only once all of it is on disk; a failed
write (a full disk) is cut back to where it started, so later frames
stay readable, and the journal is off for the rest of the run. An input
layout count read from the file is checked against the bytes there
before anything is allocated for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since #680 `pso::mem_windows` carries HEAP_WINDOWS (0x100) when the title's
shaders take the memory windows from the descriptor heap (XCL_HEAP_WINDOWS=1).
The frame's windows byte cut it off, so a heap-window run's pipelines read
as the switch form's. The count stays in the low 7 bits and the flag goes
in the top bit (`windows_byte`, `mem_windows_of`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013hQzywPUY9kSTPQPh31CWh
The first pipeline the title noted read the frame headers of every earlier
run (about 63 000 for a 123 MB journal) with the journal's lock held, and
each later one hashed its shaders and desc under the same lock, so the
title's pipeline threads waited on one another. An entry is now built and
hashed with no lock held, and the lock covers its append only. The journal
is opened on a thread of its own; what is noted meanwhile waits in memory,
each frame once (up to 256 MB, past which the journal is off for the run),
and is written in order once it is open. `XCL_PSO_JOURNAL` is read once,
and a journal turned off stops entries being built at all. A panic on
another thread while it held the lock no longer ends the journal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013hQzywPUY9kSTPQPh31CWh
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:30 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 07:06 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head b617c88 (on its base f4ce27c).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 702 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: graphics_round_trip.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 07:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/758#issuecomment-7124615286) Full-suite run, since this PR has no test report yet. Tested exact head `b617c88` (on its base `f4ce27c`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **702 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `graphics_round_trip`. **Not tested** - AMD, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 11:16 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 11:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/758#issuecomment-7160825082) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/758/head:github-bot/gh-758'
git switch 'github-bot/gh-758'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-758'
git switch 'github-bot/gh-758'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-758'
git switch 'github-bot/gh-758'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-758'
git switch 'main'
git merge --squash 'github-bot/gh-758'
git switch 'main'
git merge --ff-only 'github-bot/gh-758'
git switch 'main'
git merge 'github-bot/gh-758'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.