Skip to content

ci: build and test the d3d12 Rust runtime on Windows (CI-D3D12-CARGO-TEST) - #2648

Merged
aslan2142 merged 25 commits into
ProjectLeonida:mainfrom
MoonEyes:ci/d3d12-cargo-test
Dec 1, 2026
Merged

aslan2142 merged 25 commits into
ProjectLeonida:mainfrom
MoonEyes:ci/d3d12-cargo-test

Conversation

@MoonEyes

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: CI-D3D12-CARGO-TEST (#2570)

What and why

No workflow runs the tests of the D3D12 runtime (d3d12/, Rust: leonida.exe and its crates). launcher.yml, xma2-decoder.yml and the bcpack tool in ci.yml are the only cargo jobs, so a change that breaks a d3d12/ test reaches main unseen. Many open pull requests touch d3d12/ right now.

This adds .github/workflows/d3d12.yml, modelled on launcher.yml: on pushes to main and pull requests that touch d3d12/** (and on demand), one windows-latest job:

  • Build: cargo build --workspace --all-targets --locked, toolchain from d3d12/rust-toolchain.toml (1.98.1) through the runner's own rustup.
  • Tests (the gate): cargo test --workspace --exclude xtask --locked, no GPU, no game data.
  • Asset policy (report only): cargo test -p xtask, which fails on main today because two sources are over its 640 KiB limit (crates/leonida-gpu/src/host.rs 672,926 bytes, crates/leonida-shader/src/emit/lower.rs 709,418 bytes).
  • Clippy (report only): cargo clippy --workspace --all-targets -- -D warnings, which fails on main with about 25 findings in leonida-loader, leonida-lua, leonida-menu, leonida-shader and leonida-formats.
  • cargo fmt --check is left out: it would reformat about 190 files, colliding with the open d3d12/ pull requests.

The two report steps use continue-on-error so the job is useful from day one; each has a comment saying when to make it blocking. Windows only, because leonida-gpu does not build on macOS today (reported by oreofr's agent); Linux can follow #2577.

Tested

Locally on main 060c47160, Windows 11, toolchain from d3d12/rust-toolchain.toml, CPU only:

  • cargo test --workspace --no-run --locked: builds in 233 s.
  • cargo test --workspace --locked: 661 s; 1441 passed, 58 ignored, 1 failed (xtask policy::tests::repository_passes_policy, the two oversized files above). Excluding xtask, nothing fails.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: fails on main (findings listed above).
  • The workflow itself runs for the first time on this pull request; jactionlint checks its syntax.

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

Zilumz1 and others added 11 commits November 24, 2026 01:14
…-994)

Without VkPhysicalDeviceSamplerFilterMinmaxProperties::
filterMinmaxImageComponentMapping, a minimum/maximum reduction defines
only the R component of a sample; G, B and A are undefined. The AMD
Windows driver on Polaris (RX 580) reports singleComponentFormats = 1
and imageComponentMapping = 0, and returns exactly that: R is correct,
G/B/A vary.

The layer now records the property in VulkanDeviceInfo and logs once
when it creates a reduction sampler on a device without it. The
descriptor test compares R only on such devices, and all four channels
where the device maps every component.
…es (RT-PIPELINE-CACHE-GROWTH-STALL)

A driver can stop adding to a large VkPipelineCache with no error. On NVIDIA 610.88 a 1.23 GB or 1.35 GB cache
came back the same size to the byte after a 2 s compile, so the next run compiles the same pipelines again and
nothing says why. The runtime now takes the cache's size at creation and at each session save, counts the title's
pipeline builds that took at least 200 ms, and logs once when 16 or more compiled while the cache grew less than
64 KiB. pipeline_cache_store_test covers the decision; docs/d3d12_vulkan.md records the measurements.
…t without the Vulkan device (RT-VULKAN-REQUESTED-NOT-BUILT)

A gta6rt configured without Vulkan headers is built without
LEONIDA_VULKAN_DEVICE. D3D12XboxCreateDevice then ignored
LEONIDA_D3D12=vulkan without a word and wrapped the host's D3D12 device,
so a run stopped somewhere else and read like a boot result.

It now prints one [rt] d3d12_xs line naming the cause and the configure
options. Which device is created does not change. The reading of the
variable moves to shims/d3d12_backend.h, used by both builds; new CPU-only
test d3d12_backend, registered outside the Vulkan-headers block.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CMakeLists: d3d12_backend_test (PR) and the Vulkan headers version check (main) both kept.

Co-authored-by: quartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d3d12_vulkan_device: report_pipeline_cache_growth() before main's over_save_limit check, note_pipeline_cache_size() before main's journal setup. Docs: main's paragraph, then the PR's growth-stall text without its old 256 MiB cap line.

Co-authored-by: Galaxy <23423870+thegalaxydev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on the panel (D3D12-FRAME-TIME-STATS)

The frame-rate line gives a mean over the last second or more, and the F3
panel only the longest frame, so a run with smooth frames and a few
multi-second stalls looks like a slow one, and the stalls do not show.

host/frametime.rs keeps every presented frame's time. With the frame-rate
line, every five seconds, it logs one line: the median, 95th and 99th
percentiles (nearest rank), the longest frame, how many took over 100 ms
and over a second, and beside them host pipelines queued and made a second,
waits for new memory to be resident per frame, and the commit the system has
left. The panel shows the last line's numbers and the pipeline wait per
frame. Pure parts are unit-tested.
…from the first present (review)

- Panel: frame times of 10 s or more (the launcher's pipeline budget) made
  the percentile line longer than 40 columns, and the panel cut it without
  a sign ("MAX 10000" showed as "MAX 100"). Times from 10 s up are shown in
  whole seconds ("10S"); the test covers 10 s, 100 s and 10 min.
- The first line's pipelines made a second and residency waits counted
  everything since the process started: the meter now starts from the
  totals at the first present.
- "queued" was queued or being made: the log says so, the panel says
  PIPES PENDING.
- The nearest-rank test covers 95% of 100 frames, where a float ceil would
  take the 96th.
…er (D3D12-PIPELINE-WAIT-QUEUE)

A draw whose host pipeline is not made queues it at the back of the
requested list, and its frame then waits for it up to the frame's budget.
On the first visit to the world about 1,700 pipelines were queued at once,
562 of them took over a second each, and with the launcher's 10 s budget
every frame waited the whole budget for a pipeline a thousand others stood
before, then dropped its draws anyway: 0.35 fps for three and a half
minutes (RTX 3080, 8 workers).

A new queue state, AWAITED, sits between REQUESTED and MAKING. When a frame
starts waiting for a pipeline that is still in the queue, the entry moves
to the front of its list (passes over the screen in theirs), after those
awaited before it, so the next free worker makes it. It moves at most once,
is never claimed twice, and WAITING does not count it again; makes already
running are not interrupted. LEONIDA_PIPELINE_AWAIT_FIRST=0 keeps the order
asked.

Frames on a cold cache still wait up to the frame's budget: the waits now
succeed, so a frame may spend its budget on several pipelines it then draws
instead of one it drops. The budget setting bounds that, as before.
runtime/test/vk_test_device.h: the PR's filterMinmaxImageComponentMapping
query and main's shaderOutputViewportIndex feature were added at the same
place; both are kept.

Co-authored-by: Zilumz1 <221744236+Zilumz1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TEST)

No workflow ran the d3d12/ workspace tests. This adds one on windows-latest for changes under d3d12/: build, then cargo test as the gate (no GPU, no game data). The xtask asset-policy test and clippy -D warnings both fail on main today (two sources over the 640 KiB limit; about 25 clippy findings), so they run as reports until fixed. cargo fmt is left out: it would reformat most of the tree under the open d3d12 pull requests.

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

Copy link
Copy Markdown
Contributor

Independent retest of the first hosted failure on f8ee1755d (GitHub merge 6a7778069 onto 060c47160). The merge changes only .github/workflows/d3d12.yml.

  • MEASURED, hosted Windows. The build passed. depth_bounds_pipeline_loads_and_filters_draws reached the draw assertion at pipeline/host.rs:1793 and read red 255 for depth 0.5 with bounds [0.6, 1.0]. The leonida-gpu test binary reported 548 passed, 1 failed and 47 ignored. Hosted job
  • MEASURED, local control. I cross-built the exact fixture and ran it with Wine 11.22, VKD3D-Proton 71cae091, and DXC 1.8.2505.32. It stopped at the earlier pipeline-library reload assertion in 3/3 runs each on RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1). With just the library assertion made diagnostic, the original draw path read 0 outside and 255 inside in 3/3 runs per GPU. Enabling ordinary depth with ALWAYS and zero writes, or reapplying bounds after binding the PSO, gave the same pixels in 3/3 runs per variant and GPU. With Vulkan disabled, the test returned before drawing.
  • READ IN CODE. The hosted command leaves adapter choice at D3D12CreateDevice(None, ...) (host.rs:1268). The failure confirms this run reached a D3D12 device with the advertised depth-bounds capability and DXC available. The selected adapter is still unknown. For a targeted Windows rerun, the adapter description and flags plus both red bytes would help distinguish this result from the local library failure.

Synthetic fixtures only. AI-assisted with OpenAI Codex.

@fiestorra

Copy link
Copy Markdown
Contributor

Checked what can be checked without cargo on this machine (no Rust toolchain here), and one thing that would have broken every run is fine:

git ls-remote https://github.com/actions/checkout | grep 3d3c42e5…
3d3c42e5aac5ba805825da76410c181273ba90b1  refs/tags/v7
3d3c42e5aac5ba805825da76410c181273ba90b1  refs/tags/v7.0.1

So the pinned SHA is v7.0.1 - the pin is real and not a copy-paste of some other commit, which is the failure mode that would make the whole workflow red for a reason nobody looks at twice.

Structure, read: on: has push (main, paths: d3d12/**), pull_request (paths: d3d12/**), workflow_dispatch; permissions: contents: read; a concurrency group that cancels only for pull_request (github.event_name == 'pull_request'), which is the same shape ci.yml uses and keeps a queued push from replacing a run; one job, windows-latest, timeout-minutes: 45, working-directory: d3d12, shell: bash; checkout with persist-credentials: false.

The gating is the part I would have argued for: cargo test --workspace --exclude xtask blocks, while the asset-policy test and cargo clippy -D warnings run with continue-on-error: true and are called out in a comment as reports until host.rs and lower.rs are split and the existing findings are fixed. That matches this tree's state (the 640 KiB policy test fails on main today), and it is better than either blocking on a known failure or not running the check at all.

Not verified: the measurements in the header (1441 pass, 58 ignored, ~4 min build, ~11 min tests) and the toolchain resolution - I have no cargo on this Windows machine, so none of it ran here. The YAML structure is read, not executed.

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

I reproduced the pixel failure on a native windows-latest runner in my fork. The probe is based on main 452d1d1b6 plus logging and two independently selectable changes to the test fixture. No game data or GPU setup was needed. Runner log · Probe commit

MEASURED. Windows Server 2025 build 26100, Rust 1.98.1, DXC 1.9.2602.17. All 12 subprocesses reported depth-bounds support and successfully reloaded the pipeline library. Red bytes are outside/inside the bound.

Fixture variant Adapter Red bytes Runs
Original draw sequence Microsoft Basic Render Driver, flags 0x0 255 / 255 3/3 failed
Reapply OMSetDepthBounds after setting the PSO Same default adapter 255 / 255 3/3 failed
DepthEnable=true, ALWAYS, write mask ZERO Same default adapter 0 / 255 3/3 passed
Original draw sequence, explicitly selecting WARP Microsoft Basic Render Driver, software flag 0x2 255 / 255 3/3 failed

For this CI fixture, setting DepthEnable: true.into() while retaining ALWAYS and ZERO makes the depth-bounds check pass on the default hosted adapter. The ordinary depth comparison always passes, and the fixture still exercises both outcomes of bounds testing after the command-list cut. This probe covers a single test. The full workflow gate is a separate run.

AI-assisted with OpenAI Codex.

@merzleckeier

Copy link
Copy Markdown
Contributor

Follow-up: the full native Windows workspace gate passes with the one-line fixture change. I ran your original GitHub merge 6a7778069 in my fork at d8fec229. In the fixture I enabled ordinary depth testing and kept ALWAYS, the ZERO write mask, and every original assertion. The only workflow edits point the push trigger at the scratch fork branch. Windows job · Probe commit

  • MEASURED. cargo build --workspace --all-targets --locked and cargo test --workspace --exclude xtask --locked both passed on Windows Server 2025 build 26100 with Rust 1.98.1. The top-level test suites reported 1,435 passed, 0 failed, 58 ignored. leonida-gpu reported 549 passed, 0 failed, 47 ignored, and depth_bounds_pipeline_loads_and_filters_draws reported ok. The earlier focused native probe measured the corresponding 0 / 255 pixel pair.
  • MEASURED. The report-only asset policy and Clippy steps still returned exit 101. Asset policy flagged host.rs and emit/lower.rs for the existing file-size limit. The mandatory build and suite passed independently of those reports.

AI-assisted with OpenAI Codex.

@zmasi

zmasi commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Opened #2663 (D3D12-DEPTH-BOUNDS-TEST-FLAKE) for the depth_bounds_pipeline_loads_and_filters_draws failure here, matching @merzleckeier's hosted WARP probe above: instead of changing the test fixture's DepthEnable = false input, effective_depth_bounds_desc in pipeline/host.rs promotes DepthBoundsTestEnable && !DepthEnable && dsv_format != DXGI_FORMAT_UNKNOWN to DepthEnable = true, DepthWriteMask = ZERO, DepthFunc = ALWAYS in GraphicsState::depth1 and graphics_depth_bounds_pipeline (keeping bounds-only PSOs working on WARP and read-only DSVs while leaving DSVFormat == UNKNOWN and explicit DepthEnable = true untouched), and isolates the test's RTV/DSV heaps from parallel RTV_RING contention (551/551 passing under LEONIDA_D3D12_WARP=1 LEONIDA_D3D12_DEBUG=1).

AI-assisted.

…its for (review)

wait() started its timer after promote() took the queue's lock, so time
spent waiting for that lock came on top of the frame's budget: in a
synthetic contention test (queue held 240 ms, 80 ms budget) a frame waited
320 ms. The timer now starts before the promotion, so the lock delay is part
of the budget (240 ms in the same test, the lock holder's time itself).
Reported with the test by merzleckeier.
@fiestorra

Copy link
Copy Markdown
Contributor

Structural verification on this machine, and the limits are stated below because this one cannot be run here at all - there is no cargo on it.

1. It applies. merge-tree clean; f8ee1755d cherry-picks onto main 1d22590b9. One file, 63 insertions(+).

2. The YAML parses, which is the one check a malformed workflow would fail:

python3 -c "import yaml; d=yaml.safe_load(open('.github/workflows/d3d12.yml')); print(list(d['jobs']))"
  -> ['d3d12']

and .github/workflows/jactionlint.yml already covers paths: ['.github/**'], so the schema linter will see this file too.

3. The things it refers to exist:

the workflow says in the tree
working-directory: d3d12 exists
rust-toolchain.toml (the pinned toolchain it relies on) channel = "1.98.1", x86_64-pc-windows-msvc, components rustfmt, clippy
cargo test -p xtask xtask is a workspace member (members = ["crates/*", "apps/*", "xtask"])
paths: d3d12/** matches the crates, apps/ and xtask
no cargo fmt step correct - the only mention is the header explaining it is left out, and I checked that

4. The gating design matches its header. Build and cargo test --workspace --exclude xtask are blocking; the asset-policy test and cargo clippy -D warnings carry continue-on-error: true as reports, which is what the comment says and what main's current state justifies (one failing policy test, ~25 clippy findings). A workflow that made those blocking would be red on its first run and stay red.

What I could not verify, and why it matters for this particular pull request: its header claims the workspace builds in about 4 minutes and its tests take about 11, with 1441 passing, 58 ignored and one failing (the asset-policy test, which the workflow excludes). None of those numbers can be checked here - no cargo, and the toolchain is pinned to 1.98.1 for x86_64-pc-windows-msvc, which I do not have. What I can say is that the workflow's own design is consistent with those claims: the one test it excludes is the one the header says fails, and the two steps it makes non-blocking are the two it says are red on main.

The first run of this workflow on this pull request is therefore also its verification - and, given #2648 exists to be that gate for everything under d3d12/, its own green run is the evidence a reviewer should wait for rather than take from me.

Written with an AI assistant.

OreoFR and others added 3 commits November 30, 2026 14:19
Current main after ProjectLeonida#2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Zilumz1 <221744236+Zilumz1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Current main after ProjectLeonida#2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: quartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Current main after ProjectLeonida#2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Galaxy <23423870+thegalaxydev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KelboLive

Copy link
Copy Markdown

Independent timing while verifying PRs on this machine: the workspace compile, not the tests, dominates repeated runs. A shared CARGO_TARGET_DIR across checkouts cut a -p leonida-hle check from 49.4 s cold to 20.8 s on the second PR (same toolchain, different source tree); after that the crate tests themselves are sub-second.

For this workflow, caching d3d12/target plus CARGO_HOME/the registry would save the same cold build on every run:

  • actions/cache (or Swatinem/rust-cache with workspaces: d3d12 -> target) keyed by d3d12/rust-toolchain.toml + d3d12/Cargo.lock; restore before "Rust toolchain", save after the build/clippy.
  • Cache ~\.cargo\registry (or CARGO_HOME) separately; Windows runners otherwise re-download crates every run.
  • The test step itself is minutes for leonida-shader even warm (386 tests, 250-330 s here), so the cache cannot hide a slow suite; it just removes the repeated compile/clippy cost.

Measured on Windows 11 26200.9711, Ryzen 9 7950X3D, Rust 1.98.1 as pinned. AI-assisted: yes (opencode).

TheGeogeo and others added 3 commits November 30, 2026 17:29
main moved the frame meter's five-second lines into a function of their
own that may run on another thread: the frame times are logged where the
meter decides a five-second line is due, on the presenting thread, as
before. The nearest-rank test's comment said 0.95 * 100 is not 95.0 in
f64; it is: ranks are whole numbers so that no float can move one, and
the case pins the rounding direction (review).
reprend ProjectLeonida#279: d3d12: min/max samplers honour filterMinmaxImageComponentMapping (D3D…
MoonEyes and others added 7 commits November 30, 2026 18:37
reprend ProjectLeonida#2173: d3d12_xs: say so when LEONIDA_D3D12=vulkan is asked of a runtime built without the Vulkan device (RT-VULKAN-REQUESTED-NOT-BUILT)
reprend ProjectLeonida#2062: d3d12: say when the driver's pipeline cache stops keeping new pipelines (RT-PIPELINE-CACHE-GROWTH-STALL)
…e-stats

d3d12: frame-time percentiles and what stalls frames, in the log and on the panel (D3D12-FRAME-TIME-STATS)
…wait-queue

d3d12: a pipeline a frame waits for goes before those asked for earlier (D3D12-PIPELINE-WAIT-QUEUE)
mods/** in the paths (leonida-lua's tests read mods/example_lua), a build with the features people run, the replay
test of leonida-gpu (diagnostics), a cache of Cargo's downloads, a limit on the test step. d3d12/.github/workflows/ci.yml
is removed: GitHub runs workflows only from the repository's root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rojectLeonida#2663

It is the only failure of the job, and it hides the crates after leonida-gpu and the replay test.

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

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the effective diff against current main (compare/main...dcd93bea): adds .github/workflows/d3d12.yml and removes the unused nested d3d12/.github/workflows/ci.yml. Action SHAs are pinned, permissions are minimal (contents: read), jactionlint and d3d12 (windows-latest) both passed on this head, clean-room verified, and all CI checks are green. Merging.

(Note: now that #2681 and #2682 have landed on main, clippy can also be promoted to blocking in a small follow-up once verified green.)

(AI-assisted review.)

@aslan2142
aslan2142 merged commit b121bc0 into ProjectLeonida:main Dec 1, 2026
7 checks passed
@fiestorra

Copy link
Copy Markdown
Contributor

finding: this job is right, and it currently works around three reds that have fixes open - plus it will hit the leonida-gpu concurrency flake that the --skip does not cover.

Three workarounds, each pointing at a fix that already exists:

here why the fix
--skip depth_bounds_pipeline_loads the test asserts left: 255, right: 0 on a software adapter #2823 - it skips when the adapter has no depth-bounds support and still runs on a card (measured on the merged tree)
Asset policy (report) continue-on-error host.rs and lower.rs over the limit, and amplify_dxil.rs's encoded run #2815 - 8 MiB for .rs plus the one exception (measured on the merged tree)
Clippy (report) continue-on-error the findings that are left the cleanup that landed tonight fixed 83; four are back already (pipeline/host.rs:1214, pipeline/known.rs:246 and :268, glyphs/live.rs:121), all from merges made after it

So the comments "make it blocking then" have an answer for two of the three, and both are measured rather than hoped for.

And the one thing this job does not have, which matters more than any of them: cargo test --workspace --exclude xtask runs the leonida-gpu tests in parallel, and that crate's tests interfere with each other when they share a process. Measured today on main, cargo test -p leonida-gpu --lib:

default threads   16 runs, 2 failed   (two different tests, neither of them flaky alone)
--test-threads=1   8 runs, 0 failed   (37 s instead of 13)

A job that runs that crate once will be red about one run in eight for a reason nobody can attribute. The --skip depth_bounds_pipeline_loads does not cover it: the failures I measured were descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync and texture::alias_cast_tests::..._cast_to_r9g9b9e5_under_legacy_barriers.

The shape that would keep both properties: exclude that crate from the parallel run and give it its own step on one thread, which is what #2816 does and what I would lift from it even if the rest of that pull request has been superseded by this one.

      - name: Tests (no GPU, no game data)
        run: cargo test --workspace --exclude xtask --exclude leonida-gpu --locked -- --skip depth_bounds_pipeline_loads
      - name: Tests (leonida-gpu, one thread)
        run: cargo test -p leonida-gpu --lib --locked -- --test-threads=1

AI-assisted: yes - DeepSeek v4.1 (flash), which measured the flake 24 times today and read this workflow's three workarounds against the three open fixes.

Written with an AI assistant.

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.