Title textures: one upload batch moves its textures in two barrier calls #881

Open
github-bot wants to merge 1 commit from github-bot/gh-881 into main AGit
Owner

@⁠mastrr9 on GitHub · 2026-11-24 07:24 UTC · original
mastrr9:perf/d3d12x-batch-texture-upload-barriers → main · +160 −14 · 2 files · 1 commits · open

Batches ResourceBarrier transitions in title texture upload batches (gpu/texture.rs + hle/d3d12x/title_textures.rs) so a streaming batch of N distinct textures issues 2 ResourceBarrier calls instead of 2N (e.g., 64 textures: 128 → 2 barrier drains), allowing copies of different textures to overlap on NVIDIA GPUs:

  • record_batch transitions each run of distinct textures to COPY_DEST in one barrier call before their copies and back in one call after.
  • barrier_groups splits a new run whenever the same texture appears again in a batch so no single ResourceBarrier moves a resource twice and the later upload wins.
  • upload_all defers any texture whose memory range overlaps one already in the batch to the next batch (preserving ordering for aliased placed title textures).
  • Adds unit tests upload_barriers_are_batched_per_run_of_distinct_textures, a_batch_takes_no_two_textures_over_the_same_memory, and GPU test gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: afbba2079d8dbcda73f7e9746497722f90a32475
  • cargo build --workspace: clean (no new warnings; only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 716 passed, 0 failed, 41 ignored (gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents ok, upload_barriers_are_batched_per_run_of_distinct_textures ok, a_batch_takes_no_two_textures_over_the_same_memory ok)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Not tested

  • Retail title regression run (scripts/smoke.ps1) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run.
  • AMD RDNA hardware not tested.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
**@⁠mastrr9** on GitHub · 2026-11-24 07:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/881) `mastrr9:perf/d3d12x-batch-texture-upload-barriers` → `main` · +160 −14 · 2 files · 1 commits · open Batches `ResourceBarrier` transitions in title texture upload batches (`gpu/texture.rs` + `hle/d3d12x/title_textures.rs`) so a streaming batch of `N` distinct textures issues **2** `ResourceBarrier` calls instead of `2N` (e.g., 64 textures: 128 → 2 barrier drains), allowing copies of different textures to overlap on NVIDIA GPUs: - `record_batch` transitions each run of distinct textures to `COPY_DEST` in one barrier call before their copies and back in one call after. - `barrier_groups` splits a new run whenever the same texture appears again in a batch so no single `ResourceBarrier` moves a resource twice and the later upload wins. - `upload_all` defers any texture whose memory range overlaps one already in the batch to the next batch (preserving ordering for aliased placed title textures). - Adds unit tests `upload_barriers_are_batched_per_run_of_distinct_textures`, `a_batch_takes_no_two_textures_over_the_same_memory`, and GPU test `gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents`. **Tested** - Hardware/OS: NVIDIA RTX 5080 (driver `617.42` / `32.0.16.1742`), Windows 11 Pro 25H2 (`26200.9974`), `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC debug, DXC Windows SDK `10.0.26100.0`, `d3d12SDKLayers.dll` installed - Commit tested: `afbba2079d8dbcda73f7e9746497722f90a32475` - `cargo build --workspace`: clean (no new warnings; only pre-existing `fetch_update` deprecation warning) - `cargo test --workspace -- --test-threads=4`: **716 passed, 0 failed, 41 ignored** (`gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents` ok, `upload_barriers_are_batched_per_run_of_distinct_textures` ok, `a_batch_takes_no_two_textures_over_the_same_memory` ok) - `SKIPPED` GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` **Not tested** - Retail title regression run (`scripts/smoke.ps1`) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run. - AMD RDNA hardware not tested. **AI use** - Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
upload_batch recorded each texture on its own: a ResourceBarrier to
COPY_DEST, its copies, a ResourceBarrier back. A batch of N textures
made 2N barrier calls, and the GPU drained between the copies of one
texture and the next. The textures of a batch now go to COPY_DEST in one
ResourceBarrier, are all copied, and go back in one more: 2 calls a
batch instead of 2N, and the copies of different textures no longer wait
for each other.

The same texture twice in one batch starts a new run (barrier_groups),
so no call moves a resource from one state twice and the later contents
land last. upload_all also ends a batch before a texture over memory a
picked one covers (placed title textures can share VRAM pages), so the
copies that are now unordered never write the same memory.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:35:33 +00:00
Author
Owner

