GPU: fast-skip clean/idle bindless textures and lazy-reset upload list #3484
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3484
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3484"
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?
@Desamodeth on GitHub · 2026-11-27 07:42 UTC · original
Desamodeth:opt/bindless-uploads→main· +423 −121 · 4 files · 2 commits · openProblem
In #3425 (frame budget breakdown),
bindless::uploadswas measured at ~10.1 ms/frame with no open PR targeting it. On every submission (~24/frame),bindless::uploadscurrently:texture::recycle(),list.reset()(D3D12CommandAllocator::Reset+CommandList::Reset), andlist.close()even when zero textures changed.doneandstagedHashSets every submission and holdsviewed.inner.lock()across the entire scan of all bindless textures in the heap — callingresource::made_copy(Resource::hostlock +Arc::clone),texture::staging(a secondResource::hostlock +HostTexture::staginglock +GetCopyableFootprints/watch::trackon first use!), and cloning every recent clean texture intoworkonly forrefresh_allto discard it.work, allocatesVec<Mutex<Option<Upload>>>even for a single dirty texture, and issues oneResourceBarrierper texture forCOPY_DESTtransitions instead of batching them before copies.Changes
crates/victory-gpu/src/resource.rs:HostTexture::staging_dirty_bit: AtomicU32(STAGING_UNINIT/STAGING_ALWAYS_DIRTY/watch::DIRTYbit) andbindless_upload_check(this, presented)to check dirty bit,used_recently_at(presented), andhost_writtenunder oneResource::hostlock with zeroArc::clonefor skipped textures.STAMP_EPOCHbumped on host-copy attachment andHostTexture::stamp_atframe changes so idle/unstamped textures without staging skipResource::hostlocks within the same epoch.give_up, callbindless::clear_texture_bits(&cleared)after droppingTEXTURES_AT/GIVEN_UPwhilegonestill holds each evictedHostTexturealive (preventing stale dirty-bit reuse).crates/victory-gpu/src/texture.rs:staging_for(resource, copy)(reused bystaging) to avoid a redundantResource::hostlock and publishcopy.staging_dirty_biton creation.refresh_allfor 0 or 1 dirty texture (avoidingVec<Mutex<...>>and thread-scope overhead).record_uploadwithrecord_uploadsto batchCOPY_DESTbarriers into oneResourceBarrierbefore copies andSHADER_RESOURCEbarriers into oneResourceBarrierafter copies.crates/victory-gpu/src/bindless.rs&crates/victory-gpu/src/host.rs:(slot_count, cached_dirty_bit, idle_epoch)inInner::texturesso clean tracked textures take a lock-freewatch::clean_bitfast path and idle textures skip rescans within the sameSTAMP_EPOCH.done: HashSetfor single-heap submissions andstaged: HashSetfor <=8 dirty textures.texture::staging_foroutsideviewed.inner.lock()so title descriptor writes do not stall behind staging/watch setup.list.reset()/list.close()until at least one upload is actually ready, gatetexture::recycle()onneeds_recycle, and release held list references inDrop for UploadsviaHostList::clear_held()so skipped resets never pin evictedHostTextures or staging buffers.Verification (synthetic fixtures only, no game files)
main@63bcca43cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings(default and--features diagnostics) clean;cargo xtask policy(191 files ok).--test-threads=1):bindless::5/5 (including 2 new regression tests:cached_dirty_bit_reuploads_after_write_and_after_evict_recreateanduntracked_bindless_texture_reuploads_on_memory_change),texture::2/2,heap_textures2/2,resource::tests::18/18 — all pass.VICTORY_D3D12_WARP=1,--features diagnostics,--test-threads=1):bindless::5/5,texture::2/2,heap_textures2/2,resource::tests::18/18 — all pass.Release Benchmarks on RTX 5070 (6 forward+reverse interleaved pairs = 12 runs each, median
[min..max])Synthetic fixture: 2,048 tracked bindless 64x64 RGBA8 textures (512 recently stamped + 1,536 idle/unstamped) + 64 table textures, real D3D12
HostTexture/Staging/upload list on RTX 5070:main(63bcca43)opt/bindless-uploads[2,456.4..2,470.1][69.6..80.7][2,645.2..2,677.6][263.2..372.0][344.2..397.6][254.6..310.2][1,111.5..1,139.4][57.2..66.7][1,110.0..1,133.5][370.0..381.7][456.6..498.5][456.9..558.2](Microbenchmark timings only; full-title frame-time impact should be measured separately on a real scene.)
Trade-offs & Compatibility
AtomicU32) toHostTextureand 16 bytes (Option<u32>+u64) per distinct viewed texture inbindless::Viewed::textures.Viewed::set/forgetreverse index) and #3213 (Resource::dropguard).#issuecomment-7212539762).AI-assisted with Gemini 4 Neon.
@oni-swr on GitHub · 2026-11-27 08:05 UTC · original
WARP verification of PR #3484 (claimed on #1633). No physical GPU, no game files.
Setup: Windows 11 build 26200, WARP adapter (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1, dxil.dll from Windows Kit 10.0.26100 x64), rustc 1.98.1.cargo test -p victory-gpu --features diagnostics(the feature is needed, orVICTORY_D3D12_WARPis ignored inhost.rs),--test-threads=1. Base63bcca43vs head3b18e7ab, built in separate checkouts.Tests:
The two extra tests are the PR's new ones,
cached_dirty_bit_reuploads_after_write_and_after_evict_recreateanduntracked_bindless_texture_reuploads_on_memory_change. Both ran and passed. Theirno host GPUearly return was not taken: with it replaced by a panic in a throwaway local edit, they still passed.Review (read the diff, nothing found that blocks):
watch::DIRTYbit reads clean. Writes set the bit, so the next submission re-uploads (the new test covers this). Textures with no bit (untracked, or bit pool full) staySTAGING_ALWAYS_DIRTYand are still checked bymaybe_changed(), as before.host_writtenonly goes false to true, so skipping it is stable.give_upclears the cached bits (clear_texture_bits) while the evictedHostTextureis still alive, so a recycled bit can't make a recreated copy look clean.needs_recycledeferstexture::recycle()to the next non-empty submission. Pending uploads are not dropped: the dirty bit is consumed only insiderefresh_all, and anything it returns is recorded.Drop for Uploadsclears held resources after the wait.inner, thenResource::host). Staging creation now happens outside the heap lock, so it takes fewer locks than base.bindless.rsgains a leading BOM (U+FEFF).STAGING_*consts andSTAMP_EPOCHsit betweenHostTexture's doc comment and the struct, so that doc now attaches to the const.staging()has an unused_textureparameter.Timing: not measured (no real GPU, and WARP timings wouldn't say much about the real upload path).
AI-assisted: verification run with Claude Code (Claude Sonnet 5.5).
@Desamodeth on GitHub · 2026-11-27 12:12 UTC · original
Tested
74722f9con a native Windows RTX 5070 12 GB (621.40) in the opening car cutscene. Four A/B/B/A runs used the same save and cache seed, with 128 matched Present intervals per run. Both builds included #2885 and identical instrumentation.Mean CPU time in bindless upload preparation fell from 34.94 to 20.53 ms/frame in the first pair and 28.31 to 21.50 ms/frame in the reverse-order pair. Full-frame p95 also fell (1,136 → 964 ms and 1,048 → 990 ms). Median frame time moved in opposite directions (564 → 571 ms and 563 → 558 ms). The preparation saving reproduced on hardware. These runs show no consistent change in median frame time or peak local VRAM.
Measured locally with Codex assistance.
@neonbyte1 on GitHub · 2026-11-27 14:11 UTC · original
Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, warm caches. Base:
mainplus the unmerged PRs this setup needs (listed in #3425); this PR (head3b18e7ab) merged on top with one conflict inhost.rs's list reset (our base had grown that body; it now sits in aclear_heldthatresetand the lazy reset both call). 420 s runs, medians of the last 30 frame-rate lines; the controls ran directly before and after.So about −8.5 ms a frame, all of it on the CPU's preparing side, which is where
bindless::uploadssits (~10 ms a frame on this setup, from an earlier breakdown in #3425). This build has no time counter for that function itself, so the attribution is by where the time went, not a direct reading. No crash, no device removal; the pictures at frames 1700 and 2048 have the same lighting as the controls, and differ from them less than the two controls differ from each other (camera framing and hint timing).Not run here: the PR's own bindless regression test, which needs a D3D12 device.
AI-assisted (Claude); measured on my machine, no game data shared.
@pickles976 on GitHub · 2026-11-27 14:42 UTC · original
Focused Wine/NVIDIA verification of exact head
74722f9cc302d1f0823726eef4e395cdee3cceae:DXVK_CONFIG='dxgi.hideNvidiaGpu = False'.2576c0b4adfae4a+(local console-vtable assertion relaxations; not stock-vkd3d certification).Compiling victory-gpu v0.1.0 (.../VIctory-pr3484/crates/victory-gpu).cargo test -p victory-gpu --lib 'bindless::' -- --nocapture --test-threads=1: 5 passed, 0 failed, 0 ignored in 0.70 s.cached_dirty_bit_reuploads_after_write_and_after_evict_recreateanduntracked_bindless_texture_reuploads_on_memory_change, alongside the existing heap-view/range cases.Evidence: local log
.compat-runtime/logs/verify-pr3484-wine-bindless.log.This verifies the changed bindless ownership/dirty-tracking behavior on Wine/RTX 4060. I did not run the release microbenchmark or a matched title loading trace, so this result does not independently establish the reported speedup or full-title frame-time impact.
@pickles976 on GitHub · 2026-11-27 15:28 UTC · original
Local matched upload-preparation benchmark now corroborates the clean/sparse-write fast path on Wine 11 / Linux 6.17 / i7-13620H / 16 GiB / RTX 4060 Laptop 8 GiB, NVIDIA 590.48.1. Exact production base
63bcca43c6a00a758510398fa43096ce7e4f7df0versus head74722f9cc302d1f0823726eef4e395cdee3cceae, identical temporary ignored benchmark on both. Fresh intended-worktree release builds (including local dependency roots), vendor masking disabled, diagnostic-relaxed vkd3d2576c0b4adfae4a+; not stock certification.2,048 tracked 64x64 RGBA8 textures, 512 stamped active. After initial preparation and clean warm-up, 21 samples of 24
bindless::uploadspreparations for each dirty count. Dirty texture bytes change on every preparation; fixture checks list presence and exact upload-count increments. Timing includes CPU writes/VEH, preparation and dropping the upload holder. Real host resources, but the recorded upload lists are not submitted: this measures CPU preparation, not GPU upload completion, rendered frame time or a retail loading sequence. Same current title/shader cache was not involved.Clean/single-dirty medians fall 98.5%/93.7%, with non-overlapping sample ranges. The 16-dirty ranges overlap widely; do not interpret its median alone as a stable speedup. One base→head process pair, no title A/B. Both fixtures passed 1/1 with no skips. Across these two guarded commands, GPU peak310 MiB, minimum availableRAM11552.6 MiB, disk minimum14.464 GiB; 9 GiB/512 MiB scope/global guards unchanged.
The first draft benchmark rewrote the same byte on repeated calls yet asserted every call must upload; the base correctly skipped an unchanged hash and that harness failed. Changed the stimulus to distinct bytes before the matched passing pair; not a PR defect.
Evidence
.compat-runtime/logs/verify-VIctory-pr3484-bench-base-bindless-bench-changing-20261127T152635Z/andverify-VIctory-pr3484-bindless-bench-changing-20261127T152711Z/. Temporary includes removed after measuring; exact local fixture archived asbindless-bench-source.txtfor reproduction. Together with the preceding 5/5 functional bindless checks, this supports the optimization mechanism locally. It does not establish that our loading stutter is fixed or clear the unrelated Wave64/BVH title-promotion blockers.@pickles976 on GitHub · 2026-11-27 15:50 UTC · original
Early-loading follow-through on the same exact production refs: base
63bcca43c6a00a758510398fa43096ce7e4f7df0versus #348474722f9cc302d1f0823726eef4e395cdee3cceae. Fresh diagnostics release builds (43.95/42.37s); no engine source probes or shader-backend substitutions. Same Linux6.17/Wine11/i7-13620H/16GiB/RTX4060Laptop8GiB/NVIDIA590.48.1 and diagnostic-relaxed vkd3d2576c0b4adfae4a+, vendor unmasked; not stock certification.One base→head pair, 60s each. Each gets a fresh copy of the identical saved cache/data/vkd3d-cache seed, using a temporary lab-launcher path override; original live state is untouched and the launcher is restored afterwards. Both visibly show the account picker, one focus-checked live A at ~29s advances to the six-star intro, and the 35s/55s observations show the same intro/loading-art stages. No scene or gameplay. No shader approximation or guard changes.
Existing
VICTORY_LOG=info,victory_gpu::frame=debugtimestamps measure CPU intervals afterPresentreturns, not GPU-completed/displayed frame times; existing code ignores Present's HRESULT. Preselected comparison window: 5–25s after the live input call begins; nearest-rank percentiles, no token gaps.This pair does not demonstrate a tail-latency improvement attributable to #3484; one pair with uncontrolled OS/driver warmth is also insufficient to establish a regression. The local user watching the latest run independently reports a “buttery smooth splash screen” and “a little bit of stutter during loading, but significantly less.” Record that observed improvement separately: its comparison baseline was not specified, and the narrow controlled pair does not isolate its cause. The earlier preparation microbenchmark still establishes the clean/sparse-write CPU saving.
Both stopped at the 60s wall limit/137, not a resource cutoff. Base/head minimum available RAM4547.7/4653.8MiB, GPUpeak3341/3337MiB, scopepeak5643.2/6019.5MiB, diskminimum13.924/13.720GiB. Starting availableRAM11915.7/12207.7MiB. Both scopes inactive/success; queried kernel intervals empty. Requested mode1920x1080/window1280x720, actual swapchain3840x2160; native FFX context reports1280x720→1920x1080. These loading observations do not certify gameplay resolution or frame rate.
Evidence
.compat-runtime/logs/loading3484-20261127T154000Z/{cadence-summary.json,hitch-times.json,rendering-configuration.json}, guard prefixes20261127T154507Zand20261127T154702Z, exact binary hashes/build logs/input timestamps retained. Screenshots remain local. The preliminary namespace-isolation attempt never launched Wine (nested namespace denied); corrected launcher-path isolation then passed a separate20s startup before this pair. No additional loading retry is justified by these results alone; later-loading/display-pacing attribution still needs a shader-cleared runtime and a consumer-visible timing capture.maincan take merges more often #3347View 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.