Textures: detile big subresources in bands on several threads #92
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!92
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-92"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@marquezinii on GitHub · 2026-11-24 21:25 UTC · original
marquezinii:perf/detile→main· +377 −15 · 3 files · 2 commits · openA sampled texture whose memory changed is detiled into its staging buffer on the submitting thread, subresource by subresource, at about 4.5 GB/s. That is 7-17 ms for one 33-67 MB texture, and it is part of the frame line's
texturestime (44-51 ms a frame in the 4060 Ti numbers in #10).This cuts the detile of a big subresource into bands of rows and runs them on the threads
shadow::wide_runalready keeps:victory-formats:Layout::detile_rowsdetiles rowsy0..y1of a subresource one slice deep into a buffer that starts at rowy0. It goes through the samewalkasdetile, with an optional row range, so the runs and their fixed-length copies are the same.victory-gpu:Staging::detilecallsdetile_wide, which cuts a subresource of 8 MiB or more into bands of about 4 MiB and hands them towide_run. Smaller subresources, and 3D ones, are detiled whole as before.Render targets in the
_Xmodes are not detiled on the CPU (the layout has no pattern for them), so this only affects sampled textures in theS/Dmodes, such as streamed textures and the ones the title rewrites.Checked
bands_detile_as_the_whole(formats): for every mode, mip and array slice, with block compression, odd sizes and padded rows, any band split gives the same bytes asdetile. Bad bands (past the mip, empty, too small, 3D) are refused.a_texture_detiled_in_bands_is_the_one_detiled_whole(gpu):detile_wideagainstdetileon big and small textures and their mips.wide_runhas three threads plus the caller here), release, best of 7:SW_4KB_S(33 MB)SW_64KB_S(67 MB)SW_64KB_D(67 MB)It levels off at about 8 GB/s from four threads, which looks like this machine's memory bandwidth.
cargo clippy --workspace --all-targets -- -D warnings(default and--all-features),cargo test -p victory-formats -p victory-gpuandcargo xtask policypass. Only my own lines were run through rustfmt; both files had older unformatted parts, which I left alone.Not checked: a run of the title, since I don't have the files here. How much of the
texturestime this removes depends on how big the changed textures are in a given scene: the read of title memory before the detile is still on one thread, and many small textures gain nothing. If someone runs it, thetextures N ms M MBpart of the frame line before and after is the number to compare.@ryotdev on GitHub · 2026-11-24 21:30 UTC · original
I tested
02c2743on Windows x64 with a Ryzen 7 7800X3D (8 cores, 16 logical processors). The large-texture speedup reproduced here.I compared the serial implementation from base
4e17478with the PR's banded implementation and worker pool. The native release microbenchmark alternated which version ran first, warmed both paths for four rounds, then measured 22 rounds per case. The table shows median CPU time per conversion, rounded. The machine had a game session open during measurement.All six outputs matched base byte-for-byte, including row padding. The formats suite passed 25 tests with 5 ignored, and the GPU crate's CPU test
a_texture_detiled_in_bands_is_the_one_detiled_wholepassed. The two cases below 8 MiB stayed on the serial path. I haven't measured this PR's effect on in-game frame times.AI-assisted test and report.
@adriaespii on GitHub · 2026-11-24 21:30 UTC · original
Independent test run on commit
02c2743(AMD RDNA4):x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test --workspace: 498 passed, 0 failed, 9 ignored (victory-formats: 25 passed, 0 failed, 5 ignored;victory-gpu: 111 passed, 0 failed, 2 ignored;victory-shader: 210 passed, 0 failed, 2 ignored)--ignoredbenchmarks and live game run (no game files on this machine)AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.
@BitWuehler on GitHub · 2026-11-24 22:40 UTC · original
Tested on CachyOS Linux (
Ryzen 7 9800X3D,RTX 5080620.73.04,GE-Proton11-14, release build) bundled with#95,#108,#159on top of4e17478+#454/#127/#154:victory-formats: 25 passed, 0 failed, 5 ignored underGE-Proton11-14(wine).victory-gpu: 114 passed, 1 failed, 3 ignored (only the knownCreatePipelineLibrarystub in vkd3d-proton fails;a_texture_detiled_in_bands_is_the_one_detiled_wholepasses).preparing: texturesdropped from596.55 msmedian (892.66 msmean) to91.30 msmedian (122.55 msmean;10.5 msin the final 5,426-draw frame).(AI-assisted build/log analysis.)
@LastThylacine on GitHub · 2026-11-24 22:42 UTC · original
An in-game data point on an RTX 5070 Ti, measured together with #95 and #108. Full table and setup: #108.
On one exe with a warm cache, a local switch turned the band detile on and off (D vs C: #95 + #108 with and without this PR):
In the opening scenes the texture time per megabyte is the same with and without bands. The frame difference is within run-to-run noise: two runs of the same configuration differ by 14% in median. My reading is that few refreshed subresources here reach the 8 MiB the band path needs (2 ×
BAND_BYTES). The cost there is many smaller textures, not a few big ones. This is not a regression: it merges cleanly with #95 and #108, the formats and gpu tests pass on the combination, and nothing went wrong in 8 minutes. A counter of the subresources that take the band path would show which scenes it helps. Streamed 4K textures later in the game are probably where it pays.AI use: measured and written with Claude Code (Claude Opus 5.5); posted with my approval.
@marquezinii on GitHub · 2026-11-24 23:20 UTC · original
Thanks to both of you for the in-game runs.
@LastThylacine, I agree with your reading. The A/B isolates this PR, and the same 0.33 ms per MB with and without bands means the opening scenes' texture time comes from many subresources under the 8 MiB threshold, plus the read of title memory before the detile, which stays on one thread. @BitWuehler, your drop from 597 to 91 ms comes with #95 in the same build, and #95 takes the texture refresh's waits for remappings away. That fits the A/B: most of that drop is likely #95's.
As suggested,
f31ad94adds the counter. In a diagnostics build the frame account line now readsN subresources detiled X MB, M of them in bands Y MB, per frame, so a run shows how much of a scene's texture work the band path even reaches. It is twocopystatcounters around the existing branch indetile_wide; nothing changes outside diagnostics builds. Both clippy runs and the detile tests pass with and without--features diagnostics.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.Merge
Merge the changes and update on Forgejo.