Skip to content

GPU: refresh directly indexed SRVs that share a page as one range - #462

Closed
desplmfao wants to merge 3 commits into
Marvisak:mainfrom
desplmfao:fix/direct-srv-merge
Closed

desplmfao wants to merge 3 commits into
Marvisak:mainfrom
desplmfao:fix/direct-srv-merge

Conversation

@desplmfao

@desplmfao desplmfao commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #185 (its two commits come first); review that first.

GPU hangs: not tied to this change. Xid 109 (CTX SWITCH TIMEOUT) ended runs both with and without it, 3–4 min after start, as it does on this machine without any of these changes (#71). Last pair, same build, #436 and #462 switched off and on together: off hung about 4 min after start; on had not hung when stopped at 4.5 min. Too few runs to say whether either makes it come sooner or later. With #493 (+#336) added, four runs with these changes on went 7.5–10 min without a hang, so the hangs were most likely what #493 fixes (reads past the end of root SRVs); see the comment there.

Same pair, last frames in the world: off 5.0–6.2 s per frame (862,000–929,000 direct SRV ranges), on with #436 and #462 2.4–4.2 s (280,000–290,000 ranges).

Unwatched copies: most of them came from write-watch questions over ranges spanning several allocations, which the kernel refuses as a whole; that is #515. With #436, #462, #515 and #464/#514 together, unwatched copies fell to 1–81 MB per world frame, and the median world frame from 6.0 s (none of these) to 3.0 s; what is left is bound by CPU time per range rather than bytes.

Problem

#185 refreshes the live directly indexed SRV ranges before each submission, merging only ranges that overlap. In the world most of them are small and close together but do not overlap, so each becomes its own Shadow::update, with its own write-watch query: about 900,000 updates per world frame here, which took 7–8 s of each frame to prepare.

Change

refresh_direct_srvs also merges a range of the same buffer that starts in the page where the previous one ends (or at its end). The bytes between them are under a page; update still leaves out ranges shaders may be writing.

Measured

RTX 5080, Linux (proton-cachyos, vkd3d-proton 3.2.0), Series X 1.0.2.1. Diagnostics build of main d2a4bae + #185 + #436 + #440 + #259, #177, #151 (needed to reach the world here), one run with and one without this change, Enter into story mode at about 35 s, first 1–2 min in the world:

per world frame without with
direct SRV ranges 862,000–920,000 267,000–288,000
direct SRV preparation 7.0–8.2 s 4.5–5.5 s
frame time 7.2–9.6 s 5.1–7.6 s
direct SRV bytes copied 2.5–3.8 GB 4.2–6.4 GB
bytes copied unwatched 2.4 GB 3.1–4.8 GB

More bytes are copied: a merged range also covers the gaps between views, and a merged range whose write-watch query fails (it reaches uncommitted private memory) is copied whole. That case is a follow-up: the failing ranges start in reserved, uncommitted pages of otherwise watched buffers.

Related

Tests

New directly_indexed_srvs_in_one_page_refresh_as_one_range in #185's coherency tests: 16 small SRVs in one page refresh as one range and each still reads its own value; it fails without the change (16 ranges). All 9 coherency tests pass on the GPU (vkd3d-proton, VICTORY_PC_DXC set).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

aycow and others added 3 commits November 23, 2026 20:11
refresh_direct_srvs merged only overlapping ranges. In the world most
directly indexed SRVs are small and close together without overlapping,
so each became its own Shadow::update with its own write-watch query:
about 900,000 per world frame.

Also merge a range of the same buffer that starts in the page where the
previous one ends, or at its end. The bytes between them are under a
page, and update still leaves out ranges shaders may be writing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

Copy link
Copy Markdown
Contributor Author

Thanks for measuring. One thing to separate: your comparison is #185 + this PR against neither, since this one is stacked on #185. The per-view watches you see come from #185's refresh of directly indexed SRVs, one write-watch question per range before every submission; this PR merges ranges that share a page, so it lowers that count rather than adding it.

With #185 in both builds (RTX 5080, proton-cachyos / vkd3d-proton 3.2.0, Series X, world frames), this PR took direct SRV ranges from 862,000–929,000 to 280,000–290,000 per frame and frames from 5.0–6.2 s to 2.4–4.2 s, as in the description.

What you measured is still real: under Wine each of those questions is expensive, so #185 makes loading and world frames much slower there. I'm working on that next: asking once per buffer and submission for the written pages over the span its ranges cover, instead of once per range. In a synthetic test (8 views into one watched buffer) that is 1 question per submission instead of 8, and #185's coherency tests still pass. It is being measured in the world now; I'll link it here with numbers once it holds up. Over several allocations it relies on #515 (asking per allocation when a span covers several).

AI-assisted (Claude Code).

@desplmfao

Copy link
Copy Markdown
Contributor Author

Follow-up to the above: the per-range questions you measured are in draft #600 now. It asks once per span of title memory instead of once per range, across host copies (most ranges are in different small buffers, so per-buffer grouping alone did not help).

Same stack with and without it, write-watch questions per frame: menus about 3,500 → 223, loading 3,500–6,400 → 900–3,600, world 165,000–184,000 → 80,000–162,000. The world gains little so far because most of its ranges reach the title's GPU heap of physical-page views, which cannot be write-watched and still go one by one; that is the next step, described in the PR.

AI-assisted (Claude Code).

desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 24, 2026
Resolves the overlap in refresh_direct_srvs: Marvisak#462's page-sharing merge
condition in this branch's loop, and both PRs' tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ghost ghost mentioned this pull request Nov 24, 2026
@desplmfao

Copy link
Copy Markdown
Contributor Author

Closing in favour of #185 as it is now: its later commit 53e36e7 builds the uncovered ranges per host copy and hands them over together, and skips ranges unchanged since the last submission, which covers what this PR did and more. Measured here (RTX 5080, Linux / proton-cachyos, world frames): old #185 + this and three other PRs 4.3 s per frame, new #185 alone 2.9 s.

AI-assisted (Claude Code).

@desplmfao desplmfao closed this Nov 24, 2026
Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…d there

A fresh descriptor table's constant buffer was filled into the list's
upload memory from title memory on the CPU at the submission, unless it
lay where shaders had been seen to write (VICTORY_FILL_HOT /
VICTORY_FILL_DIRECT). A fill reads title memory behind every flight that
may write it. Now a constant buffer that lies in a title buffer's host
copy in the card's memory, 256-byte aligned there, is bound to that copy,
as the hot ones are: the copy takes the title's bytes before the
submission's lists run, so the draw sees them and what earlier lists
wrote, from the card's own memory. Only a copy that is there already is
taken (shadow::existing); none is made for it.

Measured by the source line only on an RTX 4070 with the Series S
profile (realblastex/flamingo run 41: 10.7 -> 11.1 frames a second, no
fill waiting for the card); not measured here. On by default as the hot
case is; VICTORY_CARD_CONSTANTS=0 fills them as before. README: the table
in "Faster settings".

Source: theinkbit/victory-lot9-next ffd04e130 (also crt4ever/
DumbFloridaMoron 40acb8854); fxceless/victory-fork PRs Marvisak#462 / Marvisak#522 solve
the relay's form of the wait, which our tree does not run by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants