Skip the global texture lock when no host-written textures #152
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/Belobug--VIctory-Belobug-AMD!152
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-152"
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?
@Adika713 on GitHub · 2026-11-25 17:25 UTC · original
Adika713:perf/host-written-fast-path→main· +101 −17 · 1 files · 1 commits · openSTATUS: opened as #146 (head
TBD).Skip the global host-written-texture lock when it is empty.
Every texture use asked
HOST_WRITTEN, a globalMutex<Option<HashSet>>, whetherthe texture had been written by a host copy. Most submissions have no such
textures, so that was a lock/unlock just to read an empty set. An
AtomicBoolnow records whether the set has anything; readers skip the lock while it is
false. Writers keep the flag in sync while holding the same mutex.
What is in it
HOST_WRITTEN_ANYplusis_host_written();host_written,rewritten,forget,upload_firstanduploaduse them.Tested
AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11,
rustc/cargo 1.98.1. No game data; the game was not run. Isolated
CARGO_TARGET_DIRper tree.cargo test --release -p victory-gpu --lib host_written_check_fast_path -- --ignored --nocapture --test-threads=1,3 runs, median of 5 samples each:
Correctness:
cargo check -p victory-gpu --lib --tests --locked: exit 0.cargo test -p victory-gpu --lib texture:: -- --test-threads=1: 6 passed, 0 failed, 1 ignored, 110 filtered.victory-gpulib, 20 serial runs with the pre-existing #102 flake skipped: 0 failed; each 111 passed, 0 failed, 5 ignored, 1 filtered.cargo test --workspace --no-fail-fast --locked: no new failures; known xmem, shader and policy failures remain.victory-gpu112 passed, 0 failed, 5 ignored.Not tested
about frame rate.
first_usebefore the same lock inupload; if bothchanges land, that hunk needs rebasing. The fast path also benefits
upload_first, which #127 does not touch.AI use
AI-assisted: OpenCode, model Big Pickle. No game data.
@KernelSmoker on GitHub · 2026-11-25 17:36 UTC · original
Tested PR head
f637727on Bazzite Linux 45, with GE-Proton 10-34 / Wine 10.0 and vkd3d-proton 3.0.0, on an NVIDIA GeForce RTX 3090 (host driver 620.73.04). No game files were needed.Cross-compilation of the Windows GNU
victory-gputest target succeeded. Under Proton, the targeted regression testtexture::tests::host_written_flag_clears_with_the_last_texturepassed (1 passed, 0 failed). The fulltexture::filter also passed: 6 passed, 0 failed, 1 ignored (the synthetic CPU release benchmark), 110 filtered out.This is a Windows test binary running through Proton on NVIDIA, not a native Windows run. I did not use the ignored benchmark for performance claims because Proton timings would not be comparable to the native Windows measurements.
@gut0to on GitHub · 2026-11-27 14:43 UTC · original · reviewed
AI-assisted static review (ChatGPT); I inspected the locking path but did not run tests.
@ -171,0 +175,4 @@/// Whether a host copy or resolve has written `resource`.fn is_host_written(resource: usize) -> bool {if !HOST_WRITTEN_ANY.load(Ordering::Acquire) {@gut0to on GitHub · 2026-11-27 14:43 UTC · original
This fast path can observe
falseafter the resource has been inserted intoHOST_WRITTENbut beforeHOST_WRITTEN_ANY.store(true): the writer holds the mutex across both operations, while this branch returns without taking that mutex. That contradicts the comment below and can classify a host-written texture as untouched. Could the flag be published before insertion while holding the lock, or could the false path synchronize with the writer, with a deterministic test for this interleaving?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.