Skip to content

GPU: bind 256-byte-aligned table CBVs directly from shadow buffers - #144

Open
MartinIndra02 wants to merge 1 commit into
fxceless:mainfrom
MartinIndra02:perf/fxceless-table-cbv-shadow
Open

MartinIndra02 wants to merge 1 commit into
fxceless:mainfrom
MartinIndra02:perf/fxceless-table-cbv-shadow

Conversation

@MartinIndra02

Copy link
Copy Markdown

Summary

Mirrors
oot_view\ (\draw.rs:391) for \View::Constant(address, size)\ entries inside descriptor tables (\draw.rs:2008):

  • Previously, every \View::Constant\ in a descriptor table unconditionally allocated upload scratch memory (\list.scratch) and pushed a \Step::Fill\ copy from title memory.
  • When a table CBV resides in a \Shadow\ buffer at a 256-byte-aligned host GPU address with \�ligned_size\ in \1..=65536\ and fits within \shadow.left(address), this PR now binds \shadow.gpu(address)\ directly via \shadow.refresh(list, address, aligned_size)\ + \host.constant_at(index, shadow.gpu(address), size), falling back to the existing \list.scratch\ + \defer_fill\ path for unaligned or out-of-shadow views.
  • This avoids unnecessary per-draw upload-scratch allocations and CPU memcpys, and prevents 256-byte-aligned table CBVs that read GPU-written shadow buffers from triggering \WHY_READ\ (\� fill of upload memory) submission stalls.

RTX 3080 A/B Measurement (Windows 11, 10 GB)

On our local RTX 3080 run (paired with #71 + #25, same switches):

  • \ itle memory read\ caused by \� fill of upload memory\ dropped from **\1.0\ → \

@ericomeehan

Copy link
Copy Markdown

#104 and this PR change the same lines (the View::Constant arm of table binding in crates/victory-gpu/src/draw.rs, around line 2008), so whichever merges second needs a rebase. They also fit together:

  • On main, the table path makes a CBV of the guest's full size (constant_at rounds to 256 but does not cap). D3D12 allows at most 65536 bytes per CBV, and root_view already caps constant buffers at 1 << 16. GPU: limit staged constant-buffer uploads to 64 KiB #104 adds that cap to the table path.
  • Here, a constant buffer over 64 KiB takes the fallback, which is main's code unchanged, so it still gets the oversized view. With GPU: limit staged constant-buffer uploads to 64 KiB #104's cap the fallback is fine, and the direct path could clamp to 64 KiB, as root_view does, instead of refusing.
  • One difference from the scratch path: defer_fill copies into upload memory private to this list, while the shadow is shared with other lists. Both are brought up to date when the list is submitted. root_view already binds shadows this way, so this is consistent with it; the only new exposure is if another list refreshes the same range while this one is still in flight, which depends on the shadow's in-flight tracking.

Suggestion: merge #104 first, then rebase this onto it with aligned_size.min(65536).

I only read the code. I didn't build or run it.

Written with an AI assistant (Claude).

@Revens2

Revens2 commented Nov 25, 2026

Copy link
Copy Markdown

Build check only: this PR merges cleanly on main c96b4f2 and the integration build of eight PRs (#115 #66 #36 #144 #147 #141 #139 #130) compiles (diagnostics profile). In the game, that combo was run alone 3 times (900 s, VICTORY_RELAY=2, scripted input): one run to the end (median 4.95 fps, about 4.9k draws per frame, against 4.84-5.04 fps on main), one title breakpoint 0x80000003 at about 157 s after a failed dstorage request (the pattern is explained on #115), one device removed (0x887A0005) at about 160 s that did not repeat in the two other runs. Nothing is proven for this PR alone: it was not run on its own, cargo test was not run on the combo, and nothing was checked on the title side of its change. Not verified.

@ryotdev

ryotdev commented Nov 25, 2026

Copy link
Copy Markdown

I reviewed the direct CBV path at 1ac9b30. There is a dependency missing when a command list is cut. The first physical list records shadow.refresh(...) for the table CBV. After the cut, State::replay preserves the table cache, and a cache hit skips CBVs. The second physical list can therefore bind the cached GPU address without recording that shadow or its byte range among its own refresh dependencies. A title write to the constants between the two parts can go unseen by this binding. #742 discusses the related scratch-buffer lifetime case.

Could you retain the shadow and exact byte range for each directly bound CBV and request its refresh on cache hits, or evict CBV-bearing tables at the cut and rebuild them? A focused regression would bind the same table on both sides of a cut, change its constant bytes before the second submission, and check that the second draw sees the update.

One performance detail worth counting in the A/B is the number of new shadows created by the eligibility check. shadow::find can allocate on a miss, including a loose window for an unregistered range. The alignment check follows the lookup, so a binding can pay for that allocation and still fall back to scratch.

AI-assisted source review. I traced the paths on this PR head. My RTX 5070 timing runs used a separate diagnostics build, so I have no FPS claim for this PR.

e4glevlr added a commit to e4glevlr/victory-fork that referenced this pull request Nov 25, 2026
- fxceless#860 (a544813): fingerprint fill_ahead reads so title rewrites do not permanently trip global fill waits, hold back only affected 64 KiB pieces (up to 8), log depth UAVs once per view, and fix VICTORY_CARD_ROOM_FOR_BUFFERS doc
- fxceless#462: add opt-in VICTORY_FILL_ON_CARD=1 (off by default) HostList::card_constants path in draw.rs/host.rs when aligned direct shadow bind (fxceless#144) does not apply
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.

4 participants