@⁠ryosen0 on GitHub · 2026-11-24 07:40 UTC · original

Retail smoke for the pending Regression run, on RTX 3060 Ti 8 GB (Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11, release) — the title whose texture streaming this batches:

xcl-smoke v1
commit: afbba2079d8dbcda73f7e9746497722f90a32475
gpu: NVIDIA GeForce RTX 3060 Ti
title: ScarlettGame
seconds: 90
exit: 0x0
frames shown: 2413 (PresentX 2413)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14623 MB

Plus a 150 s run with scripted presses that reaches the loading screens and the heavy upload phase (thousands of title-texture uploads, ≈1.75 GB of CPU writes through the sparse windows): clean, 4203 frames, steady 60 presents / 2 s, 0 removals / 0 crashes. The batching survives the phase it targets on a second NVIDIA host.

The matched main-side block still needs to come from current main (a1672ef) for the checks — the head block above is yours to paste.

One observation, not a request: this title's load phase has an intermittent device removal on 8 GB cards (~1 in 6 runs on the #541 branch, 0x887a0006 during upload churn). Since this change reorders barrier drains around copies, it would be worth one longer run on an 8 GB card before merge to see the tally doesn't move — I can run that shape here if you rebase onto current main.

AI use: GPT-6.2 Astra (API model selector) in DSH built the head, ran the smoke and the 150 s run, and drafted this comment; the human contributor reviewed the numbers before posting.

**@⁠ryosen0** on GitHub · 2026-11-24 07:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7125240076) Retail smoke for the pending **Regression run**, on RTX 3060 Ti 8 GB (Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11, release) — the title whose texture streaming this batches: ``` xcl-smoke v1 commit: afbba2079d8dbcda73f7e9746497722f90a32475 gpu: NVIDIA GeForce RTX 3060 Ti title: ScarlettGame seconds: 90 exit: 0x0 frames shown: 2413 (PresentX 2413) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14623 MB ``` Plus a 150 s run with scripted presses that reaches the loading screens and the heavy upload phase (thousands of title-texture uploads, ≈1.75 GB of CPU writes through the sparse windows): clean, 4203 frames, steady 60 presents / 2 s, 0 removals / 0 crashes. The batching survives the phase it targets on a second NVIDIA host. The matched main-side block still needs to come from current main (`a1672ef`) for the checks — the head block above is yours to paste. One observation, not a request: this title's load phase has an intermittent device removal on 8 GB cards (~1 in 6 runs on the #541 branch, `0x887a0006` during upload churn). Since this change reorders barrier drains around copies, it would be worth one longer run on an 8 GB card before merge to see the tally doesn't move — I can run that shape here if you rebase onto current main. **AI use:** GPT-6.2 Astra (API model selector) in DSH built the head, ran the smoke and the 150 s run, and drafted this comment; the human contributor reviewed the numbers before posting.
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-24 08:39 UTC · original

@⁠ryosen0 Thank you so much for running both the 90 s smoke and the 150 s loading-phase run on your RTX 3060 Ti — really helpful data!

I've rebased this branch cleanly onto current main (09940bb, PR head is now 2d2997bb8e72164134fad06d10e1e60e144f888a) and re-verified on Windows 11 / RTX 5080 (cargo test --workspace -- --test-threads=4: 719 passed / 0 failed / 41 ignored). Ready whenever you have time for that longer 8 GB stress run!

**@⁠mastrr9** on GitHub · 2026-11-24 08:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7126405229) @⁠ryosen0 Thank you so much for running both the 90 s smoke and the 150 s loading-phase run on your RTX 3060 Ti — really helpful data! I've rebased this branch cleanly onto current `main` (`09940bb`, PR head is now `2d2997bb8e72164134fad06d10e1e60e144f888a`) and re-verified on Windows 11 / RTX 5080 (`cargo test --workspace -- --test-threads=4`: 719 passed / 0 failed / 41 ignored). Ready whenever you have time for that longer 8 GB stress run!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 09:34 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 2d2997b onto main 077ce40, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 709 passed, 10 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). upload-batch barrier tests green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 09:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7127590340) Linux / AMD RDNA3 datapoint. **Merged state:** head `2d2997b` onto main `077ce40`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **709 passed, 10 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). upload-batch barrier tests green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:05 UTC · original

