Buffer views that start off a 16-byte boundary are read at the right element #4984
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4984
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4983"
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?
@TheDarkDnKTv on GitHub · 2026-12-01 16:25 UTC · original
TheDarkDnKTv:pr/view-offset-remainder→main· +896 −111 · 22 files · 3 commits · openWhat it changes
What was wrong. Shop and neon signs and their glow are dark on
main. The console can start a buffer view anywhere on a 4-byte boundary, the card only on a multiple of 16. A structured view that starts off 16 bytes was left as a structured view of the host buffer, and a translated shader reads a view by byte offset, so it landed on the wrong element. Measured in the title on a table of 24-byte records: a shader asking for elementngot element3n. About 300 to 370 views of this kind are made a frame.The change.
Shaders:the translator reads a 0 to 15 byte remainder from the view's stride word (bits 26 to 29), from the same slot as the descriptor, and adds it to the byte offset once the console offset is computed (loads, stores, atomics, formatted and sub-dword accesses, scalar loads). The access is first checked against the console view's own extent, so the bytes before the console start are never reachable (out-of-range reads give zero, out-of-range writes and atomics do nothing). Programs that cannot resolve a shifted view keep their old lowering. New moduleemit/lower/viewstart.rs.GPU:the host makes such a view raw, from the 16-byte boundary below its start, on the original buffer, and publishes the remainder in the stride word after the descriptor (persistent slots, dynamic tables and the listed copy).descriptor/host/viewstart.rsdecides which views qualify and logsunaligned structured views per frame: ....README:one row in the settings table.Switch.
VICTORY_VIEW_START_REMAINDER: on by default,=0gives the old reading in both the layer and the translator. It is in the shader cache key, and the change is undervictory-shader/src, so every shader re-translates once after this merges and the pipelines are rebuilt.Not changed by this. The flicker in reflections and in the wall mirror is there on
mainand is the same with this branch. The phone screen is unchanged.How it was tested
victory playat5fabb46e(no ray tracing), the same for before and after.main(5fabb46e), shop and neon signs are dark.main.cargo testpassed for the crates it touches: yes (commit674402aa, Windows, rustc 1.98.0):cargo test -p victory-shader --lib: 538 passed, 0 failed, 10 ignoredcargo test -p victory-gpu -- --test-threads=1: 1098 passed, 0 failed, 66 ignoredcargo test --workspace --locked --no-fail-fast: 2493 passed, 0 failed, 96 ignoredcargo clippy --workspace --all-targets --locked -- -D warnings(and--all-features) does not pass: 5 findings inhost/font.rs,host/menu.rsandhost/panel.rs, files this change does not touch (the same onmain). Nothing in the files of this change.cargo xtask policy: okNot tested: any AMD card; Series S; the cost of the extra loads (a shader reading through a heap view now also loads the stride word and the view's size); a run with the switch off in the same scene;
victory translateorvictory shadersover the whole game on this branch.Known limit. A persistent slot's descriptor and its remainder are two writes, so a draw recorded before the slot is rewritten sees the later descriptor and the later word, as it did before for the descriptor alone.
Checked for overlap
raw_dwords,view_dwordshere), so whichever lands second needs a few lines of rebase. None found with the same symptom.🤖 Generated with Claude Code
@mstrmoos on GitHub · 2026-12-01 17:26 UTC · original
I measured the cost the description lists as not tested. On an RTX 5080 it's large, so worth knowing before this merges.
Setup. RTX 5080 16 GB, Ryzen 7 9800X3D. Series X, 2560x1440, DLSS Balanced, frame generation off, ray tracing off. Standing on a pier for 120 s after a warm-up run (each switch value re-translates): water, a terrace with people, the far shore, about 3,800-5,400 draws a frame. Diagnostics build of my branch (#4836's code) with this PR and #4927 picked on top.
It does its job.
unaligned structured views per frame: SRV 357.7 seen, 357.7 with remainder, 0.0 disabled …, and no crash.But the card time doubles:
VICTORY_VIEW_START_REMAINDER=0, same buildWhere it goes. Per-command card time (
VICTORY_GPU_TIME=1) with it on, against my earlier profile of the same scene: the 21 programs that are in both top-40 lists go from 5.25 to 9.86 ms a frame together. Some single programs:915ed81e(compute, indirect)b7a81f5b/43e24028(mesh / pixel)5b6eed17(compute)2dc364df(compute, indirect)56a84ca7/02ff1207(mesh / pixel)Why.
victory translatewithVICTORY_SHADER_CENSUSover all 26,180 programs, before against this PR:So every access through a heap buffer view pays for the stride-word load, the size load, the extent check and the selects, while about 360 views a frame are actually unaligned. The extra loads depend on the descriptor, so they lengthen the chains the card is already waiting on (long-scoreboard stalls dominate this title on NVIDIA; numbers in #4917).
Ideas, untested:
I'm not putting it on my play branch as it is, but the signs are worth fixing, and I'm happy to measure a revised version on the same scene.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.