Skip to content

D3D12.X: the tile-mapping fence is signalled once before the next title work - #3010

Draft
voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-tile-fence-once
Draft

voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/nv-tile-fence-once

Conversation

@voiceovarian1-max

Copy link
Copy Markdown

For nvidia-dev. vram::Pages signalled its fence after each tile mapping (map and unmap), and title queues wait for that fence in before_execute. vkd3d-proton merges consecutive sparse binds into one vkQueueBindSparse, but each signal ends a batch. So a title that streams textures paid one bind per texture, ~0.4 ms each on NVIDIA. In a retail title's world this was 13,000–24,000 sparse ops per 4 s; after the change it was ~700 per 4 s (run on our Linux tree). The frame rate did not rise in that run: the binds still took 2.5–3.1 s of every 4 s, because of the number of tiles (~24,000 a second).

Mappings now only mark the fence unsignalled. before_execute signals it once, before a title queue's next work, then has that queue wait as before. #1747 kept the immediate signal so that tile-mapping operations are fenced before a heap is released. That still holds: pool heaps are only reclaimed in before_execute, after this signal, and unmap_mark takes the signalled value. XCL_PAGE_SIGNAL_EACH=1 signals after each mapping, as before.

What is in it

  • hle/d3d12x/vram.rs: Pages::unsignalled, mappings_changed, and the signal in before_execute. New GPU test tile_mappings_are_signalled_once_before_the_next_title_work: two textures placed on pages, no signal; before_execute signals once; a second call does not signal again.

Tested

  • Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04, i7-14700K. Rust 1.100.0, x86_64-pc-windows-gnu, release. On nvidia-dev 3f39671d.
  • Whole lib suite under Wine (cargo test -p xcl --lib -- --test-threads=4), on this commit before the test was added (974d5844): 1691 passed, 8 failed, 28 ignored. nvidia-dev 3f39671d: the same 8 failures.
  • Head 67322ca9, cargo test -p xcl --lib vram:: -- --test-threads=1: 23 passed, 0 failed, 1 ignored (churn_update_tile_mappings_timing). With the signal after each mapping forced on, the new test fails (1 failed).

Regression run

  • None: scripts/smoke.ps1 needs Windows, and we only have Linux. A Windows smoke run on nvidia-dev and on this head would be welcome.

Not tested

  • Windows, AMD (whether D3D12 drivers there also split work at a fence signal), a retail title on this branch.

AI use

  • Claude Code with Claude Opus 5.5: found the split batches in a queue trace, wrote the change, the test and this description, and ran the tests.

🤖 Generated with Claude Code

…le work

The `Pages` queue signalled its fence after each tile mapping, and title
queues wait for it. Under vkd3d-proton every signal ended a sparse-bind batch:
one vkQueueBindSparse per texture, ~0.4 ms each on NVIDIA, with the queues
full while a title streamed. Mappings now only mark the fence unsignalled; it
is signalled once in `before_execute`, before a title queue's next work.
`XCL_PAGE_SIGNAL_EACH=1`: after each mapping, as before. GPU test included. The code is
platform-neutral; the cost was measured under Wine.

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

Copy link
Copy Markdown

Windows RTX 4090 test of #3010

Five 60-second runs on native Windows completed with exit 0, zero logged crashes and zero device removals. The RTX 4090 exercised the deferred fence in the synthetic test. The frame difference changed sign when the order of the two NVIDIA builds was reversed.

GPU fence test

On clean PR head 67322ca9146d5468f35e5b663feba021fbf22d51, the isolated test reached the native D3D12 tiled-resource path. It placed two 512×512 textures, checked that both mappings left the fence value unchanged, called before_execute and checked that the value advanced exactly once. A second call kept the same value. The test waited for the fence and passed.

With XCL_PAGE_SIGNAL_EACH=1 in a fresh process, the same binary reported one pass in 0.00 s. The head contains an early return for that setting, before DXGI initialization. The default run took 0.32 s and logged the tiled-resource device, queue and fence. Only the default run exercised the assertions. Test source

The VRAM module reported 23 passed, 0 failed, 1 ignored, with no explicit SKIPPED lines. The ignored case was the queue timing benchmark. The complete workspace suite was outside this run.