Regression run of 2d2997bb on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 2d2997bb8e72164134fad06d10e1e60e144f888a
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1614 (PresentX 1614)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14816 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7151574825) Regression run of `2d2997bb` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 2d2997bb8e72164134fad06d10e1e60e144f888a gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1614 (PresentX 1614) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14816 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:45 UTC · original

Empirical test report (2d2997bb)

Hardware / environment

  • PR #881 at 2d2997bb8e72164134fad06d10e1e60e144f888a, Windows x64 build 26200, AMD64 Family 23 Model 113 with 12 logical processors. A separate probe of the default D3D12 device identified Intel Arc A770 Graphics (PCI 8086:56A0). The GPU fixture requests the default D3D12 adapter.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5 (01b62ad47), unoptimized test profile.

Commands and results

  • cargo test --workspace --no-run completed outside Invoke-ArcTest.ps1 with exit code 0.
  • Ran the built xcl library test executable with --exact for gpu::texture::tests::upload_barriers_are_batched_per_run_of_distinct_textures and hle::d3d12x::title_textures::tests::a_batch_takes_no_two_textures_over_the_same_memory. With XCL_ADAPTER=NONE_CPU_ONLY, the CPU run had 2 passed, 0 failed, 0 ignored, 0 skipped.
  • Ran the same executable through Invoke-ArcTest.ps1 -Test { ... } with --exact gpu::texture::tests::gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents and XCL_ADAPTER=A770. The wrapper acquired and released the Arc test lock. The GPU run had 1 passed, 0 failed, 0 ignored, 0 skipped.
  • Both runs used RUST_TEST_NOCAPTURE=1. Totals from the focused log were 3 passed, 0 failed, 0 ignored, 0 skipped.

Observed behavior

The CPU fixtures verified that repeated textures start a new run without changing upload order and that overlapping memory spans end a batch while adjacent spans can share it. The D3D12 fixture uploaded A, B, then A again in one batch. Readback matched A's second payload and B's own payload byte for byte.

Not tested

The full GPU workspace suite and game smoke runs on main and the PR head were omitted. The barrier call count and upload timing were not measured.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr881-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7154106854) ### Empirical test report (2d2997bb) **Hardware / environment** - PR #881 at `2d2997bb8e72164134fad06d10e1e60e144f888a`, Windows x64 build 26200, AMD64 Family 23 Model 113 with 12 logical processors. A separate probe of the default D3D12 device identified Intel Arc A770 Graphics (PCI 8086:56A0). The GPU fixture requests the default D3D12 adapter. - Rust `1.100.0 (0ef1bc386 2026-11-09)`, DXC `1.9.2609.5 (01b62ad47)`, unoptimized test profile. **Commands and results** - `cargo test --workspace --no-run` completed outside `Invoke-ArcTest.ps1` with exit code 0. - Ran the built `xcl` library test executable with `--exact` for `gpu::texture::tests::upload_barriers_are_batched_per_run_of_distinct_textures` and `hle::d3d12x::title_textures::tests::a_batch_takes_no_two_textures_over_the_same_memory`. With `XCL_ADAPTER=NONE_CPU_ONLY`, the CPU run had 2 passed, 0 failed, 0 ignored, 0 skipped. - Ran the same executable through `Invoke-ArcTest.ps1 -Test { ... }` with `--exact gpu::texture::tests::gpu_upload_batch_with_a_texture_twice_keeps_the_later_contents` and `XCL_ADAPTER=A770`. The wrapper acquired and released the Arc test lock. The GPU run had 1 passed, 0 failed, 0 ignored, 0 skipped. - Both runs used `RUST_TEST_NOCAPTURE=1`. Totals from the focused log were 3 passed, 0 failed, 0 ignored, 0 skipped. **Observed behavior** The CPU fixtures verified that repeated textures start a new run without changing upload order and that overlapping memory spans end a batch while adjacent spans can share it. The D3D12 fixture uploaded A, B, then A again in one batch. Readback matched A's second payload and B's own payload byte for byte. **Not tested** The full GPU workspace suite and game smoke runs on main and the PR head were omitted. The barrier call count and upload timing were not measured. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr881-focused.log` and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 09:52 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 09:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7158918288) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:11 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 03:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/881#issuecomment-7181478021) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/title_textures.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/881/head:github-bot/gh-881'
git switch 'github-bot/gh-881'

Merge

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