Skip to content

D3D12.X: faster title texture uploads (reused upload memory, faster detiling) - #451

Merged
theaustinayers merged 4 commits into
xcl-dev:mainfrom
1984742628:perf/reuse-upload-memory
Nov 24, 2026
Merged

theaustinayers merged 4 commits into
xcl-dev:mainfrom
1984742628:perf/reuse-upload-memory

Conversation

@1984742628

@1984742628 1984742628 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A retail title that rewrites textures with the CPU (kept in step with its memory by title_textures) fell to 1 – 3 frames a second on an NVIDIA RTX 3070 Ti once it streamed them. The time went to uploading those textures inside the title's own submit and present: D3D12 objects made and released for every upload, then detiling every texel through a full offset computation, one texture after another. This PR makes the uploads reuse their D3D12 objects and detiles faster and in parallel, and now also carries #440's linear fast path (by @emirduran707, see the 4th commit), which speeds up the linear levels this PR's per-row form only helped 3×. In back-to-back runs of the title the combined change is the only build that reaches the title's 30 fps cap at the end of a 60 s run.

What is in it

  • D3D12.X: title texture uploads reuse their queue's buffer and list (gpu/texture.rs): upload_batch made an upload buffer per texture and an allocator, a list and a fence per batch – each a call that waits for the video memory manager, 200 – 650 ms apiece while the title streamed (timed in its runs). Each upload queue now keeps one persistently mapped upload buffer (grown only when a batch needs more; textures at 512-byte aligned offsets), its allocator and list (reset) and a fence. When a batch's wait times out, the set is retired and kept alive instead of released under the GPU, which removed the device. record_upload_states keeps its behaviour for its other callers.
  • Textures: detiling a mip level computes column and row parts once (gpu/tiling.rs): Chain::detile_level computed Layout::offset_z for every element (divisions, modulos, six lookups). The x-only parts are now computed once per level and the y/slice parts once per row: two lookups and an XOR per element, byte for byte the same result.
  • D3D12.X: the title textures of a big batch are detiled on several threads (hle/d3d12x/title_textures.rs): batches of 1 MB or more are detiled on up to 8 threads (half the cores), in order; smaller batches stay on the calling thread.
  • Textures: linear levels are detiled a row at a time (gpu/tiling.rs, authored by @emirduran707, from Textures: linear levels are detiled a row at a time #440 be722a7): a linear level (mode 0, no base swizzle, not in a mip tail) has contiguous rows, so they are copied whole, in front of the per-row loop above; which elements are copied from a source cut short is unchanged. Textures: linear levels are detiled a row at a time #440 can be closed if this lands.
  • Tests: detile_level_matches_element_by_element (every swizzled mode, element size, pipe configuration and level including mip tails, a base swizzle, two slices, a source cut short), linear_levels_detile_by_rows_as_by_elements (from Textures: linear levels are detiled a row at a time #440: every element size, padded rows, every mip, a source cut short inside a row and inside an element), gpu_upload_batches_reuse_the_queues_upload_buffer (two batches of three textures – mips, an odd size, BC7 – read back exactly, and the second batch made no new upload buffer), a_batch_detiled_on_several_threads_matches_one_thread (2, 3 and 8 threads against one).

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 Ti 8 GB (driver 32.0.16.2124), AMD Ryzen 9 7950X (16 cores / 32 threads), 32 GB RAM, Windows 11 10.0.26100, rustc 1.98.0; tests in debug, timings and title runs in release.
  • cargo test --workspace -- --test-threads=4 at 1f282c7 with no uncommitted changes: 680 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2, both "no wave64": gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware). The XCL_SAMPLE_* variables were not set, so the tests on game data did nothing.
  • Each commit builds with its tests on its own.
  • detile_level alone (a local timing test, not committed; best of 7, release, the levels @emirduran707 timed):
level main 2997c9a #440 be722a7 this PR before #440 2cefc88 this PR 1f282c7
3840x2160 R8, linear 66.0 ms 0.87 ms 13.5 ms 0.86 ms
1920x1080 R8, linear 16.5 ms 0.22 ms 3.7 ms 0.23 ms
2048x2048 RGBA8, 64KB_S, 8 pipes 41.2 ms 41.9 ms 15.7 ms 15.1 ms
  • The retail title, scripts/smoke.ps1 60 s, two runs per build one after another (same session, no input): main 260 / 292 frames (last 6 s: 3 – 5 presents per 2 s); Textures: linear levels are detiled a row at a time #440 alone 231 / 295 (0 – 5); this PR before Textures: linear levels are detiled a row at a time #440 552 / 553 (1); this PR 670 / 1011 (60, the title's 30 fps cap). No crash or device removal in any of them. The frame counts vary from run to run and between sessions (main showed 720 in the regression run below, in an earlier session), so only runs of one session are compared.

Regression run
scripts/smoke.ps1 -Game <the title's folder> -Xcl target\release\xcl.exe (60 s), built from main and from this PR's head with no uncommitted changes. (Windows PowerShell 5.1 does not set $PSScriptRoot in the parameter default, hence -Xcl.)

main:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: NVIDIA GeForce RTX 3070 Ti
title: RetailGame
seconds: 60
exit: 0x0
frames shown: 720 (PresentX 721)
presents per 2 s (last 3): 30 29 26
device removals: 0
crashes: 0
peak commit: 14594 MB

PR:

xcl-smoke v1
commit: 1f282c737b5637b58de4847cacde208d23504ed7
gpu: NVIDIA GeForce RTX 3070 Ti
title: RetailGame
seconds: 60
exit: 0x0
frames shown: 1094 (PresentX 1105)
presents per 2 s (last 3): 53 60 59
device removals: 0
crashes: 0
peak commit: 15156 MB

Not tested

  • One title; two runs per build in the comparison, one in the regression run: frame counts vary a lot between runs and sessions.
  • Not tested on AMD or Intel GPUs here (Textures: linear levels are detiled a row at a time #440's own runs were on an RX 9060 XT).
  • tests/texture_states.rs (upload barriers checked by the D3D12 debug layer) skips here: the debug layer is not installed.
  • The title's intro video (the linear planes Textures: linear levels are detiled a row at a time #440 targets) was not started by hand in these runs.
  • The upload buffer is kept per queue for the process and only grows (up to a batch: BATCH_BYTES, 256 MB, plus one texture); it is not shrunk.

AI use

1984742628 and others added 3 commits November 24, 2026 01:26
`gpu::texture::upload_batch` made a new upload buffer for every texture
and a new command allocator, command list and fence for every batch,
and released them all again. Each of these D3D12 calls waits for the
video memory manager. While a retail title streamed textures the CPU
writes, they took 200 - 650 ms apiece (timed in the title's runs), and
its frames fell to 1 - 3 a second.

Each upload queue now keeps an `Uploader`: one persistently mapped
upload buffer that the batch's textures share (each at a 512-byte
aligned offset; it grows only when a batch needs more room), an
allocator and list that are reset, and a fence whose value counts up.
When the wait for a batch times out, the uploader is retired and kept
alive instead of released: the GPU may still read the buffer and run
the list, and releasing them under it removed the device.

`record_upload_states` is split into `layout` and `record_into`; it
keeps its behaviour (a buffer of its own) for its other callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Chain::detile_level` called `element_at` / `Layout::offset_z` for every
element: a `div_ceil`, several divisions and modulos and six table
lookups each. Once the upload buffers were reused, it was most of a
retail title's render thread while the title streamed textures the CPU
writes (thread samples, frames named from a symbol build).

The parts of the offset that depend on x alone (block column and the
x and high-x pattern bits) are now computed once per level, those that
depend on y and the slice once per row, leaving two lookups and an XOR
per element. The result is the same: a new test compares it with
`element_at` for every mode, element size, pipe configuration and level
(mip tails too), with a base swizzle, two slices and a source cut short.

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

`title_textures::upload_all` read and detiled each texture of a batch
one after another, inside the title's own submit and present. Batches of
1 MB or more are now detiled on up to 8 threads (half the cores), each
taking the next texture; the results keep the batch's order. Smaller
batches stay on the calling thread.

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

Copy link
Copy Markdown
Contributor

This overlaps #440 in Chain::detile_level (they conflict textually), but the two speed up different layouts, so they combine rather than compete. detile_level alone, single thread, release, on a Ryzen 5 5600 (local timing test, not committed; same harness on both heads):

level main this PR (2cefc88) #440 (be722a7)
3840x2160 R8, linear (an intro-video plane) 56.9 ms 21.2 ms 1.2 ms
1920x1080 R8, linear 14.4 ms 5.0 ms 0.3 ms
2048x2048 RGBA8, 64KB_S, 8 pipes 48.4 ms 16.0 ms 48.4 ms (unchanged)

A linear level's rows are contiguous, so #440 copies them whole; your per-row form is what the swizzled modes need. Whichever lands first, I'll rebase #440 onto it as a linear fast path in front of your loop (a few lines plus its equivalence test) – or feel free to fold it into this PR if you prefer, and I'll close #440.

AI use: Claude Code with Claude Opus 5.5 ran the timings and wrote this comment.

@thehollowedone

Copy link
Copy Markdown

Tested

Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (NVIDIA 621.35), Rust 1.99.1 MSVC, debug. Commit 2cefc889

cargo test --locked -p xcl --lib -- detile_level_matches_element_by_element gpu_upload_batches_reuse_the_queues_upload_buffer a_batch_detiled_on_several_threads_matches_one_thread --test-threads=1 --nocapture: 3 passed, 0 failed, 0 ignored, zero reported skips. The GPU check matched the readbacks from both batches and confirmed the second batch reused the staging buffer. The two CPU checks matched the element-by-element detiler and the single-threaded batch output.

Not tested

Full workspace suite, AMD, retail titles, and performance.

AI use

Codex with GPT-6.2 Sol ran the tests and drafted this report.

@1984742628

Copy link
Copy Markdown
Contributor Author

This overlaps #440 in Chain::detile_level (they conflict textually), but the two speed up different layouts, so they combine rather than compete. detile_level alone, single thread, release, on a Ryzen 5 5600 (local timing test, not committed; same harness on both heads):

level main this PR (2cefc88) #440 (be722a7)
3840x2160 R8, linear (an intro-video plane) 56.9 ms 21.2 ms 1.2 ms
1920x1080 R8, linear 14.4 ms 5.0 ms 0.3 ms
2048x2048 RGBA8, 64KB_S, 8 pipes 48.4 ms 16.0 ms 48.4 ms (unchanged)
A linear level's rows are contiguous, so #440 copies them whole; your per-row form is what the swizzled modes need. Whichever lands first, I'll rebase #440 onto it as a linear fast path in front of your loop (a few lines plus its equivalence test) – or feel free to fold it into this PR if you prefer, and I'll close #440.

AI use: Claude Code with Claude Opus 5.5 ran the timings and wrote this comment.

Do you want to merge our PRs?

Chain::detile_level computed the address of every element and copied it
on its own. A linear level (mode 0) keeps each row's elements contiguous,
so its rows are now copied whole; which elements are copied when the
source is cut short is unchanged. Swizzled modes, a base swizzle and
levels in a mip tail keep the per-row form of the previous commit.

A retail title's intro video is three linear R8 planes per frame
(3840x2160 and two 1920x1080), uploaded on every frame through the
kept-in-step title textures: release, one plane 56.9 ms -> 1.2 ms and
14.4 ms -> 0.3 ms, about 85 ms -> 2 ms a frame. The video played at
3.5 fps on an RX 9060 XT with the element-by-element form.

Test: linear levels give the same bytes by rows as by elements, for
every element size, padded rows, every mip and a cut-short source.

From xcl-dev#440 (be722a7), placed in front of the per-row loop of this PR.

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

Copy link
Copy Markdown

Tested 2cefc88 merged onto main 2997c9a.

RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_*.

Pass: 679 passed, 0 failed, 41 ignored. SKIPPED: only the 2 no wave64 tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware). Build clean.

Run and written with Claude Code (Claude Opus 5.5).

@TheHoracio

Copy link
Copy Markdown
Contributor

Test report on AMD RDNA3: RX 7800 XT (16 GB, wave32 and wave64), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. The PR's own runs are all on NVIDIA, so this adds an AMD GPU with 64-lane waves.

Tested: the PR head 2cefc88 as it is (on its base a6f5f7a).

  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 679 passed, 0 failed, 41 ignored, no SKIPPED tests (the two no wave64 tests run here).
  • The three new tests pass: gpu_upload_batches_reuse_the_queues_upload_buffer (GPU), detile_level_matches_element_by_element and a_batch_detiled_on_several_threads_matches_one_thread.

Not tested: a regression run on a title, a release build, the head merged onto current main.

AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above.

@1984742628

Copy link
Copy Markdown
Contributor Author

Thanks @emirduran707, good catch. The two changes fit together: your linear fast path is now the 4th commit of this PR (1f282c7, with you as author), placed in front of the per-row loop, so linear levels take your row copy and swizzled ones take the per-row form. Your linear_levels_detile_by_rows_as_by_elements test came along unchanged, and the whole suite passes at 1f282c7 (680 passed, 0 failed, 41 ignored).

Combined numbers, measured on an RTX 3070 Ti and a Ryzen 9 7950X:

detile_level alone (release, best of 7, the levels you timed):

level main 2997c9a #440 be722a7 #451 before #440 2cefc88 combined 1f282c7
3840x2160 R8, linear 66.0 ms 0.87 ms 13.5 ms 0.86 ms
1920x1080 R8, linear 16.5 ms 0.22 ms 3.7 ms 0.23 ms
2048x2048 RGBA8, 64KB_S, 8 pipes 41.2 ms 41.9 ms 15.7 ms 15.1 ms

The retail title, scripts/smoke.ps1 60 s, two runs per build back to back in one session:

build frames shown presents per 2 s at the end
main 260 / 292 3 – 5
#440 alone 231 / 295 0 – 5
#451 before #440 552 / 553 1
combined 670 / 1011 60 (the title's 30 fps cap)

None of the runs crashed or removed the device. Frame counts vary a lot from run to run, so only runs from the same session are compared. I didn't start the title's intro video by hand, so your video case was measured only through the timings above.

If this lands, #440 can be closed. The PR description is updated to match.

(Written with Claude Code, Claude Opus 5.5; I checked the numbers against the runs.)

@Chrysana

Chrysana commented Nov 24, 2026 •

Copy link
Copy Markdown

Test report for #451 at 2cefc88 on AMD RDNA4 (the "Not tested" item), with the retail title reaching the intro video.

Setup: AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008 (the CPU's integrated Radeon is also present; XCL ran on the RX 9070 XT), Ryzen 7 9800X3D, 31 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17 (SDK 10.0.26100). Retail title 1.0.2.1. Debug build for the tests, release build for the runs.

Tests: cargo test --workspace --no-fail-fast -- --test-threads=4 at 2cefc88: 679 passed, 0 failed, 41 ignored. SKIPPED: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state, both because the D3D12 debug layer isn't installed here.

Title runs: scripts/smoke.ps1 -Game <folder> -Seconds 60 with XCL_PRESS_A_AT=14,17,21. Every run reaches the Bink intro (21 kept-in-step textures in each run's log). The picture was checked by eye only on main, where the video plays. Two rounds of main, #451, #440 and #458, interleaved, same machine, same saved state:

build frames, round 1 / round 2 last 20 s
main a6f5f7a 489 / 497 ~5.5 fps
#451 2cefc88 1489 / 1515 30 fps
#440 be722a7 1261 / 1269 ~28 fps
#458 a173fe0 1082 / 1085 ~12 fps (from its older base, see #458)

No device removal or crash in any run. Peak commit was 16150 / 16023 MB with this PR against 15824 / 15815 MB on main (+2 %).

Regression run (round 1):

main:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 489 (PresentX 490)
presents per 2 s (last 3): 10 12 10
device removals: 0
crashes: 0
peak commit: 15824 MB

PR:

xcl-smoke v1
commit: 2cefc889564d5216618f65f9f2c3c32ce1d64f64
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1489 (PresentX 1489)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16150 MB

Not tested: gameplay past the video; picture correctness beyond what the person watching saw; any title other than this one.

AI use: Claude Code with Claude Opus 5.5 built the commits, ran the tests and the title runs, and wrote this report. The runs were made on my machine.

@grahamster2

grahamster2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Tested on an RTX 3080 against main and the two other PRs for the same fix (#455, #465). #451 is the only one that speeds up the intro video here: about 4.5 → 20 fps (it takes 21 s instead of ~100 s), and world streaming starts at 60 s instead of 140 s. There were no device removals. The local patch from the #283 comment, on db1ddb2, gave 30 fps in the earlier test, so this head is slower than that patch was.

Setup: RTX 3080 10 GB, driver 610.88, 32 GB RAM with ~15–17 GB used by other programs. Release builds of main 2997c9a (code-identical to a6f5f7a) and of #451 2cefc88, #455 07e6199 and #465 1152852. Each PR was tested on its own. The retail title ran 180 s per run with XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PRESS_A_AT=14,17,21 on a warm cache. Numbers are from the activity (2 s) lines; the earlier patch test on db1ddb2 is here.

main #451 #455 #465
Runs 2 2 3 (2 ended in a device removal) 2
Intro video, presents per 2 s 8–10 (≈4.5 fps) 37–43 (≈20 fps) 8–11 (≈4.7 fps) 8–10 (≈4.5 fps)
Intro video, start → end 20 → 119 / 121 s 20 → 41 / 41 s 20 → 113 s 20 → 118 / 117 s
World streaming starts 140 / 140 s 60 / 60 s 134 s 138 / 136 s
Max presents per 2 s after that 35 / 35 45 / 58 47 55 / 48
Commit at the end 23.7 / 24.0 GB 24.5 / 24.4 GB 24.1 GB 24.5 / 25.1 GB
  • Every completed run was stopped by my watchdog (it kills XCL when free RAM falls below 1.5 GB). That happened 15–25 s after world streaming started, at about 24 GB commit, in every build. It's this machine's RAM limit, so the "after that" row covers only those seconds.
  • D3D12.X: title texture uploads run on the submitting queue, without a CPU wait #455: 2 of 3 runs ended in a device removal. The removal was 0x887a0006 (DEVICE_HUNG), at 13.5 s and 11.0 s, before the intro video. The log line is D3D12 device removed: 0x887a0006 … – the title is stopped, and then the process ends with status 0x887a0006. main and the other PRs had no removals in their runs.
  • smoke.ps1, 60 s: it presses nothing, so every build stays on the menu, and all four look the same there.
smoke commit frames shown last 3 removals crashes peak commit
main 2997c9a 1532 60 60 60 0 0 14613 MB
#451 2cefc88 1590 60 61 60 0 0 14723 MB
#455 07e6199 1518 61 60 59 0 0 14589 MB
#465 1152852 1528 60 59 61 0 0 14663 MB

All smoke runs reported exit: 0x0 and gpu: NVIDIA GeForce RTX 3080. I left the title line out of the table.

Not tested:

  • Picture correctness: I can't see the screen.
  • Anything past ~20 s of world streaming, because of the RAM limit.
  • Combinations of the PRs.

The same numbers are posted on the other PRs: #455, #465.

Test runs and this report: Claude Code (Claude Opus 5.5).

@1bugproof

Copy link
Copy Markdown
Contributor

please review @ivall / @theaustinayers / @Mavixot

@grahamster2

Copy link
Copy Markdown
Collaborator

Follow-up on the RTX 3080 now that #486 is merged: yes, #451 still helps on top of #486. With main alone the intro video plays at ~6 fps. With main + #451 it plays at 30 fps, and world streaming starts ~60 s earlier.

Builds:

The setup is the same as in my comment above: the retail title, 180 s, XCL_NETWORK=0 XCL_ACTIVITY=1, warm cache, and a watchdog that stops the run when free RAM falls below 1.5 GB.

main 7ebf1b8 (#486) main 7ebf1b8 + #451 1f282c7
Intro video, presents per 2 s 10–14 (≈6 fps) 58–60 (30 fps)
Intro video, start → end 24 → 95 s / 20 → 93 s 22 → 37 s / 20 → 33 s
World streaming starts 116 / 112 s 56 / 52 s
Max presents per 2 s after that 43 / 41 49 / 47
Device removals 0 0

For comparison, on 2997c9a (before #486) main played the video at ~4.5 fps and #451 2cefc88 at ~20 fps. #486 alone raises it to only ~6 fps on this card, not 30.

Two extra #451 runs aren't in the table. I ran them with the same XCL_PRESS_A_AT=14,17,21 as main. In both, the title read the gamepad for the first time only at ~21 s, so the press before the video came too early. The title then sat on that screen for the rest of the 180 s, at 60 presents per 2 s and 14.7 GB commit. Neither run had a crash or a removal. The two runs in the table used 21,25,31 and 14,17,21,25,31; the extra presses didn't cut the video short.

Not tested: picture correctness (I can't see the screen), and anything past the first ~20 s of world streaming, because of the RAM limit.

Test runs and this report: Claude Code (Claude Opus 5.5).

@Alpha325

Copy link
Copy Markdown

I tested PR head 1f282c737b5637b58de4847cacde208d23504ed7 on Radeon RX 9060 XT with a local test-only fixture. The existing reuse test covers two batches that fit the same buffer. This fixture forces the buffer to grow and checks that a rejected item doesn't disturb the other uploads.

  1. A small upload allocated a 4 MiB staging buffer.
  2. A second batch contained a valid 6 MiB texture, a texture with one byte missing, and another valid texture. The buffer grew to 8 MiB, and the batch reported only index 1 as failed.
  3. GPU readback matched both valid uploads byte for byte. The rejected texture retained its previous contents. A later small upload reused the same 8 MiB buffer and also read back exactly.

Results: 17 focused upload and detiling tests passed, with 0 failures, 0 ignored, and no skips. Windows 11, Radeon driver 32.0.32029.2010, Rust 1.100.0 MSVC x64, release. Synthetic fixtures only. This covers buffer growth, reuse, and per-item error handling. I did not measure performance or test GPU timeouts.

AI use: OpenAI Codex (GPT-6.2 Sol) wrote the fixture, ran the tests, and drafted this report.

@theaustinayers
theaustinayers merged commit 9ce2070 into xcl-dev:main Nov 24, 2026
1 of 2 checks passed
@tiagonleal

Copy link
Copy Markdown
Contributor

After the merge, for the record: #440, #451 and #458 side by side on the retail title's intro video (RTX 5070 Ti)

The three PRs sped up the same path (title_textures::refresh → Chain::detile_level). I measured them against each other on the retail title (one machine, one procedure) before this was merged; the numbers agree with the choice, and #458 (still open) is below #451 here.

Setup: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 32.0.16.1742, 32-lane waves), Ryzen 7 9800X3D, 31 GB RAM, Windows 11 Pro build 26300, rustc 1.100.0 MSVC, DXC 1.8.2502.11 (SDK 10.0.26100), cargo build --release -p xcl. Title 1.0.2.1, unpacked, learned coherent window and warm DXIL cache (same for every build).

Builds: main 2997c9a; #440 be722a7; #451 1f282c7; #458 a173fe0 as it is and merged onto main 2997c9a. #440 and #451 are on a6f5f7a, which differs from 2997c9a only in the README.

Procedure: xcl run for 100 s with XCL_NETWORK=0, XCL_ACTIVITY=1, XCL_PRESS_AT=30:A (A on the account picker; the intro video starts right after). Intro fps = presents per second in the activity windows from 38 to 48 s. Two rounds, builds alternated (main, #440, #451, #458, #458 on main, then again).

build intro fps (round 1 / 2) leaves the intro (commit +1 GB) presents in 100 s peak commit
main 6.5 / 4.2 not within 100 s 888 / 882 15.6 / 15.0 GB
#440 18.9 / 25.2 66 / 60 s 1238 / 1405 25.2 / 25.4 GB
#451 28.5 / 29.9 56 / 56 s 1753 / 1868 30.4 / 30.5 GB
#458 27.4 / 22.5 58 / 62 s 1474 / 1530 26.8 / 26.8 GB
#458 on main 22.7 / 22.8 60 / 62 s 1514 / 1484 26.8 / 27.2 GB

Not tested: AMD, other CPUs, the PRs' unit tests on this machine (only the title runs above), debug builds, a full cargo test --workspace on each head.

AI use: Claude Code (Claude Opus 5.5) built the five binaries, ran the title and the thread dumps on my machine, computed the numbers from the logs and wrote this comment.

Geckomacabre added a commit to Geckomacabre/gexcl that referenced this pull request Nov 24, 2026
Upstream rewrote the title texture system the fork had also changed
(ivall#248 shared VRAM pages, retire_overlapping, ivall#451 reused upload memory,
ivall#486 unchanged textures not uploaded, detiling on several threads): its
title_textures.rs, vram.rs, device_x.rs and texture.rs are taken as they
are, and the fork's own versions of those (streamed textures on pages and
own tiles, dead-texture eviction, async uploads, release counters) and their
XCL_ACTIVITY lines are dropped.

- kernelx/lazy.rs: upstream's `allows` retry replaces the fork's retry of a
  lazily mapped page another thread committed; `state` stays (diagnostics)
- dstorage.rs: the fork keeps holding a request whose page entry is still 0
  (up to HOLD_MAX) instead of upstream's single re-read when it runs;
  upstream's test of it waits out the hold
- present.rs: upstream's FPS in the title with the fork's count of the
  pipelines waiting to be built

cargo test --release -p xcl --lib -- --test-threads=4 (RTX 4090):
645 passed, 0 failed, 24 ignored; SKIPPED (no wave64): 2.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1984742628
1984742628 deleted the perf/reuse-upload-memory branch November 24, 2026 02:26
Mavixot pushed a commit that referenced this pull request Nov 24, 2026
Before each upload of a title texture, and before hashing it to see whether
it changed, its memory was copied into a new zeroed buffer of its size
(read_committed). The copy, a fresh allocation and its page faults every
time, cost as much as the detile itself: GTA VI's intro video re-uploads
its 3840x2160 and 1920x1080 R8 planes several times a frame.

title_bytes now hands out the title's memory where it is when the whole
range is readable (gpu::shader::readable), and the page-by-page copy as
before when it is not. The 2D slices, 3D textures and the unchanged-content
hash take it.

Measured on an RX 5700 XT / Ryzen 5 2600 during the video (release, a
local counter around the upload batches, with a row-at-a-time detile like
the one #451 merged): reading and detiling 0.9 -> 0.4 s of every 2 s,
36 -> 54 presents per 2 s.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ryosen0 added a commit to ryosen0/xcl that referenced this pull request Nov 24, 2026
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 24, 2026
…l#486, ivall#574, ivall#602, ivall#634, ivall#636

Upstream's texture detiling and uploads replace the fork's (ivall#440 and the threaded detile); its disk cache of driver blobs (ivall#634) replaces the fork's first version.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
Check every tiling mode, element size and pipe configuration: offsets
one-to-one and in bounds, equal to addrlib's swizzle equations across
the full coordinate range (guarding xcl-dev#435), tile / detile round trips,
the detile fast paths from xcl-dev#451 and xcl-dev#602 against a texel-by-texel
reader, mip chains and volumes without overlaps, and invalid input
giving None.

Assisted-by: Claude Code (Claude Opus 5.5)
@ArturoWolff

Copy link
Copy Markdown

Follow-up to the AMD growth/reuse test: reuse worked here too. The remaining cost I could isolate was temporary overlap when a completed upload buffer grows, not retained memory after the batch.

On a Linux RTX 4060 (8 GB, NVIDIA 620.73.04, GE-Proton11-14), I ran a game-free RGBA8 fixture on 47efa2ecea0a12934719ae69b81930cf02a4b1c3: four batches needing 4, 8, 8 and 4 MiB, same destination textures on both builds. At the 4 → 8 MiB step:

Driver-reported allocation order (vkd3d memory type 2) After growth
Main allocate replacement → 12 MiB; free old buffer → 8 MiB 8 MiB
Private change release completed undersized buffer → 0 MiB; allocate replacement → 8 MiB 8 MiB

The later equal/smaller batches made no new type-2 allocations. All six 4 MiB texture readbacks per build matched the expected bytes. A separate destruction-notifier test confirmed the old resource was gone before replacement creation only on the changed build. The change is limited to the synchronous upload_batch path: release only a completed cached buffer that is too small, and drop the batch-local reference before publishing the uploader back to the pool. No change to in-flight or timed-out work.

gpu/texture.rs is unchanged between that tested revision and 930e8b4 (source comparison only). Not a measured retail saving, a reduction in final footprint, or a Windows smoke result. If investigating this on a title, the useful measurement is the old/new capacity of the same completed uploader at growth; matching allocation sizes in a driver log alone don't identify the owner.

AI use: Hermes Agent (gpt-6.2-astra) built the private fixture and candidate, ran the tests, and checked the driver logs and readbacks.

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.