GPU: maintain shadow-buffer coherency for directly indexed SRVs #185
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!185
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/185/head"
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?
@aycow on GitHub · 2026-11-24 01:15 UTC · original
aycow:fix/direct-indexed-buffer-coherency→main· +5877 −280 · 26 files · 22 commits · closed without mergingStatus
The prior draft head
a6367baintegrated desplmfao's Wine fix and cross-shadow batching, preserving original commits9e94c21and9131c10. The same-reservation fallback check and PR description also credit desp's per-allocation and never-committed handling from #515 that informed481fb1a.Cross-shadow batching
The combined tree passed 16 selected tests each on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop and WARP with Agility SDK 1.620.2, the D3D12 debug layer and full GPU-based validation. Separate deterministic checks passed with batching both enabled and disabled. They cover older journal readers on overlapping shadows, pending GPU writes and copyback, reservation recommit, and observing a post-sample write in the next refresh.
On desplmfao's Proton workload, write-watch time was 776 ms on
1efd438, 662 ms after the Wine fix, and 22 ms with both changes. Frame time stayed within run-to-run spread. In separate AMD Windows synthetic runs, host preparation per 80 submissions was 3.061 → 1.344 ms for dense views, 3.205 → 4.119 ms for sparse views that fit one shared span, and 3.313 → 3.581 ms for gapped views that fell back. Exact-head title validation and a matched Linux preparation breakdown remain open. Synthetic methodology and profiling branch · Review testsA later matched warm-cache RTX 5080 Proton run toggled only shared spans on the same binary. Sharing reduced write-watch queries from 111,891 to 3,650 and watch time from 684 to 23.1 ms per world frame. Direct-SRV preparation was 2,391 → 2,052 ms and submission preparation was 2,439 → 2,350 ms. Frame time was 2,800 → 2,700 ms, alongside about 10% fewer direct ranges, so the run leaves overall frame-time impact unresolved. The contributor is profiling reservation lookups separately. Matched Proton report
The subsequent reservation-cache draft attributes roughly 1.8–2.3 s per sampled Proton world frame to reservation queries. Its locked per-pass cache produced a small preparation difference in the short runs. The cross-frame version still needs an ownership proof for commit state. An independent synthetic review observed a cached zero committed count after a native commit and before its mapping notification, while a fresh query saw 65,536 committed bytes. The draft remains separate. A separate diagnostics-only fixture tested the contributor's mapped-view hint without caching commitment or bypassing per-shadow refresh. For two learned mapped views and one private reservation, native Windows reservation queries fell from three to one. A same-address remap and an injected stale hint both preserved the refreshed bytes. There is no Proton timing result for this hint. Reproduction and coordination
Independent in-game A/B on
1efd438The testers held their respective stacks, settings and inputs fixed across
53e36e7plus #202 compatibility and1efd438. These results compare revisions of this PR.The AMD baseline contributed one comparable steady window. The NVIDIA run had one sample per build and differed in submissions per frame. Both reports still ended in device removal. GamingRipperDoc independently ran 78 Windows 10 tests with app-local Agility enabled, including the two binding regressions, and 77 with it disabled. AMD and Windows 10 report · NVIDIA report
On the fork PR's RTX 5080 Proton stack, the Wine fix reduced watch calls from 147,000 to 116,000 per frame. Its 2.9 to 2.6 s frame interval was within run spread. The combined revision passed the synthetic direct-SRV suite on AMD Radeon Graphics, RTX 5070 Laptop and WARP with Agility SDK 1.620.2 and full GPU-based validation, plus the Windows private/mapped-reservation classification tests. Exact-head title and Wine retests remain open. Wine test and measured stack
Earlier implementation and synthetic results
EricPlayZ identified three amplification mechanisms in the NVIDIA run and supplied the original implementation. His clean commit was kept with its original authorship on the local test branch, and the draft revision credits him as co-author. The two linked branches were compared against
c6bf7df. The measured stack was used to verify the configuration, including PR #202 and its local allocation, shader, and title changes. Performance report · Clean commit · Measured stackChanges in
53e36e7VirtualAllocorVirtualFreecalls change the backing pages. The allocation wrappers preserve flags andLastError.Synthetic performance
AMD, 320 submissions with four lists each. The stable heap contains 8,192 live descriptors and 1,024 merged ranges per submission over 128 MiB of title memory. It models 2,621,440 slot visits, 327,680 range visits, and 21.46 GB of logical direct requests. The fixture checks the shader result, pending GPU copybacks, committed data, and hole contents.
c6bf7dfc6bf7df+ #2020dd303b0dd303b+ #202Fully mapped baseline and clean-patch times are medians of three. Fragmented and revised timings are single samples. Fragmented preparation fell from 17.392 s at
c6bf7dfto 3.307 s in the revision. Repeated zero fills fell from 9.87 GB to zero. Composing the latest revision with #202 in a scratch worktree produced identical bytes and outputs and took 4.163 s in one fragmented sample. #202 substantially accelerated the original sparse fallback. PR #202Once the heap cache was warm, unrestricted indexing did zero repeated slot enumeration or sorting in this fixture. A separate fixed-slot control visited 320 slots across 320 submissions and filled 20.97 MB. The unrestricted mapped case still fills 10.42 GB where ordinary CPU memory has no dirty signal. Fragmented ranges still require 545,280 instrumented write-watch queries in the instrumented fixture, 327,040 failed bulk-read attempts, and mapping checks. The in-game cost of those paths remains to be measured.
Correctness and validation
19when the title wrote500to a committed 4 KiB island following a reserved prefix within a 64 KiB tracking page. The revised regressions exercise this layout and verify that a clean watched refresh retains live bytes without recopying holes.Exallocation APIs and deferredMEM_RESETdiscards are outside the guest notification path. PR #261PR #393's conventional batching and mapped guard fast path are complementary. PR #420 tracks selections for rebuilt root descriptor tables. This revision's completeness proof concerns emitted resource-heap handles. Both upstream patches and the measured title stack remain separate. PR #393 · PR #420
The next in-game comparison should hold the integration stack, title scene, and timing options fixed. Please include completed frames before any device removal, submission and heap counts, direct requested and filled bytes, and the top refreshed ranges.
AI-assisted with OpenAI Codex.
Earlier results through
c6bf7dfReproduction
VIctory schedules shadow-buffer refreshes for known vertex, index, root, and conventional table bindings. A shader can select a directly indexed heap slot without going through those paths. In a synthetic Shader Model 6.6 test on upstream
35b054e, the real VIctory descriptor and shadow path returned13after the title CPU changed its value to500. The patched path returned500with the same recorded list and descriptor. A separate fixed-index test covers the first use of a descriptor that has never gone through a conventional table.Implementation
Validation
cargo test --workspacecargo clippy --workspace --all-targetscargo fmt --all -- --checkcargo xtask policyandgit diff --checkDXC-compiled synthetic tests ran on AMD Radeon Graphics, NVIDIA GeForce RTX 5070 Laptop GPU, and Microsoft WARP. Each adapter reported Shader Model 6.6 and passed all five functional regressions. AMD also passed all five without diagnostics and ran the benchmark. A temporary local adapter selection forced the NVIDIA device. See the performance follow-up for the current debug-layer and GPU-based validation results.
Synthetic AMD benchmark
64 submissions with a one-million-slot heap, 1,024 populated overlapping SRV slots over 32 shadows, and one CPU-dirtied 64 KiB page per submission.
35b054eThe patched run visits 1,024 slots and merges them to 32 ranges per submission. A follow-up clean submission copies zero bytes. For 1,024 populated slots, the estimated metadata and peak snapshot payload total about 72 KiB, before tree and allocator overhead. This is a payload estimate rather than a process memory measurement.
Performance follow-up
The follow-up is
c6bf7df. On83963c5, the 12.21 MB attributed to direct SRVs is already included in the 23,025.1 MB aggregate. The aggregate also includes conventional shadow fills and requested lengths for deferred CPU copies and upload fills. The aggregate measures software-accounted logical bytes. Snapshots contribute to overall submission preparation, while texture operations and post-fence copyback have separate counters. Contributor A/B reportAn end-to-end AMD test confirmed one way a small direct refresh can produce substantial conventional traffic. The direct SRV read four bytes from an ordinary private reservation adjacent to a 16 MiB write-watched reservation. Both views used the same native shadow. The failed write-watch probe previously disabled tracking for the entire shadow, so later clean conventional ranges copied in full. The correction keeps the fallback local to the affected pages and preserves the fast path when an initially unclassified shadow fits in a single committed private region. It retains dirty-page tracking, pending GPU writes and the existing copyback behavior. Diagnostics now report conventional requested and filled bytes, allocation and watch activity, snapshots, copyback, and descriptor materialization. The top conventional ranges include failed probes for the same shadow.
The larger AMD fixture uses a 262,144-slot heap, 24,576 populated slots over 192 shadows, four lists per submission, and 1,920 dispatches per 12-submission sample. It revisits 294,912 slots and 221,184 merged ranges per sample. The mixed clean/dirty samples filled 145.9/147.2 MB on both builds, with 84.6/85.4 MB conventional and 61.3/61.8 MB direct. Preparation measured 390.8/394.0 ms before and 380.3/370.2 ms after in single samples. Clean all-watched submissions filled zero bytes. All-unwatched samples filled 291.9 MB on both builds. The warmed control with direct refresh scheduling omitted filled 84.6/85.4 MB and retained stale direct data after a CPU write. Both builds allocated 24 MiB of native shadows during setup. Timed native shadow allocations were zero.
AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU, and WARP each passed the five original correctness tests and the new mixed-reservation regression with the D3D12 debug layer and GPU-based validation with resource-state tracking active. We used an app-local Microsoft Agility SDK 1.620.2 test build. The allocation, watched-range, and benchmark measurements above are synthetic. With
VICTORY_PC_DXCset, runcargo test -p victory-gpu --features diagnostics directly_indexed_srv_unwatched_range_preserves_watched_refreshes -- --nocapture --test-threads=1for the focused case. SetVICTORY_COH_MIXED_BENCH=1and filter todirectly_indexed_srv_mixed_heap_benchmarkfor the larger fixture.The reviewed diffs cover post-fence copyback (#124), profiling (#130), draw admission and resource retirement (#135), and null texture UAVs (#205). We reproduced the three conflict locations with #135. The correction's standalone branch merges cleanly with #124. The contributor's resolved integration and its detailed logs are still needed to measure how much of the 23 GB came from this mechanism. The broader benchmark retains direct scan and unwatched-range traffic.
Scope
Directly indexed UAV write detection and copyback, direct CBVs, and coherency between distinct native shadow resources for aliased title memory remain separate work. The patch reuses existing buffer dirty tracking and leaves native resource-state handoffs to producers. The GPU ordering test uses an explicit copy-to-SRV transition. Existing workspace coverage exercises physical-page remapping, while the new GPU fixtures cover ordinary and write-watched allocations. Title behavior and any connection to issue #71 remain unverified.
AI-assisted with OpenAI Codex.
Current main integration and preparation
68c8f20preserves desplmfao's exact4740e19merge from fork #4 ontoffe310e. The subsequent change names an existing worklist type for strict Clippy. Both workspace Clippy configurations passed. On the contributor merge, AMD, NVIDIA, and WARP each passed eight focused shader readbacks with full GPU-based validation, a coherency bookkeeping check, and the binding/runtime checks. The later fork-tip shader handle typing change has its own scope.Native Windows, AMD Radeon Graphics: five alternating fresh processes per allocation mode, debug build with validation off, 12 submissions and 1,920 dispatches per phase. Each phase visited 221,184 direct ranges. All readbacks matched.
Clean direct-SRV timing includes building the range cache. The dirty phase reuses it. This comparison changes allocation types on the same commit and preserves the shared-span setting.
On the contributor's stock Wine server, the separate earlier lookup measurement was 2.3 s to 0.9 s with the view cache. On the patched Wine server, the cache comparison measured 46 to 26 ms per world frame in reservation queries. The two patched runs had 584 and 2,270 median draws per frame, so frame-time and cross-server comparisons are unresolved. The rebase keeps the existing live checks and leaves the fork #3 cache separate. Contributor Wine measurements
Disjoint conventional refreshes
20ff80ecredits pablogonz12's report and keeps exact disjoint ranges through readiness and refresh. Only overlapping or touching requests for the same native shadow coalesce. Larger grouped write-watch observations can still be shared. The unrequested dirty gap stays available for a later reader.The 174 MiB synthetic sparse case copied 182,452,224 bytes on
68c8f20and 131,072 bytes on20ff80e. On native Windows AMD, five alternating optimized runs with validation off put median CPU preparation at 19.387 and 0.038 ms, respectively. GetWriteWatch calls were one and two. Dense access copied 174 MiB with one query on both paths, with medians of 20.037 and 20.414 ms. AMD, NVIDIA and WARP passed full GPU-based validation for this fixture and the existing overlapping-shadow, pending-write, remap and partial-reservation cases. Both strict workspace Clippy configurations passed.The contributor's exact
02a59ccand integration tip are still requested for source comparison. ReportCPU updates inside UAV-declared ranges
The synchronous branch snapshots UAV backing after conventional and direct SRV refreshes finish. The synthetic regression covers title data written after recording, a real GPU write, and a separate late CPU write. CBV and direct SRV values recovered from 11/13 to 43/43. Values 77 and 61 survived GPU copyback and the later CPU write. The focused case, coherency suite and shadow suite passed on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU and WARP with full GPU-based validation. Workspace Clippy passed with default and all features.
Credit to Kevin Pratap Sidhu for the original investigation and synchronous main fix. Earlier in-flight reads/writes require separate fence ownership in #595. Matched Proton and title material retesting are pending.
58fed37) into #185 bc1f4448b5c7a5f49) into #185 73081455c7ffe310e) into #185 4740e19c29@DaviTostes on GitHub · 2026-11-24 01:21 UTC · original
Tested
83963c5under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build withcargo xwin ... --target x86_64-pc-windows-msvcand a native Microsoftd3dcompiler_47: pass, no regression.victory_gpu: 46 passed, 2 failed, 1 ignored, including the 6 tests this PR adds.a_rejected_blob_gives_an_empty_library(vkd3d needs a non-empty blob) and #128.host::batch::texture_checks_per_submission(benchmark).No game data used.
@gw1337x on GitHub · 2026-11-24 01:44 UTC · original
Tested in game on an RX 7800 XT (Windows 11 26200, 31.6 GB). Build:
mainatd2a4bae+ #135 + #124 + #130 + this PR + #205. It merged with #135 with three small conflicts, all keeping both sides:HostHeap'sDropwithSlots,bind's-> bool, andtake_retiredwithrefresh_direct_srvs.In the world (opening cutscene) frame time went from about 0.8–1.1 s without this PR to about 6 s. Copies grew from about 300–450 MB per frame to about 23 GB per frame:
The world picture stays black (only the intro card and subtitles show), as without this PR. So on this title the extra copies seem to come from the refreshes the PR triggers for directly indexed SRV slots, about 25k slots a frame, not from the direct-SRV copy itself, which is only 12 MB.
No device loss in about 3 minutes; I stopped the run.
@aycow on GitHub · 2026-11-24 01:49 UTC · original · edited 2026-11-24 01:50 UTC
Thanks for the detailed A/B and conflict notes, @gw1337x. I’m tracing the gap between the 12.21 MB attributed to direct SRV refresh and the 23 GB of aggregate copying. Could you share the integration branch or exact commit SHAs for the two builds, along with the diagnostics flags you used? That will let me compare the actual conflict resolutions and counter definitions against the standalone PR.
If you have the logs for both builds, the adjoining copies-per-frame line and the top copied-from ranges would also help separate deferred copies from conventional shadow refreshes.
@aycow on GitHub · 2026-11-24 02:10 UTC · original
@gw1337x I pushed
c6bf7dfto the existing PR. The synthetic GPU test now reproduces and fixes one path from a small direct refresh to large conventional copies. A 4-byte unwatched SRV disabled write watching for the rest of a mixed shadow. Four clean conventional submissions then copied 64 MiB. With the correction they copied zero, and a later CPU write still reached the shader after refreshing one 64 KiB page. AMD, NVIDIA, and WARP passed the correctness suite with the debug layer and full GPU-based validation active.Could you repeat the opening cutscene A/B with
83963c5andc6bf7df, holding the other PRs, conflict resolutions, build configuration, and diagnostics flags constant? The exact SHAs and the full copy lines from both runs would help attribute the 23 GB. The revised build also logsshadow traffic per frameand failed watch probes alongside the top conventional ranges.@ChruutvoLuzi on GitHub · 2026-11-24 02:47 UTC · original
In-game numbers from NVIDIA with
c6bf7df, for the A/B asked above. RTX 4090, driver 621.01, Windows 11.d2a4baewith #205, #206, #189, #134, #123 and #89, then this PR atc6bf7df. It conflicts with #206 inbuffer_srv; I computed theSrvRangefrom the view's own first element before #206 moves it into the host copy, which covers the same bytes. Diag build,VICTORY_D3D12_DRED=1, loop limit 1024, the opening of the first mission.c6bf7dfdirect SRVs per frame0x887A0006So on this card, at
c6bf7dfthe large copies are in the direct SRV refresh itself: it visits about a million slots per frame. The world reached about as many frames as without the PR before the device was removed; that removal is the hang in #71.AI-assisted (Claude Code).
@aycow on GitHub · 2026-11-24 02:52 UTC · original · edited 2026-11-24 02:56 UTC
@ChruutvoLuzi Thanks for running this comparison and sharing the direct SRV counters. The current head still has a scalability regression. Your data shows that descriptor enumeration and the subsequent range refreshes need investigation. The time until device removal increased, and the completed frame count was comparable.
Could you share the full copy and
shadow traffic per framelines for a few paired frames, the native submission count, the number of distinct view heaps if available, and any top refreshed ranges? The exact integration SHAs or conflict-resolution diff for #206 would also help reproduce the same descriptor ranges. I’m keeping the current commit in place while testing the redesign.@EricPlayZ on GitHub · 2026-11-24 03:29 UTC · original
A/B on NVIDIA, as asked, plus what removed most of the remaining cost on this title.
Setup: RTX 2070 SUPER (driver 596.49), Ryzen 7 5700X, 48 GB, Windows 11 26100. Diagnostics build (
--profile diag --features diagnostics),VICTORY_GPU_TIMING=1. Same save, same inputs, opening cutscene into the world. The base also carries a few unrelated local fixes, held constant across runs. Frame lines are the runtime's ownfps, ms/framereports, taken from the steady world frames (the first, cheaper world frames are left out).83963c5c6bf7dfc6bf7df+ the diff below + #202On this title
c6bf7dfalone did not help: its new counters showed ~480–600kinitial_pagesper frame against ~7.5kdirty_pages. Three causes, each fixed in the diff:copy_stalemarks a page copied only when the refreshed range covers it whole. Most directly indexed views are smaller than a page, so their pages stayed "never copied" and were copied again on every submission.Shadow::updatenow rounds a refresh to whole pages when the memory may be watched, without crossing ranges shaders are writing. Where watching fails, only the requested bytes are copied, as before.refresh_direct_srvsalso joins views whose pages touch: about 1M → about 240kupdatecalls per frame.GetWriteWatchrefuses a range that crosses an allocation, so the whole range fell back to a full copy.writesnow asks such a range page by page.title_memory_remapped(called by XMem's map and unmap) now also records the remapped pages as written. Mapped views keep the existing whole-range guard path.The measured build also write-watched the title's own
VirtualAllocreservations. That made no measurable difference in its own A/B, so it is left out of the diff.With these,
untracked_filled_mbwent from 4.5–5.5 GB to 0; what is left is pages watching reports as written (~31k a frame here). #202 (sparse copies) stacks with this: without it the same bytes took about 3x longer.Tests: all of
victory-gpupasses on this machine (60 withdiagnostics, 55 without, GPU tests enabled viaVICTORY_PC_DXC), serially and in parallel. New tests: whole-page refresh of small watched views (Shadow::update), a range over adjacent watched allocations, a range over watched pages and a hole, a remapped page reported written, a hole committed later not taken as unchanged, and a write found before an unwatched page kept in the journal. I checked that the first two fail without the change.Existing assertions changed, and why:
directly_indexed_srv_unwatched_range_preserves_watched_refreshesexpecteddirect_bytes == 4; the view's page is now copied whole once (PAGE).unwatched_subrange_does_not_disable_watch_elsewhere_in_shadow, the border refresh now asserts "at most one page refetched, then 0" rather than exact counts.written_pages_are_reported_to_every_askerassumed an empty global journal for a fresh allocation. It failed depending on test order, because an earlier test's freed pages at the same address stay in the journal. It now compares only askings after its first.Not measured here: AMD/WARP, Linux/Wine. The GPU device hang on this title (DXGI_ERROR_DEVICE_HUNG a few minutes into the world) happens with and without this PR.
AI-assisted (Claude Code); I reviewed and ran it as described above.
Diff against
c6bf7df(326+/24−: watch.rs, shadow.rs, host.rs, coherency test)@aycow on GitHub · 2026-11-24 03:33 UTC · original
@EricPlayZ Thanks for the controlled NVIDIA comparison and for posting the implementation. Your partial-page, split-allocation, and reserved-hole findings give us concrete cases to test against the draft. I’ll credit your findings and any code we bring in.
Could you share a fork branch or commit for the posted diff and the exact commit stack used for the run with #202? That would let me verify the patch and measure the changes separately. I’m checking partial commits within a 64 KiB tile, transitions from populated memory to holes, and pending GPU writes on AMD, NVIDIA, and WARP before integrating.
@EricPlayZ on GitHub · 2026-11-24 03:44 UTC · original
Branches on my fork:
c6bf7df: https://github.com/EricPlayZ/VIctory/tree/pr185-page-refresh (0dd303b)04afafa)What
04afafaholds, onmainatd2a4bae:56f0072), #202 (dcf6664), this PR at83963c5and thenc6bf7df(mergese0714fa,181cfea,ee0c950,794308a).5b43506: diagnostics-only title byte patching. It was used to skip the title's own hang watchdog; no game bytes are in the repo.8e166d9and0076c12: guard handling for partially remapped and read-only view blocks.de58539: the fault handler reuses the guard lock it already holds.3a823ed: image sample addressing in the translator.b510007→04afafa: the work behind the diff, in the order I tried it.b510007and dropped incc6fdef(no gain).0b7b2ad).VirtualAllocwrite-watch change (e5b5359, no measurable effect on its own).The
0dd303bdiff equals04afafa'swatch.rs,shadow.rsand coherency-test changes, plus thehost.rsjoin, minus the diagnostics and theVirtualAllocchange. One adaptation: inc6bf7df,title_memory_remappedhas noendbinding, so the journal loop uses(at + len).The runs were NVIDIA only. I have not tested partial commits inside a 64 KiB tile or populated-to-hole transitions beyond the unit tests listed above (a hole committed later; a remap marking pages written).
@GamingRipperDoc on GitHub · 2026-11-24 04:01 UTC · original
AMD + Windows 10 data point for @EricPlayZ's diff, as the comment above asked ("Not measured here: AMD"). Short version: the write-watch cost went down as described, but frames did not get faster here, and the copy volume the frame line reports went up. One run, with caveats below.
Setup: Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X. Base
maind2a4bae+ #175 (Agility SDK, needed on Windows 10) + #336. Then this PR atc6bf7df(one conflict with #336 indraw.rs: #336 makesbindreturnbool, this PR makes itpub(crate); kept both) + the diff from the comment above (applied cleanly) + #202. Diag build,VICTORY_D3D12_DRED=1, driven with a pad into the first mission.cargo test -p victory-gpu: 56 passed (61 withdiagnostics);VICTORY_PC_DXCnot set here, so the GPU-backed tests may have been skipped.Steady world frames, from the runtime's
fps, ms/frameandcopystatlines:copiesin the frame linewatches(copystat)So the change does what it says for write-watching (about 12× more queries, each far cheaper, about half the time), but here the bytes copied per frame grew 5–10× and the frame got slower. My guess, not checked: the whole-page rounding (
Shadow::update) copying full pages for small views where watching then doesn't cover the page. The per-rangecopied fromlines don't account for the GB, so I can't say where it goes.Caveats: one run each, and the two runs were at different moments (the summary I compared shows 202 submissions per frame in the base run, 22.7 in this one), so this is a direction, not a measurement. I didn't run without the diff (#185 + #202 alone), so I can't separate the diff's effect from #185's. Happy to run that A/B, or with a diagnostics switch you'd like, on this machine.
No game data used.
AI-assisted (Claude Code); I played the runs, and the logs were read with the model.
@aycow on GitHub · 2026-11-24 04:06 UTC · original · edited 2026-11-24 04:13 UTC
Thanks, @EricPlayZ, for isolating the three refresh costs and sharing both branches. I kept your original commit intact on a local test branch. The draft revision
53e36e7credits you and adapts the reservation splitting and hole handling. The new regression covers a committed 4 KiB island after a reserved prefix, where the clean patch returned stale data.On the matched AMD fragmented fixture,
c6bf7df, your clean patch plus #202, and the revised build took 17.83 s, 5.05 s, and 4.03 s over 320 submissions. The revised build filled 1.30 GB of direct shadow data versus 10.92 GB onc6bf7df, with matching shader results and copybacks. The focused suite passed on AMD, NVIDIA, and WARP with full D3D12 GPU-based validation.@EricPlayZ @ChruutvoLuzi @GamingRipperDoc, could one of you please run another controlled in-game A/B with
53e36e7and your previous baseline, keeping the other PRs, settings, scene, timing options, and #202 status fixed? If possible, please include direct requested and filled bytes, preparation time, submission and unique heap counts, top refreshed ranges, and frames completed before any device removal. An independent Wine run would also help. I’ll keep this in draft while we wait for the in-game result.@GamingRipperDoc on GitHub · 2026-11-24 04:25 UTC · original
@aycow In-game A/B of
53e36e7, as asked. Same pattern as my earlier run: far fewer bytes filled, but on this machine the per-range work costs more than it saves, and frames got slower.Setup: Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X. Diag build,
VICTORY_D3D12_DRED=1, no captures, Series X mode, same profile and path into the first mission with a pad, a fresh build (cold shader cache) for each side.maind2a4bae+ #175 (Agility SDK, needed on Windows 10) + #33653e36e7. One conflict with #336 indraw.rs(#336 makesbindreturnbool, this PR makes itpub(crate); kept both).host.rs(#202'sread_sparsecalls the oldread_pieces(src, dst, len), which this PR changes toread_pieces(dst, src, len) -> bool), and I didn't want to rewrite either side.cargo test -p victory-gpuon B: 70 passed (77 withdiagnostics), 2 failed:shader_usage_tests::bind_keeps_shader_srv_usage_for_stable_view_heapandno_buffer_srv_use_keeps_native_descriptor_owners_alive, both atexpect("synthetic graphics pipeline"). They fail the same way on53e36e7alone: on Windows 10 the test executable only has the in-box D3D12 (shader model 6.5), so heap-indexed root signatures are refused. #362 handles this forvictory-shader's tests;victory-gpu's would need the same.Steady world frames (after pipelines were made), from the runtime's lines:
copies(frame line)watchesB's direct-SRV counters (
direct SRVs per frame), steady world:Top refreshed range in B, every window: the title buffer at
0x2c040000+0xae00000(182 MB), 21–33× per frame, 3.8–6.1 GB requested and 3–9 MB filled per frame, 7–14 ms.So on this machine the filled bytes are small, but with ~0.4–0.9 M ranges per frame the per-range cost (one write-watch query each, judging by the
watchescount) adds up to over a second of preparation per frame. The submission counts differ a lot between A and B, which may just reflect B's slower frames. A's run was short (25 s), so this is one run each; the direction matches my earlierc6bf7df+ diff run.Happy to rerun with a switch or a build you'd like, e.g. a cap on ranges per submission.
No game data used.
AI-assisted (Claude Code); I played both runs, and the logs were read with the model.
@aycow on GitHub · 2026-11-24 04:57 UTC · original
@GamingRipperDoc, the draft now batches watches by verified reservation for dense requests, indexes dirty-page history, and reuses a fresh observation across the exact reads in its preparation group. It also includes the compatible #202 fallback and app-local Agility support for the GPU test executable. Thanks to KaiserBloo for the clean guard fast path from #393 and to wrothgaril for the guard lookup approach from #490.
In three interleaved AMD samples per layout over 320 submissions, total time changed from 201 to 175 ms (dense watched), 369 to 201 ms (gapped watched), and 3,473 to 2,756 ms (fragmented mixed). Fragmented native watch calls fell from 565,760 to 66,560. Fully mapped mixed measured 1,984 to 2,160 ms, with substantial run-to-run variation and 48,640 to 28,160 watch calls. Filled bytes and GPU results matched in all four layouts. The focused suite passed on AMD, NVIDIA, and WARP with SDK 620 and full GPU-based validation on Windows 11.
Could you run an independent in-game A/B of
53e36e7and1efd438with the same stack, scene, and diagnostics settings? The compatibility commitf324f0ecan be applied to the baseline to keep #202 in both builds. Preparation time, watch counts and failures, filled bytes, and frames completed before device removal would be helpful. If you can also rerun the two binding fixtures on Windows 10, the GPU test build supports staging SDK 1.620.2 and settingVICTORY_TEST_AGILITY=1to activate it.@GamingRipperDoc on GitHub · 2026-11-24 05:32 UTC · original
@aycow In-game A/B of
53e36e7and1efd438, as asked. On this machine1efd438cuts watch calls about 7× and halves frame time against53e36e7; it's now about as fast here as the same base without this PR. Plus the Windows 10 binding tests pass withVICTORY_TEST_AGILITY=1.Setup: Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X. Diag build,
VICTORY_D3D12_DRED=1, no captures, Series X mode, same profile and path into the first mission with a pad, fresh build (cold shader cache) per side. Both ond2a4bae+ #175 + #336, with #202 in both:53e36e7+f324f0echerry-picked1efd438bind()resolution against #336 (-> boolfrom #336,pub(crate)from here).Binding fixtures on Windows 10 (B,
cargo test -p victory-gpu, runtime staged intarget\debug\D3D12\):VICTORY_TEST_AGILITY=1: 78 passed, 0 failed, includingbind_keeps_shader_srv_usage_for_stable_view_heap,no_buffer_srv_use_keeps_native_descriptor_owners_aliveandagility_runtime_meets_the_requested_versionVICTORY_TEST_AGILITY=0: 77 passed, 0 failedSteady world, at comparable load (~30–36 submissions per frame):
watches0xb8b600000/0xb8b680000, 28.17 MB requested)Caveat: A's world lasted only ~23 s, so it has just one steady window at this load; the direction is clear, but A's numbers are one sample. Relative to the same base without this PR (my earlier A: 667–1,598 ms per frame at 113–176 submissions), B is now in the same range, so the earlier slowdown on this machine is gone. Fallbacks run higher in B than in A, if that's useful.
No game data used.
AI-assisted (Claude Code); I played both runs, and the logs were read with the model.
@EricPlayZ on GitHub · 2026-11-24 05:34 UTC · original
@aycow In-game A/B of
53e36e7and1efd438on NVIDIA, as asked.Setup: RTX 2070 SUPER (driver 596.49), Ryzen 7 5700X, 48 GB, Windows 11 26100.
Builds (same base on both sides):
maind2a4bae+ #48 + my local guard fixes (8e166d9,0076c12,de58539),3a823ed, and diagnostics-only title patching (5b43506), as in my earlier table.53e36e7+f324f0e(#202), as you suggested.1efd438.Both merges conflicted only in
title_memory_remapped. I took your version and kept my local partial-block write-access restore inside its block loop on both sides.Branches: https://github.com/EricPlayZ/VIctory/tree/pr185-ab-a and https://github.com/EricPlayZ/VIctory/tree/pr185-ab-b
Steady world frames, from the runtime's lines:
53e36e7+ #2021efd438copies(frame line)watchesDXGI_ERROR_DEVICE_HUNG(no DRED)Caveats:
copies per frame), so the two may have sampled different moments of the cutscene.AI-assisted (Claude Code); the runs were scripted and the logs read with the model.
@desplmfao on GitHub · 2026-11-24 06:03 UTC · original
481fb1amentions "the wholly reserved case examined in #515", and the same commit credits #393 and #490 withCo-authored-bylines. If #515's per-allocation and never-committed handling fed into it the same way, would you mind addingCo-authored-by: desp <[email protected]>there too? Thanks, and nice work on the rework; it measures well here (numbers on #436 / #515).@desplmfao on GitHub · 2026-11-24 06:09 UTC · original
A small fix for this branch under Wine: https://github.com/aycow/VIctory/pull/1.
watch::allocationreads the Private bit fromQueryVirtualMemoryInformation's region flags, which Wine leaves all zero, so under Proton every reservation looked like a view and the grouping by reservation never took the private path. The PR falls back toVirtualQuery(MEM_PRIVATE) when the flags are zero, with a test, and has before/after numbers from the world (write-watch questions 147,000 → 116,000 per frame).AI-assisted (Claude Code).
@aycow on GitHub · 2026-11-24 06:38 UTC · original
@GamingRipperDoc @EricPlayZ Thanks for running the controlled A/B and reporting the caveats. I added both tables and the independent Windows 10 Agility results to the description. The AMD report's 2,777 → 850–1,567 ms and the NVIDIA report's 1,999–3,300 → 1,300–1,900 ms are comparisons against the earlier draft revision on your test stacks.
@desplmfao I integrated the Wine fix with your original commit
9e94c21intact. The follow-up commit and PR description credit your #515 per-allocation and never-committed handling in481fb1a, preserving the previously tested commit IDs. The combined6c5322cpassed the synthetic direct-SRV suite on AMD, NVIDIA and WARP with full GPU validation. I’m keeping this in draft for an exact-head title/Wine retest. The cross-shadow profiling follow-up is in #600.@desplmfao on GitHub · 2026-11-24 06:40 UTC · original
Thanks for the credit. One pointer: I closed #600 since it was on the old base; the cross-shadow port now lives as https://github.com/aycow/VIctory/pull/2 against this branch (head
9131c10, on top of the merged Wine fix). The timing-only runs for the remaining frame cost will be posted there.AI-assisted (Claude Code).
@pablogonz12 on GitHub · 2026-11-24 16:56 UTC · original
Measured on our tree (Linux, RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master, diagnostics build, 240 s world runs, two runs a side). Merging your watch side on top of a tree that carries #490/#464/#393/#124,
copiestook 2333 / 3871 ms per frame against 628 / 864 on the same tree without it (write-watch90/128 vs 459/573 was the only gain). fps 4.75 and 0.21 — one run reached the world, one did not.Cause, traced in our merge:
Batch::addcollapses every refresh of a buffer in a submission into one min..max range, andflushasks the shadow's readiness over that union, soShadow::answeredtakes the whole span and copies every 64 KiB page written anywhere between a buffer's ranges (the 174 MB buffer is read through many ranges per submission). Copy volume goes ~180-250 MB to up to 1,389 MB per frame, about 5x.The fix keeps a copy's disjoint, page-coalesced ranges end to end:
addappends,flushcoalesces each copy's ranges, and the shared question is still asked once per group but per range. That gives 74 tests passing under Wine (watch 12, shadow 4 + 1 ignored) and copies back at baseline. I have it as commit02a59ccon our branchr-w1; happy to put it anywhere you like if you want to take it into this PR, or to test a version of yours.Not tested: native Windows; only these two dumps of the world.
@aycow on GitHub · 2026-11-24 17:05 UTC · original
@pablogonz12 Thanks for isolating the copy amplification. We confirmed that
68c8f20grows multiple refresh requests on one shadow into a bounding range. Could you publish02a59ccand the exact tested integration tip as fetchable Git refs, or link them if they’re already public? The parent revisions would let us compare the patch and rerun a matched native fixture while preserving your original authorship. We need code revisions and aggregate counters only.@pablogonz12 on GitHub · 2026-11-24 17:20 UTC · original
@aycow Both are public now on my fork:
w1-as-tested, tipf9a8032— https://github.com/pablogonz12/VIctory/tree/w1-as-testedw1b-span-batching, tip02a59cc(merge of the above onto my integration base with #393 and #490) — https://github.com/pablogonz12/VIctory/tree/w1b-span-batchingThe fix itself is in
crates/victory-gpu/src/host.rs(Batch::addkeeps disjoint ranges per copy instead of one min..max span; the question is still asked once per group) andshadow.rs(answeredper range). Parents are in the branch history. Game runs of 02a59cc on my RX 9070 XT are queued; I'll post the counters when they're in.@aycow on GitHub · 2026-11-24 17:20 UTC · original
@pablogonz12 The independently validated fix is in #185 at
20ff80e. If you can run a matched warm-cache Proton A/B, please hold the stack, scene and frame window fixed and toggle only this change. Aggregate copied bytes, watch queries, preparation time, frame time, draw count and whether both reached the same scene are enough. I'd still like to compare exact02a59ccwhen the ref is available.@pablogonz12 on GitHub · 2026-11-24 17:30 UTC · original
@aycow Queued: a matched warm-cache Proton A/B on my RX 9070 XT, same stack, scene and frame window, toggling only
20ff80e. I'll post aggregate copied bytes, watch queries, preparation time, frame time, draw count, and whether both runs reach the same scene. Not tested yet: any of this; no numbers until it runs.@aycow on GitHub · 2026-11-24 18:13 UTC · original
The synchronous branch now snapshots UAV-declared ranges after conventional and direct SRV preparation in
f173d36. Credit to @KevinPratap for isolating the failure in #1322. In the recorded→submit test, the CBV/direct SRV readback changed from 11/13 to 43/43. It still returned the GPU write of 77 and preserved a later CPU write of 61. The focused case plus the coherency and shadow suites passed with full GBV on AMD Radeon Graphics, RTX 5070 Laptop and WARP. Both workspace Clippy configurations passed.@pablogonz12 thanks for the public refs. I compared f9a8032 with 02a59cc and
20ff80e. Your corrected composition avoids bridging the distant requests while sharing observations across copies. This branch retains exact requested byte intervals; it does not import the #393 integration merge. The queued warm Proton A/B against20ff80eremains useful for the sparse-range change. Please identifyf173d36separately if you also A/B the UAV correction. No title performance result is established here.@aycow on GitHub · 2026-11-24 21:29 UTC · original
I checked the latest #595 7465030 against
f173d36. The current #185 keeps the submission lock through direct refresh, the UAV snapshot, fence wait, and copyback. Individual slot locks are released after descriptor metadata is collected, so retaining the backing Arc does not freeze the native slot or the bytes a queued reader will see. The fix needs to select the latest generation at submission, retain that native slot and protect the refreshed backing span through the fence. Any blocking path needs to drop the shader-heap registry lock before waiting so lease retirement can make progress. No branch or draft change. The matched warm-cache preparation comparison and async ownership remain the two separate checks.AI-assisted using Codex.
@pablogonz12 on GitHub · 2026-11-24 22:04 UTC · original
Not run yet: the matched warm-cache A/B you describe (only
20ff80etoggled, stack, scene and frame window held fixed, copies, watch queries, preparation time, frame time and draw count, both reaching the same scene) needs the GPU and is on my list for the next free slot. I will post the numbers here when it has actually run.Pull request closed