fix(gpu): respect indirect count buffer and bind null root views #583
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!583
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-583"
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?
@matheusfrta on GitHub · 2026-11-24 05:13 UTC · original
matheusfrta:patch-1795497178→main· +260 −49 · 4 files · 1 commits · openRebased shadow.rs cleanly onto main so null addresses skip loose shadow allocation, and updated State::root_view and ROOT_VIEW_OFFSET to bind a cached null raw view with offset 0 when a root view is null or unset instead of dropping the draw or dispatch.
@rouges78 on GitHub · 2026-11-24 09:12 UTC · original
Hardware data point on the budget loop, RTX 4080, Windows 11. I added one test to this branch: N draw records of one vertex instance each (kind 0, stride 16, no count buffer), which all fit the budget, clamp alone, timing
host.execute.When many records fit, each successful compare-exchange makes the other threads retry, so the work grows roughly with the square of the record count. 4,096 small records already sit at the host's 2 s time-out. Each device loss came with an nvlddmkm event 153. WARP does not show this (no time-out), and the garbage-record tests don't either, because the budget saturates after a few reservations and everything else exits early.
main does not have the problem but still wraps. A single thread walking the records with a saturating count avoids both (27 ms for 65,536 records here): https://github.com/rouges78/VIctory/tree/fix/indirect-budget-wrap, test
records_within_the_budget_all_run. It has no count-buffer awareness, which this PR has; the two could be combined.AI-assisted; the numbers are from real runs on the card.
@Marvisak on GitHub · 2026-11-25 00:28 UTC · original · edited 2026-11-26 00:21 UTC
Automated triage for the maintainers.
Needs work. This PR now does two separate things, and only one of them is ready.
crates/victory-gpu/src/indirect.rs,bound, and the call indraw.rs). Lane 0 readsmin(records, count)into a groupsharedlimitbehind a barrier, so records past the title's count no longer use up the list's budget or get zeroed. It fitsmain's single-group walk, which already answers @rouges78's timing report.clamp_honours_count_buffer_and_does_not_wrap_budgetcovers it. This part looks right.State::root_view, theROOT_VIEW_OFFSETentry, the root-view loop, andHost::null_root_view/null_root_uav). A draw or dispatch that used to be dropped now runs against a zeroed 64 KiB buffer. That changes GPU state handling, and the PR gives no evidence for what the title expects: no log of which draws hit a null or unset root view, and no run comparing the result. Two concrete problems:Suggestion: split part 1 into its own PR, which could go forward as is. For part 2, give evidence that the dropped draws should run, for example a diagnostics run listing the shaders and slots and an A/B of the frame. Also clear or size the null UAV for its use.
On your reply: thanks for the rebase that moves the count buffer to SRV
t1next to the per-list argument buffer. That part reads correctly.CI: passing.
Generated by Claude Code
@matheusfrta on GitHub · 2026-11-25 01:19 UTC · original
Rebased onto
mainand integratedcount_bufinto the single-group tile clamp, keeping a separate sink buffer for null root UAVs so writes do not dirty the zeroed CBV/SRV buffer.Regarding the failing CI check: both
clippysteps passed, andcargo test --workspacefailed on the twovictory-shader::emit::synthetic_testshardware-adapter tests (gathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out) on the GitHub runner, which are unrelated tovictory-gpu.@Mericas77 on GitHub · 2026-11-25 08:31 UTC · original
Thanks for this one. One gap I noticed while reading the diff (code reading only, I have not reproduced it in a title):
With
shadow::find(0, _)now returningNone, the null fallback only covers thestage.root_cbvs / root_srvs / root_uavsloop. Sinced71c388, root SRVs and UAVs in programs that don't use title memory no longer go through that loop (it only holdsVIEW_STRIDESfor them now, see theemitmodule notes, "Root SRVs and root UAVs"). They go through the user-data entries instead, and both of those paths drop the whole draw/dispatch whenfindfails:ROOT_VIEW_OFFSETentry:crate::shadow::find(address, 1)->None => return false(draw.rs#L617-L627)ROOT_SRV_VIEW/ROOT_UAV_VIEWentries:self.root_view(...)->None => return false(draw.rs#L629-L634), becauseState::root_viewdoescrate::shadow::find(address, 1)?(draw.rs#L779)On the base,
find(0, 1)falls through toloose()and returns a 4 MiB copy of[0, 4 MiB)(its refresh just fails inReadProcessMemory), so those draws were still bound and ran. With this PR, any draw or dispatch whose shader reads a root SRV/UAV the title left at 0 is dropped instead, which looks like the opposite of what the null-view change is meant to do.A possible fix: in
State::root_view, whenaddress == 0, hand out a raw view ofnull_root_view()/null_root_uav()(cached inroot_slotslike the others) with offset 0, and make theROOT_VIEW_OFFSETbranch return 0 for address 0 instead ofreturn false. The page-table path (L603, title-memory programs) already just skips a failedfind, so it seems fine as is.Happy to test a rebased version on an RTX 4070 (NVIDIA) if useful.
AI-assisted review, read against 586d7da and current main (
940d32f).@matheusfrta on GitHub · 2026-11-25 10:50 UTC · original
@Mericas77 Thanks for pointing this out! Feel free to test the rebased version on your RTX 4070. I’ll test it on my PC as well to verify the behavior. I’ll submit an updated PR with any necessary fixes as soon as I can.
@matheusfrta on GitHub · 2026-11-25 14:26 UTC · original
@Mericas77 Rebased onto current
main(keeping the write-marks changes indraw.rsandshadow.rs) and fixed the gap you spotted:State::root_viewnow caches and binds a null raw view with offset0for null (0) or unset root SRVs/UAVs instead of dropping the draw/dispatch (clearing any stale mark entry on UAV slots).ROOT_VIEW_OFFSETnow returns0for null/unset root views instead of returningfalse.shadow::find(0, _)and null/unset root views inState::root_view.CI is green and
victory-gpuclippy + WARP tests (with--skip a_texture_written_in_one_format_reads_in_another_through_a_placed_view, which fails on this host's WARP due to castable format support) pass. Still worth checking on your RTX 4070 if you want to verify on hardware.@Mericas77 on GitHub · 2026-11-25 15:04 UTC · original · edited 2026-11-25 15:05 UTC
Thanks, the rebased version (f99ec1b) looks right to me:
ROOT_VIEW_OFFSETnow gives 0 andState::root_viewbinds a cached null raw view for null/unset root SRVs/UAVs, so those draws are no longer dropped.Tested on an RTX 4070 (Windows), plain debug
cargo test -p victory-gpu, againstmainat940d32f:940d32fdraw::tests::null_and_unset_root_views_read_zeros,shadow::tests::null_address_does_not_allocate_shadow_copy,host::tests::null_root_view_is_aligned,indirect::tests::clamp_honours_count_buffer_and_does_not_wrap_budget.descriptor::host::tests::dynamic_slots_are_held_until_released(descriptor heap cap,NumDescriptors >= HEAP_VIEWS) andmemory::tests::lists_share_a_table_and_copies_keep_their_views.draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view, the one you skipped on WARP, passes on the 4070 on both sides.cargo clippy -p victory-gpu --all-targets: clean.No regressions on NVIDIA from what I can see.
Me and AI-assisted. (Gemini+Claude)
@matheusfrta on GitHub · 2026-11-25 23:18 UTC · original
Rebased onto
main(adaptedcount_bufinindirect::boundas read-only SRVt1alongside the new per-list argument buffer, and keptshadow.page_range/not_rundiagnostics inState::root_view).View 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.