perf: a draw's texture read looks its host side up once #443
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!443
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-443"
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?
@KainanP on GitHub · 2026-11-26 18:53 UTC · original
KainanP:perf/texture-read-once→main· +161 −30 · 5 files · 1 commits · openPort of Marvisak/VIctory#3258 (mine) to this tree's
draw::readable. Vice-Tay already has half of it (a host texture keeps its resource flags, andHostList::transitiontakes the legal state from them); the other half, one host-side lookup per texture read, is not there.The problem
Every texture a draw or dispatch reads through a view goes through
draw::readable. For one texture it looks the title texture's host side up three times:resource::host_copyfor the upload check,HostList::twin_use→resource::twin, andlist::ensure_state→HostList::transition→host_copyagain. Each lookup (resource::hosted) takes the texture'smademutex, reads the clock and clones twoArcs; title threads (or, withVICTORY_THIN=1, our translating threads) drawing with the same textures queue on the same per-texture mutexes.ensure_statealso asks the driver for the texture's description (legal_state→GetDesc) for each barrier it records.The change
resource::host_sidereturns the host copy and the twin from one lookup.HostList::transition_held,list::ensure_held_stateandHostList::twin_use_heldwork on a copy the caller holds.transition,ensure_stateandtwin_uselook the copy up once and call them, so every other caller gets the same answer.ensure_held_statetakes the legal state fromtransition_heldinstead ofGetDesc.readablelooks the texture up once for the upload, the twin and the state. A texture let go between the old lookups could give the upload and the barrier two different host textures; with one lookup it can't.resource::twinhad no other caller and is gone.The commands recorded are the same.
Measured
The list bench of #441 (
pipeline::list_bench,#[ignore]d). Each row: best of 5 × 20,000 calls; each build's test binary ran 7 times interleaved with the others, median [min–max]. RTX 4060 Laptop GPU, Core i7-14650HX, Windows 11, release profile. Quiet machine: no game running, Windows reported 0–31 % CPU load around the runs (mostly under 16 %).DrawIndexedInstanced, six textures, nothing changedDispatch(table: texture + UAV buffer)ExecuteIndirect, 1 indexed drawAbout 35 ns less per texture read on one thread (−15 % a draw), −20 % a draw on five threads. With #444 as well, the draw sequence on 5 threads goes 3267 → 2156 ns (placed views 4315 → 2347).
Tests
New,
draw/texture_read_tests.rs:a_texture_read_looks_its_host_side_up_oncecounts the host-side lookups (HOSTED_ASKED, test-only) of a draw's read: one. Withreadableput back ontwin_useandensure_state(main's path) it counts three and fails. It also checks the read still moves and uploads the texture as before.cargo test -p victory-gpu --release --lib, one thread: RTX 4060 Laptop 422 passed (main 421), Intel UHD (a78b,VICTORY_D3D12_ADAPTER=Intel) with #441/#444 too 428 passed (main 421), WARP (--features diagnostics,VICTORY_D3D12_WARP=1) with #441/#444 too: the same single failure as main (timeline::report::tests::real_waits_are_recorded_with_who_ended_them). Clippy (--all-targets, with and withoutdiagnostics): only main's warning.cargo xtask policyok, ruff clean.What this does not show
No in-game numbers: I don't run the title here. The bench's draw reads six textures; a title draw reads from none to dozens, so the saving scales with that. Please A/B it in game (frame time, or the translating threads' time with
VICTORY_THIN=1).Overlaps
git merge-treeagainst the open PRs that touchthird_party/victoryand merge with main: only #433 conflicts (both add a testmodline at the top ofdraw.rs; keep both). #441 and #444 merge with this in any order (built and tested together).AI use: Claude Code (Claude Opus 5.5) ported the change, wrote the tests, ran the measurements and drafted this description.
🤖 Generated with Claude Code
73b7eaf5bdtob4984d6156@KainanP on GitHub · 2026-11-26 20:21 UTC · original
Re-ported onto the combined base (#409) and force-pushed. The base already keeps the host texture's flags, so this is now only the single host-side lookup per read (it was 3). List bench of #441, median of 7 interleaved runs, RTX 4060 Laptop: draw with six textures 2133 → 1782 ns, draw sequence 1 / 5 threads 2095 / 5597 → 1747 / 4517 ns. With #444, 5 threads go 5597 → 3955. The new test counts lookups and fails on main (3 instead of 1). Description updated.
AI use: Claude Code (Claude Opus 5.5).
b4984d6156to2e0986b4eb@KainanP on GitHub · 2026-11-26 20:46 UTC · original
Main reverted #409 (#452), so this is back to the Neptune-base version measured in the original body, rebased onto
15024d5(RTX: its tests pass, and the suite gives the same results as before). The combined-base port is kept on branchperf/texture-read-once-combinedfor when it returns.AI use: Claude Code (Claude Opus 5.5).
perf: a draw's texture read looks its host copy up once, its flags keptto perf: a draw's texture read looks its host side up once2e0986b4ebto946b2de53c@KainanP on GitHub · 2026-11-26 23:48 UTC · original
Re-ported onto the Vice-Tay base (#454). The base already keeps a host texture's flags (half of this PR); the single host-side lookup per read was still missing, so that is what this PR does now. On
b6d86cf8(list bench of #441, quiet machine): draw sequence 1340 → 1134 ns on one thread, 3267 → 2629 ns on five (placed views 4315 → 3627); with #444, 2156 (2347). Suites on RTX, Intel UHD and WARP: same results as main. Description updated; the Neptune version is onperf/texture-read-once-neptune.AI use: Claude Code (Claude Opus 5.5).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.