$case = 'hle::d3d12x::vram::tests::tile_mappings_are_signalled_once_before_the_next_title_work'
cargo test --locked --release -p xcl --lib $case -- --exact --test-threads=1 --nocapture
$env:XCL_PAGE_SIGNAL_EACH = '1'
cargo test --locked --release -p xcl --lib $case -- --exact --test-threads=1 --nocapture
Remove-Item Env:XCL_PAGE_SIGNAL_EACH
cargo test --locked --release -p xcl --lib hle::d3d12x::vram:: -- --test-threads=1 --nocapture

Regression run

RTX 4090 (24 GB), NVIDIA 621.40, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 Pro 26300.10075, Rust 1.99.1 MSVC x64, Windows SDK DXC 1.9.2602.17. Each clean checkout was built with cargo build --locked --release -p xcl. The first-party scripts/smoke.ps1 was byte-identical on all three revisions.

nvidia-dev at d1be8103 was the branch control. It differs from the PR parent 3f39671d by the relicensing commit, which changed documentation, manifest metadata and Rust comments. main at 06f90c19 was included for the project's regression comparison. PR #3010 · NVIDIA branch delta

The title ran for 60 seconds per invocation on the Series X profile. Each invocation received an independently hash-checked copy of the same checkpoint, a fresh XCL shader-cache directory and the same A-button schedule (25, 30, 35 and 40 seconds). The wrapper disabled networking, enabled activity logging and set the timer. XCL_PREPARE=0 bypassed the startup shader preparation. The NVIDIA driver cache remained under driver control.

Run in execution order Frames shown First frame (s) Peak process commit (MB) Final target pages (MB)
nvidia-dev, first 1370 7.297 18824 4508
PR, first 1493 3.190 18910 4508
main 1271 3.461 17415 4779
PR, repeat 1500 2.446 17685 4507
nvidia-dev, repeat 1536 2.602 17741 4515

The PR showed 123 more frames than nvidia-dev in the first pair (+9.0%) and 36 fewer in the reversed pair (−2.3%). In the first pair, the real D3D12 backend was ready at 4.653 s on the base and 0.702 s on the PR. In the reversed pair it was ready at 0.721 s on the PR and 0.739 s on the base. The differences in startup time and run order limit any inference about frame rate. The logs show live tiled textures in all five runs. World rendering, visual correctness and per-frame counts of fence signals during gameplay remain unmeasured.

Regression blocks for main and PR, copied from the original script output.

xcl-smoke v1
commit: 06f90c1986f43698d0405eff3c2ab0af230e1ed9
gpu: NVIDIA GeForce RTX 4090
title: 7850d621
seconds: 60
exit: 0x0
frames shown: 1271 (PresentX 1272)
presents per 2 s (last 3): 60 60 44
device removals: 0
crashes: 0
peak commit: 17415 MB
xcl-smoke v1
commit: 67322ca9146d5468f35e5b663feba021fbf22d51
gpu: NVIDIA GeForce RTX 4090
title: 7850d621
seconds: 60
exit: 0x0
frames shown: 1493 (PresentX 1493)
presents per 2 s (last 3): 57 57 60
device removals: 0
crashes: 0
peak commit: 18910 MB

AI use. OpenAI Codex (GPT-6) built the revisions, ran the tests and checked the report against the machine-generated logs and manifests.

@andrewDoing

Copy link
Copy Markdown
Contributor

I tested the two-consumer mapping dependency on RTX 5070 / NVIDIA 616.92 at head 67322ca9 with a test-only native fixture. It gates the production mapping queue, records the same mapping generation on two independent consumer queues, and observes their completion fences.

In both deferred mode and XCL_PAGE_SIGNAL_EACH=1, the two consumer markers stayed at [0, 0] while the mapping queue was gated and advanced to [1, 1] after release. As a sensitivity control, deliberately omitting the second consumer's wait produced [0, 1] before release and failed the expected-dependency assertion in both modes. The proper cases passed with no skips.

This covers ordering for synthetic mapped textures and the forced mode, whose existing test returns before GPU setup. It does not measure title behavior, frame time, or performance.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 67322ca

Main's vram::Pages still signals after each mapping (native_queue_signal in map / unmap), and no open PR on main defers it. #3024 (amd-dev) does the same for the sparse windows' UpdateTileMappings, not for vram::Pages. The old amd-dev base also had 5730337 ("batch vram tile-mapping fence signals into before_execute"), but current amd-dev does not.
No problem found in the diff: every read of pages.value is in before_execute after the pending signal, including unmap_mark for heap retirement. Main's vram.rs has changed a lot since (mark_unmap, native_queue_signal, a helper that expects map to leave the fence signalled), so the PR conflicts and needs a rebase that checks those new users of pages.value.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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.

4 participants