GPU: a raw buffer view's range stays inside its buffer (a description the driver refuses leaves the slot undefined) #1266
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1266
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1266"
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?
@lichenlang89 on GitHub · 2026-11-26 05:39 UTC · original
lichenlang89:fix/raw-buffer-view-range→main· +242 −6 · 1 files · 4 commits · openWhat
descriptor/host.rs'raw_at()andraw_uav_at()turn the title's byte offset and length into a buffer view without checking either against the buffer:CreateShaderResourceViewandCreateUnorderedAccessViewreturn nothing, so a description that runs past the buffer is refused with no line from us, and what a refused creation leaves in the slot is undefined. The slot is shader-visible: a later draw or dispatch may read through it.This branch keeps the range inside the buffer. The start is used exactly as asked, the length is cut at what the buffer holds and at
u32::MAX, and a request that lies outside the buffer gets the null view the file already has (null_raw_at,null_raw_uav_at).Correctness
asked = offset / 4is what goes intoFirstElement; nothing narrows it to 32 bits and nothing clamps it back. A test assertsfirst == offset / 4over every accepted case.asked >= size / 4→None→ null view, never a view of the buffer's tail.u32::MAX(NumElementsis 32-bit,FirstElementis 64-bit).draw.rsbiases byoffset & 15on the UAV path and makes a null view for a root SRV that is not on 16 bytes;memory.rspasses 0.Past,Length,Short,Unaligned, each for SRV and UAV — and say so on the first and every 4096th event. A legal, uncut request touches no counter and logs nothing.Correction after review
The first revision of this branch clamped the start to the buffer's end, which mapped a request that lies entirely past the buffer onto the buffer's tail:
That was an error introduced by this PR's first revision — it is not in
be721d5a, where such a request simply produces an out-of-range description. It is fixed indafd86a: the clamp is gone, the start is used as asked, and the table test above is the regression test. The first revision also narrowed the start tou32::MAX; that is gone too.Testing
Six focused tests: the review's table including the counterexample; the four cause labels plus "no counter when nothing was cut"; a start past 32 bits keeps its 64-bit value; the length is cut at
u32::MAX(1 TiB,len = u64::MAX→(0, u32::MAX)); an aligned start past the buffer is refused asPastrather than through the unaligned branch; and 640 shapes asserting the start is unchanged, the range ends inside the buffer, the start is on 16 bytes, and no request the input rules allow is refused.One known flaky test, unrelated to this change but visible here:
inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset. Controlled on one machine, alternating, ten parallel runs each:be721d5a(untouched)STATUS_ACCESS_VIOLATION)Always the same test, which uses the WARP adapter and never calls
raw_at/raw_uav_at; it passes on both trees when run alone, and both pass with--test-threads=1. The rates are indistinguishable at ten runs each, so this branch neither causes it nor is cleared of making it worse — it is reported rather than worked around: no test was skipped, disabled or changed.Not run: a real-GPU regression with the new commits. No earlier run's result is offered in its place.
Limitations
constant_view_size(), fork PR #1206), and the guard's counters stayed at 0, so it has never fired on the machine we measured.GetDesc()is called once per raw view. Not measured against keeping the width beside the slot.🤖 Generated with Claude Code
@CuteBooty on GitHub · 2026-11-26 08:28 UTC · original
RTX 3070 8 GB, Series S: ported; all eight counters stayed at zero for a whole run
VICTORY_RAW_VIEW_CLAMP, on by default).raw view clamp (past end, shortened, sub-dword, unaligned) since start: SRV [0, 0, 0, 0], UAV [0, 0, 0, 0]from the first line to the last.So on this title, card and mode the guarded cases do not occur, and the fix costs nothing. The port's six tests pass here (quick suite 379 passed). If you know a scene or card where the counters move, I can run it.
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.