Repository navigation
GPU: no texture layouts or name copies per draw for unchanged answers - #1978
0xkn0wh3r3 wants to merge 1 commit into
Conversation
VIctory V2: community PRs, merged and testedOpen PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: Unofficial community fork of Marvisak/VIctory, GPL-3.0. |
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
No per-draw texture layouts/name copies when answers are unchanged — draw-call CPU overhead reduction; caching must be keyed on everything that affects the layout. Windows perf validation needed.
|
@catminou4: nothing is cached here. Both changes compute the same answers as before, only in a cheaper order. |
|
Automated triage for the maintainers. Merge candidate (re-checked on Neither change alters any answer. The gain is unmeasured in a game run, but it removes per-draw work done under global locks. CI: passing ( Generated by Claude Code |
392b396 to
c05b669
Compare
…nchanged answers) into demo
…for unchanged answers
Two lookups every draw makes did work whose answer rarely needs it: - `resource::alias_source` runs for every placed view a draw reads and built the placed texture's full console layout (`texture_layout`, a mip chain of vectors) under the global `TEXTURES_AT` lock before looking at the other textures at its address. Most placed views have no texture the GPU writes at that address, so the layout is now built only once one is found; the cheap tests (another resource, written by the GPU, its own host texture) come first. Same answer in every case. - `memory::note_use` copied the pipeline's name into a new String on every draw that reads title memory, under the process-wide stats lock, even when the name was counted already. It now looks the name up first and copies it once per frame.
c05b669 to
bc51d6f
Compare
…for unchanged answers
|
Measured with a per-call list benchmark on main 63bcca4, with this PR merged on top (RTX 4060 Laptop, release build, median of 7 interleaved runs; method and full table in #2586 (comment)):
#3238 makes the same AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this comment. |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed crates/victory-gpu/src/memory.rs and crates/victory-gpu/src/resource.rs at bc51d6f6 merged onto origin/main (63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.
Code & equivalence audit
resource::alias_source(resource.rs:1792-1822): purely reorders predicates with no cross-draw caching (so no invalidation hazards). Filteringr != placed,a.desc.flags & WRITTEN != 0, and distinctmade(a)/made(b)Arcs first (resource.rs:1808-1819), thenwritten.peek()?(resource.rs:1819) before computingbytes(&b.desc)?(resource.rs:1820) andwritten.find(...)(resource.rs:1821), preserves exact return values and match order in every case while skippingtexture_layoutbuilds underTEXTURES_ATwhen no writable alias exists.made(a)drops its lock beforemade(b)locks, so there is no nested locking.memory::note_use(memory.rs:285-292): checkss.uses.get_mut(pipeline)(memory.rs:286) first and only allocatespipeline.to_owned()on first insertion per frame.- Merge note: expect a small textual conflict with open
#3245inalias_source(both are semantically composable).
Verification
cargo run -p xtask -- policy: 191 files ok.cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features): clean.memory:: resource:: draw:: texture::withVICTORY_D3D12_DEBUG=1: 47/47 passed on RTX 5090 (skipping the pre-existing NVIDIA 1M-caplists_share_a_table_and_copies_keep_their_views) and 48/48 passed on WARP (--features diagnostics, zero skips), plus a repeatednote_usecounting check.
The problem
Two lookups that run on every draw did expensive work even when the answer did not need it. Both run under a global lock, so the cost adds to every draw.
resource::alias_sourceruns for every placed view a draw reads. It built the placed texture's full console layout (texture_layout, a mip chain of vectors) under the globalTEXTURES_ATlock, and only then looked at the other textures at its address. Most placed views have no texture the GPU writes at that address, so the layout was usually built for nothing.memory::note_useruns on every draw that reads title memory. It copied the pipeline's name into a newStringeach time, under the process-wide stats lock, even when that name was counted already.The fix
resource::alias_sourcenow does the cheap tests first: another resource, written by the GPU, whose host texture is made (and is not this one's). It builds the layout only once such a texture is found. The answer is the same in every case.memory::note_uselooks the name up first and only copies it when it is new, so the name is copied once per frame instead of once per draw.Testing
cargo test -p victory-gpuon an RTX 5070 Ti (driver 621.24): all pass exceptdescriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, which fail the same way onmain(the NVIDIA 1,000,000-descriptor heap cap, NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #1835).cargo clippy -p victory-gpu --all-targets, with and without--features diagnostics: clean.Not covered
Not measured in a game run (no game data here). The answers are the same by construction.
Rebased onto 13f91ca
made). Before, it checked for a host texture of its own. The code of both changes is otherwise the same.